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