History

Rate control refine to fit MAX bitrate requirement

lyao2 committed 11 years ago

Commit c01606c1 parent ea93f397 files · +5819 −5681Browse files

Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 7 files). Show all

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+15−30
@@ -3035,29 +3035,6 @@ int32_t GetSubSequenceId (sWelsEncCtx* pCtx, EVideoFrameType eFrameType) { · 3034 unmodified lines
30353035 return iSubSeqId;
30363036 }
30373037
3038−//loop each layer to check if have skip frame when RC and frame skip enable (maxbr>0)
3039−bool CheckFrameSkipBasedMaxbr (sWelsEncCtx* pCtx, int32_t iSpatialNum, EVideoFrameType eFrameType,
3040− const long long uiTimeStamp) {
3041− SSpatialPicIndex* pSpatialIndexMap = &pCtx->sSpatialIndexMap[0];
3042− bool bSkipMustFlag = false;
3043− if (pCtx->pSvcParam->bEnableFrameSkip) {
3044− if ((RC_QUALITY_MODE == pCtx->pSvcParam->iRCMode) || (RC_BITRATE_MODE == pCtx->pSvcParam->iRCMode)) {
3045− for (int32_t i = 0; i < iSpatialNum; i++) {
3046− if (UNSPECIFIED_BIT_RATE == pCtx->pSvcParam->sSpatialLayers[i].iMaxSpatialBitrate) {
3047− break;
3048− }
3049− pCtx->uiDependencyId = (uint8_t) (pSpatialIndexMap + i)->iDid;
3050− pCtx->pFuncList->pfRc.pfWelsRcPicDelayJudge (pCtx, eFrameType, uiTimeStamp);
3051− if (true == pCtx->pWelsSvcRc[pCtx->uiDependencyId].bSkipFlag) {
3052− bSkipMustFlag = true;
3053− break;
3054− }
3055− }
3056− }
3057− }
3058− return bSkipMustFlag;
3059−}
3060−
30613038 /*!
30623039 * \brief core svc encoding process
30633040 *
@@ -3108,29 +3085,37 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 44 unmodified lines
31083085 pFbi->uiTimeStamp = pSrcPic->uiTimeStamp;
31093086 // perform csc/denoise/downsample/padding, generate spatial layers
31103087 iSpatialNum = pCtx->pVpp->BuildSpatialPicList (pCtx, pSrcPic);
3088+
3089+ if (pCtx->pSvcParam->bEnableFrameSkip) {
3090+ UpdateMaxBrCheckWindowStatus(pCtx, iSpatialNum, pSrcPic->uiTimeStamp);
3091+ }
3092+
31113093 if (iSpatialNum < 1) { // skip due to temporal layer settings (different frame rate)
31123094 ++ pCtx->iCodingIndex;
31133095 pFbi->eFrameType = videoFrameTypeSkip;
3114− WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, Frame type =%d",
3115− pSrcPic->uiTimeStamp, pFbi->eFrameType);
3096+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, skip one frame, continual skipped %d frames",
3097+ pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames);
31163098 return ENC_RETURN_SUCCESS;
31173099 }
31183100
31193101 eFrameType = DecideFrameType (pCtx, iSpatialNum);
31203102 if (eFrameType == videoFrameTypeSkip) {
3103+ UpdateBufferWhenFrameSkipped(pCtx, iSpatialNum);
31213104 pFbi->eFrameType = eFrameType;
3122− WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, Frame type =%d",
3123− pSrcPic->uiTimeStamp, pFbi->eFrameType);
3105+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, skip one frame, continual skipped %d frames",
3106+ pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames);
31243107 return ENC_RETURN_SUCCESS;
31253108 }
31263109
31273110 //loop each layer to check if have skip frame when RC and frame skip enable
3128− if (CheckFrameSkipBasedMaxbr (pCtx, iSpatialNum, eFrameType, pSrcPic->uiTimeStamp)) {
3111+ if (CheckFrameSkipBasedMaxbr (pCtx, iSpatialNum, eFrameType, (uint32_t)pSrcPic->uiTimeStamp)) {
31293112 pFbi->eFrameType = videoFrameTypeSkip;
3130− WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, Frame type =%d",
3131− pSrcPic->uiTimeStamp, pFbi->eFrameType);
3113+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, skip one frame, continual skipped %d frames",
3114+ pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames);
31323115 return ENC_RETURN_SUCCESS;
31333116 }
3117+
3118+ pCtx->iContinualSkipFrames = 0;
31343119 InitFrameCoding (pCtx, eFrameType);
31353120
31363121 iCurTid = GetTemporalLevel (&pSvcParam->sDependencyLayers[pSpatialIndexMap->iDid], pCtx->iCodingIndex,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t