ref: a3ab13c30d08eecd2994354cf6476e5fcb3dafbc
parent: 89728faf8d2adec1e41f6a5514fef5aca3911a24
parent: 85869921d3164f0924e3fa78e544402e088d9fd3
author: sijchen <sijchen@cisco.com>
date: Mon May 18 12:56:32 EDT 2015
Merge pull request #1955 from ruil2/rc_reset reset buffer status when force IDR
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3418,7 +3418,7 @@
pCtx->bEncCurFrmAsIdrFlag = true;
pCtx->iCodingIndex = 0;
-
+ pCtx->bCheckWindowStatusRefreshFlag = false;
return 0;
}
--- a/codec/encoder/core/src/ratectl.cpp
+++ b/codec/encoder/core/src/ratectl.cpp
@@ -694,7 +694,8 @@
pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW] += (pWelsSvcRc->iFrameDqBits - kiOutputMaxBits);
pWelsSvcRc->iBufferMaxBRFullness[ODD_TIME_WINDOW] += (pWelsSvcRc->iFrameDqBits - kiOutputMaxBits);
- WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] bits in buffer = %" PRId64 ", bits in Max bitrate buffer = %" PRId64,
+ WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
+ "[Rc] bits in buffer = %" PRId64 ", bits in Max bitrate buffer = %" PRId64,
pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW]);
//condition 2: VGOP bits constraint
int64_t iVGopBitsPred = 0;
@@ -808,7 +809,8 @@
pWelsSvcRc->iBufferFullnessSkip = pWelsSvcRc->iBufferFullnessSkip - kiOutputBits;
pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW] -= kiOutputMaxBits;
pWelsSvcRc->iBufferMaxBRFullness[ODD_TIME_WINDOW] -= kiOutputMaxBits;
- WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] bits in buffer = %" PRId64 ", bits in Max bitrate buffer = %" PRId64,
+ WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
+ "[Rc] bits in buffer = %" PRId64 ", bits in Max bitrate buffer = %" PRId64,
pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW]);
pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);
@@ -827,6 +829,15 @@
} else {
pEncCtx->iCheckWindowCurrentTs = pEncCtx->iCheckWindowStartTs = uiTimeStamp;
pEncCtx->bCheckWindowStatusRefreshFlag = true;
+ for (int32_t i = 0; i < iSpatialNum; i++) {
+ int32_t iCurDid = (pSpatialIndexMap + i)->iDid;
+ pEncCtx->pWelsSvcRc[iCurDid].iBufferFullnessSkip = 0;
+ pEncCtx->pWelsSvcRc[iCurDid].iBufferMaxBRFullness[ODD_TIME_WINDOW] = 0;
+ pEncCtx->pWelsSvcRc[iCurDid].iBufferMaxBRFullness[EVEN_TIME_WINDOW] = 0;
+ pEncCtx->pWelsSvcRc[iCurDid].bNeedShiftWindowCheck[ODD_TIME_WINDOW] = false;
+ pEncCtx->pWelsSvcRc[iCurDid].bNeedShiftWindowCheck[EVEN_TIME_WINDOW] = false;
+ }
+
}
pEncCtx->iCheckWindowInterval = (int32_t) (pEncCtx->iCheckWindowCurrentTs - pEncCtx->iCheckWindowStartTs);
if (pEncCtx->iCheckWindowInterval >= (TIME_CHECK_WINDOW >> 1) && !pEncCtx->bCheckWindowShiftResetFlag) {
@@ -1273,7 +1284,8 @@
}
}
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
- "WelsRcFrameDelayJudgeTimeStamp iSkipFrameNum = %d,buffer = %" PRId64 ",threadhold = %d,bitrate = %d,iSentBits = %d,lasttimestamp = %lld,timestamp=%lld\n",
+ "WelsRcFrameDelayJudgeTimeStamp iSkipFrameNum = %d,buffer = %" PRId64
+ ",threadhold = %d,bitrate = %d,iSentBits = %d,lasttimestamp = %lld,timestamp=%lld\n",
pWelsSvcRc->iSkipFrameNum, pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iBufferSizeSkip, iBitRate, iSentBits,
pWelsSvcRc->uiLastTimeStamp, uiTimeStamp);
}
@@ -1315,7 +1327,8 @@
pWelsSvcRc->iCost2BitsIntra), pWelsSvcRc->iTargetBits);
iLumaQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);
- iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iLastCalculatedQScale - DELTA_QP_BGD_THD, pWelsSvcRc->iLastCalculatedQScale + DELTA_QP_BGD_THD);
+ iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iLastCalculatedQScale - DELTA_QP_BGD_THD,
+ pWelsSvcRc->iLastCalculatedQScale + DELTA_QP_BGD_THD);
} else {
iLumaQp = pWelsSvcRc->iLastCalculatedQScale + DELTA_QP_BGD_THD;
@@ -1322,7 +1335,8 @@
}
iLumaQp = WELS_CLIP3 (iLumaQp, MIN_IDR_QP, MAX_IDR_QP);
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
- "[Rc]I iLumaQp = %d,iQStep = %d,iTargetBits = %d,iBufferFullnessSkip =%" PRId64 ",iMaxTh=%d,iMinTh = %d,iFrameComplexity= %" PRId64,
+ "[Rc]I iLumaQp = %d,iQStep = %d,iTargetBits = %d,iBufferFullnessSkip =%" PRId64
+ ",iMaxTh=%d,iMinTh = %d,iFrameComplexity= %" PRId64,
iLumaQp, pWelsSvcRc->iQStep, pWelsSvcRc->iTargetBits, pWelsSvcRc->iBufferFullnessSkip, iMaxTh, iMinTh,
pWelsSvcRc->iIntraComplexity);
@@ -1352,7 +1366,8 @@
pWelsSvcRc->iQStep = WELS_DIV_ROUND ((pTOverRc->iLinearCmplx * iCmplxRatio), (pWelsSvcRc->iTargetBits * INT_MULTIPLY));
iLumaQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);
- iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iLastCalculatedQScale - DELTA_QP_BGD_THD, pWelsSvcRc->iLastCalculatedQScale + DELTA_QP_BGD_THD);
+ iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iLastCalculatedQScale - DELTA_QP_BGD_THD,
+ pWelsSvcRc->iLastCalculatedQScale + DELTA_QP_BGD_THD);
}
} else {
iLumaQp = pWelsSvcRc->iLastCalculatedQScale + DELTA_QP_BGD_THD;
@@ -1361,7 +1376,8 @@
iLumaQp = WELS_CLIP3 (iLumaQp, GOM_MIN_QP_MODE, GOM_MAX_QP_MODE);
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
- "[Rc]P iTl = %d,iLumaQp = %d,iQStep = %d,iTargetBits = %d,iBufferFullnessSkip =%" PRId64 ",iMaxTh=%d,iMinTh = %d,iFrameComplexity= %lld,iCmplxRatio=%" PRId64,
+ "[Rc]P iTl = %d,iLumaQp = %d,iQStep = %d,iTargetBits = %d,iBufferFullnessSkip =%" PRId64
+ ",iMaxTh=%d,iMinTh = %d,iFrameComplexity= %lld,iCmplxRatio=%" PRId64,
iTl, iLumaQp, pWelsSvcRc->iQStep, pWelsSvcRc->iTargetBits, pWelsSvcRc->iBufferFullnessSkip, iMaxTh, iMinTh,
pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity, iCmplxRatio);
}
@@ -1375,8 +1391,9 @@
float fInstantFps = (uiTimeStamp - pWelsSvcRc->uiLastTimeStamp) > 0 ? (1000.0f / (uiTimeStamp -
pWelsSvcRc->uiLastTimeStamp)) : 0;
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
- "[Rc]Tid = %d,Did = %d,pEncCtx->iGlobalQp= %d,iLumaQp = %d,uiTimeStamp = %lld,uiLastTimeStamp = %lld,InstantFps = %f,settingFps = %f",pEncCtx->uiTemporalId,pEncCtx->uiDependencyId,
- pEncCtx->iGlobalQp, iLumaQp,uiTimeStamp, pWelsSvcRc->uiLastTimeStamp,
+ "[Rc]Tid = %d,Did = %d,pEncCtx->iGlobalQp= %d,iLumaQp = %d,uiTimeStamp = %lld,uiLastTimeStamp = %lld,InstantFps = %f,settingFps = %f",
+ pEncCtx->uiTemporalId, pEncCtx->uiDependencyId,
+ pEncCtx->iGlobalQp, iLumaQp, uiTimeStamp, pWelsSvcRc->uiLastTimeStamp,
fInstantFps, pDLayerParam->fFrameRate);
pWelsSvcRc->uiLastTimeStamp = uiTimeStamp;