Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 5 files). Show all
Unified · Split
| @@ -156,6 +156,8 @@ int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) { · 155 unmodified lines | |||
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | } | 158 | } |
| 159 | return WelsCheckRefFrameLimitation (pLogCtx, pCfg); | ||
| 160 | |||
| 159 | return ENC_RETURN_SUCCESS; | 161 | return ENC_RETURN_SUCCESS; |
| 160 | } | 162 | } |
| 161 | 163 | ||
| @@ -753,7 +755,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 591 unmodified lines | |||
| 753 | pMa = (*ppCtx)->pMemAlign; | 755 | pMa = (*ppCtx)->pMemAlign; |
| 754 | pParam = (*ppCtx)->pSvcParam; | 756 | pParam = (*ppCtx)->pSvcParam; |
| 755 | iDlayerCount = pParam->iSpatialLayerNum; | 757 | iDlayerCount = pParam->iSpatialLayerNum; |
| 756 | iNumRef = pParam->iNumRefFrame; | 758 | iNumRef = pParam->iMaxNumRefFrame; |
| 757 | 759 | ||
| 758 | const int32_t kiFeatureStrategyIndex = FME_DEFAULT_FEATURE_INDEX; | 760 | const int32_t kiFeatureStrategyIndex = FME_DEFAULT_FEATURE_INDEX; |
| 759 | const int32_t kiMe16x16 = ME_DIA_CROSS; | 761 | const int32_t kiMe16x16 = ME_DIA_CROSS; |
| @@ -927,7 +929,8 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 167 unmodified lines | |||
| 927 | 929 | ||
| 928 | // Need port pSps/pPps initialization due to spatial scalability changed | 930 | // Need port pSps/pPps initialization due to spatial scalability changed |
| 929 | if (!bUseSubsetSps) { | 931 | if (!bUseSubsetSps) { |
| 930 | WelsInitSps (pSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod, pParam->iNumRefFrame, | 932 | WelsInitSps (pSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod, |
| 933 | pParam->iMaxNumRefFrame, | ||
| 931 | iSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE); | 934 | iSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE); |
| 932 | 935 | ||
| 933 | if (iDlayerCount > 1) { | 936 | if (iDlayerCount > 1) { |
| @@ -937,7 +940,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 3 unmodified lines | |||
| 937 | } | 940 | } |
| 938 | } else { | 941 | } else { |
| 939 | WelsInitSubsetSps (pSubsetSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod, | 942 | WelsInitSubsetSps (pSubsetSps, pDlayerParam, &pParam->sDependencyLayers[iDlayerIndex], pParam->uiIntraPeriod, |
| 940 | pParam->iNumRefFrame, | 943 | pParam->iMaxNumRefFrame, |
| 941 | iSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE); | 944 | iSpsId, pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE); |
| 942 | } | 945 | } |
| 943 | 946 | ||
| @@ -1420,7 +1423,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 476 unmodified lines | |||
| 1420 | if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) { | 1423 | if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) { |
| 1421 | (*ppCtx)->pVaa = (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa"); | 1424 | (*ppCtx)->pVaa = (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa"); |
| 1422 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx)) | 1425 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx)) |
| 1423 | if (RequestMemoryVaaScreen ((*ppCtx)->pVaa, pMa, (*ppCtx)->pSvcParam->iNumRefFrame, iCountMaxMbNum << 2)) { | 1426 | if (RequestMemoryVaaScreen ((*ppCtx)->pVaa, pMa, (*ppCtx)->pSvcParam->iMaxNumRefFrame, iCountMaxMbNum << 2)) { |
| 1424 | WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMemoryVaaScreen failed!"); | 1427 | WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMemoryVaaScreen failed!"); |
| 1425 | FreeMemorySvc (ppCtx); | 1428 | FreeMemorySvc (ppCtx); |
| 1426 | return 1; | 1429 | return 1; |
| @@ -1674,7 +1677,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 247 unmodified lines | |||
| 1674 | FreePicture (pMa, &pRefList->pRef[iRef]); | 1677 | FreePicture (pMa, &pRefList->pRef[iRef]); |
| 1675 | } | 1678 | } |
| 1676 | ++ iRef; | 1679 | ++ iRef; |
| 1677 | } while (iRef < 1 + pParam->iNumRefFrame); | 1680 | } while (iRef < 1 + pParam->iMaxNumRefFrame); |
| 1678 | 1681 | ||
| 1679 | pMa->WelsFree (pCtx->ppRefPicListExt[ilayer], "ppRefPicListExt[]"); | 1682 | pMa->WelsFree (pCtx->ppRefPicListExt[ilayer], "ppRefPicListExt[]"); |
| 1680 | pCtx->ppRefPicListExt[ilayer] = NULL; | 1683 | pCtx->ppRefPicListExt[ilayer] = NULL; |
| @@ -1727,7 +1730,7 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 46 unmodified lines | |||
| 1727 | pCtx->pVaa->sVaaCalcInfo.pMad8x8 = NULL; | 1730 | pCtx->pVaa->sVaaCalcInfo.pMad8x8 = NULL; |
| 1728 | } | 1731 | } |
| 1729 | if (pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) | 1732 | if (pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) |
| 1730 | ReleaseMemoryVaaScreen (pCtx->pVaa, pMa, pCtx->pSvcParam->iNumRefFrame); | 1733 | ReleaseMemoryVaaScreen (pCtx->pVaa, pMa, pCtx->pSvcParam->iMaxNumRefFrame); |
| 1731 | pMa->WelsFree (pCtx->pVaa, "pVaa"); | 1734 | pMa->WelsFree (pCtx->pVaa, "pVaa"); |
| 1732 | pCtx->pVaa = NULL; | 1735 | pCtx->pVaa = NULL; |
| 1733 | } | 1736 | } |
| @@ -3568,16 +3571,18 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 1834 unmodified lines | |||
| 3568 | /* Decide whether need reset for IDR frame based on adjusting prarameters changed */ | 3571 | /* Decide whether need reset for IDR frame based on adjusting prarameters changed */ |
| 3569 | /* Temporal levels, spatial settings and/ or quality settings changed need update parameter sets related. */ | 3572 | /* Temporal levels, spatial settings and/ or quality settings changed need update parameter sets related. */ |
| 3570 | bNeedReset = (pOldParam == NULL) || | 3573 | bNeedReset = (pOldParam == NULL) || |
| 3571 | (pOldParam->iTemporalLayerNum != pNewParam->iTemporalLayerNum) || | ||
| 3572 | (pOldParam->uiGopSize != pNewParam->uiGopSize) || | ||
| 3573 | (pOldParam->iSpatialLayerNum != pNewParam->iSpatialLayerNum) || | 3574 | (pOldParam->iSpatialLayerNum != pNewParam->iSpatialLayerNum) || |
| 3574 | (pOldParam->iDecompStages != pNewParam->iDecompStages) || | ||
| 3575 | (pOldParam->iPicWidth != pNewParam->iPicWidth | 3575 | (pOldParam->iPicWidth != pNewParam->iPicWidth |
| 3576 | || pOldParam->iPicHeight != pNewParam->iPicHeight) || | 3576 | || pOldParam->iPicHeight != pNewParam->iPicHeight) || |
| 3577 | (pOldParam->SUsedPicRect.iWidth != pNewParam->SUsedPicRect.iWidth | 3577 | (pOldParam->SUsedPicRect.iWidth != pNewParam->SUsedPicRect.iWidth |
| 3578 | || pOldParam->SUsedPicRect.iHeight != pNewParam->SUsedPicRect.iHeight) || | 3578 | || pOldParam->SUsedPicRect.iHeight != pNewParam->SUsedPicRect.iHeight) || |
| 3579 | (pOldParam->bEnableLongTermReference != pNewParam->bEnableLongTermReference) || | 3579 | (pOldParam->bEnableLongTermReference != pNewParam->bEnableLongTermReference) || |
| 3580 | (pOldParam->iLTRRefNum != pNewParam->iLTRRefNum); | 3580 | (pOldParam->iLTRRefNum != pNewParam->iLTRRefNum); |
| 3581 | if (pNewParam->iMaxNumRefFrame > pOldParam->iMaxNumRefFrame) { | ||
| 3582 | pNewParam->iMaxNumRefFrame = pOldParam->iMaxNumRefFrame; | ||
| 3583 | bNeedReset = true; | ||
| 3584 | } | ||
| 3585 | |||
| 3581 | if (!bNeedReset) { // Check its picture resolutions/quality settings respectively in each dependency layer | 3586 | if (!bNeedReset) { // Check its picture resolutions/quality settings respectively in each dependency layer |
| 3582 | iIndexD = 0; | 3587 | iIndexD = 0; |
| 3583 | assert (pOldParam->iSpatialLayerNum == pNewParam->iSpatialLayerNum); | 3588 | assert (pOldParam->iSpatialLayerNum == pNewParam->iSpatialLayerNum); |
| @@ -3615,12 +3620,6 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 31 unmodified lines | |||
| 3615 | bNeedReset = true; | 3620 | bNeedReset = true; |
| 3616 | break; | 3621 | break; |
| 3617 | } | 3622 | } |
| 3618 | |||
| 3619 | if (kpOldDlp->iHighestTemporalId != kpNewDlp->iHighestTemporalId) { | ||
| 3620 | bNeedReset = true; | ||
| 3621 | break; | ||
| 3622 | } | ||
| 3623 | |||
| 3624 | ++ iIndexD; | 3623 | ++ iIndexD; |
| 3625 | } while (iIndexD < pOldParam->iSpatialLayerNum); | 3624 | } while (iIndexD < pOldParam->iSpatialLayerNum); |
| 3626 | } | 3625 | } |
| @@ -3801,12 +3800,13 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 174 unmodified lines | |||
| 3801 | int16_t* pFirstMbInSlice = (int16_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int16_t), "pSliceSeg->pFirstMbInSlice"); | 3800 | int16_t* pFirstMbInSlice = (int16_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int16_t), "pSliceSeg->pFirstMbInSlice"); |
| 3802 | if (NULL == pFirstMbInSlice) | 3801 | if (NULL == pFirstMbInSlice) |
| 3803 | return ENC_RETURN_MEMALLOCERR; | 3802 | return ENC_RETURN_MEMALLOCERR; |
| 3804 | memset(pFirstMbInSlice, 0, sizeof(int16_t) * iMaxSliceNum); | 3803 | memset (pFirstMbInSlice, 0, sizeof (int16_t) * iMaxSliceNum); |
| 3805 | memcpy (pFirstMbInSlice, pCurLayer->pSliceEncCtx->pFirstMbInSlice, sizeof (int16_t) * iMaxSliceNumOld); | 3804 | memcpy (pFirstMbInSlice, pCurLayer->pSliceEncCtx->pFirstMbInSlice, sizeof (int16_t) * iMaxSliceNumOld); |
| 3806 | pMA->WelsFree (pCurLayer->pSliceEncCtx->pFirstMbInSlice, "pSliceSeg->pFirstMbInSlice"); | 3805 | pMA->WelsFree (pCurLayer->pSliceEncCtx->pFirstMbInSlice, "pSliceSeg->pFirstMbInSlice"); |
| 3807 | pCurLayer->pSliceEncCtx->pFirstMbInSlice = pFirstMbInSlice; | 3806 | pCurLayer->pSliceEncCtx->pFirstMbInSlice = pFirstMbInSlice; |
| 3808 | 3807 | ||
| 3809 | int32_t* pCountMbNumInSlice = (int32_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int32_t),"pSliceSeg->pCountMbNumInSlice"); | 3808 | int32_t* pCountMbNumInSlice = (int32_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int32_t), |
| 3809 | "pSliceSeg->pCountMbNumInSlice"); | ||
| 3810 | if (NULL == pCountMbNumInSlice) | 3810 | if (NULL == pCountMbNumInSlice) |
| 3811 | return ENC_RETURN_MEMALLOCERR; | 3811 | return ENC_RETURN_MEMALLOCERR; |
| 3812 | memcpy (pCountMbNumInSlice, pCurLayer->pSliceEncCtx->pCountMbNumInSlice, sizeof (int32_t) * iMaxSliceNumOld); | 3812 | memcpy (pCountMbNumInSlice, pCurLayer->pSliceEncCtx->pCountMbNumInSlice, sizeof (int32_t) * iMaxSliceNumOld); |
| @@ -3824,13 +3824,15 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 11 unmodified lines | |||
| 3824 | memcpy (pSlcingOverRc, pCtx->pWelsSvcRc->pSlicingOverRc, sizeof (SRCSlicing) * iMaxSliceNumOld); | 3824 | memcpy (pSlcingOverRc, pCtx->pWelsSvcRc->pSlicingOverRc, sizeof (SRCSlicing) * iMaxSliceNumOld); |
| 3825 | uiSliceIdx = iMaxSliceNumOld; | 3825 | uiSliceIdx = iMaxSliceNumOld; |
| 3826 | SRCSlicing* pSORC = &pSlcingOverRc[uiSliceIdx]; | 3826 | SRCSlicing* pSORC = &pSlcingOverRc[uiSliceIdx]; |
| 3827 | const int32_t kiBitsPerMb = WELS_DIV_ROUND(pCtx->pWelsSvcRc->iTargetBits * INT_MULTIPLY, pCtx->pWelsSvcRc->iNumberMbFrame); | 3827 | const int32_t kiBitsPerMb = WELS_DIV_ROUND (pCtx->pWelsSvcRc->iTargetBits * INT_MULTIPLY, |
| 3828 | pCtx->pWelsSvcRc->iNumberMbFrame); | ||
| 3828 | while (uiSliceIdx < iMaxSliceNum) { | 3829 | while (uiSliceIdx < iMaxSliceNum) { |
| 3829 | pSORC->iComplexityIndexSlice = 0; | 3830 | pSORC->iComplexityIndexSlice = 0; |
| 3830 | pSORC->iCalculatedQpSlice = pCtx->iGlobalQp; | 3831 | pSORC->iCalculatedQpSlice = pCtx->iGlobalQp; |
| 3831 | pSORC->iTotalQpSlice = 0; | 3832 | pSORC->iTotalQpSlice = 0; |
| 3832 | pSORC->iTotalMbSlice = 0; | 3833 | pSORC->iTotalMbSlice = 0; |
| 3833 | pSORC->iTargetBitsSlice = WELS_DIV_ROUND(kiBitsPerMb * pCurLayer->pSliceEncCtx->pCountMbNumInSlice[uiSliceIdx], INT_MULTIPLY); | 3834 | pSORC->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * pCurLayer->pSliceEncCtx->pCountMbNumInSlice[uiSliceIdx], |
| 3835 | INT_MULTIPLY); | ||
| 3834 | pSORC->iFrameBitsSlice = 0; | 3836 | pSORC->iFrameBitsSlice = 0; |
| 3835 | pSORC->iGomBitsSlice = 0; | 3837 | pSORC->iGomBitsSlice = 0; |
| 3836 | pSORC ++; | 3838 | pSORC ++; |