Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 4 files). Show all
Unified · Split
| @@ -4834,6 +4834,9 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 4833 unmodified lines | ||
| 4834 | 4834 | SSlice* pBaseSlice = &pCurLayer->sLayerInfo.pSliceInLayer[0]; |
| 4835 | 4835 | SSliceHeaderExt* pBaseSHExt = &pBaseSlice->sSliceHeaderExt; |
| 4836 | 4836 | SSlice* pSliceIdx = &pSlice[uiSliceIdx]; |
| 4837 | + const int32_t kiCurDid = pCtx->uiDependencyId; | |
| 4838 | + const int32_t kiBitsPerMb = WELS_DIV_ROUND (pCtx->pWelsSvcRc[kiCurDid].iTargetBits * INT_MULTIPLY, | |
| 4839 | + pCtx->pWelsSvcRc[kiCurDid].iNumberMbFrame); | |
| 4837 | 4840 | while (uiSliceIdx < iMaxSliceNum) { |
| 4838 | 4841 | SSliceHeaderExt* pSHExt = &pSliceIdx->sSliceHeaderExt; |
| 4839 | 4842 | pSliceIdx->uiSliceIdx = uiSliceIdx; |
| @@ -4848,51 +4851,32 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 8 unmodified lines | ||
| 4848 | 4851 | return ENC_RETURN_MEMALLOCERR; |
| 4849 | 4852 | } |
| 4850 | 4853 | |
| 4851 | − pSliceIdx->bSliceHeaderExtFlag = pBaseSlice->bSliceHeaderExtFlag; | |
| 4852 | − pSHExt->sSliceHeader.iPpsId = pBaseSHExt->sSliceHeader.iPpsId; | |
| 4853 | − pSHExt->sSliceHeader.pPps = pBaseSHExt->sSliceHeader.pPps; | |
| 4854 | − pSHExt->sSliceHeader.iSpsId = pBaseSHExt->sSliceHeader.iSpsId; | |
| 4855 | − pSHExt->sSliceHeader.pSps = pBaseSHExt->sSliceHeader.pSps; | |
| 4854 | + pSliceIdx->bSliceHeaderExtFlag = pBaseSlice->bSliceHeaderExtFlag; | |
| 4855 | + pSHExt->sSliceHeader.iPpsId = pBaseSHExt->sSliceHeader.iPpsId; | |
| 4856 | + pSHExt->sSliceHeader.pPps = pBaseSHExt->sSliceHeader.pPps; | |
| 4857 | + pSHExt->sSliceHeader.iSpsId = pBaseSHExt->sSliceHeader.iSpsId; | |
| 4858 | + pSHExt->sSliceHeader.pSps = pBaseSHExt->sSliceHeader.pSps; | |
| 4856 | 4859 | pSHExt->sSliceHeader.uiRefCount = pCtx->iNumRef0; |
| 4857 | 4860 | memcpy (&pSHExt->sSliceHeader.sRefMarking, &pBaseSHExt->sSliceHeader.sRefMarking, sizeof (SRefPicMarking)); |
| 4858 | 4861 | memcpy (&pSHExt->sSliceHeader.sRefReordering, &pBaseSHExt->sSliceHeader.sRefReordering, |
| 4859 | 4862 | sizeof (SRefPicListReorderSyntax)); |
| 4860 | 4863 | |
| 4864 | + pSliceIdx->sSlicingOverRc.iComplexityIndexSlice = 0; | |
| 4865 | + pSliceIdx->sSlicingOverRc.iCalculatedQpSlice = pCtx->iGlobalQp; | |
| 4866 | + pSliceIdx->sSlicingOverRc.iTotalQpSlice = 0; | |
| 4867 | + pSliceIdx->sSlicingOverRc.iTotalMbSlice = 0; | |
| 4868 | + pSliceIdx->sSlicingOverRc.iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * | |
| 4869 | + pCurLayer->sLayerInfo.pSliceInLayer[uiSliceIdx].iCountMbNumInSlice, | |
| 4870 | + INT_MULTIPLY); | |
| 4871 | + pSliceIdx->sSlicingOverRc.iFrameBitsSlice = 0; | |
| 4872 | + pSliceIdx->sSlicingOverRc.iGomBitsSlice = 0; | |
| 4873 | + | |
| 4861 | 4874 | pSliceIdx++; |
| 4862 | 4875 | uiSliceIdx++; |
| 4863 | 4876 | } |
| 4864 | 4877 | pMA->WelsFree (pCurLayer->sLayerInfo.pSliceInLayer, "Slice"); |
| 4865 | 4878 | pCurLayer->sLayerInfo.pSliceInLayer = pSlice; |
| 4866 | 4879 | |
| 4867 | − //deal with rate control variables | |
| 4868 | − const int32_t kiCurDid = pCtx->uiDependencyId; | |
| 4869 | − SRCSlicing* pSlcingOverRc = (SRCSlicing*)pMA->WelsMallocz (iMaxSliceNum * sizeof (SRCSlicing), "SlicingOverRC"); | |
| 4870 | − if (NULL == pSlcingOverRc) { | |
| 4871 | − WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, | |
| 4872 | − "CWelsH264SVCEncoder::DynSliceRealloc: realloc pSlcingOverRc not successful"); | |
| 4873 | − return ENC_RETURN_MEMALLOCERR; | |
| 4874 | − } | |
| 4875 | − memcpy (pSlcingOverRc, pCtx->pWelsSvcRc[kiCurDid].pSlicingOverRc, sizeof (SRCSlicing) * iMaxSliceNumOld); | |
| 4876 | − uiSliceIdx = iMaxSliceNumOld; | |
| 4877 | − SRCSlicing* pSORC = &pSlcingOverRc[uiSliceIdx]; | |
| 4878 | − const int32_t kiBitsPerMb = WELS_DIV_ROUND (pCtx->pWelsSvcRc[kiCurDid].iTargetBits * INT_MULTIPLY, | |
| 4879 | − pCtx->pWelsSvcRc[kiCurDid].iNumberMbFrame); | |
| 4880 | − while (uiSliceIdx < iMaxSliceNum) { | |
| 4881 | − pSORC->iComplexityIndexSlice = 0; | |
| 4882 | − pSORC->iCalculatedQpSlice = pCtx->iGlobalQp; | |
| 4883 | − pSORC->iTotalQpSlice = 0; | |
| 4884 | − pSORC->iTotalMbSlice = 0; | |
| 4885 | − pSORC->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * | |
| 4886 | − pCurLayer->sLayerInfo.pSliceInLayer[uiSliceIdx].iCountMbNumInSlice, | |
| 4887 | − INT_MULTIPLY); | |
| 4888 | − pSORC->iFrameBitsSlice = 0; | |
| 4889 | − pSORC->iGomBitsSlice = 0; | |
| 4890 | − pSORC ++; | |
| 4891 | − uiSliceIdx ++; | |
| 4892 | − } | |
| 4893 | − pMA->WelsFree (pCtx->pWelsSvcRc[kiCurDid].pSlicingOverRc, "SlicingOverRC"); | |
| 4894 | − pCtx->pWelsSvcRc[kiCurDid].pSlicingOverRc = pSlcingOverRc; | |
| 4895 | − | |
| 4896 | 4880 | if (pCtx->iMaxSliceCount < iMaxSliceNum) |
| 4897 | 4881 | pCtx->iMaxSliceCount = iMaxSliceNum; |
| 4898 | 4882 | pCurLayer->sSliceEncCtx.iMaxSliceNumConstraint = iMaxSliceNum; |