History

use correct complexity for screen content mode

Karina committed 9 years ago

Commit 4e984ba1 parent 6ab98df2 files · +833 −821Browse files

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

Unified · Split

codec/encoder/core/src/ratectl.cpp+33−21
@@ -390,7 +390,11 @@ void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) { · 389 unmodified lines
390390 int32_t dInitialQPArray[4][4] = {{28, 26, 24, 22}, {30, 28, 26, 24}, {32, 30, 28, 26}, {34, 32, 30, 28}};
391391 int32_t iBppIndex = 0;
392392 int32_t iQpRangeArray[4][2] = {{37, 25}, {36, 24}, {35, 23}, {34, 22}};
393−
393+ int64_t iFrameComplexity = pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity;
394+ if (pEncCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
395+ SVAAFrameInfoExt* pVaa = static_cast<SVAAFrameInfoExt*> (pEncCtx->pVaa);
396+ iFrameComplexity = pVaa->sComplexityScreenParam.iFrameComplexity;
397+ }
394398 SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
395399 SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
396400 SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
@@ -427,13 +431,12 @@ void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) { · 30 unmodified lines
427431 pWelsSvcRc->iIntraMbCount;
428432 }
429433
430− int64_t iCmplxRatio = WELS_DIV_ROUND64 (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity * INT_MULTIPLY,
434+ int64_t iCmplxRatio = WELS_DIV_ROUND64 (iFrameComplexity * INT_MULTIPLY,
431435 pWelsSvcRc->iIntraComplxMean);
432436 iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);
433437 pWelsSvcRc->iQStep = WELS_DIV_ROUND ((pWelsSvcRc->iIntraComplexity * iCmplxRatio),
434438 (pWelsSvcRc->iTargetBits * INT_MULTIPLY));
435439 pWelsSvcRc->iInitialQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);
436−
437440 }
438441 pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, iMinQp, iMaxQp);
439442 pEncCtx->iGlobalQp = pWelsSvcRc->iInitialQp;
@@ -450,6 +453,11 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { · 10 unmodified lines
450453 SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl];
451454 int32_t iLumaQp = 0;
452455 int32_t iDeltaQpTemporal = 0;
456+ int64_t iFrameComplexity = pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity;
457+ if (pEncCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
458+ SVAAFrameInfoExt* pVaa = static_cast<SVAAFrameInfoExt*> (pEncCtx->pVaa);
459+ iFrameComplexity = pVaa->sComplexityScreenParam.iFrameComplexity;
460+ }
453461 if (0 == pTOverRc->iPFrameNum) {
454462 iLumaQp = pWelsSvcRc->iInitialQp;
455463 } else if (pWelsSvcRc->iCurrentBitsLevel == BITS_EXCEEDED) {
@@ -466,7 +474,7 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { · 10 unmodified lines
466474 iDeltaQpTemporal -= 1;
467475
468476 } else {
469− int64_t iCmplxRatio = WELS_DIV_ROUND64 (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity * INT_MULTIPLY,
477+ int64_t iCmplxRatio = WELS_DIV_ROUND64 (iFrameComplexity * INT_MULTIPLY,
470478 pTOverRc->iFrameCmplxMean);
471479 iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);
472480
@@ -1039,9 +1047,14 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) { · 566 unmodified lines
10391047 if (iAlpha < (INT_MULTIPLY / 4)) iAlpha = INT_MULTIPLY / 4;
10401048 int32_t iQStep = RcConvertQp2QStep (pWelsSvcRc->iAverageFrameQp);
10411049 int64_t iIntraCmplx = iQStep * static_cast<int64_t> (pWelsSvcRc->iFrameDqBits);
1050+ int64_t iFrameComplexity = pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity;
1051+ if (pEncCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
1052+ SVAAFrameInfoExt* pVaa = static_cast<SVAAFrameInfoExt*> (pEncCtx->pVaa);
1053+ iFrameComplexity = pVaa->sComplexityScreenParam.iFrameComplexity;
1054+ }
10421055 if (pWelsSvcRc->iIdrNum == 0) {
10431056 pWelsSvcRc->iIntraComplexity = iIntraCmplx;
1044− pWelsSvcRc->iIntraComplxMean = pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity;
1057+ pWelsSvcRc->iIntraComplxMean = iFrameComplexity;
10451058 } else {
10461059 pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * pWelsSvcRc->iIntraComplexity +
10471060 (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) *
@@ -1050,7 +1063,7 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) { · 2 unmodified lines
10501063
10511064 pWelsSvcRc->iIntraComplxMean = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * static_cast<int64_t>
10521065 (pWelsSvcRc->iIntraComplxMean)
1053− + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity)),
1066+ + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (iFrameComplexity)),
10541067 INT_MULTIPLY);
10551068 }
10561069
@@ -1069,20 +1082,25 @@ void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) { · 12 unmodified lines
10691082 const int32_t kiTl = pEncCtx->uiTemporalId;
10701083 SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[kiTl];
10711084
1085+ int64_t iFrameComplexity = pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity;
1086+ if (pEncCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
1087+ SVAAFrameInfoExt* pVaa = static_cast<SVAAFrameInfoExt*> (pEncCtx->pVaa);
1088+ iFrameComplexity = pVaa->sComplexityScreenParam.iFrameComplexity;
1089+ }
10721090 int32_t iQStep = RcConvertQp2QStep (pWelsSvcRc->iAverageFrameQp);
10731091 int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));
10741092 if (iAlpha < SMOOTH_FACTOR_MIN_VALUE)
10751093 iAlpha = SMOOTH_FACTOR_MIN_VALUE;
10761094 if (0 == pTOverRc->iPFrameNum) {
10771095 pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * iQStep;
1078− pTOverRc->iFrameCmplxMean = (int32_t)pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity;
1096+ pTOverRc->iFrameCmplxMean = (int32_t)iFrameComplexity;
10791097 } else {
10801098 pTOverRc->iLinearCmplx = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * (int64_t)pTOverRc->iLinearCmplx
10811099 + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * ((int64_t)pWelsSvcRc->iFrameDqBits * iQStep)),
10821100 INT_MULTIPLY);
10831101 pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * static_cast<int64_t>
10841102 (pTOverRc->iFrameCmplxMean)
1085− + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity),
1103+ + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * iFrameComplexity),
10861104 INT_MULTIPLY);
10871105 }
10881106
@@ -1094,8 +1112,8 @@ void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) { · 5 unmodified lines
10941112 "RcUpdateFrameComplexity iFrameDqBits = %d,iQStep= %d,pWelsSvcRc->iQStep= %d,pTOverRc->iLinearCmplx = %" PRId64,
10951113 pWelsSvcRc->iFrameDqBits,
10961114 iQStep, pWelsSvcRc->iQStep, pTOverRc->iLinearCmplx);
1097− WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "iFrameCmplxMean = %" PRId64 ",iFrameComplexity = %lld",
1098− pTOverRc->iFrameCmplxMean, pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity);
1115+ WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "iFrameCmplxMean = %" PRId64 ",iFrameComplexity = %" PRId64 ,
1116+ pTOverRc->iFrameCmplxMean, iFrameComplexity);
10991117 }
11001118
11011119 int32_t RcCalculateCascadingQp (struct TagWelsEncCtx* pEncCtx, int32_t iQp) {
@@ -1480,18 +1498,12 @@ void WelsRcInitFuncPointers (sWelsEncCtx* pEncCtx, RC_MODES iRcMode) { · 378 unmodified lines
14801498 pRcf->pfWelsRcPostFrameSkipping = WelsRcPostFrameSkipping;
14811499 break;
14821500 case RC_TIMESTAMP_MODE:
1483− if (pEncCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
1484− pRcf->pfWelsRcPictureInit = WelRcPictureInitScc;
1485− pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateScc;
1486− pRcf->pfWelsRcMbInit = WelsRcMbInitScc;
1487− pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateDisable;
14881501
1489− } else {
1490− pRcf->pfWelsRcPictureInit = WelsRcPictureInitGom;
1491− pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateGomTimeStamp;
1492− pRcf->pfWelsRcMbInit = WelsRcMbInitGom;
1493− pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateGom;
1494− }
1502+ pRcf->pfWelsRcPictureInit = WelsRcPictureInitGom;
1503+ pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateGomTimeStamp;
1504+ pRcf->pfWelsRcMbInit = WelsRcMbInitGom;
1505+ pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateGom;
1506+
14951507 pRcf->pfWelsRcPicDelayJudge = WelsRcFrameDelayJudgeTimeStamp;
14961508 pRcf->pfWelsCheckSkipBasedMaxbr = NULL;
14971509 pRcf->pfWelsUpdateBufferWhenSkip = NULL;

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