Showing the changes to codec/encoder/core/src/ratectl.cpp (1 of 10 files). Show all
Unified · Split
| @@ -127,10 +127,10 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) { · 126 unmodified lines | ||
| 127 | 127 | |
| 128 | 128 | pWelsSvcRc->dSkipBufferRatio = SKIP_RATIO; |
| 129 | 129 | |
| 130 | − pWelsSvcRc->iQpRangeUpperInFrame = QP_RANGE_UPPER_MODE1 - (int32_t) ((QP_RANGE_UPPER_MODE1 - QP_RANGE_MODE0) * | |
| 131 | − pWelsSvcRc->dRcVaryRatio + 0.5); | |
| 132 | − pWelsSvcRc->iQpRangeLowerInFrame = QP_RANGE_LOWER_MODE1 - (int32_t) ((QP_RANGE_LOWER_MODE1 - QP_RANGE_MODE0) * | |
| 133 | − pWelsSvcRc->dRcVaryRatio + 0.5); | |
| 130 | + pWelsSvcRc->iQpRangeUpperInFrame = QP_RANGE_UPPER_MODE1 - WELS_ROUND ((QP_RANGE_UPPER_MODE1 - QP_RANGE_MODE0) * | |
| 131 | + pWelsSvcRc->dRcVaryRatio); | |
| 132 | + pWelsSvcRc->iQpRangeLowerInFrame = QP_RANGE_LOWER_MODE1 - WELS_ROUND ((QP_RANGE_LOWER_MODE1 - QP_RANGE_MODE0) * | |
| 133 | + pWelsSvcRc->dRcVaryRatio); | |
| 134 | 134 | |
| 135 | 135 | if (iMbWidth <= MB_WIDTH_THRESHOLD_90P) { |
| 136 | 136 | pWelsSvcRc->iSkipQpValue = SKIP_QP_90P; |
| @@ -149,17 +149,17 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) { · 12 unmodified lines | ||
| 149 | 149 | iGomRowMode0 = GOM_ROW_MODE0_720P; |
| 150 | 150 | iGomRowMode1 = GOM_ROW_MODE1_720P; |
| 151 | 151 | } |
| 152 | − iGomRowMode0 = iGomRowMode1 + (int32_t) ((iGomRowMode0 - iGomRowMode1) * pWelsSvcRc->dRcVaryRatio + 0.5); | |
| 152 | + iGomRowMode0 = iGomRowMode1 + WELS_ROUND ((iGomRowMode0 - iGomRowMode1) * pWelsSvcRc->dRcVaryRatio); | |
| 153 | 153 | |
| 154 | 154 | pWelsSvcRc->iNumberMbGom = iMbWidth * iGomRowMode0; |
| 155 | 155 | |
| 156 | 156 | pWelsSvcRc->iMinQp = GOM_MIN_QP_MODE; |
| 157 | 157 | pWelsSvcRc->iMaxQp = GOM_MAX_QP_MODE; |
| 158 | 158 | |
| 159 | − pWelsSvcRc->iFrameDeltaQpUpper = LAST_FRAME_QP_RANGE_UPPER_MODE1 - (int32_t) ((LAST_FRAME_QP_RANGE_UPPER_MODE1 - | |
| 160 | − LAST_FRAME_QP_RANGE_UPPER_MODE0) * pWelsSvcRc->dRcVaryRatio + 0.5); | |
| 161 | − pWelsSvcRc->iFrameDeltaQpLower = LAST_FRAME_QP_RANGE_LOWER_MODE1 - (int32_t) ((LAST_FRAME_QP_RANGE_LOWER_MODE1 - | |
| 162 | − LAST_FRAME_QP_RANGE_LOWER_MODE0) * pWelsSvcRc->dRcVaryRatio + 0.5); | |
| 159 | + pWelsSvcRc->iFrameDeltaQpUpper = LAST_FRAME_QP_RANGE_UPPER_MODE1 - WELS_ROUND ((LAST_FRAME_QP_RANGE_UPPER_MODE1 - | |
| 160 | + LAST_FRAME_QP_RANGE_UPPER_MODE0) * pWelsSvcRc->dRcVaryRatio); | |
| 161 | + pWelsSvcRc->iFrameDeltaQpLower = LAST_FRAME_QP_RANGE_LOWER_MODE1 - WELS_ROUND ((LAST_FRAME_QP_RANGE_LOWER_MODE1 - | |
| 162 | + LAST_FRAME_QP_RANGE_LOWER_MODE0) * pWelsSvcRc->dRcVaryRatio); | |
| 163 | 163 | |
| 164 | 164 | pWelsSvcRc->iSkipFrameNum = 0; |
| 165 | 165 | pWelsSvcRc->iGomSize = (pWelsSvcRc->iNumberMbFrame + pWelsSvcRc->iNumberMbGom - 1) / pWelsSvcRc->iNumberMbGom; |
| @@ -213,7 +213,7 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) { · 47 unmodified lines | ||
| 213 | 213 | const int32_t kiGopSize = (1 << pDLayerParam->iDecompositionStages); |
| 214 | 214 | const int32_t kiHighestTid = pDLayerParam->iHighestTemporalId; |
| 215 | 215 | double input_dBitsPerFrame = pDLayerParam->iSpatialBitrate / pDLayerParam->fInputFrameRate; |
| 216 | − const int32_t kiGopBits = (int32_t) (input_dBitsPerFrame * kiGopSize); | |
| 216 | + const int32_t kiGopBits = WELS_ROUND (input_dBitsPerFrame * kiGopSize); | |
| 217 | 217 | int32_t i; |
| 218 | 218 | |
| 219 | 219 | pWelsSvcRc->iBitRate = pDLayerParam->iSpatialBitrate; |
| @@ -225,16 +225,16 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) { · 5 unmodified lines | ||
| 225 | 225 | |
| 226 | 226 | for (i = 0; i <= kiHighestTid; i++) { |
| 227 | 227 | const double kdConstraitBits = kiGopBits * pTOverRc[i].dTlayerWeight; |
| 228 | − pTOverRc[i].iMinBitsTl = (int32_t) (kdConstraitBits * dMinBitsRatio); | |
| 229 | − pTOverRc[i].iMaxBitsTl = (int32_t) (kdConstraitBits * dMaxBitsRatio); | |
| 228 | + pTOverRc[i].iMinBitsTl = WELS_ROUND (kdConstraitBits * dMinBitsRatio); | |
| 229 | + pTOverRc[i].iMaxBitsTl = WELS_ROUND (kdConstraitBits * dMaxBitsRatio); | |
| 230 | 230 | } |
| 231 | 231 | //When bitrate is changed, pBuffer size should be updated |
| 232 | − pWelsSvcRc->iBufferSizeSkip = (int32_t) (pWelsSvcRc->iBitRate * pWelsSvcRc->dSkipBufferRatio); | |
| 233 | − pWelsSvcRc->iBufferSizePadding = (int32_t) (pWelsSvcRc->iBitRate * PADDING_BUFFER_RATIO); | |
| 232 | + pWelsSvcRc->iBufferSizeSkip = WELS_ROUND (pWelsSvcRc->iBitRate * pWelsSvcRc->dSkipBufferRatio); | |
| 233 | + pWelsSvcRc->iBufferSizePadding = WELS_ROUND (pWelsSvcRc->iBitRate * PADDING_BUFFER_RATIO); | |
| 234 | 234 | |
| 235 | 235 | //change remaining bits |
| 236 | 236 | if (pWelsSvcRc->dBitsPerFrame > 0.1) |
| 237 | − pWelsSvcRc->iRemainingBits = (int32_t) (pWelsSvcRc->iRemainingBits * input_dBitsPerFrame / pWelsSvcRc->dBitsPerFrame); | |
| 237 | + pWelsSvcRc->iRemainingBits = WELS_ROUND (pWelsSvcRc->iRemainingBits * input_dBitsPerFrame / pWelsSvcRc->dBitsPerFrame); | |
| 238 | 238 | pWelsSvcRc->dBitsPerFrame = input_dBitsPerFrame; |
| 239 | 239 | } |
| 240 | 240 | |
| @@ -245,7 +245,7 @@ void RcInitVGop (sWelsEncCtx* pEncCtx) { · 4 unmodified lines | ||
| 245 | 245 | SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; |
| 246 | 246 | const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId; |
| 247 | 247 | |
| 248 | − pWelsSvcRc->iRemainingBits = (int32_t) (VGOP_SIZE * pWelsSvcRc->dBitsPerFrame); | |
| 248 | + pWelsSvcRc->iRemainingBits = WELS_ROUND (VGOP_SIZE * pWelsSvcRc->dBitsPerFrame); | |
| 249 | 249 | pWelsSvcRc->dRemainingWeights = pWelsSvcRc->iGopNumberInVGop; |
| 250 | 250 | |
| 251 | 251 | pWelsSvcRc->iFrameCodedInVGop = 0; |
| @@ -325,9 +325,9 @@ void RcTraceVGopBitrate (sWelsEncCtx* pEncCtx) { · 73 unmodified lines | ||
| 325 | 325 | } |
| 326 | 326 | int32_t iFrameInVGop = pWelsSvcRc->iFrameCodedInVGop + pWelsSvcRc->iSkipFrameInVGop; |
| 327 | 327 | if (0 != iFrameInVGop) |
| 328 | − iVGopBitrate = (int32_t) (iTotalBits / iFrameInVGop * pWelsSvcRc->fFrameRate); | |
| 328 | + iVGopBitrate = WELS_ROUND (iTotalBits / iFrameInVGop * pWelsSvcRc->fFrameRate); | |
| 329 | 329 | #ifdef _TEST_TEMP_Rc_ |
| 330 | − fprintf (fp_vgop, "%d\n", (int32_t) ((double)iTotalBits / iFrameInVGop)); | |
| 330 | + fprintf (fp_vgop, "%d\n", WELS_ROUND ((double)iTotalBits / iFrameInVGop)); | |
| 331 | 331 | #endif |
| 332 | 332 | WelsLog (pEncCtx, WELS_LOG_INFO, "[Rc] VGOPbitrate%d: %d \n", kiDid, iVGopBitrate); |
| 333 | 333 | if (iTotalBits > 0) { |
| @@ -400,7 +400,7 @@ void RcInitIdrQp (sWelsEncCtx* pEncCtx) { · 66 unmodified lines | ||
| 400 | 400 | break; |
| 401 | 401 | } |
| 402 | 402 | pWelsSvcRc->iInitialQp = dInitialQPArray[iBppIndex][i]; |
| 403 | − pWelsSvcRc->iInitialQp = (int32_t)WELS_CLIP3 (pWelsSvcRc->iInitialQp, MIN_IDR_QP, MAX_IDR_QP); | |
| 403 | + pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, MIN_IDR_QP, MAX_IDR_QP); | |
| 404 | 404 | pEncCtx->iGlobalQp = pWelsSvcRc->iInitialQp; |
| 405 | 405 | pWelsSvcRc->dQStep = RcConvertQp2QStep (pEncCtx->iGlobalQp); |
| 406 | 406 | pWelsSvcRc->iLastCalculatedQScale = pEncCtx->iGlobalQp; |
| @@ -410,11 +410,12 @@ void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) { · 3 unmodified lines | ||
| 410 | 410 | SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; |
| 411 | 411 | //obtain the idr qp using previous idr complexity |
| 412 | 412 | if (pWelsSvcRc->iNumberMbFrame != pWelsSvcRc->iIntraMbCount) { |
| 413 | − pWelsSvcRc->iIntraComplexity = (int32_t) ((double)pWelsSvcRc->iIntraComplexity * pWelsSvcRc->iNumberMbFrame / | |
| 414 | − pWelsSvcRc->iIntraMbCount + 0.5); | |
| 413 | + pWelsSvcRc->iIntraComplexity = WELS_ROUND ((double)pWelsSvcRc->iIntraComplexity * pWelsSvcRc->iNumberMbFrame / | |
| 414 | + pWelsSvcRc->iIntraMbCount); | |
| 415 | 415 | } |
| 416 | − pWelsSvcRc->iInitialQp = (int32_t)RcConvertQStep2Qp ((double)pWelsSvcRc->iIntraComplexity / pWelsSvcRc->iTargetBits); | |
| 417 | − pWelsSvcRc->iInitialQp = (int32_t)WELS_CLIP3 (pWelsSvcRc->iInitialQp, MIN_IDR_QP, MAX_IDR_QP); | |
| 416 | + pWelsSvcRc->iInitialQp = WELS_ROUND (RcConvertQStep2Qp ((double)pWelsSvcRc->iIntraComplexity / | |
| 417 | + pWelsSvcRc->iTargetBits)); | |
| 418 | + pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, MIN_IDR_QP, MAX_IDR_QP); | |
| 418 | 419 | pEncCtx->iGlobalQp = pWelsSvcRc->iInitialQp; |
| 419 | 420 | pWelsSvcRc->dQStep = RcConvertQp2QStep (pEncCtx->iGlobalQp); |
| 420 | 421 | pWelsSvcRc->iLastCalculatedQScale = pEncCtx->iGlobalQp; |
| @@ -451,7 +452,7 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { · 30 unmodified lines | ||
| 451 | 452 | pWelsSvcRc->iLastCalculatedQScale = iLumaQp; |
| 452 | 453 | |
| 453 | 454 | if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) { |
| 454 | − iLumaQp = (int32_t) (iLumaQp - pEncCtx->pVaa->sAdaptiveQuantParam.dAverMotionTextureIndexToDeltaQp); | |
| 455 | + iLumaQp = WELS_ROUND (iLumaQp - pEncCtx->pVaa->sAdaptiveQuantParam.dAverMotionTextureIndexToDeltaQp); | |
| 455 | 456 | } |
| 456 | 457 | |
| 457 | 458 | pEncCtx->iGlobalQp = iLumaQp; |
| @@ -462,7 +463,7 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { · 4 unmodified lines | ||
| 462 | 463 | dCmplxRatio = WELS_CLIP3 (dCmplxRatio, 1.0 - FRAME_CMPLX_RATIO_RANGE, 1.0 + FRAME_CMPLX_RATIO_RANGE); |
| 463 | 464 | |
| 464 | 465 | pWelsSvcRc->dQStep = pTOverRc->dLinearCmplx * dCmplxRatio / pWelsSvcRc->iTargetBits; |
| 465 | − iLumaQp = (int32_t) (RcConvertQStep2Qp (pWelsSvcRc->dQStep) + 0.5); | |
| 466 | + iLumaQp = WELS_ROUND (RcConvertQStep2Qp (pWelsSvcRc->dQStep)); | |
| 466 | 467 | |
| 467 | 468 | //limit QP |
| 468 | 469 | int32_t iLastIdxCodecInVGop = pWelsSvcRc->iFrameCodedInVGop - 1; |
| @@ -487,10 +488,10 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { · 18 unmodified lines | ||
| 487 | 488 | #ifndef _NOT_USE_AQ_FOR_TEST_ |
| 488 | 489 | if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) { |
| 489 | 490 | |
| 490 | − iLumaQp = (int32_t) (iLumaQp - pEncCtx->pVaa->sAdaptiveQuantParam.dAverMotionTextureIndexToDeltaQp); | |
| 491 | + iLumaQp = WELS_ROUND (iLumaQp - pEncCtx->pVaa->sAdaptiveQuantParam.dAverMotionTextureIndexToDeltaQp); | |
| 491 | 492 | |
| 492 | 493 | if (pEncCtx->pSvcParam->iRCMode != RC_LOW_BW_MODE) |
| 493 | − iLumaQp = (int32_t)WELS_CLIP3 (iLumaQp, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp); | |
| 494 | + iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp); | |
| 494 | 495 | |
| 495 | 496 | } |
| 496 | 497 | #endif |
| @@ -510,7 +511,7 @@ void RcInitSliceInformation (sWelsEncCtx* pEncCtx) { · 13 unmodified lines | ||
| 510 | 511 | pSOverRc->iEndMbSlice += (pCurSliceCtx->pCountMbNumInSlice[i] - 1); |
| 511 | 512 | pSOverRc->iTotalQpSlice = 0; |
| 512 | 513 | pSOverRc->iTotalMbSlice = 0; |
| 513 | − pSOverRc->iTargetBitsSlice = (int32_t) (kdBitsPerMb * pCurSliceCtx->pCountMbNumInSlice[i]); | |
| 514 | + pSOverRc->iTargetBitsSlice = WELS_ROUND (kdBitsPerMb * pCurSliceCtx->pCountMbNumInSlice[i]); | |
| 514 | 515 | pSOverRc->iFrameBitsSlice = 0; |
| 515 | 516 | pSOverRc->iGomBitsSlice = 0; |
| 516 | 517 | ++ pSOverRc; |
| @@ -524,10 +525,10 @@ void RcDecideTargetBits (sWelsEncCtx* pEncCtx) { · 7 unmodified lines | ||
| 524 | 525 | pWelsSvcRc->iCurrentBitsLevel = BITS_NORMAL; |
| 525 | 526 | //allocate bits |
| 526 | 527 | if (pEncCtx->eSliceType == I_SLICE) { |
| 527 | − pWelsSvcRc->iTargetBits = (int32_t) (pWelsSvcRc->dBitsPerFrame * IDR_BITRATE_RATIO); | |
| 528 | + pWelsSvcRc->iTargetBits = WELS_ROUND (pWelsSvcRc->dBitsPerFrame * IDR_BITRATE_RATIO); | |
| 528 | 529 | } else { |
| 529 | − pWelsSvcRc->iTargetBits = (int32_t) (pWelsSvcRc->iRemainingBits * pTOverRc->dTlayerWeight / | |
| 530 | − pWelsSvcRc->dRemainingWeights); | |
| 530 | + pWelsSvcRc->iTargetBits = WELS_ROUND (pWelsSvcRc->iRemainingBits * pTOverRc->dTlayerWeight / | |
| 531 | + pWelsSvcRc->dRemainingWeights); | |
| 531 | 532 | if ((pWelsSvcRc->iTargetBits <= 0) && (pEncCtx->pSvcParam->iRCMode == RC_LOW_BW_MODE)) { |
| 532 | 533 | pWelsSvcRc->iCurrentBitsLevel = BITS_EXCEEDED; |
| 533 | 534 | } else if ((pWelsSvcRc->iTargetBits <= pTOverRc->iMinBitsTl) && (pEncCtx->pSvcParam->iRCMode == RC_LOW_BW_MODE)) { |
| @@ -625,7 +626,7 @@ void RcGomTargetBits (sWelsEncCtx* pEncCtx, const int32_t kiSliceId) { · 91 unmodified lines | ||
| 625 | 626 | dAllocateBits = (double)iLeftBits * pWelsSvcRc_Base->pCurrentFrameGomSad[kiComplexityIndex + 1] / iSumSad; |
| 626 | 627 | |
| 627 | 628 | } |
| 628 | − pSOverRc->iGomTargetBits = int32_t (dAllocateBits + 0.5); | |
| 629 | + pSOverRc->iGomTargetBits = WELS_ROUND (dAllocateBits); | |
| 629 | 630 | } |
| 630 | 631 | |
| 631 | 632 | |
| @@ -665,11 +666,11 @@ void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) { · 33 unmodified lines | ||
| 665 | 666 | void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) { |
| 666 | 667 | SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; |
| 667 | 668 | SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc; |
| 668 | − const int32_t kiOutputBits = (int32_t) (pWelsSvcRc->dBitsPerFrame + 0.5); | |
| 669 | + const int32_t kiOutputBits = WELS_ROUND (pWelsSvcRc->dBitsPerFrame); | |
| 669 | 670 | //condition 1: whole pBuffer fullness |
| 670 | 671 | pWelsSvcRc->iBufferFullnessSkip += (pWelsSvcRc->iFrameDqBits - kiOutputBits); |
| 671 | 672 | //condition 2: VGOP bits constraint |
| 672 | − const int32_t kiVGopBits = (int32_t) (pWelsSvcRc->dBitsPerFrame * VGOP_SIZE); | |
| 673 | + const int32_t kiVGopBits = WELS_ROUND (pWelsSvcRc->dBitsPerFrame * VGOP_SIZE); | |
| 673 | 674 | int32_t iVGopBitsPred = 0; |
| 674 | 675 | for (int32_t i = pWelsSvcRc->iFrameCodedInVGop + 1; i < VGOP_SIZE; i++) |
| 675 | 676 | iVGopBitsPred += pTOverRc[pWelsSvcRc->iTlOfFrames[i]].iMinBitsTl; |
| @@ -690,7 +691,7 @@ void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) { · 14 unmodified lines | ||
| 690 | 691 | pWelsSvcRc->iBufferFullnessSkip = 0; |
| 691 | 692 | |
| 692 | 693 | if (pEncCtx->iSkipFrameFlag == 1) { |
| 693 | − pWelsSvcRc->iRemainingBits += (int32_t) (pWelsSvcRc->dBitsPerFrame + 0.5); | |
| 694 | + pWelsSvcRc->iRemainingBits += WELS_ROUND (pWelsSvcRc->dBitsPerFrame); | |
| 694 | 695 | pWelsSvcRc->iSkipFrameNum++; |
| 695 | 696 | pWelsSvcRc->iSkipFrameInVGop++; |
| 696 | 697 | } |
| @@ -698,8 +699,8 @@ void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) { · 1 unmodified line | ||
| 698 | 699 | |
| 699 | 700 | void RcVBufferCalculationPadding (sWelsEncCtx* pEncCtx) { |
| 700 | 701 | SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; |
| 701 | − const int32_t kiOutputBits = (int32_t) (pWelsSvcRc->dBitsPerFrame + 0.5); | |
| 702 | − const int32_t kiBufferThreshold = (int32_t) (PADDING_THRESHOLD * (-pWelsSvcRc->iBufferSizePadding)); | |
| 702 | + const int32_t kiOutputBits = WELS_ROUND (pWelsSvcRc->dBitsPerFrame); | |
| 703 | + const int32_t kiBufferThreshold = WELS_ROUND (PADDING_THRESHOLD * (-pWelsSvcRc->iBufferSizePadding)); | |
| 703 | 704 | |
| 704 | 705 | pWelsSvcRc->iBufferFullnessPadding += (pWelsSvcRc->iFrameDqBits - kiOutputBits); |
| 705 | 706 | |
| @@ -736,7 +737,7 @@ void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) { · 30 unmodified lines | ||
| 736 | 737 | ++ pSOverRc; |
| 737 | 738 | } |
| 738 | 739 | if (iTotalMb > 0) |
| 739 | − pWelsSvcRc->iAverageFrameQp = (int32_t) (1.0 * iTotalQp / iTotalMb + 0.5); | |
| 740 | + pWelsSvcRc->iAverageFrameQp = WELS_ROUND (1.0 * iTotalQp / iTotalMb); | |
| 740 | 741 | else |
| 741 | 742 | pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp; |
| 742 | 743 | } else { |
| @@ -753,7 +754,7 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) { · 10 unmodified lines | ||
| 753 | 754 | |
| 754 | 755 | double dIntraCmplx = pWelsSvcRc->dQStep * pWelsSvcRc->iFrameDqBits; |
| 755 | 756 | dIntraCmplx = (1.0 - iAlpha) * pWelsSvcRc->iIntraComplexity + iAlpha * dIntraCmplx; |
| 756 | − pWelsSvcRc->iIntraComplexity = (int32_t) (dIntraCmplx + 0.5); | |
| 757 | + pWelsSvcRc->iIntraComplexity = WELS_ROUND (dIntraCmplx); | |
| 757 | 758 | pWelsSvcRc->iIntraMbCount = pWelsSvcRc->iNumberMbFrame; |
| 758 | 759 | |
| 759 | 760 | pWelsSvcRc->iIdrNum++; |
| @@ -775,8 +776,8 @@ void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) { · 15 unmodified lines | ||
| 775 | 776 | double iAlpha = 1.0 / (1 + pTOverRc->iPFrameNum); |
| 776 | 777 | if (iAlpha < SMOOTH_FACTOR_MIN_VALUE) |
| 777 | 778 | iAlpha = SMOOTH_FACTOR_MIN_VALUE; |
| 778 | − pTOverRc->iFrameCmplxMean = (int32_t) ((1.0 - iAlpha) * pTOverRc->iFrameCmplxMean + iAlpha * | |
| 779 | − pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity + 0.5); | |
| 779 | + pTOverRc->iFrameCmplxMean = WELS_ROUND ((1.0 - iAlpha) * pTOverRc->iFrameCmplxMean + iAlpha * | |
| 780 | + pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity); | |
| 780 | 781 | |
| 781 | 782 | pTOverRc->iPFrameNum++; |
| 782 | 783 | if (pTOverRc->iPFrameNum > 255) |
| @@ -918,10 +919,10 @@ void WelsRcPictureInitDisable (void* pCtx) { · 135 unmodified lines | ||
| 918 | 919 | pEncCtx->iGlobalQp = RcCalculateCascadingQp (pEncCtx, kiQp); |
| 919 | 920 | |
| 920 | 921 | if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) { |
| 921 | − pEncCtx->iGlobalQp = (int32_t)WELS_CLIP3 (pEncCtx->iGlobalQp - | |
| 922 | − pEncCtx->pVaa->sAdaptiveQuantParam.dAverMotionTextureIndexToDeltaQp, GOM_MIN_QP_MODE, GOM_MAX_QP_MODE); | |
| 923 | − }else{ | |
| 924 | − pEncCtx->iGlobalQp = WELS_CLIP3(pEncCtx->iGlobalQp, FIX_MIN_QP_MODE, FIX_MAX_QP_MODE); | |
| 922 | + pEncCtx->iGlobalQp = WELS_CLIP3 (WELS_ROUND (pEncCtx->iGlobalQp - | |
| 923 | + pEncCtx->pVaa->sAdaptiveQuantParam.dAverMotionTextureIndexToDeltaQp), GOM_MIN_QP_MODE, GOM_MAX_QP_MODE); | |
| 924 | + } else { | |
| 925 | + pEncCtx->iGlobalQp = WELS_CLIP3 (pEncCtx->iGlobalQp, FIX_MIN_QP_MODE, FIX_MAX_QP_MODE); | |
| 925 | 926 | } |
| 926 | 927 | |
| 927 | 928 | pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp; |
| @@ -937,8 +938,8 @@ void WelsRcMbInitDisable (void* pCtx, SMB* pCurMb, SSlice* pSlice) { · 9 unmodified lines | ||
| 937 | 938 | if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) { |
| 938 | 939 | iLumaQp = (int8_t)WELS_CLIP3 (iLumaQp + |
| 939 | 940 | pEncCtx->pVaa->sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[pCurMb->iMbXY], GOM_MIN_QP_MODE, 51); |
| 940 | − }else{ | |
| 941 | − iLumaQp = WELS_CLIP3(iLumaQp,FIX_MIN_QP_MODE,FIX_MAX_QP_MODE); | |
| 941 | + } else { | |
| 942 | + iLumaQp = WELS_CLIP3 (iLumaQp, FIX_MIN_QP_MODE, FIX_MAX_QP_MODE); | |
| 942 | 943 | } |
| 943 | 944 | pCurMb->uiChromaQp = g_kuiChromaQpTable[iLumaQp]; |
| 944 | 945 | pCurMb->uiLumaQp = iLumaQp; |