use the external qp setting for screen content
This commit is contained in:
parent
9be80c088d
commit
c51975acdf
@ -271,18 +271,21 @@ int32_t ParamValidation (SLogContext* pLogCtx, SWelsSvcCodingParam* pCfg) {
|
||||
WelsLog (pLogCtx, WELS_LOG_WARNING,
|
||||
"bEnableFrameSkip = %d,bitrate can't be controlled for RC_QUALITY_MODE,RC_BITRATE_MODE and RC_TIMESTAMP_MODE without enabling skip frame.",
|
||||
pCfg->bEnableFrameSkip);
|
||||
|
||||
if (pCfg->iRCMode == RC_QUALITY_MODE) {
|
||||
pCfg->iMinQp = WELS_CLIP3 (pCfg->iMinQp , GOM_MIN_QP_MODE, GOM_MAX_QP_MODE);
|
||||
pCfg->iMaxQp = WELS_CLIP3 (pCfg->iMaxQp , GOM_MIN_QP_MODE, GOM_MAX_QP_MODE);
|
||||
if (pCfg->iMaxQp < pCfg->iMinQp)
|
||||
pCfg->iMaxQp = GOM_MAX_QP_MODE;
|
||||
pCfg->iMinQp = GOM_MIN_QP_MODE;
|
||||
pCfg->iMaxQp = GOM_MAX_QP_MODE;
|
||||
} else if (pCfg->iUsageType == SCREEN_CONTENT_REAL_TIME) {
|
||||
pCfg->iMinQp = MIN_SCREEN_QP;
|
||||
pCfg->iMaxQp = MAX_SCREEN_QP;
|
||||
} else {
|
||||
pCfg->iMinQp = WELS_CLIP3 (pCfg->iMinQp , 0, 51);
|
||||
pCfg->iMinQp = WELS_CLIP3 (pCfg->iMinQp , GOM_MIN_QP_MODE, 51);
|
||||
pCfg->iMaxQp = WELS_CLIP3 (pCfg->iMaxQp , 0, 51);
|
||||
if (pCfg->iMaxQp < pCfg->iMinQp)
|
||||
if (pCfg->iMaxQp <= pCfg->iMinQp)
|
||||
pCfg->iMaxQp = 51;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// ref-frames validation
|
||||
if (((pCfg->iUsageType == CAMERA_VIDEO_REAL_TIME) || (pCfg->iUsageType == SCREEN_CONTENT_REAL_TIME))
|
||||
|
@ -1102,7 +1102,7 @@ void WelsRcPictureInitDisable (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
|
||||
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) {
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 ((pEncCtx->iGlobalQp * INT_MULTIPLY -
|
||||
pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp) / INT_MULTIPLY, GOM_MIN_QP_MODE, GOM_MAX_QP_MODE);
|
||||
pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp) / INT_MULTIPLY, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
||||
} else {
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 (pEncCtx->iGlobalQp, 0, 51);
|
||||
}
|
||||
@ -1114,15 +1114,16 @@ void WelsRcPictureInfoUpdateDisable (sWelsEncCtx* pEncCtx, int32_t iLayerSize)
|
||||
}
|
||||
|
||||
void WelsRcMbInitDisable (sWelsEncCtx* pEncCtx, SMB* pCurMb, SSlice* pSlice) {
|
||||
int32_t iLumaQp = pEncCtx->iGlobalQp;
|
||||
int32_t iLumaQp = pEncCtx->iGlobalQp;
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
|
||||
|
||||
SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
|
||||
const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
|
||||
|
||||
|
||||
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) {
|
||||
iLumaQp = (int8_t)WELS_CLIP3 (iLumaQp +
|
||||
pEncCtx->pVaa->sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[pCurMb->iMbXY], GOM_MIN_QP_MODE, 51);
|
||||
pEncCtx->pVaa->sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[pCurMb->iMbXY], pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
||||
} else {
|
||||
iLumaQp = WELS_CLIP3 (iLumaQp, 0, 51);
|
||||
}
|
||||
@ -1134,7 +1135,9 @@ void WelsRcMbInfoUpdateDisable (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iCos
|
||||
}
|
||||
|
||||
void WelRcPictureInitBufferBasedQp (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
SVAAFrameInfo* pVaa = static_cast<SVAAFrameInfo*> (pEncCtx->pVaa);
|
||||
|
||||
SVAAFrameInfo* pVaa = static_cast<SVAAFrameInfo*> (pEncCtx->pVaa);
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
|
||||
int32_t iMinQp = MIN_SCREEN_QP;
|
||||
if (pVaa->eSceneChangeIdc == LARGE_CHANGED_SCENE)
|
||||
@ -1147,7 +1150,7 @@ void WelRcPictureInitBufferBasedQp (sWelsEncCtx* pEncCtx, long long uiTimeStamp)
|
||||
pEncCtx->iGlobalQp -= 1;
|
||||
else
|
||||
pEncCtx->iGlobalQp += 2;
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 (pEncCtx->iGlobalQp, iMinQp, MAX_SCREEN_QP);
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 (pEncCtx->iGlobalQp, iMinQp, pWelsSvcRc->iMaxQp);
|
||||
}
|
||||
void WelRcPictureInitScc (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
@ -1166,7 +1169,7 @@ void WelRcPictureInitScc (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
int32_t iQstep = WELS_DIV_ROUND (iFrameCplx * pWelsSvcRc->iCost2BitsIntra, iTargetBits);
|
||||
int32_t iQp = RcConvertQStep2Qp (iQstep);
|
||||
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 (iQp, MIN_IDR_QP, MAX_IDR_QP);
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 (iQp, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
||||
} else {
|
||||
int64_t iTargetBits = WELS_ROUND (((float)iBitRate / pDLayerParamInternal->fOutputFrameRate)); //iBitRate / 10;
|
||||
int32_t iQstep = WELS_DIV_ROUND (iFrameCplx * pWelsSvcRc->iAvgCost2Bits, iTargetBits);
|
||||
@ -1186,21 +1189,21 @@ void WelRcPictureInitScc (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
} else if ((iDeltaQp <= -6)) {
|
||||
--iBaseQp;
|
||||
}
|
||||
iBaseQp = WELS_CLIP3 (iBaseQp, MIN_IDR_QP, MAX_IDR_QP);
|
||||
iBaseQp = WELS_CLIP3 (iBaseQp, pWelsSvcRc->iMinQp, pWelsSvcRc->iMinQp);
|
||||
|
||||
pEncCtx->iGlobalQp = iBaseQp;
|
||||
|
||||
|
||||
if (iDeltaQp < -6) {
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 (pWelsSvcRc->iBaseQp - 6, MIN_SCREEN_QP, MAX_SCREEN_QP);
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 (pWelsSvcRc->iBaseQp - 6, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
||||
}
|
||||
|
||||
if (iDeltaQp > 5) {
|
||||
if (LARGE_CHANGED_SCENE == pEncCtx->pVaa->eSceneChangeIdc || pWelsSvcRc->iBufferFullnessSkip > 2 * iBitRate
|
||||
|| iDeltaQp > 10) {
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 (pWelsSvcRc->iBaseQp + iDeltaQp, MIN_SCREEN_QP, MAX_SCREEN_QP);
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 (pWelsSvcRc->iBaseQp + iDeltaQp, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
||||
} else if (MEDIUM_CHANGED_SCENE == pEncCtx->pVaa->eSceneChangeIdc || pWelsSvcRc->iBufferFullnessSkip > iBitRate) {
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 (pWelsSvcRc->iBaseQp + 5, MIN_SCREEN_QP, MAX_SCREEN_QP);
|
||||
pEncCtx->iGlobalQp = WELS_CLIP3 (pWelsSvcRc->iBaseQp + 5, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
||||
}
|
||||
}
|
||||
pWelsSvcRc->iBaseQp = iBaseQp;
|
||||
@ -1303,7 +1306,7 @@ void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp
|
||||
dBpp = (double) (pDLayerParam->iSpatialBitrate) / (double) (pDLayerParam->fFrameRate * pDLayerParam->iVideoWidth *
|
||||
pDLayerParam->iVideoHeight);
|
||||
pWelsSvcRc->iInitialQp = (int32_t) (50 - dBpp * 10 * 4);
|
||||
pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, MIN_IDR_QP, MAX_IDR_QP);
|
||||
pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
||||
|
||||
iLumaQp = pWelsSvcRc->iInitialQp;
|
||||
pWelsSvcRc->iTargetBits = static_cast<int32_t> (((double) (pDLayerParam->iSpatialBitrate) / (double) (
|
||||
@ -1334,7 +1337,7 @@ void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp
|
||||
} else {
|
||||
iLumaQp = pWelsSvcRc->iLastCalculatedQScale + DELTA_QP_BGD_THD;
|
||||
}
|
||||
iLumaQp = WELS_CLIP3 (iLumaQp, MIN_IDR_QP, MAX_IDR_QP);
|
||||
iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"[Rc]I iLumaQp = %d,iQStep = %d,iTargetBits = %d,iBufferFullnessSkip =%" PRId64
|
||||
",iMaxTh=%d,iMinTh = %d,iFrameComplexity= %" PRId64,
|
||||
@ -1374,7 +1377,7 @@ void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp
|
||||
iLumaQp = pWelsSvcRc->iLastCalculatedQScale + DELTA_QP_BGD_THD;
|
||||
}
|
||||
|
||||
iLumaQp = WELS_CLIP3 (iLumaQp, GOM_MIN_QP_MODE, GOM_MAX_QP_MODE);
|
||||
iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
||||
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"[Rc]P iTl = %d,iLumaQp = %d,iQStep = %d,iTargetBits = %d,iBufferFullnessSkip =%" PRId64
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user