History

update the number of reference when ltr changes

ruil2 committed 12 years ago

Commit 9b5902b1 parent 035019f3 files · +42 −10Browse files

Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 3 files). Show all

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+40−2
@@ -480,6 +480,7 @@ void WelsEncoderApplyBitRate (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, · 479 unmodified lines
480480 }
481481 }
482482 }
483+
483484 /*!
484485 * \brief acquire count number of layers and NALs based on configurable paramters dependency
485486 * \pParam pCtx sWelsEncCtx*
@@ -1273,8 +1274,10 @@ void GetMvMvdRange (SWelsSvcCodingParam* pParam, int32_t& iMvRange, int32_t& iMv · 787 unmodified lines
12731274 if (pParam->sSpatialLayers[iLayer].uiLevelIdc < iMinLevelIdc)
12741275 iMinLevelIdc = pParam->sSpatialLayers[iLayer].uiLevelIdc;
12751276 }
1276− iMinMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMinVmv)>>2;
1277− iMaxMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMaxVmv)>>2;
1277+
1278+ iMinMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMinVmv) >> 2;
1279+ iMaxMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMaxVmv) >> 2;
1280+
12781281 iMvRange = WELS_MIN (WELS_ABS (iMinMv), iMaxMv);
12791282
12801283 iMvRange = WELS_MIN (iMvRange, iFixMvRange);
@@ -3797,6 +3800,41 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 2516 unmodified lines
37973800 return 0;
37983801 }
37993802
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+}
38003838 int32_t DynSliceRealloc (sWelsEncCtx* pCtx,
38013839 SFrameBSInfo* pFrameBsInfo,
38023840 SLayerBSInfo* pLayerBsInfo) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t