From 05684744c905ad66b864b41962bbca6ad9c02cbd Mon Sep 17 00:00:00 2001 From: Sijia Chen Date: Wed, 17 Sep 2014 18:10:27 +0800 Subject: [PATCH] remove duplicate constant macro and modify the num_ref check accordingly --- codec/encoder/core/inc/param_svc.h | 2 +- codec/encoder/core/inc/wels_const.h | 4 ++-- codec/encoder/core/src/encoder_ext.cpp | 6 +++--- codec/encoder/plus/src/welsEncoderExt.cpp | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/codec/encoder/core/inc/param_svc.h b/codec/encoder/core/inc/param_svc.h index ddfae9f5..253e363d 100644 --- a/codec/encoder/core/inc/param_svc.h +++ b/codec/encoder/core/inc/param_svc.h @@ -362,7 +362,7 @@ int32_t ParamTranscode (const SEncParamExt& pCodingParam) { iLTRRefNum = bEnableLongTermReference ? LONG_TERM_REF_NUM : 0; if (iNumRefFrame == AUTO_REF_PIC_COUNT) { iNumRefFrame = ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + iLTRRefNum) : (MIN_REF_PIC_COUNT + iLTRRefNum); - iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM); + iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA); } } if (iNumRefFrame > iMaxNumRefFrame) diff --git a/codec/encoder/core/inc/wels_const.h b/codec/encoder/core/inc/wels_const.h index e1916cb0..ec01e3a0 100644 --- a/codec/encoder/core/inc/wels_const.h +++ b/codec/encoder/core/inc/wels_const.h @@ -149,7 +149,6 @@ #define MAX_SHORT_REF_COUNT (MAX_GOP_SIZE>>1) // 16 in standard, maximal count number of short reference pictures #define LONG_TERM_REF_NUM 2 #define LONG_TERM_REF_NUM_SCREEN 4 -#define MAX_LONG_REF_COUNT 2 // 16 in standard, maximal count number of long reference pictures #define MAX_REF_PIC_COUNT 16 // 32 in standard, maximal Short + Long reference pictures #define MIN_REF_PIC_COUNT 1 // minimal count number of reference pictures, 1 short + 2 key reference based? #define MAX_MULTI_REF_PIC_COUNT 1 //maximum multi-reference number @@ -159,7 +158,8 @@ // adjusted numbers reference picture functionality related definition #define MAX_REFERENCE_MMCO_COUNT_NUM 4 // adjusted MAX_MMCO_COUNT(66 in standard) definition per encoder design #define MAX_REFERENCE_REORDER_COUNT_NUM 2 // adjusted MAX_REF_PIC_COUNT(32 in standard) for reference reordering definition per encoder design -#define MAX_REFERENCE_PICTURE_COUNT_NUM (MAX_SHORT_REF_COUNT+MAX_LONG_REF_COUNT) // <= MAX_REF_PIC_COUNT, memory saved if < +#define MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA (MAX_SHORT_REF_COUNT+LONG_TERM_REF_NUM) // <= MAX_REF_PIC_COUNT, memory saved if < +#define MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN (MAX_SHORT_REF_COUNT+LONG_TERM_REF_NUM_SCREEN) // <= MAX_REF_PIC_COUNT, memory saved if < #define BASE_QUALITY_ID 0 #define BASE_DEPENDENCY_ID 0 diff --git a/codec/encoder/core/src/encoder_ext.cpp b/codec/encoder/core/src/encoder_ext.cpp index 2e70bf69..198993fa 100644 --- a/codec/encoder/core/src/encoder_ext.cpp +++ b/codec/encoder/core/src/encoder_ext.cpp @@ -1358,7 +1358,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { iTargetSpatialBsSize = iLayerBsSize; iCountBsLen = iNonVclLayersBsSizeCount + iVclLayersBsSizeCount; - pParam->iNumRefFrame = WELS_CLIP3 (pParam->iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM); + pParam->iNumRefFrame = WELS_CLIP3 (pParam->iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA); // Output (*ppCtx)->pOut = (SWelsEncoderOutput*)pMa->WelsMalloc (sizeof (SWelsEncoderOutput), "SWelsEncoderOutput"); @@ -3741,7 +3741,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa } else { /* maybe adjustment introduced in bitrate or little settings adjustment and so on.. */ pNewParam->iNumRefFrame = WELS_CLIP3 (pNewParam->iNumRefFrame, MIN_REF_PIC_COUNT, - MAX_REFERENCE_PICTURE_COUNT_NUM); + (pNewParam->iUsageType==CAMERA_VIDEO_REAL_TIME?MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA:MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN)); pNewParam->iLoopFilterDisableIdc = WELS_CLIP3 (pNewParam->iLoopFilterDisableIdc, 0, 6); pNewParam->iLoopFilterAlphaC0Offset = WELS_CLIP3 (pNewParam->iLoopFilterAlphaC0Offset, -6, 6); pNewParam->iLoopFilterBetaOffset = WELS_CLIP3 (pNewParam->iLoopFilterBetaOffset, -6, 6); @@ -3846,7 +3846,7 @@ void WelsEncoderApplyLTR (SLogContext* pLogCtx, sWelsEncCtx** ppCtx, SLTRConfig* } 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); + iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA); } if (sConfig.iNumRefFrame < iNumRefFrame) diff --git a/codec/encoder/plus/src/welsEncoderExt.cpp b/codec/encoder/plus/src/welsEncoderExt.cpp index 43ef48e6..f2f8cc6e 100644 --- a/codec/encoder/plus/src/welsEncoderExt.cpp +++ b/codec/encoder/plus/src/welsEncoderExt.cpp @@ -325,7 +325,7 @@ int CWelsH264SVCEncoder::InitializeInternal (SWelsSvcCodingParam* pCfg) { if (pCfg->iNumRefFrame == AUTO_REF_PIC_COUNT) { pCfg->iNumRefFrame = ((pCfg->uiGopSize >> 1) > 1) ? ((pCfg->uiGopSize >> 1) + pCfg->iLTRRefNum) : (MIN_REF_PIC_COUNT + pCfg->iLTRRefNum); - pCfg->iNumRefFrame = WELS_CLIP3 (pCfg->iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM); + pCfg->iNumRefFrame = WELS_CLIP3 (pCfg->iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA); } } if (pCfg->iNumRefFrame > pCfg->iMaxNumRefFrame) @@ -519,8 +519,9 @@ void CWelsH264SVCEncoder::CheckLevelSetting (int32_t iLayer, ELevelIdc uiLevelId } } void CWelsH264SVCEncoder::CheckReferenceNumSetting (int32_t iNumRef) { + int32_t iRefUpperBound = (m_pEncContext->pSvcParam->iUsageType == CAMERA_VIDEO_REAL_TIME)?MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA:MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN; m_pEncContext->pSvcParam->iNumRefFrame = iNumRef; - if ((iNumRef < MIN_REF_PIC_COUNT) || (iNumRef > MAX_REFERENCE_PICTURE_COUNT_NUM)) { + if ((iNumRef < MIN_REF_PIC_COUNT) || (iNumRef > iRefUpperBound)) { m_pEncContext->pSvcParam->iNumRefFrame = AUTO_REF_PIC_COUNT; WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, "doesn't support the number of reference frame(%d) change to auto select mode", iNumRef);