Showing the changes to codec/encoder/core/src/ratectl.cpp (1 of 2 files). Show all
Unified · Split
| @@ -390,7 +390,11 @@ void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) { · 389 unmodified lines | ||
| 390 | 390 | int32_t dInitialQPArray[4][4] = {{28, 26, 24, 22}, {30, 28, 26, 24}, {32, 30, 28, 26}, {34, 32, 30, 28}}; |
| 391 | 391 | int32_t iBppIndex = 0; |
| 392 | 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 | 398 | SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; |
| 395 | 399 | SSpatialLayerConfig* pDLayerParam = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId]; |
| 396 | 400 | SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId]; |
| @@ -427,13 +431,12 @@ void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) { · 30 unmodified lines | ||
| 427 | 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 | 435 | pWelsSvcRc->iIntraComplxMean); |
| 432 | 436 | iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE); |
| 433 | 437 | pWelsSvcRc->iQStep = WELS_DIV_ROUND ((pWelsSvcRc->iIntraComplexity * iCmplxRatio), |
| 434 | 438 | (pWelsSvcRc->iTargetBits * INT_MULTIPLY)); |
| 435 | 439 | pWelsSvcRc->iInitialQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep); |
| 436 | − | |
| 437 | 440 | } |
| 438 | 441 | pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, iMinQp, iMaxQp); |
| 439 | 442 | pEncCtx->iGlobalQp = pWelsSvcRc->iInitialQp; |
| @@ -450,6 +453,11 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { · 10 unmodified lines | ||
| 450 | 453 | SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[iTl]; |
| 451 | 454 | int32_t iLumaQp = 0; |
| 452 | 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 | 461 | if (0 == pTOverRc->iPFrameNum) { |
| 454 | 462 | iLumaQp = pWelsSvcRc->iInitialQp; |
| 455 | 463 | } else if (pWelsSvcRc->iCurrentBitsLevel == BITS_EXCEEDED) { |
| @@ -466,7 +474,7 @@ void RcCalculatePictureQp (sWelsEncCtx* pEncCtx) { · 10 unmodified lines | ||
| 466 | 474 | iDeltaQpTemporal -= 1; |
| 467 | 475 | |
| 468 | 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 | 478 | pTOverRc->iFrameCmplxMean); |
| 471 | 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 | 1047 | if (iAlpha < (INT_MULTIPLY / 4)) iAlpha = INT_MULTIPLY / 4; |
| 1040 | 1048 | int32_t iQStep = RcConvertQp2QStep (pWelsSvcRc->iAverageFrameQp); |
| 1041 | 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 | 1055 | if (pWelsSvcRc->iIdrNum == 0) { |
| 1043 | 1056 | pWelsSvcRc->iIntraComplexity = iIntraCmplx; |
| 1044 | − pWelsSvcRc->iIntraComplxMean = pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity; | |
| 1057 | + pWelsSvcRc->iIntraComplxMean = iFrameComplexity; | |
| 1045 | 1058 | } else { |
| 1046 | 1059 | pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * pWelsSvcRc->iIntraComplexity + |
| 1047 | 1060 | (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * |
| @@ -1050,7 +1063,7 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) { · 2 unmodified lines | ||
| 1050 | 1063 | |
| 1051 | 1064 | pWelsSvcRc->iIntraComplxMean = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * static_cast<int64_t> |
| 1052 | 1065 | (pWelsSvcRc->iIntraComplxMean) |
| 1053 | − + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity)), | |
| 1066 | + + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (iFrameComplexity)), | |
| 1054 | 1067 | INT_MULTIPLY); |
| 1055 | 1068 | } |
| 1056 | 1069 | |
| @@ -1069,20 +1082,25 @@ void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) { · 12 unmodified lines | ||
| 1069 | 1082 | const int32_t kiTl = pEncCtx->uiTemporalId; |
| 1070 | 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 | 1090 | int32_t iQStep = RcConvertQp2QStep (pWelsSvcRc->iAverageFrameQp); |
| 1073 | 1091 | int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pTOverRc->iPFrameNum)); |
| 1074 | 1092 | if (iAlpha < SMOOTH_FACTOR_MIN_VALUE) |
| 1075 | 1093 | iAlpha = SMOOTH_FACTOR_MIN_VALUE; |
| 1076 | 1094 | if (0 == pTOverRc->iPFrameNum) { |
| 1077 | 1095 | pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * iQStep; |
| 1078 | − pTOverRc->iFrameCmplxMean = (int32_t)pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity; | |
| 1096 | + pTOverRc->iFrameCmplxMean = (int32_t)iFrameComplexity; | |
| 1079 | 1097 | } else { |
| 1080 | 1098 | pTOverRc->iLinearCmplx = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * (int64_t)pTOverRc->iLinearCmplx |
| 1081 | 1099 | + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * ((int64_t)pWelsSvcRc->iFrameDqBits * iQStep)), |
| 1082 | 1100 | INT_MULTIPLY); |
| 1083 | 1101 | pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND64 (((LINEAR_MODEL_DECAY_FACTOR) * static_cast<int64_t> |
| 1084 | 1102 | (pTOverRc->iFrameCmplxMean) |
| 1085 | − + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity), | |
| 1103 | + + (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * iFrameComplexity), | |
| 1086 | 1104 | INT_MULTIPLY); |
| 1087 | 1105 | } |
| 1088 | 1106 | |
| @@ -1094,8 +1112,8 @@ void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) { · 5 unmodified lines | ||
| 1094 | 1112 | "RcUpdateFrameComplexity iFrameDqBits = %d,iQStep= %d,pWelsSvcRc->iQStep= %d,pTOverRc->iLinearCmplx = %" PRId64, |
| 1095 | 1113 | pWelsSvcRc->iFrameDqBits, |
| 1096 | 1114 | 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); | |
| 1099 | 1117 | } |
| 1100 | 1118 | |
| 1101 | 1119 | int32_t RcCalculateCascadingQp (struct TagWelsEncCtx* pEncCtx, int32_t iQp) { |
| @@ -1480,18 +1498,12 @@ void WelsRcInitFuncPointers (sWelsEncCtx* pEncCtx, RC_MODES iRcMode) { · 378 unmodified lines | ||
| 1480 | 1498 | pRcf->pfWelsRcPostFrameSkipping = WelsRcPostFrameSkipping; |
| 1481 | 1499 | break; |
| 1482 | 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 { | |
| 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 | + | |
| 1495 | 1507 | pRcf->pfWelsRcPicDelayJudge = WelsRcFrameDelayJudgeTimeStamp; |
| 1496 | 1508 | pRcf->pfWelsCheckSkipBasedMaxbr = NULL; |
| 1497 | 1509 | pRcf->pfWelsUpdateBufferWhenSkip = NULL; |