ref: 9b5902b94a19cfbdd056a5ce0f1c817552ad97e3
parent: 035019f05292c73835676746ee8dfb785c3b5deb
author: ruil2 <[email protected]>
date: Wed Aug 27 08:19:59 EDT 2014
update the number of reference when ltr changes
--- a/codec/encoder/core/inc/extern.h
+++ b/codec/encoder/core/inc/extern.h
@@ -108,7 +108,7 @@
int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNew);
void WelsEncoderApplyFrameRate (SWelsSvcCodingParam* pParam);
void WelsEncoderApplyBitRate (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iLayer);
-
+void WelsEncoderApplyLTR (SLogContext* pLogCtx, sWelsEncCtx*pCtx,SLTRConfig* pLTRValue);
int32_t FilterLTRRecoveryRequest (sWelsEncCtx* pCtx, SLTRRecoverRequest* pLTRRecoverRequest);
void FilterLTRMarkingFeedback (sWelsEncCtx* pCtx, SLTRMarkingFeedback* pLTRMarkingFeedback);
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -480,6 +480,7 @@
}
}
}
+
/*!
* \brief acquire count number of layers and NALs based on configurable paramters dependency
* \pParam pCtx sWelsEncCtx*
@@ -1273,8 +1274,10 @@
if (pParam->sSpatialLayers[iLayer].uiLevelIdc < iMinLevelIdc)
iMinLevelIdc = pParam->sSpatialLayers[iLayer].uiLevelIdc;
}
- iMinMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMinVmv)>>2;
- iMaxMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMaxVmv)>>2;
+
+ iMinMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMinVmv) >> 2;
+ iMaxMv = (g_ksLevelLimits[iMinLevelIdc - 1].iMaxVmv) >> 2;
+
iMvRange = WELS_MIN (WELS_ABS (iMinMv), iMaxMv);
iMvRange = WELS_MIN (iMvRange, iFixMvRange);
@@ -3797,6 +3800,41 @@
return 0;
}
+void WelsEncoderApplyLTR (SLogContext* pLogCtx, sWelsEncCtx* pCtx, SLTRConfig* pLTRValue) {
+ SWelsSvcCodingParam sConfig;
+ int32_t iNumRefFrame = 1;
+ memcpy (&sConfig, pCtx->pSvcParam, sizeof (SWelsSvcCodingParam));
+ sConfig.bEnableLongTermReference = pLTRValue->bEnableLongTermReference;
+ sConfig.iLTRRefNum = pLTRValue->iLTRRefNum;
+ int32_t uiGopSize = 1 << (sConfig.iTemporalLayerNum - 1);
+ if (sConfig.iUsageType == SCREEN_CONTENT_REAL_TIME) {
+ if (sConfig.bEnableLongTermReference) {
+ sConfig.iLTRRefNum = WELS_CLIP3 (sConfig.iLTRRefNum, 1, LONG_TERM_REF_NUM_SCREEN);
+ iNumRefFrame = WELS_MAX (1, WELS_LOG2 (uiGopSize)) + sConfig.iLTRRefNum;
+ } else {
+ sConfig.iLTRRefNum = 0;
+ iNumRefFrame = WELS_MAX (1, uiGopSize >> 1);
+ }
+ } else {
+ if (sConfig.bEnableLongTermReference) {
+ sConfig.iLTRRefNum = WELS_CLIP3 (sConfig.iLTRRefNum, 1, LONG_TERM_REF_NUM);
+ } else {
+ sConfig.iLTRRefNum = 0;
+ }
+ iNumRefFrame = ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + sConfig.iLTRRefNum) : (MIN_REF_PIC_COUNT +
+ sConfig.iLTRRefNum);
+ iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM);
+
+ }
+ if (sConfig.iNumRefFrame < iNumRefFrame)
+ sConfig.iNumRefFrame = iNumRefFrame;
+ if (sConfig.iNumRefFrame > sConfig.iMaxNumRefFrame)
+ sConfig.iMaxNumRefFrame = sConfig.iNumRefFrame;
+
+ WelsLog (pLogCtx, WELS_LOG_WARNING, " CWelsH264SVCEncoder::SetOption enable LTR = %d,ltrnum = %d",
+ sConfig.bEnableLongTermReference, sConfig.iLTRRefNum);
+ WelsEncoderParamAdjust (&pCtx, &sConfig);
+}
int32_t DynSliceRealloc (sWelsEncCtx* pCtx,
SFrameBSInfo* pFrameBsInfo,
SLayerBSInfo* pLayerBsInfo) {
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -825,13 +825,7 @@
break;
case ENCODER_OPTION_LTR: {
SLTRConfig* pLTRValue = ((SLTRConfig*) (pOption));
- SWelsSvcCodingParam sConfig;
- memcpy (&sConfig, m_pEncContext->pSvcParam, sizeof (SWelsSvcCodingParam));
- sConfig.bEnableLongTermReference = pLTRValue->bEnableLongTermReference;
- sConfig.iLTRRefNum = pLTRValue->iLTRRefNum;
- WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, " CWelsH264SVCEncoder::SetOption enable LTR = %d,ltrnum = %d",
- sConfig.bEnableLongTermReference, sConfig.iLTRRefNum);
- WelsEncoderParamAdjust (&m_pEncContext, &sConfig);
+ WelsEncoderApplyLTR (&m_pWelsTrace->m_sLogCtx, m_pEncContext, pLTRValue);
}
break;
case ENCODER_OPTION_ENABLE_SSEI: {