Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 3 files). Show all
Unified · Split
| @@ -480,6 +480,7 @@ void WelsEncoderApplyBitRate (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, · 479 unmodified lines | |||
| 480 | } | 480 | } |
| 481 | } | 481 | } |
| 482 | } | 482 | } |
| 483 | |||
| 483 | /*! | 484 | /*! |
| 484 | * \brief acquire count number of layers and NALs based on configurable paramters dependency | 485 | * \brief acquire count number of layers and NALs based on configurable paramters dependency |
| 485 | * \pParam pCtx sWelsEncCtx* | 486 | * \pParam pCtx sWelsEncCtx* |
| @@ -1273,8 +1274,10 @@ void GetMvMvdRange (SWelsSvcCodingParam* pParam, int32_t& iMvRange, int32_t& iMv · 787 unmodified lines | |||
| 1273 | if (pParam->sSpatialLayers[iLayer].uiLevelIdc < iMinLevelIdc) | 1274 | if (pParam->sSpatialLayers[iLayer].uiLevelIdc < iMinLevelIdc) |
| 1274 | iMinLevelIdc = pParam->sSpatialLayers[iLayer].uiLevelIdc; | 1275 | iMinLevelIdc = pParam->sSpatialLayers[iLayer].uiLevelIdc; |
| 1275 | } | 1276 | } |
| 1276 | iMinMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMinVmv)>>2; | 1277 | |
| 1277 | iMaxMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMaxVmv)>>2; | 1278 | iMinMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMinVmv) >> 2; |
| 1279 | iMaxMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMaxVmv) >> 2; | ||
| 1280 | |||
| 1278 | iMvRange = WELS_MIN (WELS_ABS (iMinMv), iMaxMv); | 1281 | iMvRange = WELS_MIN (WELS_ABS (iMinMv), iMaxMv); |
| 1279 | 1282 | ||
| 1280 | iMvRange = WELS_MIN (iMvRange, iFixMvRange); | 1283 | iMvRange = WELS_MIN (iMvRange, iFixMvRange); |
| @@ -3797,6 +3800,41 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 2516 unmodified lines | |||
| 3797 | return 0; | 3800 | return 0; |
| 3798 | } | 3801 | } |
| 3799 | 3802 | ||
| 3803 | void WelsEncoderApplyLTR (SLogContext* pLogCtx, sWelsEncCtx* pCtx, SLTRConfig* pLTRValue) { | ||
| 3804 | SWelsSvcCodingParam sConfig; | ||
| 3805 | int32_t iNumRefFrame = 1; | ||
| 3806 | memcpy (&sConfig, pCtx->pSvcParam, sizeof (SWelsSvcCodingParam)); | ||
| 3807 | sConfig.bEnableLongTermReference = pLTRValue->bEnableLongTermReference; | ||
| 3808 | sConfig.iLTRRefNum = pLTRValue->iLTRRefNum; | ||
| 3809 | int32_t uiGopSize = 1 << (sConfig.iTemporalLayerNum - 1); | ||
| 3810 | if (sConfig.iUsageType == SCREEN_CONTENT_REAL_TIME) { | ||
| 3811 | if (sConfig.bEnableLongTermReference) { | ||
| 3812 | sConfig.iLTRRefNum = WELS_CLIP3 (sConfig.iLTRRefNum, 1, LONG_TERM_REF_NUM_SCREEN); | ||
| 3813 | iNumRefFrame = WELS_MAX (1, WELS_LOG2 (uiGopSize)) + sConfig.iLTRRefNum; | ||
| 3814 | } else { | ||
| 3815 | sConfig.iLTRRefNum = 0; | ||
| 3816 | iNumRefFrame = WELS_MAX (1, uiGopSize >> 1); | ||
| 3817 | } | ||
| 3818 | } else { | ||
| 3819 | if (sConfig.bEnableLongTermReference) { | ||
| 3820 | sConfig.iLTRRefNum = WELS_CLIP3 (sConfig.iLTRRefNum, 1, LONG_TERM_REF_NUM); | ||
| 3821 | } else { | ||
| 3822 | sConfig.iLTRRefNum = 0; | ||
| 3823 | } | ||
| 3824 | iNumRefFrame = ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + sConfig.iLTRRefNum) : (MIN_REF_PIC_COUNT + | ||
| 3825 | sConfig.iLTRRefNum); | ||
| 3826 | iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM); | ||
| 3827 | |||
| 3828 | } | ||
| 3829 | if (sConfig.iNumRefFrame < iNumRefFrame) | ||
| 3830 | sConfig.iNumRefFrame = iNumRefFrame; | ||
| 3831 | if (sConfig.iNumRefFrame > sConfig.iMaxNumRefFrame) | ||
| 3832 | sConfig.iMaxNumRefFrame = sConfig.iNumRefFrame; | ||
| 3833 | |||
| 3834 | WelsLog (pLogCtx, WELS_LOG_WARNING, " CWelsH264SVCEncoder::SetOption enable LTR = %d,ltrnum = %d", | ||
| 3835 | sConfig.bEnableLongTermReference, sConfig.iLTRRefNum); | ||
| 3836 | WelsEncoderParamAdjust (&pCtx, &sConfig); | ||
| 3837 | } | ||
| 3800 | int32_t DynSliceRealloc (sWelsEncCtx* pCtx, | 3838 | int32_t DynSliceRealloc (sWelsEncCtx* pCtx, |
| 3801 | SFrameBSInfo* pFrameBsInfo, | 3839 | SFrameBSInfo* pFrameBsInfo, |
| 3802 | SLayerBSInfo* pLayerBsInfo) { | 3840 | SLayerBSInfo* pLayerBsInfo) { |