fix iContinualSkipFrames calculation

This commit is contained in:
Karina 2016-05-31 21:01:11 +08:00
parent df77a5d587
commit dd021b6ca8
4 changed files with 21 additions and 22 deletions

View File

@ -172,7 +172,6 @@ typedef struct TagWelsEncCtx {
int32_t iCheckWindowInterval;
int32_t iCheckWindowIntervalShift;
bool bCheckWindowShiftResetFlag;
int32_t iContinualSkipFrames;
int32_t iGlobalQp; // global qp
// VAA

View File

@ -222,7 +222,7 @@ int32_t iBufferFullnessPadding;
int32_t iPaddingSize;
int32_t iPaddingBitrateStat;
bool bSkipFlag;
int32_t iContinualSkipFrames;
SRCTemporal* pTemporalOverRc;
//for scc

View File

@ -3455,14 +3455,13 @@ EVideoFrameType PrepareEncodeFrame (sWelsEncCtx* pCtx, SLayerBSInfo*& pLayerBsIn
bool bSkipFrameFlag = WelsRcCheckFrameStatus (pCtx,uiTimeStamp,iSpatialNum);
EVideoFrameType eFrameType = DecideFrameType (pCtx, iSpatialNum, iCurDid, bSkipFrameFlag);
if (eFrameType == videoFrameTypeSkip) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,
"[Rc] Frame timestamp = %lld, skip one frame due to target_br, continual skipped %d frames",
uiTimeStamp, pCtx->iContinualSkipFrames);
if (pSvcParam->bSimulcastAVC) {
if (pCtx->pFuncList->pfRc.pfWelsUpdateBufferWhenSkip)
pCtx->pFuncList->pfRc.pfWelsUpdateBufferWhenSkip (pCtx, iCurDid);
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,
"[Rc] Frame timestamp = %lld, iDid = %d,skip one frame due to target_br, continual skipped %d frames",
uiTimeStamp, iCurDid, pCtx->pWelsSvcRc[iCurDid].iContinualSkipFrames);
}
else {
@ -3471,11 +3470,14 @@ EVideoFrameType PrepareEncodeFrame (sWelsEncCtx* pCtx, SLayerBSInfo*& pLayerBsIn
pCtx->pFuncList->pfRc.pfWelsUpdateBufferWhenSkip (pCtx, (pSpatialIndexMap + i)->iDid);
}
}
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,
"[Rc] Frame timestamp = %lld, iDid = %d,skip one frame due to target_br, continual skipped %d frames",
uiTimeStamp, pSpatialIndexMap->iDid, pCtx->pWelsSvcRc[pSpatialIndexMap->iDid].iContinualSkipFrames);
}
} else {
SSpatialLayerInternal* pParamInternal = &pSvcParam->sDependencyLayers[iCurDid];
pCtx->iContinualSkipFrames = 0;
iCurTid = GetTemporalLevel (&pSvcParam->sDependencyLayers[iCurDid], pParamInternal->iCodingIndex,
pSvcParam->uiGopSize);
pCtx->uiTemporalId = iCurTid;
@ -3500,10 +3502,12 @@ EVideoFrameType PrepareEncodeFrame (sWelsEncCtx* pCtx, SLayerBSInfo*& pLayerBsIn
for (int32_t i = 0; i < pSvcParam->iSpatialLayerNum; i++) {
SSpatialLayerInternal* pParamInternal = &pSvcParam->sDependencyLayers[i];
pParamInternal->iCodingIndex ++;
pCtx->pWelsSvcRc[i].iContinualSkipFrames = 0;
}
} else {
SSpatialLayerInternal* pParamInternal = &pSvcParam->sDependencyLayers[iCurDid];
pParamInternal->iCodingIndex++;
pCtx->pWelsSvcRc[iCurDid].iContinualSkipFrames = 0;
}
}
return eFrameType;
@ -3575,8 +3579,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
pFbi->eFrameType = videoFrameTypeSkip;
pLayerBsInfo->eFrameType = videoFrameTypeSkip;
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,
"[Rc] Frame timestamp = %lld, skip one frame due to preprocessing return (temporal layer settings or else), continual skipped %d frames",
pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames);
"[Rc] Frame timestamp = %lld, skip one frame due to preprocessing return (temporal layer settings or else)",
pSrcPic->uiTimeStamp);
return ENC_RETURN_SUCCESS;
}
@ -3935,9 +3939,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
}
WelsRcPostFrameSkippedUpdate (pCtx, iCurDid);
WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO,
"[Rc] Frame timestamp = %lld, skip one frame due to post skip, continual skipped %d frames",
pFbi->uiTimeStamp, pCtx->iContinualSkipFrames);
pCtx->iEncoderError = ENC_RETURN_SUCCESS;
return ENC_RETURN_SUCCESS;
}

