Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 1 file). Show all
Unified · Split
| @@ -1287,7 +1287,8 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 1286 unmodified lines | |||
| 1287 | 1287 | ||
| 1288 | fCompressRatioThr = COMPRESS_RATIO_THR; | 1288 | fCompressRatioThr = COMPRESS_RATIO_THR; |
| 1289 | 1289 | ||
| 1290 | iLayerBsSize = WELS_ROUND (((3 * fDlp->iFrameWidth * fDlp->iFrameHeight) >> 1) * fCompressRatioThr) + MAX_MACROBLOCK_SIZE_IN_BYTE; | 1290 | iLayerBsSize = WELS_ROUND (((3 * fDlp->iFrameWidth * fDlp->iFrameHeight) >> 1) * fCompressRatioThr) + |
| 1291 | MAX_MACROBLOCK_SIZE_IN_BYTE; | ||
| 1291 | iLayerBsSize = WELS_ALIGN (iLayerBsSize, 4); // 4 bytes alinged | 1292 | iLayerBsSize = WELS_ALIGN (iLayerBsSize, 4); // 4 bytes alinged |
| 1292 | iVclLayersBsSizeCount += iLayerBsSize; | 1293 | iVclLayersBsSizeCount += iLayerBsSize; |
| 1293 | ++ iIndex; | 1294 | ++ iIndex; |
| @@ -1305,8 +1306,8 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 11 unmodified lines | |||
| 1305 | (*ppCtx)->pOut->uiSize = iCountBsLen; | 1306 | (*ppCtx)->pOut->uiSize = iCountBsLen; |
| 1306 | (*ppCtx)->pOut->sNalList = (SWelsNalRaw*)pMa->WelsMalloc (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList"); | 1307 | (*ppCtx)->pOut->sNalList = (SWelsNalRaw*)pMa->WelsMalloc (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList"); |
| 1307 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->sNalList), FreeMemorySvc (ppCtx)) | 1308 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->sNalList), FreeMemorySvc (ppCtx)) |
| 1308 | (*ppCtx)->pOut->pNalLen = (int32_t*)pMa->WelsMallocz(iCountNals * sizeof (int32_t), "pOut->pNalLen"); | 1309 | (*ppCtx)->pOut->pNalLen = (int32_t*)pMa->WelsMallocz (iCountNals * sizeof (int32_t), "pOut->pNalLen"); |
| 1309 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->pNalLen), FreeMemorySvc(ppCtx)) | 1310 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->pNalLen), FreeMemorySvc (ppCtx)) |
| 1310 | (*ppCtx)->pOut->iCountNals = iCountNals; | 1311 | (*ppCtx)->pOut->iCountNals = iCountNals; |
| 1311 | (*ppCtx)->pOut->iNalIndex = 0; | 1312 | (*ppCtx)->pOut->iNalIndex = 0; |
| 1312 | 1313 | ||
| @@ -1504,7 +1505,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 191 unmodified lines | |||
| 1504 | // NALs len | 1505 | // NALs len |
| 1505 | if (NULL != pCtx->pOut->pNalLen) { | 1506 | if (NULL != pCtx->pOut->pNalLen) { |
| 1506 | pMa->WelsFree (pCtx->pOut->pNalLen, "pOut->pNalLen"); | 1507 | pMa->WelsFree (pCtx->pOut->pNalLen, "pOut->pNalLen"); |
| 1507 | pCtx->pOut->pNalLen = NULL; | 1508 | pCtx->pOut->pNalLen = NULL; |
| 1508 | } | 1509 | } |
| 1509 | pMa->WelsFree (pCtx->pOut, "SWelsEncoderOutput"); | 1510 | pMa->WelsFree (pCtx->pOut, "SWelsEncoderOutput"); |
| 1510 | pCtx->pOut = NULL; | 1511 | pCtx->pOut = NULL; |
| @@ -3090,7 +3091,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 1579 unmodified lines | |||
| 3090 | int32_t iPayloadSize = 0; | 3091 | int32_t iPayloadSize = 0; |
| 3091 | 3092 | ||
| 3092 | if (pCtx->bNeedPrefixNalFlag) { | 3093 | if (pCtx->bNeedPrefixNalFlag) { |
| 3093 | pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, eNalType, eNalRefIdc, | 3094 | pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, eNalType, |
| 3095 | eNalRefIdc, | ||
| 3094 | iPayloadSize); | 3096 | iPayloadSize); |
| 3095 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | 3097 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 3096 | iLayerSize += iPayloadSize; | 3098 | iLayerSize += iPayloadSize; |
| @@ -3123,7 +3125,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 26 unmodified lines | |||
| 3123 | // for dynamic slicing single threading.. | 3125 | // for dynamic slicing single threading.. |
| 3124 | else if ((SM_DYN_SLICE == pParam->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc <= 1)) { | 3126 | else if ((SM_DYN_SLICE == pParam->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc <= 1)) { |
| 3125 | const int32_t kiLastMbInFrame = pCtx->pCurDqLayer->pSliceEncCtx->iMbNumInFrame; | 3127 | const int32_t kiLastMbInFrame = pCtx->pCurDqLayer->pSliceEncCtx->iMbNumInFrame; |
| 3126 | pCtx->iEncoderError = WelsCodeOnePicPartition (pCtx, pFbi, pLayerBsInfo, &iNalIdxInLayer, &iLayerSize, 0, kiLastMbInFrame, 0); | 3128 | pCtx->iEncoderError = WelsCodeOnePicPartition (pCtx, pFbi, pLayerBsInfo, &iNalIdxInLayer, &iLayerSize, 0, |
| 3129 | kiLastMbInFrame, 0); | ||
| 3127 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | 3130 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 3128 | } else { | 3131 | } else { |
| 3129 | //other multi-slice uiSliceMode | 3132 | //other multi-slice uiSliceMode |
| @@ -3260,7 +3263,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 130 unmodified lines | |||
| 3260 | int32_t iSliceSize = 0; | 3263 | int32_t iSliceSize = 0; |
| 3261 | int32_t iPayloadSize = 0; | 3264 | int32_t iPayloadSize = 0; |
| 3262 | if (bNeedPrefix) { | 3265 | if (bNeedPrefix) { |
| 3263 | pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, eNalType, eNalRefIdc, | 3266 | pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, eNalType, |
| 3267 | eNalRefIdc, | ||
| 3264 | iPayloadSize); | 3268 | iPayloadSize); |
| 3265 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | 3269 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 3266 | iLayerSize += iPayloadSize; | 3270 | iLayerSize += iPayloadSize; |
| @@ -3686,9 +3690,9 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 419 unmodified lines | |||
| 3686 | return 0; | 3690 | return 0; |
| 3687 | } | 3691 | } |
| 3688 | 3692 | ||
| 3689 | int32_t DynSliceRealloc(sWelsEncCtx* pCtx, | 3693 | int32_t DynSliceRealloc (sWelsEncCtx* pCtx, |
| 3690 | SFrameBSInfo* pFrameBsInfo, | 3694 | SFrameBSInfo* pFrameBsInfo, |
| 3691 | SLayerBSInfo* pLayerBsInfo) { | 3695 | SLayerBSInfo* pLayerBsInfo) { |
| 3692 | CMemoryAlign* pMA = pCtx->pMemAlign; | 3696 | CMemoryAlign* pMA = pCtx->pMemAlign; |
| 3693 | SDqLayer* pCurLayer = pCtx->pCurDqLayer; | 3697 | SDqLayer* pCurLayer = pCtx->pCurDqLayer; |
| 3694 | 3698 | ||
| @@ -3698,22 +3702,22 @@ int32_t DynSliceRealloc(sWelsEncCtx* pCtx, · 3 unmodified lines | |||
| 3698 | iCountNals += iMaxSliceNum * (pCtx->pSvcParam->iSpatialLayerNum + pCtx->bNeedPrefixNalFlag); | 3702 | iCountNals += iMaxSliceNum * (pCtx->pSvcParam->iSpatialLayerNum + pCtx->bNeedPrefixNalFlag); |
| 3699 | iMaxSliceNum *= SLICE_NUM_EXPAND_COEF; | 3703 | iMaxSliceNum *= SLICE_NUM_EXPAND_COEF; |
| 3700 | 3704 | ||
| 3701 | SWelsNalRaw* pNalList = (SWelsNalRaw*)pMA->WelsMalloc(iCountNals * sizeof(SWelsNalRaw), "pOut->sNalList"); | 3705 | SWelsNalRaw* pNalList = (SWelsNalRaw*)pMA->WelsMalloc (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList"); |
| 3702 | if (NULL == pNalList) | 3706 | if (NULL == pNalList) |
| 3703 | return ENC_RETURN_MEMALLOCERR; | 3707 | return ENC_RETURN_MEMALLOCERR; |
| 3704 | memcpy(pNalList, pCtx->pOut->sNalList, sizeof(SWelsNalRaw) * pCtx->pOut->iCountNals); | 3708 | memcpy (pNalList, pCtx->pOut->sNalList, sizeof (SWelsNalRaw) * pCtx->pOut->iCountNals); |
| 3705 | pMA->WelsFree(pCtx->pOut->sNalList, "pOut->sNalList"); | 3709 | pMA->WelsFree (pCtx->pOut->sNalList, "pOut->sNalList"); |
| 3706 | pCtx->pOut->sNalList = pNalList; | 3710 | pCtx->pOut->sNalList = pNalList; |
| 3707 | 3711 | ||
| 3708 | int32_t* pNalLen = (int32_t*)pMA->WelsMalloc(iCountNals * sizeof(int32_t), "pOut->pNalLen"); | 3712 | int32_t* pNalLen = (int32_t*)pMA->WelsMalloc (iCountNals * sizeof (int32_t), "pOut->pNalLen"); |
| 3709 | if (NULL == pNalLen) | 3713 | if (NULL == pNalLen) |
| 3710 | return ENC_RETURN_MEMALLOCERR; | 3714 | return ENC_RETURN_MEMALLOCERR; |
| 3711 | memcpy(pNalLen, pCtx->pOut->pNalLen, sizeof(int32_t) * pCtx->pOut->iCountNals); | 3715 | memcpy (pNalLen, pCtx->pOut->pNalLen, sizeof (int32_t) * pCtx->pOut->iCountNals); |
| 3712 | pMA->WelsFree(pCtx->pOut->pNalLen, "pOut->pNalLen"); | 3716 | pMA->WelsFree (pCtx->pOut->pNalLen, "pOut->pNalLen"); |
| 3713 | pCtx->pOut->pNalLen = pNalLen; | 3717 | pCtx->pOut->pNalLen = pNalLen; |
| 3714 | 3718 | ||
| 3715 | pCtx->pOut->iCountNals = iCountNals; | 3719 | pCtx->pOut->iCountNals = iCountNals; |
| 3716 | SLayerBSInfo *pLBI1, *pLBI2; | 3720 | SLayerBSInfo* pLBI1, *pLBI2; |
| 3717 | pLBI1 = &pFrameBsInfo->sLayerInfo[0]; | 3721 | pLBI1 = &pFrameBsInfo->sLayerInfo[0]; |
| 3718 | pLBI1->pNalLengthInByte = pCtx->pOut->pNalLen; | 3722 | pLBI1->pNalLengthInByte = pCtx->pOut->pNalLen; |
| 3719 | while (pLBI1 != pLayerBsInfo) { | 3723 | while (pLBI1 != pLayerBsInfo) { |
| @@ -3722,23 +3726,23 @@ int32_t DynSliceRealloc(sWelsEncCtx* pCtx, · 2 unmodified lines | |||
| 3722 | pLBI1->pNalLengthInByte = pLBI2->pNalLengthInByte + pLBI2->iNalCount; | 3726 | pLBI1->pNalLengthInByte = pLBI2->pNalLengthInByte + pLBI2->iNalCount; |
| 3723 | } | 3727 | } |
| 3724 | 3728 | ||
| 3725 | SSlice *pSlice = (SSlice*)pMA->WelsMallocz( sizeof(SSlice) * iMaxSliceNum, "Slice"); | 3729 | SSlice* pSlice = (SSlice*)pMA->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "Slice"); |
| 3726 | if (NULL == pSlice) | 3730 | if (NULL == pSlice) |
| 3727 | return ENC_RETURN_MEMALLOCERR; | 3731 | return ENC_RETURN_MEMALLOCERR; |
| 3728 | memcpy(pSlice, pCurLayer->sLayerInfo.pSliceInLayer, sizeof(SSlice) * iMaxSliceNumOld); | 3732 | memcpy (pSlice, pCurLayer->sLayerInfo.pSliceInLayer, sizeof (SSlice) * iMaxSliceNumOld); |
| 3729 | uint32_t uiSliceIdx; | 3733 | uint32_t uiSliceIdx; |
| 3730 | uiSliceIdx = iMaxSliceNumOld; | 3734 | uiSliceIdx = iMaxSliceNumOld; |
| 3731 | SSlice *pBaseSlice = &pCurLayer->sLayerInfo.pSliceInLayer[0]; | 3735 | SSlice* pBaseSlice = &pCurLayer->sLayerInfo.pSliceInLayer[0]; |
| 3732 | SSliceHeaderExt *pBaseSHExt = &pBaseSlice->sSliceHeaderExt; | 3736 | SSliceHeaderExt* pBaseSHExt = &pBaseSlice->sSliceHeaderExt; |
| 3733 | SSlice *pSliceIdx = &pSlice[uiSliceIdx]; | 3737 | SSlice* pSliceIdx = &pSlice[uiSliceIdx]; |
| 3734 | while (uiSliceIdx < iMaxSliceNum) { | 3738 | while (uiSliceIdx < iMaxSliceNum) { |
| 3735 | SSliceHeaderExt *pSHExt = &pSliceIdx->sSliceHeaderExt; | 3739 | SSliceHeaderExt* pSHExt = &pSliceIdx->sSliceHeaderExt; |
| 3736 | pSliceIdx->uiSliceIdx = uiSliceIdx; | 3740 | pSliceIdx->uiSliceIdx = uiSliceIdx; |
| 3737 | if (pCtx->pSvcParam->iMultipleThreadIdc > 1) | 3741 | if (pCtx->pSvcParam->iMultipleThreadIdc > 1) |
| 3738 | pSliceIdx->pSliceBsa = &pCtx->pSliceBs[uiSliceIdx].sBsWrite; | 3742 | pSliceIdx->pSliceBsa = &pCtx->pSliceBs[uiSliceIdx].sBsWrite; |
| 3739 | else | 3743 | else |
| 3740 | pSliceIdx->pSliceBsa = &pCtx->pOut->sBsWrite; | 3744 | pSliceIdx->pSliceBsa = &pCtx->pOut->sBsWrite; |
| 3741 | if (AllocMbCacheAligned(&pSliceIdx->sMbCacheInfo, pMA)) | 3745 | if (AllocMbCacheAligned (&pSliceIdx->sMbCacheInfo, pMA)) |
| 3742 | return ENC_RETURN_MEMALLOCERR; | 3746 | return ENC_RETURN_MEMALLOCERR; |
| 3743 | 3747 | ||
| 3744 | pSliceIdx->bSliceHeaderExtFlag = pBaseSlice->bSliceHeaderExtFlag; | 3748 | pSliceIdx->bSliceHeaderExtFlag = pBaseSlice->bSliceHeaderExtFlag; |
| @@ -3747,48 +3751,50 @@ int32_t DynSliceRealloc(sWelsEncCtx* pCtx, · 2 unmodified lines | |||
| 3747 | pSHExt->sSliceHeader.iSpsId = pBaseSHExt->sSliceHeader.iSpsId; | 3751 | pSHExt->sSliceHeader.iSpsId = pBaseSHExt->sSliceHeader.iSpsId; |
| 3748 | pSHExt->sSliceHeader.pSps = pBaseSHExt->sSliceHeader.pSps; | 3752 | pSHExt->sSliceHeader.pSps = pBaseSHExt->sSliceHeader.pSps; |
| 3749 | pSHExt->sSliceHeader.uiRefCount = pCtx->iNumRef0; | 3753 | pSHExt->sSliceHeader.uiRefCount = pCtx->iNumRef0; |
| 3750 | memcpy(&pSHExt->sSliceHeader.sRefMarking, &pBaseSHExt->sSliceHeader.sRefMarking, sizeof(SRefPicMarking)); | 3754 | memcpy (&pSHExt->sSliceHeader.sRefMarking, &pBaseSHExt->sSliceHeader.sRefMarking, sizeof (SRefPicMarking)); |
| 3751 | memcpy(&pSHExt->sSliceHeader.sRefReordering, &pBaseSHExt->sSliceHeader.sRefReordering, sizeof(SRefPicListReorderSyntax)); | 3755 | memcpy (&pSHExt->sSliceHeader.sRefReordering, &pBaseSHExt->sSliceHeader.sRefReordering, |
| 3756 | sizeof (SRefPicListReorderSyntax)); | ||
| 3752 | 3757 | ||
| 3753 | pSliceIdx++; | 3758 | pSliceIdx++; |
| 3754 | uiSliceIdx++; | 3759 | uiSliceIdx++; |
| 3755 | } | 3760 | } |
| 3756 | pMA->WelsFree(pCurLayer->sLayerInfo.pSliceInLayer, "Slice"); | 3761 | pMA->WelsFree (pCurLayer->sLayerInfo.pSliceInLayer, "Slice"); |
| 3757 | pCurLayer->sLayerInfo.pSliceInLayer = pSlice; | 3762 | pCurLayer->sLayerInfo.pSliceInLayer = pSlice; |
| 3758 | 3763 | ||
| 3759 | SRCSlicing *pSlcingOverRc = (SRCSlicing *)pMA->WelsMalloc(iMaxSliceNum * sizeof(SRCSlicing), "SlicingOverRC"); | 3764 | SRCSlicing* pSlcingOverRc = (SRCSlicing*)pMA->WelsMalloc (iMaxSliceNum * sizeof (SRCSlicing), "SlicingOverRC"); |
| 3760 | if (NULL == pSlcingOverRc) | 3765 | if (NULL == pSlcingOverRc) |
| 3761 | return ENC_RETURN_MEMALLOCERR; | 3766 | return ENC_RETURN_MEMALLOCERR; |
| 3762 | memcpy(pSlcingOverRc, pCtx->pWelsSvcRc->pSlicingOverRc, sizeof(SRCSlicing) * iMaxSliceNumOld); | 3767 | memcpy (pSlcingOverRc, pCtx->pWelsSvcRc->pSlicingOverRc, sizeof (SRCSlicing) * iMaxSliceNumOld); |
| 3763 | uiSliceIdx = iMaxSliceNumOld; | 3768 | uiSliceIdx = iMaxSliceNumOld; |
| 3764 | SRCSlicing *pSORC = &pSlcingOverRc[uiSliceIdx]; | 3769 | SRCSlicing* pSORC = &pSlcingOverRc[uiSliceIdx]; |
| 3765 | while (uiSliceIdx < iMaxSliceNum) { | 3770 | while (uiSliceIdx < iMaxSliceNum) { |
| 3766 | pSORC->iComplexityIndexSlice = 0; | 3771 | pSORC->iComplexityIndexSlice = 0; |
| 3767 | pSORC->iCalculatedQpSlice = pCtx->iGlobalQp; | 3772 | pSORC->iCalculatedQpSlice = pCtx->iGlobalQp; |
| 3768 | pSORC ++; | 3773 | pSORC ++; |
| 3769 | uiSliceIdx ++; | 3774 | uiSliceIdx ++; |
| 3770 | } | 3775 | } |
| 3771 | pMA->WelsFree(pCtx->pWelsSvcRc->pSlicingOverRc, "SlicingOverRC"); | 3776 | pMA->WelsFree (pCtx->pWelsSvcRc->pSlicingOverRc, "SlicingOverRC"); |
| 3772 | pCtx->pWelsSvcRc->pSlicingOverRc = pSlcingOverRc; | 3777 | pCtx->pWelsSvcRc->pSlicingOverRc = pSlcingOverRc; |
| 3773 | 3778 | ||
| 3774 | int16_t *pFirstMbInSlice = (int16_t *)pMA->WelsMalloc(iMaxSliceNum * sizeof(int16_t), "pSliceSeg->pFirstMbInSlice"); | 3779 | int16_t* pFirstMbInSlice = (int16_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int16_t), "pSliceSeg->pFirstMbInSlice"); |
| 3775 | if (NULL == pFirstMbInSlice) | 3780 | if (NULL == pFirstMbInSlice) |
| 3776 | return ENC_RETURN_MEMALLOCERR; | 3781 | return ENC_RETURN_MEMALLOCERR; |
| 3777 | memcpy(pFirstMbInSlice, pCurLayer->pSliceEncCtx->pFirstMbInSlice, sizeof(int16_t) * iMaxSliceNumOld); | 3782 | memcpy (pFirstMbInSlice, pCurLayer->pSliceEncCtx->pFirstMbInSlice, sizeof (int16_t) * iMaxSliceNumOld); |
| 3778 | pMA->WelsFree(pCurLayer->pSliceEncCtx->pFirstMbInSlice, "pSliceSeg->pFirstMbInSlice"); | 3783 | pMA->WelsFree (pCurLayer->pSliceEncCtx->pFirstMbInSlice, "pSliceSeg->pFirstMbInSlice"); |
| 3779 | pCurLayer->pSliceEncCtx->pFirstMbInSlice = pFirstMbInSlice; | 3784 | pCurLayer->pSliceEncCtx->pFirstMbInSlice = pFirstMbInSlice; |
| 3780 | 3785 | ||
| 3781 | int32_t *pCountMbNumInSlice = (int32_t *)pMA->WelsMalloc(iMaxSliceNum * sizeof(int32_t), "pSliceSeg->pCountMbNumInSlice"); | 3786 | int32_t* pCountMbNumInSlice = (int32_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int32_t), |
| 3787 | "pSliceSeg->pCountMbNumInSlice"); | ||
| 3782 | if (NULL == pCountMbNumInSlice) | 3788 | if (NULL == pCountMbNumInSlice) |
| 3783 | return ENC_RETURN_MEMALLOCERR; | 3789 | return ENC_RETURN_MEMALLOCERR; |
| 3784 | memcpy(pCountMbNumInSlice, pCurLayer->pSliceEncCtx->pCountMbNumInSlice, sizeof(int32_t) * iMaxSliceNumOld); | 3790 | memcpy (pCountMbNumInSlice, pCurLayer->pSliceEncCtx->pCountMbNumInSlice, sizeof (int32_t) * iMaxSliceNumOld); |
| 3785 | pMA->WelsFree(pCurLayer->pSliceEncCtx->pCountMbNumInSlice, "pSliceSeg->pCountMbNumInSlice"); | 3791 | pMA->WelsFree (pCurLayer->pSliceEncCtx->pCountMbNumInSlice, "pSliceSeg->pCountMbNumInSlice"); |
| 3786 | pCurLayer->pSliceEncCtx->pCountMbNumInSlice = pCountMbNumInSlice; | 3792 | pCurLayer->pSliceEncCtx->pCountMbNumInSlice = pCountMbNumInSlice; |
| 3787 | 3793 | ||
| 3788 | if (pCtx->iMaxSliceCount < iMaxSliceNum) | 3794 | if (pCtx->iMaxSliceCount < iMaxSliceNum) |
| 3789 | pCtx->iMaxSliceCount = iMaxSliceNum; | 3795 | pCtx->iMaxSliceCount = iMaxSliceNum; |
| 3790 | pCurLayer->pSliceEncCtx->iMaxSliceNumConstraint = iMaxSliceNum; | 3796 | pCurLayer->pSliceEncCtx->iMaxSliceNumConstraint = iMaxSliceNum; |
| 3791 | return ENC_RETURN_SUCCESS; | 3797 | return ENC_RETURN_SUCCESS; |
| 3792 | } | 3798 | } |
| 3793 | int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, | 3799 | int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, |
| 3794 | SFrameBSInfo* pFrameBSInfo, | 3800 | SFrameBSInfo* pFrameBSInfo, |
| @@ -3828,15 +3834,16 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 33 unmodified lines | |||
| 3828 | 3834 | ||
| 3829 | if (iSliceIdx >= (pSliceCtx->iMaxSliceNumConstraint - kiSliceIdxStep)) { // insufficient memory in pSliceInLayer[] | 3835 | if (iSliceIdx >= (pSliceCtx->iMaxSliceNumConstraint - kiSliceIdxStep)) { // insufficient memory in pSliceInLayer[] |
| 3830 | if (pCtx->iActiveThreadsNum == 1) | 3836 | if (pCtx->iActiveThreadsNum == 1) |
| 3831 | if (DynSliceRealloc(pCtx, pFrameBSInfo, pLayerBsInfo)) //only single thread support re-alloc now | 3837 | if (DynSliceRealloc (pCtx, pFrameBSInfo, pLayerBsInfo)) //only single thread support re-alloc now |
| 3832 | return ENC_RETURN_MEMALLOCERR; | 3838 | return ENC_RETURN_MEMALLOCERR; |
| 3833 | else if (iSliceIdx >= pSliceCtx->iMaxSliceNumConstraint) { | 3839 | else if (iSliceIdx >= pSliceCtx->iMaxSliceNumConstraint) { |
| 3834 | return ENC_RETURN_MEMALLOCERR; | 3840 | return ENC_RETURN_MEMALLOCERR; |
| 3835 | } | 3841 | } |
| 3836 | } | 3842 | } |
| 3837 | 3843 | ||
| 3838 | if (kbNeedPrefix) { | 3844 | if (kbNeedPrefix) { |
| 3839 | iReturn = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, keNalType, keNalRefIdc, iPayloadSize); | 3845 | iReturn = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, keNalType, keNalRefIdc, |
| 3846 | iPayloadSize); | ||
| 3840 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | 3847 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| 3841 | iPartitionBsSize += iPayloadSize; | 3848 | iPartitionBsSize += iPayloadSize; |
| 3842 | } | 3849 | } |