ref: ce14a0e4f9ea77947701a1fb6e594a88d545c33f
parent: 3244f11cfea73fae818df915e5418f56f9a5cd7c
author: ruil2 <ruil2@cisco.com>
date: Mon Jan 5 12:01:35 EST 2015
fix bug when some parameters change dynamically
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -212,7 +212,7 @@
}
if ((pCfg->iRCMode != RC_OFF_MODE) && (pCfg->iRCMode != RC_QUALITY_MODE) && (pCfg->iRCMode != RC_BUFFERBASED_MODE)
- && (pCfg->iRCMode != RC_BITRATE_MODE)&& (pCfg->iRCMode != RC_TIMESTAMP_MODE)) {
+ && (pCfg->iRCMode != RC_BITRATE_MODE) && (pCfg->iRCMode != RC_TIMESTAMP_MODE)) {
WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidation(),Invalid iRCMode = %d", pCfg->iRCMode);
return ENC_RETURN_UNSUPPORTED_PARA;
}
@@ -541,7 +541,8 @@
|| (kfMaxFrameRate - pLayerParamInternal->fInputFrameRate) < -kfEpsn) {
pLayerParamInternal->fInputFrameRate = kfMaxFrameRate;
fTargetOutputFrameRate = kfMaxFrameRate * fRatio;
- pLayerParamInternal->fOutputFrameRate = (fTargetOutputFrameRate >= 6) ? fTargetOutputFrameRate : (pLayerParamInternal->fInputFrameRate);
+ pLayerParamInternal->fOutputFrameRate = (fTargetOutputFrameRate >= 6) ? fTargetOutputFrameRate :
+ (pLayerParamInternal->fInputFrameRate);
pLayerParam->fFrameRate = pLayerParamInternal->fOutputFrameRate;
//TODO:{Sijia} from design, there is no sense to have temporal layer when under 6fps even with such setting?
}
@@ -3824,7 +3825,9 @@
|| pOldParam->SUsedPicRect.iHeight != pNewParam->SUsedPicRect.iHeight) ||
(pOldParam->bEnableLongTermReference != pNewParam->bEnableLongTermReference) ||
(pOldParam->iLTRRefNum != pNewParam->iLTRRefNum) ||
- (pOldParam->iMultipleThreadIdc != pNewParam->iMultipleThreadIdc);
+ (pOldParam->iMultipleThreadIdc != pNewParam->iMultipleThreadIdc) ||
+ (pOldParam->bEnableBackgroundDetection != pNewParam->bEnableBackgroundDetection) ||
+ (pOldParam->bEnableAdaptiveQuant != pNewParam->bEnableAdaptiveQuant);
if (pNewParam->iMaxNumRefFrame > pOldParam->iMaxNumRefFrame) {
bNeedReset = true;
}
--- a/test/encoder/EncUT_EncoderExt.cpp
+++ b/test/encoder/EncUT_EncoderExt.cpp
@@ -324,6 +324,21 @@
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeP));
+ //change backgrouddetection and qp
+ pOption ->bEnableBackgroundDetection = !pOption ->bEnableBackgroundDetection;
+ iResult = pPtrEnc->SetOption (eOptionId, pOption);
+ EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
+ pSrcPic->uiTimeStamp = 150;
+ iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
+ EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
+
+ pOption ->bEnableAdaptiveQuant = !pOption ->bEnableAdaptiveQuant;
+ iResult = pPtrEnc->SetOption (eOptionId, pOption);
+ EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
+ pSrcPic->uiTimeStamp = 180;
+ iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
+ EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
+
iResult = pPtrEnc->Uninitialize();
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
}
@@ -456,7 +471,8 @@
pEncParamBase->iPicHeight = VALID_SIZE (pEncParamBase->iPicHeight);
pEncParamBase->iTargetBitrate = rand() + 1; //!=0
// Force a bitrate of at least w*h/50, otherwise we will only get skipped frames
- pEncParamBase->iTargetBitrate = WELS_CLIP3 (pEncParamBase->iTargetBitrate, pEncParamBase->iPicWidth * pEncParamBase->iPicHeight / 50, 100000000);
+ pEncParamBase->iTargetBitrate = WELS_CLIP3 (pEncParamBase->iTargetBitrate,
+ pEncParamBase->iPicWidth * pEncParamBase->iPicHeight / 50, 100000000);
int32_t iLevelMaxBitrate = WelsCommon::g_ksLevelLimits[LEVEL_5_0 - 1].uiMaxBR * CpbBrNalFactor;
if (pEncParamBase->iTargetBitrate > iLevelMaxBitrate)
pEncParamBase->iTargetBitrate = iLevelMaxBitrate;
@@ -644,7 +660,8 @@
sEncParamExt.iPicHeight = MB_SIZE + abs ((rand() * 2) % (MAX_HEIGHT - MB_SIZE));
sEncParamExt.iTargetBitrate = rand() + 1; //!=0
// Force a bitrate of at least w*h/50, otherwise we will only get skipped frames
- sEncParamExt.iTargetBitrate = WELS_CLIP3 (sEncParamExt.iTargetBitrate, sEncParamExt.iPicWidth * sEncParamExt.iPicHeight / 50, 100000000);
+ sEncParamExt.iTargetBitrate = WELS_CLIP3 (sEncParamExt.iTargetBitrate,
+ sEncParamExt.iPicWidth * sEncParamExt.iPicHeight / 50, 100000000);
int32_t iLevelMaxBitrate = WelsCommon::g_ksLevelLimits[LEVEL_5_0 - 1].uiMaxBR * CpbBrNalFactor;
if (sEncParamExt.iTargetBitrate > iLevelMaxBitrate)
sEncParamExt.iTargetBitrate = iLevelMaxBitrate;