View File

@ -736,9 +736,9 @@ void CheckFrameSkipBasedMaxbr (sWelsEncCtx* pEncCtx, const long long uiTimeStamp
3:if in last ODD_TIME_WINDOW the MAX Br is overflowed, make more strict skipping conditions
4:such as case 3 in the other window
*/
bool bJudgeBufferFullSkip = (pEncCtx->iContinualSkipFrames <= iPredSkipFramesTarBr)
bool bJudgeBufferFullSkip = (pWelsSvcRc->iContinualSkipFrames <= iPredSkipFramesTarBr)
&& (pWelsSvcRc->iBufferFullnessSkip > pWelsSvcRc->iBufferSizeSkip);
bool bJudgeMaxBRbufferFullSkip = (pEncCtx->iContinualSkipFrames <= iPredSkipFramesMaxBr)
bool bJudgeMaxBRbufferFullSkip = (pWelsSvcRc->iContinualSkipFrames <= iPredSkipFramesMaxBr)
&& (pEncCtx->iCheckWindowInterval > TIME_CHECK_WINDOW / 2)
&& (pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW] + pWelsSvcRc->iPredFrameBit - iAvailableBitsInTimeWindow > 0);
bJudgeMaxBRbSkip[EVEN_TIME_WINDOW] = (pEncCtx->iCheckWindowInterval > TIME_CHECK_WINDOW / 2)
@ -797,7 +797,7 @@ bool WelsRcCheckFrameStatus (sWelsEncCtx* pEncCtx, long long uiTimeStamp, int32_
if (bSkipMustFlag) {
pEncCtx->pWelsSvcRc[iDidIdx].uiLastTimeStamp = uiTimeStamp;
pEncCtx->pWelsSvcRc[iDidIdx].bSkipFlag = false;
pEncCtx->iContinualSkipFrames++;
pEncCtx->pWelsSvcRc[iDidIdx].iContinualSkipFrames++;
return true;
}
} else { //SVC control
@ -821,7 +821,6 @@ bool WelsRcCheckFrameStatus (sWelsEncCtx* pEncCtx, long long uiTimeStamp, int32_
}
}
if (bSkipMustFlag) {
pEncCtx->iContinualSkipFrames++;
break;
}
}
@ -831,6 +830,7 @@ bool WelsRcCheckFrameStatus (sWelsEncCtx* pEncCtx, long long uiTimeStamp, int32_
int32_t iDidIdx = (pSpatialIndexMap + i)->iDid;
pEncCtx->pWelsSvcRc[iDidIdx].uiLastTimeStamp = uiTimeStamp;
pEncCtx->pWelsSvcRc[iDidIdx].bSkipFlag = false;
pEncCtx->pWelsSvcRc[iDidIdx].iContinualSkipFrames++;
}
return true;
}
@ -845,8 +845,8 @@ void UpdateBufferWhenFrameSkipped (sWelsEncCtx* pEncCtx, int32_t iCurDid) {
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,
pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW]);
"[Rc] iDid = %d,bits in buffer = %" PRId64 ", bits in Max bitrate buffer = %" PRId64,
iCurDid,pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW]);
pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);
@ -854,12 +854,11 @@ void UpdateBufferWhenFrameSkipped (sWelsEncCtx* pEncCtx, int32_t iCurDid) {
pWelsSvcRc->iSkipFrameNum++;
pWelsSvcRc->iSkipFrameInVGop++;
pEncCtx->iContinualSkipFrames++;
if ((pEncCtx->iContinualSkipFrames % 3) == 0) {
if ((pWelsSvcRc->iContinualSkipFrames % 3) == 0) {
//output a warning when iContinualSkipFrames is large enough, which may indicate subjective quality problem
//note that here iContinualSkipFrames must be >0, so the log output will be 3/6/....
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_WARNING, "[Rc] iContinualSkipFrames(%d) is large",
pEncCtx->iContinualSkipFrames);
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_WARNING, "[Rc] iDid = %d,iContinualSkipFrames(%d) is large",
iCurDid,pWelsSvcRc->iContinualSkipFrames);
}
}
void UpdateMaxBrCheckWindowStatus (sWelsEncCtx* pEncCtx, int32_t iSpatialNum, const long long uiTimeStamp) {