History

refine RC parameters

karina li committed 11 years ago

Commit ab370cd1 parent 3c067536 files · +6966 −6964Browse files

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

Unified · Split

codec/encoder/core/src/ratectl.cpp+37−35
@@ -343,11 +343,11 @@ void RcTraceVGopBitrate (sWelsEncCtx* pEncCtx) { · 342 unmodified lines
343 int32_t iFrameInVGop = pWelsSvcRc->iFrameCodedInVGop + pWelsSvcRc->iSkipFrameInVGop;343 int32_t iFrameInVGop = pWelsSvcRc->iFrameCodedInVGop + pWelsSvcRc->iSkipFrameInVGop;
344 if (0 != iFrameInVGop)344 if (0 != iFrameInVGop)
345 iVGopBitrate = WELS_ROUND (iTotalBits / iFrameInVGop * pWelsSvcRc->fFrameRate);345 iVGopBitrate = WELS_ROUND (iTotalBits / iFrameInVGop * pWelsSvcRc->fFrameRate);
346 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "[Rc] VGOPbitrate%d: %d ", kiDid, iVGopBitrate);346 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] VGOPbitrate%d: %d ", kiDid, iVGopBitrate);
347 if (iTotalBits > 0) {347 if (iTotalBits > 0) {
348 iTid = 0;348 iTid = 0;
349 while (iTid <= kiHighestTid) {349 while (iTid <= kiHighestTid) {
350 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "T%d=%8.3f ", iTid, (double) (pTOverRc[iTid].iGopBitsDq / iTotalBits));350 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "T%d=%8.3f ", iTid, (double) (pTOverRc[iTid].iGopBitsDq / iTotalBits));
351 ++ iTid;351 ++ iTid;
352 }352 }
353 }353 }
@@ -625,7 +625,6 @@ void RcGomTargetBits (sWelsEncCtx* pEncCtx, const int32_t kiSliceId) { · 271 unmodified lines
625 625
626 iLastGomIndex = pSOverRc->iEndMbSlice / pWelsSvcRc->iNumberMbGom;626 iLastGomIndex = pSOverRc->iEndMbSlice / pWelsSvcRc->iNumberMbGom;
627 iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice;627 iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice;
628
629 if (iLeftBits <= 0) {628 if (iLeftBits <= 0) {
630 pSOverRc->iGomTargetBits = 0;629 pSOverRc->iGomTargetBits = 0;
631 return;630 return;
@@ -671,9 +670,8 @@ void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) { · 39 unmodified lines
671 else if (iBitsRatio > 11900) //2^(1.5/6)*10000670 else if (iBitsRatio > 11900) //2^(1.5/6)*10000
672 pSOverRc->iCalculatedQpSlice -= 2;671 pSOverRc->iCalculatedQpSlice -= 2;
673 }672 }
673 pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
674 674
675 pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice,
676 pEncCtx->iGlobalQp - pWelsSvcRc->iQpRangeLowerInFrame, pEncCtx->iGlobalQp + pWelsSvcRc->iQpRangeUpperInFrame);
677 if (! (((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE) || (pEncCtx->pSvcParam->iRCMode == RC_TIMESTAMP_MODE))675 if (! (((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE) || (pEncCtx->pSvcParam->iRCMode == RC_TIMESTAMP_MODE))
678 && (pEncCtx->pSvcParam->bEnableFrameSkip == false)))676 && (pEncCtx->pSvcParam->bEnableFrameSkip == false)))
679 pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);677 pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
@@ -790,8 +788,10 @@ bool CheckFrameSkipBasedMaxbr (sWelsEncCtx* pEncCtx, int32_t iSpatialNum, EVideo · 110 unmodified lines
790 pEncCtx->iContinualSkipFrames++;788 pEncCtx->iContinualSkipFrames++;
791 break;789 break;
792 }790 }
793 791 }
794 792 if (bSkipMustFlag) {
793 for (int32_t i = 0; i < iSpatialNum; i++)
794 pEncCtx->pWelsSvcRc[i].uiLastTimeStamp = uiTimeStamp;
795 }795 }
796 return bSkipMustFlag;796 return bSkipMustFlag;
797}797}
@@ -819,7 +819,7 @@ void UpdateBufferWhenFrameSkipped (sWelsEncCtx* pEncCtx, int32_t iSpatialNum) { · 21 unmodified lines
819 819
820 }820 }
821 pEncCtx->iContinualSkipFrames++;821 pEncCtx->iContinualSkipFrames++;
822 if ( ( pEncCtx->iContinualSkipFrames % 3 ) == 0 ) {822 if ((pEncCtx->iContinualSkipFrames % 3) == 0) {
823 //output a warning when iContinualSkipFrames is large enough, which may indicate subjective quality problem823 //output a warning when iContinualSkipFrames is large enough, which may indicate subjective quality problem
824 //note that here iContinualSkipFrames must be >0, so the log output will be 3/6/....824 //note that here iContinualSkipFrames must be >0, so the log output will be 3/6/....
825 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_WARNING, "[Rc] iContinualSkipFrames(%d) is large",825 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_WARNING, "[Rc] iContinualSkipFrames(%d) is large",
@@ -916,7 +916,8 @@ void RcTraceFrameBits (sWelsEncCtx* pEncCtx, long long uiTimeStamp) { · 90 unmodified lines
916 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,916 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
917 "[Rc]Layer %d: Frame timestamp = %lld, Frame type = %d, encoding_qp = %d, average qp = %d, max qp = %d, min qp = %d, index = %d, "917 "[Rc]Layer %d: Frame timestamp = %lld, Frame type = %d, encoding_qp = %d, average qp = %d, max qp = %d, min qp = %d, index = %d, "
918 "iTid = %d, used = %d, bitsperframe = %d, target = %d, remainingbits = %d, skipbuffersize = %d",918 "iTid = %d, used = %d, bitsperframe = %d, target = %d, remainingbits = %d, skipbuffersize = %d",
919 pEncCtx->uiDependencyId, uiTimeStamp, pEncCtx->eSliceType, pEncCtx->iGlobalQp, pWelsSvcRc->iAverageFrameQp, pWelsSvcRc->iMaxFrameQp,919 pEncCtx->uiDependencyId, uiTimeStamp, pEncCtx->eSliceType, pEncCtx->iGlobalQp, pWelsSvcRc->iAverageFrameQp,
920 pWelsSvcRc->iMaxFrameQp,
920 pWelsSvcRc->iMinFrameQp,921 pWelsSvcRc->iMinFrameQp,
921 pEncCtx->iFrameIndex, pEncCtx->uiTemporalId, pWelsSvcRc->iFrameDqBits, pWelsSvcRc->iBitsPerFrame,922 pEncCtx->iFrameIndex, pEncCtx->uiTemporalId, pWelsSvcRc->iFrameDqBits, pWelsSvcRc->iBitsPerFrame,
922 pWelsSvcRc->iTargetBits, pWelsSvcRc->iRemainingBits, pWelsSvcRc->iBufferSizeSkip);923 pWelsSvcRc->iTargetBits, pWelsSvcRc->iRemainingBits, pWelsSvcRc->iBufferSizeSkip);
@@ -944,6 +945,7 @@ void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) { · 21 unmodified lines
944 pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp;945 pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp;
945 }946 }
946 pWelsSvcRc->iFrameDqBits = iCodedBits;947 pWelsSvcRc->iFrameDqBits = iCodedBits;
948 pWelsSvcRc->iLastCalculatedQScale = pWelsSvcRc->iAverageFrameQp;
947 pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId].iGopBitsDq += pWelsSvcRc->iFrameDqBits;949 pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId].iGopBitsDq += pWelsSvcRc->iFrameDqBits;
948}950}
949 951
@@ -951,8 +953,8 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) { · 1 unmodified line
951 SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];953 SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
952 int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pWelsSvcRc->iIdrNum));954 int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pWelsSvcRc->iIdrNum));
953 if (iAlpha < (INT_MULTIPLY / 4)) iAlpha = INT_MULTIPLY / 4;955 if (iAlpha < (INT_MULTIPLY / 4)) iAlpha = INT_MULTIPLY / 4;
954 956 int32_t iQStep = RcConvertQp2QStep (pWelsSvcRc->iAverageFrameQp);
955 int64_t iIntraCmplx = pWelsSvcRc->iQStep * static_cast<int64_t> (pWelsSvcRc->iFrameDqBits);957 int64_t iIntraCmplx = iQStep * static_cast<int64_t> (pWelsSvcRc->iFrameDqBits);
956 pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pWelsSvcRc->iIntraComplexity + iAlpha *958 pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pWelsSvcRc->iIntraComplexity + iAlpha *
957 iIntraCmplx), INT_MULTIPLY);959 iIntraCmplx), INT_MULTIPLY);
958 pWelsSvcRc->iIntraMbCount = pWelsSvcRc->iNumberMbFrame;960 pWelsSvcRc->iIntraMbCount = pWelsSvcRc->iNumberMbFrame;
@@ -960,9 +962,10 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) { · 1 unmodified line
960 pWelsSvcRc->iIdrNum++;962 pWelsSvcRc->iIdrNum++;
961 if (pWelsSvcRc->iIdrNum > 255)963 if (pWelsSvcRc->iIdrNum > 255)
962 pWelsSvcRc->iIdrNum = 255;964 pWelsSvcRc->iIdrNum = 255;
963 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO,965 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
964 "RcUpdateIntraComplexity iFrameDqBits = %d,iQStep= %d,iIntraCmplx = %" PRId64,966 "RcUpdateIntraComplexity iFrameDqBits = %d,iQStep= %d,iIntraCmplx = %" PRId64,
965 pWelsSvcRc->iFrameDqBits, pWelsSvcRc->iQStep, pWelsSvcRc->iIntraComplexity);967 pWelsSvcRc->iFrameDqBits, pWelsSvcRc->iQStep, pWelsSvcRc->iIntraComplexity);
968
966}969}
967 970
968void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) {971void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) {
@@ -970,26 +973,32 @@ void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) { · 1 unmodified line
970 const int32_t kiTl = pEncCtx->uiTemporalId;973 const int32_t kiTl = pEncCtx->uiTemporalId;
971 SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[kiTl];974 SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[kiTl];
972 975
976 int32_t iQStep = RcConvertQp2QStep (pWelsSvcRc->iAverageFrameQp);
973 if (0 == pTOverRc->iPFrameNum) {977 if (0 == pTOverRc->iPFrameNum) {
974 pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * pWelsSvcRc->iQStep;978 pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * iQStep;
975 } else {979 } else {
976 pTOverRc->iLinearCmplx = WELS_DIV_ROUND64 ((LINEAR_MODEL_DECAY_FACTOR * (int64_t)pTOverRc->iLinearCmplx980 pTOverRc->iLinearCmplx = WELS_DIV_ROUND64 ((LINEAR_MODEL_DECAY_FACTOR * (int64_t)pTOverRc->iLinearCmplx
977 + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (int64_t) (pWelsSvcRc->iFrameDqBits * pWelsSvcRc->iQStep)),981 + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (int64_t) (pWelsSvcRc->iFrameDqBits * iQStep)),
978 INT_MULTIPLY);982 INT_MULTIPLY);
979 }983 }
980 int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));984 int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));
981 if (iAlpha < SMOOTH_FACTOR_MIN_VALUE)985 if (iAlpha < SMOOTH_FACTOR_MIN_VALUE)
982 iAlpha = SMOOTH_FACTOR_MIN_VALUE;986 iAlpha = SMOOTH_FACTOR_MIN_VALUE;
983 pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * static_cast<int64_t> (pTOverRc->iFrameCmplxMean)987 pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND ((LINEAR_MODEL_DECAY_FACTOR * static_cast<int64_t>
984 + iAlpha * pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity),988 (pTOverRc->iFrameCmplxMean)
989 + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity),
985 INT_MULTIPLY);990 INT_MULTIPLY);
986 991
992
987 pTOverRc->iPFrameNum++;993 pTOverRc->iPFrameNum++;
988 if (pTOverRc->iPFrameNum > 255)994 if (pTOverRc->iPFrameNum > 255)
989 pTOverRc->iPFrameNum = 255;995 pTOverRc->iPFrameNum = 255;
990 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,996 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
991 "RcUpdateFrameComplexity iFrameDqBits = %d,iQStep= %d,pTOverRc->iLinearCmplx = %" PRId64, pWelsSvcRc->iFrameDqBits,997 "RcUpdateFrameComplexity iFrameDqBits = %d,iQStep= %d,pWelsSvcRc->iQStep= %d,pTOverRc->iLinearCmplx = %" PRId64,
992 pWelsSvcRc->iQStep, pTOverRc->iLinearCmplx);998 pWelsSvcRc->iFrameDqBits,
999 iQStep, pWelsSvcRc->iQStep, pTOverRc->iLinearCmplx);
1000 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "iFrameCmplxMean = %d,iFrameComplexity = %lld",
1001 pTOverRc->iFrameCmplxMean, pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity);
993}1002}
994 1003
995int32_t RcCalculateCascadingQp (struct TagWelsEncCtx* pEncCtx, int32_t iQp) {1004int32_t RcCalculateCascadingQp (struct TagWelsEncCtx* pEncCtx, int32_t iQp) {
@@ -1115,7 +1124,8 @@ void WelsRcPictureInitDisable (sWelsEncCtx* pEncCtx, long long uiTimeStamp) { · 119 unmodified lines
1115 1124
1116 if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) {1125 if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) {
1117 pEncCtx->iGlobalQp = WELS_CLIP3 ((pEncCtx->iGlobalQp * INT_MULTIPLY -1126 pEncCtx->iGlobalQp = WELS_CLIP3 ((pEncCtx->iGlobalQp * INT_MULTIPLY -
1118 pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp) / INT_MULTIPLY, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);1127 pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp) / INT_MULTIPLY, pWelsSvcRc->iMinQp,
1128 pWelsSvcRc->iMaxQp);
1119 } else {1129 } else {
1120 pEncCtx->iGlobalQp = WELS_CLIP3 (pEncCtx->iGlobalQp, 0, 51);1130 pEncCtx->iGlobalQp = WELS_CLIP3 (pEncCtx->iGlobalQp, 0, 51);
1121 }1131 }
@@ -1231,7 +1241,7 @@ void WelsRcDropFrameUpdate (sWelsEncCtx* pEncCtx, uint32_t iDropSize) { · 109 unmodified lines
1231 1241
1232 pWelsSvcRc->iBufferFullnessSkip -= (int32_t)iDropSize;1242 pWelsSvcRc->iBufferFullnessSkip -= (int32_t)iDropSize;
1233 pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (0, pWelsSvcRc->iBufferFullnessSkip);1243 pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (0, pWelsSvcRc->iBufferFullnessSkip);
1234 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "[WelsRcDropFrameUpdate:\tdrop:%d\t%" PRId64 "\n", iDropSize,1244 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "[WelsRcDropFrameUpdate:\tdrop:%d\t%" PRId64 "\n", iDropSize,
1235 pWelsSvcRc->iBufferFullnessSkip);1245 pWelsSvcRc->iBufferFullnessSkip);
1236}1246}
1237 1247
@@ -1266,8 +1276,8 @@ void InitRcModuleTimeStamp (sWelsEncCtx* pEncCtx) { · 28 unmodified lines
1266 pWelsSvcRc->iBufferFullnessSkip = 0;1276 pWelsSvcRc->iBufferFullnessSkip = 0;
1267 pWelsSvcRc->uiLastTimeStamp = 0;1277 pWelsSvcRc->uiLastTimeStamp = 0;
1268 1278
1269 pWelsSvcRc->iCost2BitsIntra = INT_MULTIPLY;1279 pWelsSvcRc->iCost2BitsIntra = 1;
1270 pWelsSvcRc->iAvgCost2Bits = INT_MULTIPLY;1280 pWelsSvcRc->iAvgCost2Bits = 1;
1271 pWelsSvcRc->iSkipBufferRatio = SKIP_RATIO;1281 pWelsSvcRc->iSkipBufferRatio = SKIP_RATIO;
1272}1282}
1273void WelsRcFrameDelayJudgeTimeStamp (sWelsEncCtx* pEncCtx, EVideoFrameType eFrameType, long long uiTimeStamp) {1283void WelsRcFrameDelayJudgeTimeStamp (sWelsEncCtx* pEncCtx, EVideoFrameType eFrameType, long long uiTimeStamp) {
@@ -1314,21 +1324,15 @@ void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp · 40 unmodified lines
1314 if (pEncCtx->eSliceType == I_SLICE) {1324 if (pEncCtx->eSliceType == I_SLICE) {
1315 if (0 == pWelsSvcRc->iIdrNum) { //iIdrNum == 0 means encoder has been initialed1325 if (0 == pWelsSvcRc->iIdrNum) { //iIdrNum == 0 means encoder has been initialed
1316 RcInitRefreshParameter (pEncCtx);1326 RcInitRefreshParameter (pEncCtx);
1317 double dBpp = 0.05;1327 RcInitIdrQp (pEncCtx);
1318 if ((pDLayerParam->fFrameRate > EPSN) && (pDLayerParam->iVideoWidth && pDLayerParam->iVideoHeight))
1319 dBpp = (double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParam->fFrameRate * pDLayerParam->iVideoWidth *
1320 pDLayerParam->iVideoHeight);
1321 pWelsSvcRc->iInitialQp = (int32_t) (50 - dBpp * 10 * 4);
1322 pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
1323
1324 iLumaQp = pWelsSvcRc->iInitialQp;1328 iLumaQp = pWelsSvcRc->iInitialQp;
1325 pWelsSvcRc->iTargetBits = static_cast<int32_t> (((double) (pDLayerParam->iSpatialBitrate) / (double) (1329 pWelsSvcRc->iTargetBits = static_cast<int32_t> (((double) (pDLayerParam->iSpatialBitrate) / (double) (
1326 pDLayerParam->fFrameRate) *1330 pDLayerParam->fFrameRate) *
1327 IDR_BITRATE_RATIO));1331 IDR_BITRATE_RATIO));
1328 1332
1329 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,1333 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
1330 "[Rc] First IDR iSpatialBitrate = %d,iBufferFullnessSkip = %" PRId64 ",iTargetBits= %d,dBpp = %f,initQp = %d",1334 "[Rc] First IDR iSpatialBitrate = %d,iBufferFullnessSkip = %" PRId64 ",iTargetBits= %d,initQp = %d",
1331 pDLayerParam->iSpatialBitrate, pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iTargetBits, dBpp,1335 pDLayerParam->iSpatialBitrate, pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iTargetBits,
1332 pWelsSvcRc->iInitialQp);1336 pWelsSvcRc->iInitialQp);
1333 1337
1334 } else {1338 } else {
@@ -1340,8 +1344,7 @@ void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp · 5 unmodified lines
1340 if (iMaxTh > 0) {1344 if (iMaxTh > 0) {
1341 pWelsSvcRc->iTargetBits = WELS_CLIP3 (pWelsSvcRc->iTargetBits, iMinTh, iMaxTh);1345 pWelsSvcRc->iTargetBits = WELS_CLIP3 (pWelsSvcRc->iTargetBits, iMinTh, iMaxTh);
1342 1346
1343 pWelsSvcRc->iQStep = WELS_DIV_ROUND ((((int64_t)pWelsSvcRc->iIntraComplexity) *1347 pWelsSvcRc->iQStep = WELS_DIV_ROUND (pWelsSvcRc->iIntraComplexity, pWelsSvcRc->iTargetBits);
1344 pWelsSvcRc->iCost2BitsIntra), pWelsSvcRc->iTargetBits);
1345 iLumaQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);1348 iLumaQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);
1346 1349
1347 iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iLastCalculatedQScale - DELTA_QP_BGD_THD,1350 iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iLastCalculatedQScale - DELTA_QP_BGD_THD,
@@ -1373,12 +1376,11 @@ void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp · 25 unmodified lines
1373 pTOverRc->iFrameCmplxMean);1376 pTOverRc->iFrameCmplxMean);
1374 iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);1377 iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);
1375 1378
1376
1377 pWelsSvcRc->iTargetBits = WELS_DIV_ROUND (pTOverRc->iTlayerWeight * kiGopBits, INT_MULTIPLY * 10 * 2);1379 pWelsSvcRc->iTargetBits = WELS_DIV_ROUND (pTOverRc->iTlayerWeight * kiGopBits, INT_MULTIPLY * 10 * 2);
1378 if (iMaxTh > 0) {1380 if (iMaxTh > 0) {
1379 pWelsSvcRc->iTargetBits = WELS_CLIP3 (pWelsSvcRc->iTargetBits, iMinTh, iMaxTh);1381 pWelsSvcRc->iTargetBits = WELS_CLIP3 (pWelsSvcRc->iTargetBits, iMinTh, iMaxTh);
1380 if (0 == pTOverRc->iPFrameNum)1382 if (0 == pTOverRc->iPFrameNum)
1381 iLumaQp = pWelsSvcRc->iInitialQp;1383 iLumaQp = pWelsSvcRc->iInitialQp + DELTA_QP_BGD_THD;
1382 else {1384 else {
1383 1385
1384 pWelsSvcRc->iQStep = WELS_DIV_ROUND ((pTOverRc->iLinearCmplx * iCmplxRatio), (pWelsSvcRc->iTargetBits * INT_MULTIPLY));1386 pWelsSvcRc->iQStep = WELS_DIV_ROUND ((pTOverRc->iLinearCmplx * iCmplxRatio), (pWelsSvcRc->iTargetBits * INT_MULTIPLY));

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