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 | SSlice* pBaseSlice = &pCurLayer->sLayerInfo.pSliceInLayer[0]; | 4834 | SSlice* pBaseSlice = &pCurLayer->sLayerInfo.pSliceInLayer[0]; |
| 4835 | SSliceHeaderExt* pBaseSHExt = &pBaseSlice->sSliceHeaderExt; | 4835 | SSliceHeaderExt* pBaseSHExt = &pBaseSlice->sSliceHeaderExt; |
| 4836 | SSlice* pSliceIdx = &pSlice[uiSliceIdx]; | 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 | while (uiSliceIdx < iMaxSliceNum) { | 4840 | while (uiSliceIdx < iMaxSliceNum) { |
| 4838 | SSliceHeaderExt* pSHExt = &pSliceIdx->sSliceHeaderExt; | 4841 | SSliceHeaderExt* pSHExt = &pSliceIdx->sSliceHeaderExt; |
| 4839 | pSliceIdx->uiSliceIdx = uiSliceIdx; | 4842 | pSliceIdx->uiSliceIdx = uiSliceIdx; |
| @@ -4848,51 +4851,32 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 8 unmodified lines | |||
| 4848 | return ENC_RETURN_MEMALLOCERR; | 4851 | return ENC_RETURN_MEMALLOCERR; |
| 4849 | } | 4852 | } |
| 4850 | 4853 | ||
| 4851 | pSliceIdx->bSliceHeaderExtFlag = pBaseSlice->bSliceHeaderExtFlag; | 4854 | pSliceIdx->bSliceHeaderExtFlag = pBaseSlice->bSliceHeaderExtFlag; |
| 4852 | pSHExt->sSliceHeader.iPpsId = pBaseSHExt->sSliceHeader.iPpsId; | 4855 | pSHExt->sSliceHeader.iPpsId = pBaseSHExt->sSliceHeader.iPpsId; |
| 4853 | pSHExt->sSliceHeader.pPps = pBaseSHExt->sSliceHeader.pPps; | 4856 | pSHExt->sSliceHeader.pPps = pBaseSHExt->sSliceHeader.pPps; |
| 4854 | pSHExt->sSliceHeader.iSpsId = pBaseSHExt->sSliceHeader.iSpsId; | 4857 | pSHExt->sSliceHeader.iSpsId = pBaseSHExt->sSliceHeader.iSpsId; |
| 4855 | pSHExt->sSliceHeader.pSps = pBaseSHExt->sSliceHeader.pSps; | 4858 | pSHExt->sSliceHeader.pSps = pBaseSHExt->sSliceHeader.pSps; |
| 4856 | pSHExt->sSliceHeader.uiRefCount = pCtx->iNumRef0; | 4859 | pSHExt->sSliceHeader.uiRefCount = pCtx->iNumRef0; |
| 4857 | memcpy (&pSHExt->sSliceHeader.sRefMarking, &pBaseSHExt->sSliceHeader.sRefMarking, sizeof (SRefPicMarking)); | 4860 | memcpy (&pSHExt->sSliceHeader.sRefMarking, &pBaseSHExt->sSliceHeader.sRefMarking, sizeof (SRefPicMarking)); |
| 4858 | memcpy (&pSHExt->sSliceHeader.sRefReordering, &pBaseSHExt->sSliceHeader.sRefReordering, | 4861 | memcpy (&pSHExt->sSliceHeader.sRefReordering, &pBaseSHExt->sSliceHeader.sRefReordering, |
| 4859 | sizeof (SRefPicListReorderSyntax)); | 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 | pSliceIdx++; | 4874 | pSliceIdx++; |
| 4862 | uiSliceIdx++; | 4875 | uiSliceIdx++; |
| 4863 | } | 4876 | } |
| 4864 | pMA->WelsFree (pCurLayer->sLayerInfo.pSliceInLayer, "Slice"); | 4877 | pMA->WelsFree (pCurLayer->sLayerInfo.pSliceInLayer, "Slice"); |
| 4865 | pCurLayer->sLayerInfo.pSliceInLayer = pSlice; | 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 | if (pCtx->iMaxSliceCount < iMaxSliceNum) | 4880 | if (pCtx->iMaxSliceCount < iMaxSliceNum) |
| 4897 | pCtx->iMaxSliceCount = iMaxSliceNum; | 4881 | pCtx->iMaxSliceCount = iMaxSliceNum; |
| 4898 | pCurLayer->sSliceEncCtx.iMaxSliceNumConstraint = iMaxSliceNum; | 4882 | pCurLayer->sSliceEncCtx.iMaxSliceNumConstraint = iMaxSliceNum; |