History

add debug info for RC max bitrate control test

lyao2 committed 12 years ago

Commit 3904c021 parent e4b373a3 files · +45 −27Browse files

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

Unified · Split

codec/encoder/core/src/ratectl.cpp+21−15
@@ -575,6 +575,8 @@ void RcInitGomParameters (sWelsEncCtx* pEncCtx) { · 574 unmodified lines
575575 const int32_t kiGlobalQp = pEncCtx->iGlobalQp;
576576
577577 pWelsSvcRc->iAverageFrameQp = 0;
578+ pWelsSvcRc->iMinFrameQp = 51;;
579+ pWelsSvcRc->iMaxFrameQp = 0;
578580 for (int32_t i = 0; i < kiSliceNum; ++i) {
579581 pSOverRc->iComplexityIndexSlice = 0;
580582 pSOverRc->iCalculatedQpSlice = kiGlobalQp;
@@ -699,6 +701,7 @@ void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) { · 118 unmodified lines
699701 const int32_t kiOutputBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
700702 //condition 1: whole pBuffer fullness
701703 pWelsSvcRc->iBufferFullnessSkip += (pWelsSvcRc->iFrameDqBits - kiOutputBits);
704+ WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,"[Rc] bits in buffer = %3d",pWelsSvcRc->iBufferFullnessSkip);
702705 //condition 2: VGOP bits constraint
703706 int32_t iVGopBitsPred = 0;
704707 for (int32_t i = pWelsSvcRc->iFrameCodedInVGop + 1; i < VGOP_SIZE; i++)
@@ -712,14 +715,13 @@ void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) { · 7 unmodified lines
712715 || (dIncPercent > pWelsSvcRc->iRcVaryPercentage)) {
713716 pEncCtx->iSkipFrameFlag = 1;
714717 pWelsSvcRc->iBufferFullnessSkip = pWelsSvcRc->iBufferFullnessSkip - kiOutputBits;
715− WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "skip one frame");
718+ WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,"[Rc] bits in buffer = %3d",pWelsSvcRc->iBufferFullnessSkip);
716719 }
717720
718− if (pWelsSvcRc->iBufferFullnessSkip < 0)
719− pWelsSvcRc->iBufferFullnessSkip = 0;
721+ pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);
720722
721723 if (pEncCtx->iSkipFrameFlag == 1) {
722− pWelsSvcRc->iRemainingBits += WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
724+ pWelsSvcRc->iRemainingBits += kiOutputBits;
723725 pWelsSvcRc->iSkipFrameNum++;
724726 pWelsSvcRc->iSkipFrameInVGop++;
725727 }
@@ -739,6 +741,7 @@ void WelsRcFrameDelayJudge (void* pCtx, EVideoFrameType eFrameType, long long ui · 13 unmodified lines
739741 pWelsSvcRc->iSkipFrameNum++;
740742 pWelsSvcRc->iSkipFrameInVGop++;
741743 pWelsSvcRc->iBufferFullnessSkip -= iSentBits;
744+ WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,"[Rc] bits in buffer = %3d",pWelsSvcRc->iBufferFullnessSkip);
742745 pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);
743746 }
744747 }
@@ -759,14 +762,17 @@ void RcVBufferCalculationPadding (sWelsEncCtx* pEncCtx) { · 14 unmodified lines
759762 }
760763
761764
762−void RcTraceFrameBits (sWelsEncCtx* pEncCtx) {
765+void RcTraceFrameBits (void* pCtx, long long uiTimeStamp) {
766+ sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
763767 SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
764768
765769 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
766− "[Rc] encoding_qp%d, qp = %3d, index = %8d, iTid = %1d, used = %8d, target = %8d, remaingbits = %8d",
767− pEncCtx->uiDependencyId, pWelsSvcRc->iAverageFrameQp, pEncCtx->iFrameIndex, pEncCtx->uiTemporalId,
768− pWelsSvcRc->iFrameDqBits,
769− pWelsSvcRc->iTargetBits, pWelsSvcRc->iRemainingBits);
770+ "[Rc] Frame timestamp = %8d, Frame type =%d, encoding_qp%d, average qp = %3d, max qp = %3d, min qp = %3d, index = %8d,\
771+ iTid = %1d, used = %8d, bitsperframe = %8d, target = %8d, remaingbits = %8d, skipbuffersize = %8d",
772+ (uint32_t)uiTimeStamp,pEncCtx->eSliceType, pEncCtx->uiDependencyId, pWelsSvcRc->iAverageFrameQp,pWelsSvcRc->iMaxFrameQp,pWelsSvcRc->iMinFrameQp,
773+ pEncCtx->iFrameIndex, pEncCtx->uiTemporalId, pWelsSvcRc->iFrameDqBits,WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY),
774+ pWelsSvcRc->iTargetBits, pWelsSvcRc->iRemainingBits, pWelsSvcRc->iBufferSizeSkip);
775+
770776 }
771777
772778 void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) {
@@ -891,8 +897,6 @@ void WelsRcPictureInfoUpdateGom (void* pCtx, int32_t iLayerSize) { · 118 unmodified lines
891897 }
892898 pWelsSvcRc->iRemainingBits -= pWelsSvcRc->iFrameDqBits;
893899
894− RcTraceFrameBits (pEncCtx);
895−
896900 if (pEncCtx->pSvcParam->bEnableFrameSkip /*&&
897901 pEncCtx->uiDependencyId == pEncCtx->pSvcParam->iSpatialLayerNum - 1*/) {
898902 RcVBufferCalculationSkip (pEncCtx);
@@ -945,13 +949,15 @@ void WelsRcMbInfoUpdateGom (void* pCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* · 46 unmodified lines
945949 SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId];
946950 const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice;
947951
948− int32_t cur_mb_bits = BsGetBitsPos (bs) - pSOverRc->iBsPosSlice;
949− pSOverRc->iFrameBitsSlice += cur_mb_bits;
950− pSOverRc->iGomBitsSlice += cur_mb_bits;
952+ int32_t iCurMbBits = BsGetBitsPos (bs) - pSOverRc->iBsPosSlice;
953+ pSOverRc->iFrameBitsSlice += iCurMbBits;
954+ pSOverRc->iGomBitsSlice += iCurMbBits;
951955
952956 pWelsSvcRc->pGomCost[kiComplexityIndex] += iCostLuma;
953957
954− if (cur_mb_bits > 0) {
958+ pWelsSvcRc->iMinFrameQp = WELS_MIN(pWelsSvcRc->iMinFrameQp,pCurMb->uiLumaQp);
959+ pWelsSvcRc->iMaxFrameQp = WELS_MAX(pWelsSvcRc->iMaxFrameQp,pCurMb->uiLumaQp);
960+ if (iCurMbBits > 0) {
955961 pSOverRc->iTotalQpSlice += pCurMb->uiLumaQp;
956962 pSOverRc->iTotalMbSlice++;
957963 }

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