History

using WelsRound for all the double-int32_t conversion

Sijia Chen committed 12 years ago

Commit 74130321 parent cc8102010 files · +67 −65Browse files

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

Unified · Split

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

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