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
390 int32_t dInitialQPArray[4][4] = {{28, 26, 24, 22}, {30, 28, 26, 24}, {32, 30, 28, 26}, {34, 32, 30, 28}};390 int32_t dInitialQPArray[4][4] = {{28, 26, 24, 22}, {30, 28, 26, 24}, {32, 30, 28, 26}, {34, 32, 30, 28}};
391 int32_t iBppIndex = 0;391 int32_t iBppIndex = 0;
392 int32_t iQpRangeArray[4][2] = {{37, 25}, {36, 24}, {35, 23}, {34, 22}};392 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 }
394 SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];398 SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
395 SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];399 SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
396 SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];400 SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
@@ -427,13 +431,12 @@ void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) { · 30 unmodified lines
427 pWelsSvcRc->iIntraMbCount;431 pWelsSvcRc->iIntraMbCount;
428 }432 }
429 433
430 int64_t iCmplxRatio = WELS_DIV_ROUND64 (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity * INT_MULTIPLY,434 int64_t iCmplxRatio = WELS_DIV_ROUND64 (iFrameComplexity * INT_MULTIPLY,
431 pWelsSvcRc->iIntraComplxMean);435 pWelsSvcRc->iIntraComplxMean);
432 iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);436 iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);
433 pWelsSvcRc->iQStep = WELS_DIV_ROUND ((pWelsSvcRc->iIntraComplexity * iCmplxRatio),437 pWelsSvcRc->iQStep = WELS_DIV_ROUND ((pWelsSvcRc->iIntraComplexity * iCmplxRatio),
434 (pWelsSvcRc->iTargetBits * INT_MULTIPLY));438 (pWelsSvcRc->iTargetBits * INT_MULTIPLY));
435 pWelsSvcRc->iInitialQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);439 pWelsSvcRc->iInitialQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);
436
437 }440 }
438 pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, iMinQp, iMaxQp);441 pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, iMinQp, iMaxQp);
439 pEncCtx->iGlobalQp = pWelsSvcRc->iInitialQp;442 pEncCtx->iGlobalQp = pWelsSvcRc->iInitialQp;
@@ -450,6 +453,11 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { · 10 unmodified lines
450 SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl];453 SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl];
451 int32_t iLumaQp = 0;454 int32_t iLumaQp = 0;
452 int32_t iDeltaQpTemporal = 0;455 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 }
453 if (0 == pTOverRc->iPFrameNum) {461 if (0 == pTOverRc->iPFrameNum) {
454 iLumaQp = pWelsSvcRc->iInitialQp;462 iLumaQp = pWelsSvcRc->iInitialQp;
455 } else if (pWelsSvcRc->iCurrentBitsLevel == BITS_EXCEEDED) {463 } else if (pWelsSvcRc->iCurrentBitsLevel == BITS_EXCEEDED) {
@@ -466,7 +474,7 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { · 10 unmodified lines
466 iDeltaQpTemporal -= 1;474 iDeltaQpTemporal -= 1;
467 475
468 } else {476 } else {
469 int64_t iCmplxRatio = WELS_DIV_ROUND64 (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity * INT_MULTIPLY,477 int64_t iCmplxRatio = WELS_DIV_ROUND64 (iFrameComplexity * INT_MULTIPLY,
470 pTOverRc->iFrameCmplxMean);478 pTOverRc->iFrameCmplxMean);
471 iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);479 iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);
472 480
@@ -1039,9 +1047,14 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) { · 566 unmodified lines
1039 if (iAlpha < (INT_MULTIPLY / 4)) iAlpha = INT_MULTIPLY / 4;1047 if (iAlpha < (INT_MULTIPLY / 4)) iAlpha = INT_MULTIPLY / 4;
1040 int32_t iQStep = RcConvertQp2QStep (pWelsSvcRc->iAverageFrameQp);1048 int32_t iQStep = RcConvertQp2QStep (pWelsSvcRc->iAverageFrameQp);
1041 int64_t iIntraCmplx = iQStep * static_cast<int64_t> (pWelsSvcRc->iFrameDqBits);1049 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 }
1042 if (pWelsSvcRc->iIdrNum == 0) {1055 if (pWelsSvcRc->iIdrNum == 0) {
1043 pWelsSvcRc->iIntraComplexity = iIntraCmplx;1056 pWelsSvcRc->iIntraComplexity = iIntraCmplx;
1044 pWelsSvcRc->iIntraComplxMean = pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity;1057 pWelsSvcRc->iIntraComplxMean = iFrameComplexity;
1045 } else {1058 } else {
1046 pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * pWelsSvcRc->iIntraComplexity +1059 pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * pWelsSvcRc->iIntraComplexity +
1047 (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) *1060 (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) *
@@ -1050,7 +1063,7 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) { · 2 unmodified lines
1050 1063
1051 pWelsSvcRc->iIntraComplxMean = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * static_cast<int64_t>1064 pWelsSvcRc->iIntraComplxMean = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * static_cast<int64_t>
1052 (pWelsSvcRc->iIntraComplxMean)1065 (pWelsSvcRc->iIntraComplxMean)
1053 + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity)),1066 + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (iFrameComplexity)),
1054 INT_MULTIPLY);1067 INT_MULTIPLY);
1055 }1068 }
1056 1069
@@ -1069,20 +1082,25 @@ void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) { · 12 unmodified lines
1069 const int32_t kiTl = pEncCtx->uiTemporalId;1082 const int32_t kiTl = pEncCtx->uiTemporalId;
1070 SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[kiTl];1083 SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[kiTl];
1071 1084
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 }
1072 int32_t iQStep = RcConvertQp2QStep (pWelsSvcRc->iAverageFrameQp);1090 int32_t iQStep = RcConvertQp2QStep (pWelsSvcRc->iAverageFrameQp);
1073 int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));1091 int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));
1074 if (iAlpha < SMOOTH_FACTOR_MIN_VALUE)1092 if (iAlpha < SMOOTH_FACTOR_MIN_VALUE)
1075 iAlpha = SMOOTH_FACTOR_MIN_VALUE;1093 iAlpha = SMOOTH_FACTOR_MIN_VALUE;
1076 if (0 == pTOverRc->iPFrameNum) {1094 if (0 == pTOverRc->iPFrameNum) {
1077 pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * iQStep;1095 pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * iQStep;
1078 pTOverRc->iFrameCmplxMean = (int32_t)pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity;1096 pTOverRc->iFrameCmplxMean = (int32_t)iFrameComplexity;
1079 } else {1097 } else {
1080 pTOverRc->iLinearCmplx = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * (int64_t)pTOverRc->iLinearCmplx1098 pTOverRc->iLinearCmplx = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * (int64_t)pTOverRc->iLinearCmplx
1081 + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * ((int64_t)pWelsSvcRc->iFrameDqBits * iQStep)),1099 + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * ((int64_t)pWelsSvcRc->iFrameDqBits * iQStep)),
1082 INT_MULTIPLY);1100 INT_MULTIPLY);
1083 pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * static_cast<int64_t>1101 pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * static_cast<int64_t>
1084 (pTOverRc->iFrameCmplxMean)1102 (pTOverRc->iFrameCmplxMean)
1085 + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity),1103 + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * iFrameComplexity),
1086 INT_MULTIPLY);1104 INT_MULTIPLY);
1087 }1105 }
1088 1106
@@ -1094,8 +1112,8 @@ void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) { · 5 unmodified lines
1094 "RcUpdateFrameComplexity iFrameDqBits = %d,iQStep= %d,pWelsSvcRc->iQStep= %d,pTOverRc->iLinearCmplx = %" PRId64,1112 "RcUpdateFrameComplexity iFrameDqBits = %d,iQStep= %d,pWelsSvcRc->iQStep= %d,pTOverRc->iLinearCmplx = %" PRId64,
1095 pWelsSvcRc->iFrameDqBits,1113 pWelsSvcRc->iFrameDqBits,
1096 iQStep, pWelsSvcRc->iQStep, pTOverRc->iLinearCmplx);1114 iQStep, pWelsSvcRc->iQStep, pTOverRc->iLinearCmplx);
1097 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "iFrameCmplxMean = %" PRId64 ",iFrameComplexity = %lld",1115 WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "iFrameCmplxMean = %" PRId64 ",iFrameComplexity = %" PRId64 ,
1098 pTOverRc->iFrameCmplxMean, pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity);1116 pTOverRc->iFrameCmplxMean, iFrameComplexity);
1099}1117}
1100 1118
1101int32_t RcCalculateCascadingQp (struct TagWelsEncCtx* pEncCtx, int32_t iQp) {1119int32_t RcCalculateCascadingQp (struct TagWelsEncCtx* pEncCtx, int32_t iQp) {
@@ -1480,18 +1498,12 @@ void WelsRcInitFuncPointers (sWelsEncCtx* pEncCtx, RC_MODES iRcMode) { · 378 unmodified lines
1480 pRcf->pfWelsRcPostFrameSkipping = WelsRcPostFrameSkipping;1498 pRcf->pfWelsRcPostFrameSkipping = WelsRcPostFrameSkipping;
1481 break;1499 break;
1482 case RC_TIMESTAMP_MODE:1500 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;
1488 1501
1489 } else {1502 pRcf->pfWelsRcPictureInit = WelsRcPictureInitGom;
1490 pRcf->pfWelsRcPictureInit = WelsRcPictureInitGom;1503 pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateGomTimeStamp;
1491 pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateGomTimeStamp;1504 pRcf->pfWelsRcMbInit = WelsRcMbInitGom;
1492 pRcf->pfWelsRcMbInit = WelsRcMbInitGom;1505 pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateGom;
1493 pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateGom;1506
1494 }
1495 pRcf->pfWelsRcPicDelayJudge = WelsRcFrameDelayJudgeTimeStamp;1507 pRcf->pfWelsRcPicDelayJudge = WelsRcFrameDelayJudgeTimeStamp;
1496 pRcf->pfWelsCheckSkipBasedMaxbr = NULL;1508 pRcf->pfWelsCheckSkipBasedMaxbr = NULL;
1497 pRcf->pfWelsUpdateBufferWhenSkip = NULL;1509 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