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