refine RC parameters
This commit is contained in:
parent
3c06753dcc
commit
ab370cd607
@ -343,11 +343,11 @@ void RcTraceVGopBitrate (sWelsEncCtx* pEncCtx) {
|
|||||||
int32_t iFrameInVGop = pWelsSvcRc->iFrameCodedInVGop + pWelsSvcRc->iSkipFrameInVGop;
|
int32_t iFrameInVGop = pWelsSvcRc->iFrameCodedInVGop + pWelsSvcRc->iSkipFrameInVGop;
|
||||||
if (0 != iFrameInVGop)
|
if (0 != iFrameInVGop)
|
||||||
iVGopBitrate = WELS_ROUND (iTotalBits / iFrameInVGop * pWelsSvcRc->fFrameRate);
|
iVGopBitrate = WELS_ROUND (iTotalBits / iFrameInVGop * pWelsSvcRc->fFrameRate);
|
||||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "[Rc] VGOPbitrate%d: %d ", kiDid, iVGopBitrate);
|
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] VGOPbitrate%d: %d ", kiDid, iVGopBitrate);
|
||||||
if (iTotalBits > 0) {
|
if (iTotalBits > 0) {
|
||||||
iTid = 0;
|
iTid = 0;
|
||||||
while (iTid <= kiHighestTid) {
|
while (iTid <= kiHighestTid) {
|
||||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "T%d=%8.3f ", iTid, (double) (pTOverRc[iTid].iGopBitsDq / iTotalBits));
|
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "T%d=%8.3f ", iTid, (double) (pTOverRc[iTid].iGopBitsDq / iTotalBits));
|
||||||
++ iTid;
|
++ iTid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -625,7 +625,6 @@ void RcGomTargetBits (sWelsEncCtx* pEncCtx, const int32_t kiSliceId) {
|
|||||||
|
|
||||||
iLastGomIndex = pSOverRc->iEndMbSlice / pWelsSvcRc->iNumberMbGom;
|
iLastGomIndex = pSOverRc->iEndMbSlice / pWelsSvcRc->iNumberMbGom;
|
||||||
iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice;
|
iLeftBits = pSOverRc->iTargetBitsSlice - pSOverRc->iFrameBitsSlice;
|
||||||
|
|
||||||
if (iLeftBits <= 0) {
|
if (iLeftBits <= 0) {
|
||||||
pSOverRc->iGomTargetBits = 0;
|
pSOverRc->iGomTargetBits = 0;
|
||||||
return;
|
return;
|
||||||
@ -671,9 +670,8 @@ void RcCalculateGomQp (sWelsEncCtx* pEncCtx, SMB* pCurMb, int32_t iSliceId) {
|
|||||||
else if (iBitsRatio > 11900) //2^(1.5/6)*10000
|
else if (iBitsRatio > 11900) //2^(1.5/6)*10000
|
||||||
pSOverRc->iCalculatedQpSlice -= 2;
|
pSOverRc->iCalculatedQpSlice -= 2;
|
||||||
}
|
}
|
||||||
|
pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
||||||
|
|
||||||
pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice,
|
|
||||||
pEncCtx->iGlobalQp - pWelsSvcRc->iQpRangeLowerInFrame, pEncCtx->iGlobalQp + pWelsSvcRc->iQpRangeUpperInFrame);
|
|
||||||
if (! (((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE) || (pEncCtx->pSvcParam->iRCMode == RC_TIMESTAMP_MODE))
|
if (! (((pEncCtx->pSvcParam->iRCMode == RC_BITRATE_MODE) || (pEncCtx->pSvcParam->iRCMode == RC_TIMESTAMP_MODE))
|
||||||
&& (pEncCtx->pSvcParam->bEnableFrameSkip == false)))
|
&& (pEncCtx->pSvcParam->bEnableFrameSkip == false)))
|
||||||
pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
pSOverRc->iCalculatedQpSlice = WELS_CLIP3 (pSOverRc->iCalculatedQpSlice, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
||||||
@ -790,8 +788,10 @@ bool CheckFrameSkipBasedMaxbr (sWelsEncCtx* pEncCtx, int32_t iSpatialNum, EVideo
|
|||||||
pEncCtx->iContinualSkipFrames++;
|
pEncCtx->iContinualSkipFrames++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (bSkipMustFlag) {
|
||||||
|
for (int32_t i = 0; i < iSpatialNum; i++)
|
||||||
|
pEncCtx->pWelsSvcRc[i].uiLastTimeStamp = uiTimeStamp;
|
||||||
}
|
}
|
||||||
return bSkipMustFlag;
|
return bSkipMustFlag;
|
||||||
}
|
}
|
||||||
@ -819,7 +819,7 @@ void UpdateBufferWhenFrameSkipped (sWelsEncCtx* pEncCtx, int32_t iSpatialNum) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
pEncCtx->iContinualSkipFrames++;
|
pEncCtx->iContinualSkipFrames++;
|
||||||
if ( ( pEncCtx->iContinualSkipFrames % 3 ) == 0 ) {
|
if ((pEncCtx->iContinualSkipFrames % 3) == 0) {
|
||||||
//output a warning when iContinualSkipFrames is large enough, which may indicate subjective quality problem
|
//output a warning when iContinualSkipFrames is large enough, which may indicate subjective quality problem
|
||||||
//note that here iContinualSkipFrames must be >0, so the log output will be 3/6/....
|
//note that here iContinualSkipFrames must be >0, so the log output will be 3/6/....
|
||||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_WARNING, "[Rc] iContinualSkipFrames(%d) is large",
|
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_WARNING, "[Rc] iContinualSkipFrames(%d) is large",
|
||||||
@ -916,7 +916,8 @@ void RcTraceFrameBits (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
|||||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||||
"[Rc]Layer %d: Frame timestamp = %lld, Frame type = %d, encoding_qp = %d, average qp = %d, max qp = %d, min qp = %d, index = %d, "
|
"[Rc]Layer %d: Frame timestamp = %lld, Frame type = %d, encoding_qp = %d, average qp = %d, max qp = %d, min qp = %d, index = %d, "
|
||||||
"iTid = %d, used = %d, bitsperframe = %d, target = %d, remainingbits = %d, skipbuffersize = %d",
|
"iTid = %d, used = %d, bitsperframe = %d, target = %d, remainingbits = %d, skipbuffersize = %d",
|
||||||
pEncCtx->uiDependencyId, uiTimeStamp, pEncCtx->eSliceType, pEncCtx->iGlobalQp, pWelsSvcRc->iAverageFrameQp, pWelsSvcRc->iMaxFrameQp,
|
pEncCtx->uiDependencyId, uiTimeStamp, pEncCtx->eSliceType, pEncCtx->iGlobalQp, pWelsSvcRc->iAverageFrameQp,
|
||||||
|
pWelsSvcRc->iMaxFrameQp,
|
||||||
pWelsSvcRc->iMinFrameQp,
|
pWelsSvcRc->iMinFrameQp,
|
||||||
pEncCtx->iFrameIndex, pEncCtx->uiTemporalId, pWelsSvcRc->iFrameDqBits, pWelsSvcRc->iBitsPerFrame,
|
pEncCtx->iFrameIndex, pEncCtx->uiTemporalId, pWelsSvcRc->iFrameDqBits, pWelsSvcRc->iBitsPerFrame,
|
||||||
pWelsSvcRc->iTargetBits, pWelsSvcRc->iRemainingBits, pWelsSvcRc->iBufferSizeSkip);
|
pWelsSvcRc->iTargetBits, pWelsSvcRc->iRemainingBits, pWelsSvcRc->iBufferSizeSkip);
|
||||||
@ -944,6 +945,7 @@ void RcUpdatePictureQpBits (sWelsEncCtx* pEncCtx, int32_t iCodedBits) {
|
|||||||
pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp;
|
pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp;
|
||||||
}
|
}
|
||||||
pWelsSvcRc->iFrameDqBits = iCodedBits;
|
pWelsSvcRc->iFrameDqBits = iCodedBits;
|
||||||
|
pWelsSvcRc->iLastCalculatedQScale = pWelsSvcRc->iAverageFrameQp;
|
||||||
pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId].iGopBitsDq += pWelsSvcRc->iFrameDqBits;
|
pWelsSvcRc->pTemporalOverRc[pEncCtx->uiTemporalId].iGopBitsDq += pWelsSvcRc->iFrameDqBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -951,8 +953,8 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) {
|
|||||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||||
int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pWelsSvcRc->iIdrNum));
|
int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pWelsSvcRc->iIdrNum));
|
||||||
if (iAlpha < (INT_MULTIPLY / 4)) iAlpha = INT_MULTIPLY / 4;
|
if (iAlpha < (INT_MULTIPLY / 4)) iAlpha = INT_MULTIPLY / 4;
|
||||||
|
int32_t iQStep = RcConvertQp2QStep (pWelsSvcRc->iAverageFrameQp);
|
||||||
int64_t iIntraCmplx = pWelsSvcRc->iQStep * static_cast<int64_t> (pWelsSvcRc->iFrameDqBits);
|
int64_t iIntraCmplx = iQStep * static_cast<int64_t> (pWelsSvcRc->iFrameDqBits);
|
||||||
pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pWelsSvcRc->iIntraComplexity + iAlpha *
|
pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pWelsSvcRc->iIntraComplexity + iAlpha *
|
||||||
iIntraCmplx), INT_MULTIPLY);
|
iIntraCmplx), INT_MULTIPLY);
|
||||||
pWelsSvcRc->iIntraMbCount = pWelsSvcRc->iNumberMbFrame;
|
pWelsSvcRc->iIntraMbCount = pWelsSvcRc->iNumberMbFrame;
|
||||||
@ -960,9 +962,10 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) {
|
|||||||
pWelsSvcRc->iIdrNum++;
|
pWelsSvcRc->iIdrNum++;
|
||||||
if (pWelsSvcRc->iIdrNum > 255)
|
if (pWelsSvcRc->iIdrNum > 255)
|
||||||
pWelsSvcRc->iIdrNum = 255;
|
pWelsSvcRc->iIdrNum = 255;
|
||||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO,
|
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||||
"RcUpdateIntraComplexity iFrameDqBits = %d,iQStep= %d,iIntraCmplx = %" PRId64,
|
"RcUpdateIntraComplexity iFrameDqBits = %d,iQStep= %d,iIntraCmplx = %" PRId64,
|
||||||
pWelsSvcRc->iFrameDqBits, pWelsSvcRc->iQStep, pWelsSvcRc->iIntraComplexity);
|
pWelsSvcRc->iFrameDqBits, pWelsSvcRc->iQStep, pWelsSvcRc->iIntraComplexity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) {
|
void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) {
|
||||||
@ -970,26 +973,32 @@ void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) {
|
|||||||
const int32_t kiTl = pEncCtx->uiTemporalId;
|
const int32_t kiTl = pEncCtx->uiTemporalId;
|
||||||
SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[kiTl];
|
SRCTemporal* pTOverRc = &pWelsSvcRc->pTemporalOverRc[kiTl];
|
||||||
|
|
||||||
|
int32_t iQStep = RcConvertQp2QStep (pWelsSvcRc->iAverageFrameQp);
|
||||||
if (0 == pTOverRc->iPFrameNum) {
|
if (0 == pTOverRc->iPFrameNum) {
|
||||||
pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * pWelsSvcRc->iQStep;
|
pTOverRc->iLinearCmplx = ((int64_t)pWelsSvcRc->iFrameDqBits) * iQStep;
|
||||||
} else {
|
} else {
|
||||||
pTOverRc->iLinearCmplx = WELS_DIV_ROUND64 ((LINEAR_MODEL_DECAY_FACTOR * (int64_t)pTOverRc->iLinearCmplx
|
pTOverRc->iLinearCmplx = WELS_DIV_ROUND64 ((LINEAR_MODEL_DECAY_FACTOR * (int64_t)pTOverRc->iLinearCmplx
|
||||||
+ (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (int64_t) (pWelsSvcRc->iFrameDqBits * pWelsSvcRc->iQStep)),
|
+ (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * (int64_t) (pWelsSvcRc->iFrameDqBits * iQStep)),
|
||||||
INT_MULTIPLY);
|
INT_MULTIPLY);
|
||||||
}
|
}
|
||||||
int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));
|
int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));
|
||||||
if (iAlpha < SMOOTH_FACTOR_MIN_VALUE)
|
if (iAlpha < SMOOTH_FACTOR_MIN_VALUE)
|
||||||
iAlpha = SMOOTH_FACTOR_MIN_VALUE;
|
iAlpha = SMOOTH_FACTOR_MIN_VALUE;
|
||||||
pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * static_cast<int64_t> (pTOverRc->iFrameCmplxMean)
|
pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND ((LINEAR_MODEL_DECAY_FACTOR * static_cast<int64_t>
|
||||||
+ iAlpha * pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity),
|
(pTOverRc->iFrameCmplxMean)
|
||||||
|
+ (INT_MULTIPLY - LINEAR_MODEL_DECAY_FACTOR) * pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity),
|
||||||
INT_MULTIPLY);
|
INT_MULTIPLY);
|
||||||
|
|
||||||
|
|
||||||
pTOverRc->iPFrameNum++;
|
pTOverRc->iPFrameNum++;
|
||||||
if (pTOverRc->iPFrameNum > 255)
|
if (pTOverRc->iPFrameNum > 255)
|
||||||
pTOverRc->iPFrameNum = 255;
|
pTOverRc->iPFrameNum = 255;
|
||||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||||
"RcUpdateFrameComplexity iFrameDqBits = %d,iQStep= %d,pTOverRc->iLinearCmplx = %" PRId64, pWelsSvcRc->iFrameDqBits,
|
"RcUpdateFrameComplexity iFrameDqBits = %d,iQStep= %d,pWelsSvcRc->iQStep= %d,pTOverRc->iLinearCmplx = %" PRId64,
|
||||||
pWelsSvcRc->iQStep, pTOverRc->iLinearCmplx);
|
pWelsSvcRc->iFrameDqBits,
|
||||||
|
iQStep, pWelsSvcRc->iQStep, pTOverRc->iLinearCmplx);
|
||||||
|
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "iFrameCmplxMean = %d,iFrameComplexity = %lld",
|
||||||
|
pTOverRc->iFrameCmplxMean, pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RcCalculateCascadingQp (struct TagWelsEncCtx* pEncCtx, int32_t iQp) {
|
int32_t RcCalculateCascadingQp (struct TagWelsEncCtx* pEncCtx, int32_t iQp) {
|
||||||
@ -1115,7 +1124,8 @@ void WelsRcPictureInitDisable (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
|||||||
|
|
||||||
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) {
|
if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) {
|
||||||
pEncCtx->iGlobalQp = WELS_CLIP3 ((pEncCtx->iGlobalQp * INT_MULTIPLY -
|
pEncCtx->iGlobalQp = WELS_CLIP3 ((pEncCtx->iGlobalQp * INT_MULTIPLY -
|
||||||
pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp) / INT_MULTIPLY, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp) / INT_MULTIPLY, pWelsSvcRc->iMinQp,
|
||||||
|
pWelsSvcRc->iMaxQp);
|
||||||
} else {
|
} else {
|
||||||
pEncCtx->iGlobalQp = WELS_CLIP3 (pEncCtx->iGlobalQp, 0, 51);
|
pEncCtx->iGlobalQp = WELS_CLIP3 (pEncCtx->iGlobalQp, 0, 51);
|
||||||
}
|
}
|
||||||
@ -1231,7 +1241,7 @@ void WelsRcDropFrameUpdate (sWelsEncCtx* pEncCtx, uint32_t iDropSize) {
|
|||||||
|
|
||||||
pWelsSvcRc->iBufferFullnessSkip -= (int32_t)iDropSize;
|
pWelsSvcRc->iBufferFullnessSkip -= (int32_t)iDropSize;
|
||||||
pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (0, pWelsSvcRc->iBufferFullnessSkip);
|
pWelsSvcRc->iBufferFullnessSkip = WELS_MAX (0, pWelsSvcRc->iBufferFullnessSkip);
|
||||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "[WelsRcDropFrameUpdate:\tdrop:%d\t%" PRId64 "\n", iDropSize,
|
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG, "[WelsRcDropFrameUpdate:\tdrop:%d\t%" PRId64 "\n", iDropSize,
|
||||||
pWelsSvcRc->iBufferFullnessSkip);
|
pWelsSvcRc->iBufferFullnessSkip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1266,8 +1276,8 @@ void InitRcModuleTimeStamp (sWelsEncCtx* pEncCtx) {
|
|||||||
pWelsSvcRc->iBufferFullnessSkip = 0;
|
pWelsSvcRc->iBufferFullnessSkip = 0;
|
||||||
pWelsSvcRc->uiLastTimeStamp = 0;
|
pWelsSvcRc->uiLastTimeStamp = 0;
|
||||||
|
|
||||||
pWelsSvcRc->iCost2BitsIntra = INT_MULTIPLY;
|
pWelsSvcRc->iCost2BitsIntra = 1;
|
||||||
pWelsSvcRc->iAvgCost2Bits = INT_MULTIPLY;
|
pWelsSvcRc->iAvgCost2Bits = 1;
|
||||||
pWelsSvcRc->iSkipBufferRatio = SKIP_RATIO;
|
pWelsSvcRc->iSkipBufferRatio = SKIP_RATIO;
|
||||||
}
|
}
|
||||||
void WelsRcFrameDelayJudgeTimeStamp (sWelsEncCtx* pEncCtx, EVideoFrameType eFrameType, long long uiTimeStamp) {
|
void WelsRcFrameDelayJudgeTimeStamp (sWelsEncCtx* pEncCtx, EVideoFrameType eFrameType, long long uiTimeStamp) {
|
||||||
@ -1314,21 +1324,15 @@ void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp
|
|||||||
if (pEncCtx->eSliceType == I_SLICE) {
|
if (pEncCtx->eSliceType == I_SLICE) {
|
||||||
if (0 == pWelsSvcRc->iIdrNum) { //iIdrNum == 0 means encoder has been initialed
|
if (0 == pWelsSvcRc->iIdrNum) { //iIdrNum == 0 means encoder has been initialed
|
||||||
RcInitRefreshParameter (pEncCtx);
|
RcInitRefreshParameter (pEncCtx);
|
||||||
double dBpp = 0.05;
|
RcInitIdrQp (pEncCtx);
|
||||||
if ((pDLayerParam->fFrameRate > EPSN) && (pDLayerParam->iVideoWidth && pDLayerParam->iVideoHeight))
|
|
||||||
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, pWelsSvcRc->iMinQp, pWelsSvcRc->iMaxQp);
|
|
||||||
|
|
||||||
iLumaQp = pWelsSvcRc->iInitialQp;
|
iLumaQp = pWelsSvcRc->iInitialQp;
|
||||||
pWelsSvcRc->iTargetBits = static_cast<int32_t> (((double) (pDLayerParam->iSpatialBitrate) / (double) (
|
pWelsSvcRc->iTargetBits = static_cast<int32_t> (((double) (pDLayerParam->iSpatialBitrate) / (double) (
|
||||||
pDLayerParam->fFrameRate) *
|
pDLayerParam->fFrameRate) *
|
||||||
IDR_BITRATE_RATIO));
|
IDR_BITRATE_RATIO));
|
||||||
|
|
||||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||||
"[Rc] First IDR iSpatialBitrate = %d,iBufferFullnessSkip = %" PRId64 ",iTargetBits= %d,dBpp = %f,initQp = %d",
|
"[Rc] First IDR iSpatialBitrate = %d,iBufferFullnessSkip = %" PRId64 ",iTargetBits= %d,initQp = %d",
|
||||||
pDLayerParam->iSpatialBitrate, pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iTargetBits, dBpp,
|
pDLayerParam->iSpatialBitrate, pWelsSvcRc->iBufferFullnessSkip, pWelsSvcRc->iTargetBits,
|
||||||
pWelsSvcRc->iInitialQp);
|
pWelsSvcRc->iInitialQp);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -1340,8 +1344,7 @@ void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp
|
|||||||
if (iMaxTh > 0) {
|
if (iMaxTh > 0) {
|
||||||
pWelsSvcRc->iTargetBits = WELS_CLIP3 (pWelsSvcRc->iTargetBits, iMinTh, iMaxTh);
|
pWelsSvcRc->iTargetBits = WELS_CLIP3 (pWelsSvcRc->iTargetBits, iMinTh, iMaxTh);
|
||||||
|
|
||||||
pWelsSvcRc->iQStep = WELS_DIV_ROUND ((((int64_t)pWelsSvcRc->iIntraComplexity) *
|
pWelsSvcRc->iQStep = WELS_DIV_ROUND (pWelsSvcRc->iIntraComplexity, pWelsSvcRc->iTargetBits);
|
||||||
pWelsSvcRc->iCost2BitsIntra), pWelsSvcRc->iTargetBits);
|
|
||||||
iLumaQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);
|
iLumaQp = RcConvertQStep2Qp (pWelsSvcRc->iQStep);
|
||||||
|
|
||||||
iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iLastCalculatedQScale - DELTA_QP_BGD_THD,
|
iLumaQp = WELS_CLIP3 (iLumaQp, pWelsSvcRc->iLastCalculatedQScale - DELTA_QP_BGD_THD,
|
||||||
@ -1373,12 +1376,11 @@ void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp
|
|||||||
pTOverRc->iFrameCmplxMean);
|
pTOverRc->iFrameCmplxMean);
|
||||||
iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);
|
iCmplxRatio = WELS_CLIP3 (iCmplxRatio, INT_MULTIPLY - FRAME_CMPLX_RATIO_RANGE, INT_MULTIPLY + FRAME_CMPLX_RATIO_RANGE);
|
||||||
|
|
||||||
|
|
||||||
pWelsSvcRc->iTargetBits = WELS_DIV_ROUND (pTOverRc->iTlayerWeight * kiGopBits, INT_MULTIPLY * 10 * 2);
|
pWelsSvcRc->iTargetBits = WELS_DIV_ROUND (pTOverRc->iTlayerWeight * kiGopBits, INT_MULTIPLY * 10 * 2);
|
||||||
if (iMaxTh > 0) {
|
if (iMaxTh > 0) {
|
||||||
pWelsSvcRc->iTargetBits = WELS_CLIP3 (pWelsSvcRc->iTargetBits, iMinTh, iMaxTh);
|
pWelsSvcRc->iTargetBits = WELS_CLIP3 (pWelsSvcRc->iTargetBits, iMinTh, iMaxTh);
|
||||||
if (0 == pTOverRc->iPFrameNum)
|
if (0 == pTOverRc->iPFrameNum)
|
||||||
iLumaQp = pWelsSvcRc->iInitialQp;
|
iLumaQp = pWelsSvcRc->iInitialQp + DELTA_QP_BGD_THD;
|
||||||
else {
|
else {
|
||||||
|
|
||||||
pWelsSvcRc->iQStep = WELS_DIV_ROUND ((pTOverRc->iLinearCmplx * iCmplxRatio), (pWelsSvcRc->iTargetBits * INT_MULTIPLY));
|
pWelsSvcRc->iQStep = WELS_DIV_ROUND ((pTOverRc->iLinearCmplx * iCmplxRatio), (pWelsSvcRc->iTargetBits * INT_MULTIPLY));
|
||||||
|
@ -130,8 +130,8 @@ TEST_P (DecodeEncodeTest, CompareOutput) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
static const DecodeEncodeFileParam kFileParamArray[] = {
|
static const DecodeEncodeFileParam kFileParamArray[] = {
|
||||||
{"res/test_vd_1d.264", "0d38e143df069d13a5e74cfd03f7ba92964a13d6", 320, 192, 12.0f},
|
{"res/test_vd_1d.264", "aff3bbc85c39ab47fe8dbcc06403bb5135ab54d5", 320, 192, 12.0f},
|
||||||
{"res/test_vd_rc.264", "ea1e6c3bacd59312c18f9da0be105ba1fb8e57bb", 320, 192, 12.0f},
|
{"res/test_vd_rc.264", "20ffd6044c8386aae3bc229bab46744167e3a82f", 320, 192, 12.0f},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,65 +103,65 @@ TEST_P (EncoderOutputTest, CompareOutput) {
|
|||||||
static const EncodeFileParam kFileParamArray[] = {
|
static const EncodeFileParam kFileParamArray[] = {
|
||||||
{
|
{
|
||||||
"res/CiscoVT2people_320x192_12fps.yuv",
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
||||||
"bfe882345e17346a76438dad967ecd8a15052e0b", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
"03d992976d9b9c3dd7f9803883d3f7b7614b47bf", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"res/CiscoVT2people_160x96_6fps.yuv",
|
"res/CiscoVT2people_160x96_6fps.yuv",
|
||||||
"9879c0e65e0f2d166c450c371c95a1e36eadfa4e", CAMERA_VIDEO_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
"f7ccdadc446f87927d63f9a1fe78c72344a920cb", CAMERA_VIDEO_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"res/Static_152_100.yuv",
|
"res/Static_152_100.yuv",
|
||||||
"f2a4089dbf7278f9e7204351d6ce93e913d6ea1f", CAMERA_VIDEO_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
"c25d6d8c45de417cb42d861ee71a42d0ebfb6da9", CAMERA_VIDEO_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"res/CiscoVT2people_320x192_12fps.yuv",
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
||||||
"3ea419b2ea341fe548dbe65be0e955ffea59483a", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_ROWMB_SLICE, false, 1, false, false, false // One slice per MB row
|
"21dbfaaf4f09af735298434c1f97cf95a464165b", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_ROWMB_SLICE, false, 1, false, false, false // One slice per MB row
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"res/CiscoVT2people_320x192_12fps.yuv",
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
||||||
"7614af78a3cb16df8187c1db5492f82f3440a63b", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, true, 1, false, false, false
|
"a37f67d6050fe113ccfb65e562a6c32086a29eb3", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, true, 1, false, false, false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"res/CiscoVT2people_320x192_12fps.yuv",
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
||||||
"833a7ae798720f72d6a0b46e5cd1f046c0fdd758", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 2, false, false, false
|
"4f12d2b08af761b8bb61a5b25f96ad6a321a43fa", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 2, false, false, false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
||||||
"6cc7d08b2a80fc2836396808f919f9b5d4ee1d97", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, false, false, false
|
"9006ccba6d9d90815bd42ba850b344919fa399f4", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, false, false, false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
||||||
"40bc1ffec7febdb725ae99954bfa4cb64f070891", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_SINGLE_SLICE, false, 4, false, false, false
|
"a4707845cacc437fb52010eb020fca6d4bc1102d", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_SINGLE_SLICE, false, 4, false, false, false
|
||||||
},
|
},
|
||||||
// the following values may be adjusted for times since we start tuning the strategy
|
// the following values may be adjusted for times since we start tuning the strategy
|
||||||
{
|
{
|
||||||
"res/CiscoVT2people_320x192_12fps.yuv",
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
||||||
"6ce04eca6d8a6127ae1a6ee3e0d67977f806f5e2", SCREEN_CONTENT_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
"a731f20ec06d5591142f80e0d0e3edff88167d19", SCREEN_CONTENT_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"res/CiscoVT2people_160x96_6fps.yuv",
|
"res/CiscoVT2people_160x96_6fps.yuv",
|
||||||
"2a9942d8d67509712828a5268483141bb8c9b30f", SCREEN_CONTENT_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
"3a472cf6fbfa474c73fabaeb6e68c07112a2f5d2", SCREEN_CONTENT_REAL_TIME, 160, 96, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"res/Static_152_100.yuv",
|
"res/Static_152_100.yuv",
|
||||||
"2041510ebc2810596495d694672ada66f6ec3a0e", SCREEN_CONTENT_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
"43e0ea83028ea51eb41f29633af50fff7137024a", SCREEN_CONTENT_REAL_TIME, 152, 100, 6.0f, SM_SINGLE_SLICE, false, 1, false, false, false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
||||||
"116663b5a00f000ab40e95b6202563e3cb4ce488", SCREEN_CONTENT_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, false, false, false
|
"aa0aaca96475c65d66e90e513618fa814b098dff", SCREEN_CONTENT_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, false, false, false
|
||||||
},
|
},
|
||||||
//for different strategy
|
//for different strategy
|
||||||
{
|
{
|
||||||
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
||||||
"6b981e68a6e0b03a8b769fdd39ec5838380bc4d2", SCREEN_CONTENT_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, true, true, false
|
"5622722316eed2482bf78520eda7e448312e340e", SCREEN_CONTENT_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, true, true, false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"res/CiscoVT2people_320x192_12fps.yuv",
|
"res/CiscoVT2people_320x192_12fps.yuv",
|
||||||
"aae07cf34b065871921f742cdf25a4bf4d623935", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, false, false, true //turn on cabac
|
"cd9716c92c595f5492a46adf33f07bedf98db408", CAMERA_VIDEO_REAL_TIME, 320, 192, 12.0f, SM_SINGLE_SLICE, false, 1, false, false, true //turn on cabac
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
"res/Cisco_Absolute_Power_1280x720_30fps.yuv",
|
||||||
"bb8ee13f829fa593b77760afdeb1215d0a577ee1", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, false, false, true
|
"dfd4666f9b90d5d77647454e2a06d546adac6a7c", CAMERA_VIDEO_REAL_TIME, 1280, 720, 30.0f, SM_DYN_SLICE, false, 1, false, false, true
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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…
Reference in New Issue
Block a user