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
575 const int32_t kiGlobalQp = pEncCtx->iGlobalQp;575 const int32_t kiGlobalQp = pEncCtx->iGlobalQp;
576 576
577 pWelsSvcRc->iAverageFrameQp = 0;577 pWelsSvcRc->iAverageFrameQp = 0;
578 pWelsSvcRc->iMinFrameQp = 51;;
579 pWelsSvcRc->iMaxFrameQp = 0;
578 for (int32_t i = 0; i < kiSliceNum; ++i) {580 for (int32_t i = 0; i < kiSliceNum; ++i) {
579 pSOverRc->iComplexityIndexSlice = 0;581 pSOverRc->iComplexityIndexSlice = 0;
580 pSOverRc->iCalculatedQpSlice = kiGlobalQp;582 pSOverRc->iCalculatedQpSlice = kiGlobalQp;
@@ -699,6 +701,7 @@ void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) { · 118 unmodified lines
699 const int32_t kiOutputBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);701 const int32_t kiOutputBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
700 //condition 1: whole pBuffer fullness702 //condition 1: whole pBuffer fullness
701 pWelsSvcRc->iBufferFullnessSkip += (pWelsSvcRc->iFrameDqBits - kiOutputBits);703 pWelsSvcRc->iBufferFullnessSkip += (pWelsSvcRc->iFrameDqBits - kiOutputBits);
704 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,"[Rc] bits in buffer = %3d",pWelsSvcRc->iBufferFullnessSkip);
702 //condition 2: VGOP bits constraint705 //condition 2: VGOP bits constraint
703 int32_t iVGopBitsPred = 0;706 int32_t iVGopBitsPred = 0;
704 for (int32_t i = pWelsSvcRc->iFrameCodedInVGop + 1; i < VGOP_SIZE; i++)707 for (int32_t i = pWelsSvcRc->iFrameCodedInVGop + 1; i < VGOP_SIZE; i++)
@@ -712,14 +715,13 @@ void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) { · 7 unmodified lines
712 || (dIncPercent > pWelsSvcRc->iRcVaryPercentage)) {715 || (dIncPercent > pWelsSvcRc->iRcVaryPercentage)) {
713 pEncCtx->iSkipFrameFlag = 1;716 pEncCtx->iSkipFrameFlag = 1;
714 pWelsSvcRc->iBufferFullnessSkip = pWelsSvcRc->iBufferFullnessSkip - kiOutputBits;717 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);
716 }719 }
717 720
718 if (pWelsSvcRc->iBufferFullnessSkip < 0)721 pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);
719 pWelsSvcRc->iBufferFullnessSkip = 0;
720 722
721 if (pEncCtx->iSkipFrameFlag == 1) {723 if (pEncCtx->iSkipFrameFlag == 1) {
722 pWelsSvcRc->iRemainingBits += WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);724 pWelsSvcRc->iRemainingBits += kiOutputBits;
723 pWelsSvcRc->iSkipFrameNum++;725 pWelsSvcRc->iSkipFrameNum++;
724 pWelsSvcRc->iSkipFrameInVGop++;726 pWelsSvcRc->iSkipFrameInVGop++;
725 }727 }
@@ -739,6 +741,7 @@ void WelsRcFrameDelayJudge (void* pCtx, EVideoFrameType eFrameType, long long ui · 13 unmodified lines
739 pWelsSvcRc->iSkipFrameNum++;741 pWelsSvcRc->iSkipFrameNum++;
740 pWelsSvcRc->iSkipFrameInVGop++;742 pWelsSvcRc->iSkipFrameInVGop++;
741 pWelsSvcRc->iBufferFullnessSkip -= iSentBits;743 pWelsSvcRc->iBufferFullnessSkip -= iSentBits;
744 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,"[Rc] bits in buffer = %3d",pWelsSvcRc->iBufferFullnessSkip);
742 pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);745 pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);
743 }746 }
744}747}
@@ -759,14 +762,17 @@ void RcVBufferCalculationPadding (sWelsEncCtx* pEncCtx) { · 14 unmodified lines
759}762}
760 763
761 764
762void RcTraceFrameBits (sWelsEncCtx* pEncCtx) {765void RcTraceFrameBits (void* pCtx, long long uiTimeStamp) {
766 sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
763 SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];767 SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
764 768
765 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,769 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
766 "[Rc] encoding_qp%d, qp = %3d, index = %8d, iTid = %1d, used = %8d, target = %8d, remaingbits = %8d",770 "[Rc] Frame timestamp = %8d, Frame type =%d, encoding_qp%d, average qp = %3d, max qp = %3d, min qp = %3d, index = %8d,\
767 pEncCtx->uiDependencyId, pWelsSvcRc->iAverageFrameQp, pEncCtx->iFrameIndex, pEncCtx->uiTemporalId,771 iTid = %1d, used = %8d, bitsperframe = %8d, target = %8d, remaingbits = %8d, skipbuffersize = %8d",
768 pWelsSvcRc->iFrameDqBits,772 (uint32_t)uiTimeStamp,pEncCtx->eSliceType, pEncCtx->uiDependencyId, pWelsSvcRc->iAverageFrameQp,pWelsSvcRc->iMaxFrameQp,pWelsSvcRc->iMinFrameQp,
769 pWelsSvcRc->iTargetBits, pWelsSvcRc->iRemainingBits);773 pEncCtx->iFrameIndex, pEncCtx->uiTemporalId, pWelsSvcRc->iFrameDqBits,WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY),
774 pWelsSvcRc->iTargetBits, pWelsSvcRc->iRemainingBits, pWelsSvcRc->iBufferSizeSkip);
775
770}776}
771 777
772void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) {778void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) {
@@ -891,8 +897,6 @@ void WelsRcPictureInfoUpdateGom (void* pCtx, int32_t iLayerSize) { · 118 unmodified lines
891 }897 }
892 pWelsSvcRc->iRemainingBits -= pWelsSvcRc->iFrameDqBits;898 pWelsSvcRc->iRemainingBits -= pWelsSvcRc->iFrameDqBits;
893 899
894 RcTraceFrameBits (pEncCtx);
895
896 if (pEncCtx->pSvcParam->bEnableFrameSkip /*&&900 if (pEncCtx->pSvcParam->bEnableFrameSkip /*&&
897 pEncCtx->uiDependencyId == pEncCtx->pSvcParam->iSpatialLayerNum - 1*/) {901 pEncCtx->uiDependencyId == pEncCtx->pSvcParam->iSpatialLayerNum - 1*/) {
898 RcVBufferCalculationSkip (pEncCtx);902 RcVBufferCalculationSkip (pEncCtx);
@@ -945,13 +949,15 @@ void WelsRcMbInfoUpdateGom (void* pCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* · 46 unmodified lines
945 SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId];949 SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[iSliceId];
946 const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice;950 const int32_t kiComplexityIndex = pSOverRc->iComplexityIndexSlice;
947 951
948 int32_t cur_mb_bits = BsGetBitsPos (bs) - pSOverRc->iBsPosSlice;952 int32_t iCurMbBits = BsGetBitsPos (bs) - pSOverRc->iBsPosSlice;
949 pSOverRc->iFrameBitsSlice += cur_mb_bits;953 pSOverRc->iFrameBitsSlice += iCurMbBits;
950 pSOverRc->iGomBitsSlice += cur_mb_bits;954 pSOverRc->iGomBitsSlice += iCurMbBits;
951 955
952 pWelsSvcRc->pGomCost[kiComplexityIndex] += iCostLuma;956 pWelsSvcRc->pGomCost[kiComplexityIndex] += iCostLuma;
953 957
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) {
955 pSOverRc->iTotalQpSlice += pCurMb->uiLumaQp;961 pSOverRc->iTotalQpSlice += pCurMb->uiLumaQp;
956 pSOverRc->iTotalMbSlice++;962 pSOverRc->iTotalMbSlice++;
957 }963 }

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