fix iContinualSkipFrames calculation
Showing the changes to codec/encoder/core/src/ratectl.cpp (1 of 4 files). Show all
Unified · Split
| @@ -736,9 +736,9 @@ void CheckFrameSkipBasedMaxbr (sWelsEncCtx* pEncCtx, const long long uiTimeStamp · 735 unmodified lines | ||
| 736 | 736 | 3:if in last ODD_TIME_WINDOW the MAX Br is overflowed, make more strict skipping conditions |
| 737 | 737 | 4:such as case 3 in the other window |
| 738 | 738 | */ |
| 739 | − bool bJudgeBufferFullSkip = (pEncCtx->iContinualSkipFrames <= iPredSkipFramesTarBr) | |
| 739 | + bool bJudgeBufferFullSkip = (pWelsSvcRc->iContinualSkipFrames <= iPredSkipFramesTarBr) | |
| 740 | 740 | && (pWelsSvcRc->iBufferFullnessSkip > pWelsSvcRc->iBufferSizeSkip); |
| 741 | − bool bJudgeMaxBRbufferFullSkip = (pEncCtx->iContinualSkipFrames <= iPredSkipFramesMaxBr) | |
| 741 | + bool bJudgeMaxBRbufferFullSkip = (pWelsSvcRc->iContinualSkipFrames <= iPredSkipFramesMaxBr) | |
| 742 | 742 | && (pEncCtx->iCheckWindowInterval > TIME_CHECK_WINDOW / 2) |
| 743 | 743 | && (pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW] + pWelsSvcRc->iPredFrameBit - iAvailableBitsInTimeWindow > 0); |
| 744 | 744 | bJudgeMaxBRbSkip[EVEN_TIME_WINDOW] = (pEncCtx->iCheckWindowInterval > TIME_CHECK_WINDOW / 2) |
| @@ -797,7 +797,7 @@ bool WelsRcCheckFrameStatus (sWelsEncCtx* pEncCtx, long long uiTimeStamp, int32_ · 52 unmodified lines | ||
| 797 | 797 | if (bSkipMustFlag) { |
| 798 | 798 | pEncCtx->pWelsSvcRc[iDidIdx].uiLastTimeStamp = uiTimeStamp; |
| 799 | 799 | pEncCtx->pWelsSvcRc[iDidIdx].bSkipFlag = false; |
| 800 | − pEncCtx->iContinualSkipFrames++; | |
| 800 | + pEncCtx->pWelsSvcRc[iDidIdx].iContinualSkipFrames++; | |
| 801 | 801 | return true; |
| 802 | 802 | } |
| 803 | 803 | } else { //SVC control |
| @@ -821,7 +821,6 @@ bool WelsRcCheckFrameStatus (sWelsEncCtx* pEncCtx, long long uiTimeStamp, int32_ · 17 unmodified lines | ||
| 821 | 821 | } |
| 822 | 822 | } |
| 823 | 823 | if (bSkipMustFlag) { |
| 824 | − pEncCtx->iContinualSkipFrames++; | |
| 825 | 824 | break; |
| 826 | 825 | } |
| 827 | 826 | } |
| @@ -831,6 +830,7 @@ bool WelsRcCheckFrameStatus (sWelsEncCtx* pEncCtx, long long uiTimeStamp, int32_ · 3 unmodified lines | ||
| 831 | 830 | int32_t iDidIdx = (pSpatialIndexMap + i)->iDid; |
| 832 | 831 | pEncCtx->pWelsSvcRc[iDidIdx].uiLastTimeStamp = uiTimeStamp; |
| 833 | 832 | pEncCtx->pWelsSvcRc[iDidIdx].bSkipFlag = false; |
| 833 | + pEncCtx->pWelsSvcRc[iDidIdx].iContinualSkipFrames++; | |
| 834 | 834 | } |
| 835 | 835 | return true; |
| 836 | 836 | } |
| @@ -845,8 +845,8 @@ void UpdateBufferWhenFrameSkipped (sWelsEncCtx* pEncCtx, int32_t iCurDid) { · 8 unmodified lines | ||
| 845 | 845 | pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW] -= kiOutputMaxBits; |
| 846 | 846 | pWelsSvcRc->iBufferMaxBRFullness[ODD_TIME_WINDOW] -= kiOutputMaxBits; |
| 847 | 847 | WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, |
| 848 | − "[Rc] bits in buffer = %" PRId64 ", bits in Max bitrate buffer = %" PRId64, | |
| 849 | − pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW]); | |
| 848 | + "[Rc] iDid = %d,bits in buffer = %" PRId64 ", bits in Max bitrate buffer = %" PRId64, | |
| 849 | + iCurDid,pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iBufferMaxBRFullness[EVEN_TIME_WINDOW]); | |
| 850 | 850 | |
| 851 | 851 | pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0); |
| 852 | 852 | |
| @@ -854,12 +854,11 @@ void UpdateBufferWhenFrameSkipped (sWelsEncCtx* pEncCtx, int32_t iCurDid) { · 1 unmodified line | ||
| 854 | 854 | pWelsSvcRc->iSkipFrameNum++; |
| 855 | 855 | pWelsSvcRc->iSkipFrameInVGop++; |
| 856 | 856 | |
| 857 | − pEncCtx->iContinualSkipFrames++; | |
| 858 | − if ((pEncCtx->iContinualSkipFrames % 3) == 0) { | |
| 857 | + if ((pWelsSvcRc->iContinualSkipFrames % 3) == 0) { | |
| 859 | 858 | //output a warning when iContinualSkipFrames is large enough, which may indicate subjective quality problem |
| 860 | 859 | //note that here iContinualSkipFrames must be >0, so the log output will be 3/6/.... |
| 861 | − WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_WARNING, "[Rc] iContinualSkipFrames(%d) is large", | |
| 862 | − pEncCtx->iContinualSkipFrames); | |
| 860 | + WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_WARNING, "[Rc] iDid = %d,iContinualSkipFrames(%d) is large", | |
| 861 | + iCurDid,pWelsSvcRc->iContinualSkipFrames); | |
| 863 | 862 | } |
| 864 | 863 | } |
| 865 | 864 | void UpdateMaxBrCheckWindowStatus (sWelsEncCtx* pEncCtx, int32_t iSpatialNum, const long long uiTimeStamp) { |