| 567 | } |
| 568 | |
| 569 | void RcDecideTargetBits (sWelsEncCtx* pEncCtx) { |
| 570 | SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; |
| 571 | SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId]; |
| 572 | |
| 573 | pWelsSvcRc->iCurrentBitsLevel = BITS_NORMAL; |
| 574 | const bool fix_rc_overshoot = pEncCtx->pSvcParam->bFixRCOverShoot; |
| 575 | //allocate bits |
| 576 | if (pEncCtx->eSliceType == I_SLICE) { |
| 577 | if( pWelsSvcRc->iIdrNum != 0 ){ |
| 578 | pWelsSvcRc->iTargetBits = pWelsSvcRc->iBitsPerFrame * pEncCtx->pSvcParam->iIdrBitrateRatio / 100; |
| 579 | } else { |
| 580 | pWelsSvcRc->iTargetBits = pWelsSvcRc->iBitsPerFrame * IDR_BITRATE_RATIO; |
| 581 | } |
| 582 | } else { |
| 583 | if (pWelsSvcRc->iRemainingWeights > pTOverRc->iTlayerWeight || |
| 584 | (fix_rc_overshoot && pWelsSvcRc->iRemainingWeights == pTOverRc->iTlayerWeight)) |
| 585 | pWelsSvcRc->iTargetBits = WELS_DIV_ROUND (static_cast<int64_t> (pWelsSvcRc->iRemainingBits) * pTOverRc->iTlayerWeight, |
| 586 | pWelsSvcRc->iRemainingWeights); |
| 587 | else //this case should be not hit. needs to more test case to verify this |
| 588 | pWelsSvcRc->iTargetBits = pWelsSvcRc->iRemainingBits; |
| 589 | if ((pWelsSvcRc->iTargetBits <= 0) && ((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE) |
| 590 | && (pEncCtx->pSvcParam->bEnableFrameSkip == false))) { |
| 591 | pWelsSvcRc->iCurrentBitsLevel = BITS_EXCEEDED; |
| 592 | } |
| 593 | pWelsSvcRc->iTargetBits = WELS_CLIP3 (pWelsSvcRc->iTargetBits, pTOverRc->iMinBitsTl, pTOverRc->iMaxBitsTl); |
| 594 | } |
| 595 | pWelsSvcRc->iRemainingWeights -= pTOverRc->iTlayerWeight; |
| 596 | |
| 597 | } |
| 598 | |
| 599 | void RcDecideTargetBitsTimestamp (sWelsEncCtx* pEncCtx) { |
| 600 | //decide one frame bits allocated |
no outgoing calls
no test coverage detected