History

astyle all

huili2 committed 12 years ago

Commit dc3fae41 parent 101265385 files · +4906 −4701Browse files

Showing the changes to codec/encoder/core/src/ratectl.cpp (1 of 85 files). Show all

Unified · Split

codec/encoder/core/src/ratectl.cpp+61−49
@@ -57,11 +57,12 @@ FILE* fp_vgop = NULL; · 56 unmodified lines
5757 #endif
5858 #define _BITS_RANGE 0
5959 const int32_t g_kiQpToQstepTable[52] = { 63, 71, 79, 89, 100, 112, 126, 141, 159, 178,
60− 200, 224, 252, 283, 317, 356, 400, 449, 504, 566,
61− 635, 713, 800, 898, 1008, 1131, 1270, 1425, 1600, 1796,
62− 2016, 2263, 2540, 2851, 3200, 3592, 4032, 4525, 5080, 5702,
63− 6400, 7184, 8063, 9051,10159,11404,12800,14368,16127,18102,
64− 20319,22807}; //WELS_ROUND(INT_MULTIPLY*pow (2.0, (iQP - 4.0) / 6.0))
60+ 200, 224, 252, 283, 317, 356, 400, 449, 504, 566,
61+ 635, 713, 800, 898, 1008, 1131, 1270, 1425, 1600, 1796,
62+ 2016, 2263, 2540, 2851, 3200, 3592, 4032, 4525, 5080, 5702,
63+ 6400, 7184, 8063, 9051, 10159, 11404, 12800, 14368, 16127, 18102,
64+ 20319, 22807
65+ }; //WELS_ROUND(INT_MULTIPLY*pow (2.0, (iQP - 4.0) / 6.0))
6566
6667 void RcInitLayerMemory (SWelsSvcRc* pWelsSvcRc, CMemoryAlign* pMA, const int32_t kiMaxTl) {
6768 const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
@@ -106,7 +107,7 @@ static inline int32_t RcConvertQp2QStep (int32_t iQP) { · 38 unmodified lines
106107 return g_kiQpToQstepTable[iQP];
107108 }
108109 static inline int32_t RcConvertQStep2Qp (int32_t iQpStep) {
109− return WELS_ROUND((6 * log (iQpStep*1.0f/INT_MULTIPLY) / log (2.0) + 4.0));
110+ return WELS_ROUND ((6 * log (iQpStep * 1.0f / INT_MULTIPLY) / log (2.0) + 4.0));
110111 }
111112
112113 void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) {
@@ -135,10 +136,12 @@ void RcInitSequenceParameter (sWelsEncCtx* pEncCtx) { · 22 unmodified lines
135136
136137 pWelsSvcRc->iSkipBufferRatio = SKIP_RATIO;
137138
138− pWelsSvcRc->iQpRangeUpperInFrame = (QP_RANGE_UPPER_MODE1 * MAX_BITS_VARY_PERCENTAGE - ((QP_RANGE_UPPER_MODE1 - QP_RANGE_MODE0) *
139− pWelsSvcRc->iRcVaryRatio)) / MAX_BITS_VARY_PERCENTAGE;
140− pWelsSvcRc->iQpRangeLowerInFrame = (QP_RANGE_LOWER_MODE1 * MAX_BITS_VARY_PERCENTAGE - ((QP_RANGE_LOWER_MODE1 - QP_RANGE_MODE0) *
141− pWelsSvcRc->iRcVaryRatio)) / MAX_BITS_VARY_PERCENTAGE;
139+ pWelsSvcRc->iQpRangeUpperInFrame = (QP_RANGE_UPPER_MODE1 * MAX_BITS_VARY_PERCENTAGE - ((
140+ QP_RANGE_UPPER_MODE1 - QP_RANGE_MODE0) *
141+ pWelsSvcRc->iRcVaryRatio)) / MAX_BITS_VARY_PERCENTAGE;
142+ pWelsSvcRc->iQpRangeLowerInFrame = (QP_RANGE_LOWER_MODE1 * MAX_BITS_VARY_PERCENTAGE - ((
143+ QP_RANGE_LOWER_MODE1 - QP_RANGE_MODE0) *
144+ pWelsSvcRc->iRcVaryRatio)) / MAX_BITS_VARY_PERCENTAGE;
142145
143146 if (iMbWidth <= MB_WIDTH_THRESHOLD_90P) {
144147 pWelsSvcRc->iSkipQpValue = SKIP_QP_90P;
@@ -223,8 +226,9 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) { · 78 unmodified lines
223226 SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
224227 const int32_t kiGopSize = (1 << pDLayerParamInternal->iDecompositionStages);
225228 const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId;
226− int32_t input_iBitsPerFrame = WELS_ROUND(pDLayerParam->iSpatialBitrate * INT_MULTIPLY / pDLayerParamInternal->fInputFrameRate);
227− const int32_t kiGopBits = WELS_DIV_ROUND(input_iBitsPerFrame * kiGopSize, INT_MULTIPLY);
229+ int32_t input_iBitsPerFrame = WELS_ROUND (pDLayerParam->iSpatialBitrate * INT_MULTIPLY /
230+ pDLayerParamInternal->fInputFrameRate);
231+ const int32_t kiGopBits = WELS_DIV_ROUND (input_iBitsPerFrame * kiGopSize, INT_MULTIPLY);
228232 int32_t i;
229233
230234 pWelsSvcRc->iBitRate = pDLayerParam->iSpatialBitrate;
@@ -236,12 +240,14 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) { · 5 unmodified lines
236240
237241 for (i = 0; i <= kiHighestTid; i++) {
238242 const int64_t kdConstraitBits = kiGopBits * pTOverRc[i].iTlayerWeight;
239− pTOverRc[i].iMinBitsTl = WELS_DIV_ROUND(kdConstraitBits * iMinBitsRatio, INT_MULTIPLY * MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
240− pTOverRc[i].iMaxBitsTl = WELS_DIV_ROUND(kdConstraitBits * iMaxBitsRatio, INT_MULTIPLY * MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
243+ pTOverRc[i].iMinBitsTl = WELS_DIV_ROUND (kdConstraitBits * iMinBitsRatio,
244+ INT_MULTIPLY * MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
245+ pTOverRc[i].iMaxBitsTl = WELS_DIV_ROUND (kdConstraitBits * iMaxBitsRatio,
246+ INT_MULTIPLY * MAX_BITS_VARY_PERCENTAGE * WEIGHT_MULTIPLY);
241247 }
242248 //When bitrate is changed, pBuffer size should be updated
243− pWelsSvcRc->iBufferSizeSkip = WELS_DIV_ROUND(pWelsSvcRc->iBitRate * pWelsSvcRc->iSkipBufferRatio, INT_MULTIPLY);
244− pWelsSvcRc->iBufferSizePadding = WELS_DIV_ROUND(pWelsSvcRc->iBitRate * PADDING_BUFFER_RATIO, INT_MULTIPLY);
249+ pWelsSvcRc->iBufferSizeSkip = WELS_DIV_ROUND (pWelsSvcRc->iBitRate * pWelsSvcRc->iSkipBufferRatio, INT_MULTIPLY);
250+ pWelsSvcRc->iBufferSizePadding = WELS_DIV_ROUND (pWelsSvcRc->iBitRate * PADDING_BUFFER_RATIO, INT_MULTIPLY);
245251
246252 //change remaining bits
247253 if (pWelsSvcRc->iBitsPerFrame > REMAIN_BITS_TH)
@@ -256,7 +262,7 @@ void RcInitVGop (sWelsEncCtx* pEncCtx) { · 8 unmodified lines
256262 SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
257263 const int32_t kiHighestTid = pEncCtx->pSvcParam->sDependencyLayers[kiDid].iHighestTemporalId;
258264
259− pWelsSvcRc->iRemainingBits = WELS_DIV_ROUND(VGOP_SIZE * pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
265+ pWelsSvcRc->iRemainingBits = WELS_DIV_ROUND (VGOP_SIZE * pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
260266 pWelsSvcRc->iRemainingWeights = pWelsSvcRc->iGopNumberInVGop * WEIGHT_MULTIPLY;
261267
262268 pWelsSvcRc->iFrameCodedInVGop = 0;
@@ -427,7 +433,7 @@ void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) { · 164 unmodified lines
427433 pWelsSvcRc->iIntraMbCount;
428434 }
429435 pWelsSvcRc->iInitialQp = RcConvertQStep2Qp (pWelsSvcRc->iIntraComplexity /
430− pWelsSvcRc->iTargetBits);
436+ pWelsSvcRc->iTargetBits);
431437 pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, MIN_IDR_QP, MAX_IDR_QP);
432438 pEncCtx->iGlobalQp = pWelsSvcRc->iInitialQp;
433439 pWelsSvcRc->iQStep = RcConvertQp2QStep (pEncCtx->iGlobalQp);
@@ -465,17 +471,19 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { · 31 unmodified lines
465471 pWelsSvcRc->iLastCalculatedQScale = iLumaQp;
466472
467473 if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
468− iLumaQp = WELS_CLIP3 ((iLumaQp*INT_MULTIPLY - pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp)/INT_MULTIPLY, GOM_MIN_QP_MODE, MAX_LOW_BR_QP);
474+ iLumaQp = WELS_CLIP3 ((iLumaQp * INT_MULTIPLY - pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp) /
475+ INT_MULTIPLY, GOM_MIN_QP_MODE, MAX_LOW_BR_QP);
469476 }
470477
471478 pEncCtx->iGlobalQp = iLumaQp;
472479
473480 return;
474481 } else {
475− int64_t iCmplxRatio = WELS_DIV_ROUND64(pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity *INT_MULTIPLY, pTOverRc->iFrameCmplxMean);
482+ int64_t iCmplxRatio = WELS_DIV_ROUND64 (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity * INT_MULTIPLY,
483+ pTOverRc->iFrameCmplxMean);
476484 iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);
477485
478− pWelsSvcRc->iQStep = WELS_DIV_ROUND((pTOverRc->iLinearCmplx * iCmplxRatio), (pWelsSvcRc->iTargetBits * INT_MULTIPLY));
486+ pWelsSvcRc->iQStep = WELS_DIV_ROUND ((pTOverRc->iLinearCmplx * iCmplxRatio), (pWelsSvcRc->iTargetBits * INT_MULTIPLY));
479487 iLumaQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);
480488
481489 //limit QP
@@ -501,7 +509,8 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { · 19 unmodified lines
501509 #ifndef _NOT_USE_AQ_FOR_TEST_
502510 if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
503511
504− iLumaQp = WELS_DIV_ROUND(iLumaQp*INT_MULTIPLY - pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp,INT_MULTIPLY);
512+ iLumaQp = WELS_DIV_ROUND (iLumaQp * INT_MULTIPLY - pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp,
513+ INT_MULTIPLY);
505514
506515 if (pEncCtx->pSvcParam->iRCMode != RC_LOW_BW_MODE)
507516 iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
@@ -516,7 +525,7 @@ void RcInitSliceInformation (sWelsEncCtx* pEncCtx) { · 8 unmodified lines
516525 SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
517526 SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
518527 const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
519− const int32_t kiBitsPerMb = WELS_DIV_ROUND(pWelsSvcRc->iTargetBits * INT_MULTIPLY, pWelsSvcRc->iNumberMbFrame);
528+ const int32_t kiBitsPerMb = WELS_DIV_ROUND (pWelsSvcRc->iTargetBits * INT_MULTIPLY, pWelsSvcRc->iNumberMbFrame);
520529
521530 for (int32_t i = 0; i < kiSliceNum; i++) {
522531 pSOverRc->iStartMbSlice =
@@ -524,7 +533,7 @@ void RcInitSliceInformation (sWelsEncCtx* pEncCtx) { · 1 unmodified line
524533 pSOverRc->iEndMbSlice += (pCurSliceCtx->pCountMbNumInSlice[i] - 1);
525534 pSOverRc->iTotalQpSlice = 0;
526535 pSOverRc->iTotalMbSlice = 0;
527− pSOverRc->iTargetBitsSlice = WELS_DIV_ROUND(kiBitsPerMb * pCurSliceCtx->pCountMbNumInSlice[i], INT_MULTIPLY);
536+ pSOverRc->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * pCurSliceCtx->pCountMbNumInSlice[i], INT_MULTIPLY);
528537 pSOverRc->iFrameBitsSlice = 0;
529538 pSOverRc->iGomBitsSlice = 0;
530539 ++ pSOverRc;
@@ -538,10 +547,10 @@ void RcDecideTargetBits (sWelsEncCtx* pEncCtx) { · 7 unmodified lines
538547 pWelsSvcRc->iCurrentBitsLevel = BITS_NORMAL;
539548 //allocate bits
540549 if (pEncCtx->eSliceType == I_SLICE) {
541− pWelsSvcRc->iTargetBits = WELS_DIV_ROUND(pWelsSvcRc->iBitsPerFrame * IDR_BITRATE_RATIO, INT_MULTIPLY);
550+ pWelsSvcRc->iTargetBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame * IDR_BITRATE_RATIO, INT_MULTIPLY);
542551 } else {
543− pWelsSvcRc->iTargetBits = (int32_t)((int64_t)pWelsSvcRc->iRemainingBits * pTOverRc->iTlayerWeight /
544− pWelsSvcRc->iRemainingWeights);
552+ pWelsSvcRc->iTargetBits = (int32_t) ((int64_t)pWelsSvcRc->iRemainingBits * pTOverRc->iTlayerWeight /
553+ pWelsSvcRc->iRemainingWeights);
545554 if ((pWelsSvcRc->iTargetBits <= 0) && (pEncCtx->pSvcParam->iRCMode == RC_LOW_BW_MODE)) {
546555 pWelsSvcRc->iCurrentBitsLevel = BITS_EXCEEDED;
547556 } else if ((pWelsSvcRc->iTargetBits <= pTOverRc->iMinBitsTl) && (pEncCtx->pSvcParam->iRCMode == RC_LOW_BW_MODE)) {
@@ -635,9 +644,10 @@ void RcGomTargetBits (sWelsEncCtx* pEncCtx, const int32_t kiSliceId) { · 87 unmodified lines
635644 iSumSad += pWelsSvcRc_Base->pCurrentFrameGomSad[i];
636645 }
637646 if (0 == iSumSad)
638− iAllocateBits = WELS_DIV_ROUND(iLeftBits, (iLastGomIndex - kiComplexityIndex));
647+ iAllocateBits = WELS_DIV_ROUND (iLeftBits, (iLastGomIndex - kiComplexityIndex));
639648 else
640− iAllocateBits = WELS_DIV_ROUND((int64_t)iLeftBits * pWelsSvcRc_Base->pCurrentFrameGomSad[kiComplexityIndex + 1], iSumSad);
649+ iAllocateBits = WELS_DIV_ROUND ((int64_t)iLeftBits * pWelsSvcRc_Base->pCurrentFrameGomSad[kiComplexityIndex + 1],
650+ iSumSad);
641651
642652 }
643653 pSOverRc->iGomTargetBits = iAllocateBits;
@@ -657,7 +667,7 @@ void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) { · 13 unmodified lines
657667 pSOverRc->iCalculatedQpSlice += 2;
658668 } else {
659669 //globe decision
660− iBitsRatio = 10000 * iLeftBits / (iTargetLeftBits+1);
670+ iBitsRatio = 10000 * iLeftBits / (iTargetLeftBits + 1);
661671 if (iBitsRatio < 8409) //2^(-1.5/6)*10000
662672 pSOverRc->iCalculatedQpSlice += 2;
663673 else if (iBitsRatio < 9439) //2^(-0.5/6)*10000
@@ -680,11 +690,11 @@ void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) { · 16 unmodified lines
680690 void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) {
681691 SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
682692 SRCTemporal* pTOverRc = pWelsSvcRc->pTemporalOverRc;
683− const int32_t kiOutputBits = WELS_DIV_ROUND(pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
693+ const int32_t kiOutputBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
684694 //condition 1: whole pBuffer fullness
685695 pWelsSvcRc->iBufferFullnessSkip += (pWelsSvcRc->iFrameDqBits - kiOutputBits);
686696 //condition 2: VGOP bits constraint
687− const int32_t kiVGopBits = WELS_DIV_ROUND(pWelsSvcRc->iBitsPerFrame * VGOP_SIZE, INT_MULTIPLY);
697+ const int32_t kiVGopBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame * VGOP_SIZE, INT_MULTIPLY);
688698 int32_t iVGopBitsPred = 0;
689699 for (int32_t i = pWelsSvcRc->iFrameCodedInVGop + 1; i < VGOP_SIZE; i++)
690700 iVGopBitsPred += pTOverRc[pWelsSvcRc->iTlOfFrames[i]].iMinBitsTl;
@@ -705,32 +715,32 @@ void RcVBufferCalculationSkip (sWelsEncCtx* pEncCtx) { · 14 unmodified lines
705715 pWelsSvcRc->iBufferFullnessSkip = 0;
706716
707717 if (pEncCtx->iSkipFrameFlag == 1) {
708− pWelsSvcRc->iRemainingBits += WELS_DIV_ROUND(pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
718+ pWelsSvcRc->iRemainingBits += WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
709719 pWelsSvcRc->iSkipFrameNum++;
710720 pWelsSvcRc->iSkipFrameInVGop++;
711721 }
712722 }
713723
714−void WelsRcFrameDelayJudge(void* pCtx) {
724+void WelsRcFrameDelayJudge (void* pCtx) {
715725 sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
716726 SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
717727 SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
718728 SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
719729
720− int32_t iSentBits = WELS_ROUND(pDLayerParam->iSpatialBitrate / pDLayerParamInternal->fOutputFrameRate);
730+ int32_t iSentBits = WELS_ROUND (pDLayerParam->iSpatialBitrate / pDLayerParamInternal->fOutputFrameRate);
721731
722732 pWelsSvcRc->bSkipFlag = false;
723733 if (pWelsSvcRc->iBufferFullnessSkip > pWelsSvcRc->iBufferSizeSkip) {
724734 pWelsSvcRc->bSkipFlag = true;
725735 pWelsSvcRc->iBufferFullnessSkip -= iSentBits;
726− pWelsSvcRc->iBufferFullnessSkip = WELS_MAX(pWelsSvcRc->iBufferFullnessSkip, 0);
736+ pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (pWelsSvcRc->iBufferFullnessSkip, 0);
727737 }
728738 }
729739
730740 void RcVBufferCalculationPadding (sWelsEncCtx* pEncCtx) {
731741 SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
732− const int32_t kiOutputBits = WELS_DIV_ROUND(pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
733− const int32_t kiBufferThreshold = WELS_DIV_ROUND(PADDING_THRESHOLD * (-pWelsSvcRc->iBufferSizePadding), INT_MULTIPLY);
742+ const int32_t kiOutputBits = WELS_DIV_ROUND (pWelsSvcRc->iBitsPerFrame, INT_MULTIPLY);
743+ const int32_t kiBufferThreshold = WELS_DIV_ROUND (PADDING_THRESHOLD * (-pWelsSvcRc->iBufferSizePadding), INT_MULTIPLY);
734744
735745 pWelsSvcRc->iBufferFullnessPadding += (pWelsSvcRc->iFrameDqBits - kiOutputBits);
736746
@@ -767,7 +777,7 @@ void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) { · 30 unmodified lines
767777 ++ pSOverRc;
768778 }
769779 if (iTotalMb > 0)
770− pWelsSvcRc->iAverageFrameQp = WELS_DIV_ROUND(INT_MULTIPLY * iTotalQp, iTotalMb * INT_MULTIPLY);
780+ pWelsSvcRc->iAverageFrameQp = WELS_DIV_ROUND (INT_MULTIPLY * iTotalQp, iTotalMb * INT_MULTIPLY);
771781 else
772782 pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp;
773783 } else {
@@ -779,11 +789,12 @@ void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) { · 5 unmodified lines
779789
780790 void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) {
781791 SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
782− int32_t iAlpha = WELS_DIV_ROUND(INT_MULTIPLY, (1 + pWelsSvcRc->iIdrNum));
783− if (iAlpha < (INT_MULTIPLY/4)) iAlpha = INT_MULTIPLY/4;
792+ int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pWelsSvcRc->iIdrNum));
793+ if (iAlpha < (INT_MULTIPLY / 4)) iAlpha = INT_MULTIPLY / 4;
784794
785795 int64_t iIntraCmplx = pWelsSvcRc->iQStep * pWelsSvcRc->iFrameDqBits;
786− pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND(((INT_MULTIPLY - iAlpha) * pWelsSvcRc->iIntraComplexity + iAlpha * iIntraCmplx), INT_MULTIPLY);
796+ pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pWelsSvcRc->iIntraComplexity + iAlpha *
797+ iIntraCmplx), INT_MULTIPLY);
787798 pWelsSvcRc->iIntraMbCount = pWelsSvcRc->iNumberMbFrame;
788799
789800 pWelsSvcRc->iIdrNum++;
@@ -799,14 +810,15 @@ void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) { · 9 unmodified lines
799810 if (0 == pTOverRc->iPFrameNum) {
800811 pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * pWelsSvcRc->iQStep;
801812 } else {
802− pTOverRc->iLinearCmplx = WELS_DIV_ROUND64((LINEAR_MODEL_DECAY_FACTOR * (int64_t)pTOverRc->iLinearCmplx
803− + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (int64_t)(pWelsSvcRc->iFrameDqBits * pWelsSvcRc->iQStep)), INT_MULTIPLY);
813+ pTOverRc->iLinearCmplx = WELS_DIV_ROUND64 ((LINEAR_MODEL_DECAY_FACTOR * (int64_t)pTOverRc->iLinearCmplx
814+ + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (int64_t) (pWelsSvcRc->iFrameDqBits * pWelsSvcRc->iQStep)),
815+ INT_MULTIPLY);
804816 }
805− int32_t iAlpha = WELS_DIV_ROUND(INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));
817+ int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));
806818 if (iAlpha < SMOOTH_FACTOR_MIN_VALUE)
807819 iAlpha = SMOOTH_FACTOR_MIN_VALUE;
808− pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND(((INT_MULTIPLY - iAlpha) * pTOverRc->iFrameCmplxMean + iAlpha *
809− pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity), INT_MULTIPLY);
820+ pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pTOverRc->iFrameCmplxMean + iAlpha *
821+ pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity), INT_MULTIPLY);
810822
811823 pTOverRc->iPFrameNum++;
812824 if (pTOverRc->iPFrameNum > 255)
@@ -951,8 +963,8 @@ void WelsRcPictureInitDisable (void* pCtx) { · 138 unmodified lines
951963 pEncCtx->iGlobalQp = RcCalculateCascadingQp (pEncCtx, kiQp);
952964
953965 if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) {
954− pEncCtx->iGlobalQp = WELS_CLIP3 ( (pEncCtx->iGlobalQp *INT_MULTIPLY -
955− pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp)/INT_MULTIPLY, GOM_MIN_QP_MODE, GOM_MAX_QP_MODE);
966+ pEncCtx->iGlobalQp = WELS_CLIP3 ((pEncCtx->iGlobalQp * INT_MULTIPLY -
967+ pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp) / INT_MULTIPLY, GOM_MIN_QP_MODE, GOM_MAX_QP_MODE);
956968 } else {
957969 pEncCtx->iGlobalQp = WELS_CLIP3 (pEncCtx->iGlobalQp, 0, 51);
958970 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t