| 211 | } |
| 212 | |
| 213 | void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) { |
| 214 | SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; |
| 215 | SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; |
| 216 | |
| 217 | SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId]; |
| 218 | SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId]; |
| 219 | const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages); |
| 220 | const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId; |
| 221 | const int32_t input_iBitsPerFrame = WELS_DIV_ROUND (pDLayerParam->iSpatialBitrate, |
| 222 | pDLayerParamInternal->fOutputFrameRate); |
| 223 | const int64_t kiGopBits = input_iBitsPerFrame * kiGopSize; |
| 224 | int32_t i; |
| 225 | |
| 226 | pWelsSvcRc->iBitRate = pDLayerParam->iSpatialBitrate; |
| 227 | pWelsSvcRc->fFrameRate = pDLayerParamInternal->fOutputFrameRate; |
| 228 | |
| 229 | int32_t iTargetVaryRange = ((MAX_BITS_VARY_PERCENTAGE - pWelsSvcRc->iRcVaryRatio) >> 1); |
| 230 | int32_t iMinBitsRatio = MAX_BITS_VARY_PERCENTAGE - iTargetVaryRange; |
| 231 | int32_t iMaxBitsRatio = MAX_BITS_VARY_PERCENTAGE_x3d2; |
| 232 | |
| 233 | for (i = 0; i <= kiHighestTid; i++) { |
| 234 | const int64_t kdConstraitBits = kiGopBits * pTOverRc[i].iTlayerWeight; |
| 235 | pTOverRc[i].iMinBitsTl = WELS_DIV_ROUND (kdConstraitBits * iMinBitsRatio, |
| 236 | MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY); |
| 237 | pTOverRc[i].iMaxBitsTl = WELS_DIV_ROUND (kdConstraitBits * iMaxBitsRatio, |
| 238 | MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY); |
| 239 | } |
| 240 | //When bitrate is changed, pBuffer size should be updated |
| 241 | pWelsSvcRc->iBufferSizeSkip = WELS_DIV_ROUND (pWelsSvcRc->iBitRate * pWelsSvcRc->iSkipBufferRatio, INT_MULTIPLY); |
| 242 | pWelsSvcRc->iBufferSizePadding = WELS_DIV_ROUND (pWelsSvcRc->iBitRate * PADDING_BUFFER_RATIO, INT_MULTIPLY); |
| 243 | |
| 244 | //change remaining bits |
| 245 | if (pWelsSvcRc->iBitsPerFrame > REMAIN_BITS_TH) { |
| 246 | pWelsSvcRc->iRemainingBits = WELS_DIV_ROUND (static_cast<int64_t> (pWelsSvcRc->iRemainingBits) * input_iBitsPerFrame, |
| 247 | pWelsSvcRc->iBitsPerFrame); |
| 248 | } |
| 249 | pWelsSvcRc->iBitsPerFrame = input_iBitsPerFrame; |
| 250 | pWelsSvcRc->iMaxBitsPerFrame = WELS_DIV_ROUND (pDLayerParam->iMaxSpatialBitrate, |
| 251 | pDLayerParamInternal->fOutputFrameRate); |
| 252 | } |
| 253 | |
| 254 | |
| 255 | void RcInitVGop (sWelsEncCtx* pEncCtx) { |
no outgoing calls
no test coverage detected