1, update the max-nal-size setting in UT and param check since we are using a larger input check
2, fix potential overflow (will change bs but little impact on bs)
This commit is contained in:
parent
7d055cae94
commit
431bcee310
@ -172,7 +172,7 @@ int32_t iRcVaryPercentage;
|
||||
int32_t iRcVaryRatio;
|
||||
|
||||
int32_t iInitialQp; //initial qp
|
||||
int32_t iBitRate;
|
||||
int64_t iBitRate; // Note: although the max bit rate is 240000*1200 which can be represented by int32, but there are many multipler of this iBitRate in the calculation of RC, so use int64 to avoid type conversion at all such places
|
||||
int32_t iPreviousBitrate;
|
||||
int32_t iPreviousGopSize;
|
||||
double fFrameRate;
|
||||
@ -186,7 +186,7 @@ int32_t iTargetBits;
|
||||
int32_t iCurrentBitsLevel;//0:normal; 1:limited; 2:exceeded.
|
||||
|
||||
int32_t iIdrNum;
|
||||
int32_t iIntraComplexity;
|
||||
int64_t iIntraComplexity; //255*255(MaxMbSAD)*36864(MaxFS) make the highest bit of 32-bit integer 1
|
||||
int32_t iIntraMbCount;
|
||||
|
||||
int8_t iTlOfFrames[VGOP_SIZE];
|
||||
|
@ -62,9 +62,9 @@ typedef struct {
|
||||
|
||||
|
||||
typedef struct {
|
||||
int32_t iMinFrameComplexity;
|
||||
int32_t iMinFrameComplexity08;
|
||||
int32_t iMinFrameComplexity11;
|
||||
int64_t iMinFrameComplexity;
|
||||
int64_t iMinFrameComplexity08;
|
||||
int64_t iMinFrameComplexity11;
|
||||
|
||||
int32_t iMinFrameNumGap;
|
||||
int32_t iMinFrameQp;
|
||||
@ -176,9 +176,9 @@ class CWelsPreProcess {
|
||||
void GetAvailableRefList (SPicture** pSrcPicList, uint8_t iCurTid, const int32_t iClosestLtrFrameNum,
|
||||
SRefInfoParam* pAvailableRefList, int32_t& iAvailableRefNum, int32_t& iAvailableSceneRefNum);
|
||||
void InitRefJudgement (SRefJudgement* pRefJudgement);
|
||||
bool JudgeBestRef (SPicture* pRefPic, const SRefJudgement& sRefJudgement, const int32_t iFrameComplexity,
|
||||
bool JudgeBestRef (SPicture* pRefPic, const SRefJudgement& sRefJudgement, const int64_t iFrameComplexity,
|
||||
const bool bIsClosestLtrFrame);
|
||||
void SaveBestRefToJudgement (const int32_t iRefPictureAvQP, const int32_t iComplexity, SRefJudgement* pRefJudgement);
|
||||
void SaveBestRefToJudgement (const int32_t iRefPictureAvQP, const int64_t iComplexity, SRefJudgement* pRefJudgement);
|
||||
void SaveBestRefToLocal (SRefInfoParam* pRefPicInfo, const SSceneChangeResult& sSceneChangeResult,
|
||||
SRefInfoParam* pRefSaved);
|
||||
void SaveBestRefToVaa (SRefInfoParam& sRefSaved, SRefInfoParam* pVaaBestRef);
|
||||
|
@ -529,7 +529,7 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa
|
||||
return ENC_RETURN_UNSUPPORTED_PARA;
|
||||
}
|
||||
|
||||
if (pCodingParam->uiMaxNalSize <= (NAL_HEADER_ADD_0X30BYTES + MAX_MACROBLOCK_SIZE_IN_BYTE)) {
|
||||
if (pCodingParam->uiMaxNalSize < (NAL_HEADER_ADD_0X30BYTES + MAX_MACROBLOCK_SIZE_IN_BYTE)) {
|
||||
WelsLog (pLogCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiMaxNalSize (%d) settings! should be larger than (NAL_HEADER_ADD_0X30BYTES + MAX_MACROBLOCK_SIZE_IN_BYTE)(%d)",
|
||||
pCodingParam->uiMaxNalSize, (NAL_HEADER_ADD_0X30BYTES + MAX_MACROBLOCK_SIZE_IN_BYTE));
|
||||
return ENC_RETURN_UNSUPPORTED_PARA;
|
||||
|
@ -218,7 +218,7 @@ void RcUpdateBitrateFps (sWelsEncCtx* pEncCtx) {
|
||||
const int32_t kiHighestTid = pDLayerParamInternal->iHighestTemporalId;
|
||||
const int32_t input_iBitsPerFrame = WELS_DIV_ROUND (pDLayerParam->iSpatialBitrate,
|
||||
pDLayerParamInternal->fOutputFrameRate);
|
||||
const int32_t kiGopBits = input_iBitsPerFrame * kiGopSize;
|
||||
const int64_t kiGopBits = input_iBitsPerFrame * kiGopSize;
|
||||
int32_t i;
|
||||
|
||||
pWelsSvcRc->iBitRate = pDLayerParam->iSpatialBitrate;
|
||||
@ -427,7 +427,7 @@ void RcCalculateIdrQp (sWelsEncCtx* pEncCtx) {
|
||||
pWelsSvcRc->iIntraComplexity = pWelsSvcRc->iIntraComplexity * pWelsSvcRc->iNumberMbFrame /
|
||||
pWelsSvcRc->iIntraMbCount;
|
||||
}
|
||||
pWelsSvcRc->iInitialQp = RcConvertQStep2Qp (static_cast<int32_t> (pWelsSvcRc->iIntraComplexity /
|
||||
pWelsSvcRc->iInitialQp = RcConvertQStep2Qp (WELS_DIV_ROUND (pWelsSvcRc->iIntraComplexity,
|
||||
pWelsSvcRc->iTargetBits));
|
||||
pWelsSvcRc->iInitialQp = WELS_CLIP3 (pWelsSvcRc->iInitialQp, MIN_IDR_QP, MAX_IDR_QP);
|
||||
pEncCtx->iGlobalQp = pWelsSvcRc->iInitialQp;
|
||||
@ -518,7 +518,8 @@ void RcInitSliceInformation (sWelsEncCtx* pEncCtx) {
|
||||
SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId];
|
||||
SRCSlicing* pSOverRc = &pWelsSvcRc->pSlicingOverRc[0];
|
||||
const int32_t kiSliceNum = pWelsSvcRc->iSliceNum;
|
||||
const int32_t kiBitsPerMb = WELS_DIV_ROUND (pWelsSvcRc->iTargetBits * INT_MULTIPLY, pWelsSvcRc->iNumberMbFrame);
|
||||
const int32_t kiBitsPerMb = WELS_DIV_ROUND (static_cast<int64_t> (pWelsSvcRc->iTargetBits) * INT_MULTIPLY,
|
||||
pWelsSvcRc->iNumberMbFrame);
|
||||
|
||||
for (int32_t i = 0; i < kiSliceNum; i++) {
|
||||
pSOverRc->iStartMbSlice =
|
||||
@ -926,7 +927,7 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) {
|
||||
int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pWelsSvcRc->iIdrNum));
|
||||
if (iAlpha < (INT_MULTIPLY / 4)) iAlpha = INT_MULTIPLY / 4;
|
||||
|
||||
int64_t iIntraCmplx = pWelsSvcRc->iQStep * pWelsSvcRc->iFrameDqBits;
|
||||
int64_t iIntraCmplx = pWelsSvcRc->iQStep * static_cast<int64_t> (pWelsSvcRc->iFrameDqBits);
|
||||
pWelsSvcRc->iIntraComplexity = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pWelsSvcRc->iIntraComplexity + iAlpha *
|
||||
iIntraCmplx), INT_MULTIPLY);
|
||||
pWelsSvcRc->iIntraMbCount = pWelsSvcRc->iNumberMbFrame;
|
||||
@ -934,7 +935,8 @@ void RcUpdateIntraComplexity (sWelsEncCtx* pEncCtx) {
|
||||
pWelsSvcRc->iIdrNum++;
|
||||
if (pWelsSvcRc->iIdrNum > 255)
|
||||
pWelsSvcRc->iIdrNum = 255;
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO, "RcUpdateIntraComplexity iFrameDqBits = %d,iQStep= %d,iIntraCmplx = %d",
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_INFO,
|
||||
"RcUpdateIntraComplexity iFrameDqBits = %d,iQStep= %d,iIntraCmplx = %"PRId64,
|
||||
pWelsSvcRc->iFrameDqBits, pWelsSvcRc->iQStep, pWelsSvcRc->iIntraComplexity);
|
||||
}
|
||||
|
||||
@ -953,8 +955,9 @@ void RcUpdateFrameComplexity (sWelsEncCtx* pEncCtx) {
|
||||
int32_t iAlpha = WELS_DIV_ROUND (INT_MULTIPLY, (1 + pTOverRc->iPFrameNum));
|
||||
if (iAlpha < SMOOTH_FACTOR_MIN_VALUE)
|
||||
iAlpha = SMOOTH_FACTOR_MIN_VALUE;
|
||||
pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * pTOverRc->iFrameCmplxMean + iAlpha *
|
||||
pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity), INT_MULTIPLY);
|
||||
pTOverRc->iFrameCmplxMean = WELS_DIV_ROUND (((INT_MULTIPLY - iAlpha) * static_cast<int64_t> (pTOverRc->iFrameCmplxMean)
|
||||
+ iAlpha * pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity),
|
||||
INT_MULTIPLY);
|
||||
|
||||
pTOverRc->iPFrameNum++;
|
||||
if (pTOverRc->iPFrameNum > 255)
|
||||
@ -1139,7 +1142,7 @@ void WelRcPictureInitScc (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
SVAAFrameInfoExt* pVaa = static_cast<SVAAFrameInfoExt*> (pEncCtx->pVaa);
|
||||
SSpatialLayerConfig* pDLayerConfig = &pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId];
|
||||
SSpatialLayerInternal* pDLayerParamInternal = &pEncCtx->pSvcParam->sDependencyLayers[pEncCtx->uiDependencyId];
|
||||
int32_t iFrameCplx = pVaa->sComplexityScreenParam.iFrameComplexity;
|
||||
int64_t iFrameCplx = pVaa->sComplexityScreenParam.iFrameComplexity;
|
||||
int32_t iBitRate = pDLayerConfig->iSpatialBitrate;// pEncCtx->pSvcParam->target_bitrate;
|
||||
|
||||
int32_t iBaseQp = pWelsSvcRc->iBaseQp;
|
||||
@ -1148,13 +1151,13 @@ void WelRcPictureInitScc (sWelsEncCtx* pEncCtx, long long uiTimeStamp) {
|
||||
if (pEncCtx->eSliceType == I_SLICE) {
|
||||
int64_t iTargetBits = iBitRate * 2 - pWelsSvcRc->iBufferFullnessSkip;
|
||||
iTargetBits = WELS_MAX (1, iTargetBits);
|
||||
int32_t iQstep = WELS_DIV_ROUND ((((int64_t)iFrameCplx) * pWelsSvcRc->iCost2BitsIntra), iTargetBits);
|
||||
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);
|
||||
} else {
|
||||
int64_t iTargetBits = WELS_ROUND (((float)iBitRate / pDLayerParamInternal->fOutputFrameRate)); //iBitRate / 10;
|
||||
int32_t iQstep = (int32_t) (WELS_DIV_ROUND64 (iFrameCplx * pWelsSvcRc->iAvgCost2Bits, iTargetBits));
|
||||
int32_t iQstep = WELS_DIV_ROUND (iFrameCplx * pWelsSvcRc->iAvgCost2Bits, iTargetBits);
|
||||
int32_t iQp = RcConvertQStep2Qp (iQstep);
|
||||
iDeltaQp = iQp - iBaseQp;
|
||||
if (pWelsSvcRc->iBufferFullnessSkip > iBitRate) {
|
||||
@ -1319,7 +1322,7 @@ void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp
|
||||
}
|
||||
iLumaQp = WELS_CLIP3 (iLumaQp, MIN_IDR_QP, MAX_IDR_QP);
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"[Rc]I iLumaQp = %d,iQStep = %d,iTargetBits = %d,iBufferFullnessSkip =%"PRId64",iMaxTh=%d,iMinTh = %d,iFrameComplexity= %d",
|
||||
"[Rc]I iLumaQp = %d,iQStep = %d,iTargetBits = %d,iBufferFullnessSkip =%"PRId64",iMaxTh=%d,iMinTh = %d,iFrameComplexity= %"PRId64,
|
||||
iLumaQp, pWelsSvcRc->iQStep, pWelsSvcRc->iTargetBits, pWelsSvcRc->iBufferFullnessSkip, iMaxTh, iMinTh,
|
||||
pWelsSvcRc->iIntraComplexity);
|
||||
|
||||
@ -1358,7 +1361,7 @@ void WelsRcPictureInitGomTimeStamp (sWelsEncCtx* pEncCtx, long long uiTimeStamp
|
||||
iLumaQp = WELS_CLIP3 (iLumaQp, GOM_MIN_QP_MODE, GOM_MAX_QP_MODE);
|
||||
|
||||
WelsLog (& (pEncCtx->sLogCtx), WELS_LOG_DEBUG,
|
||||
"[Rc]P iTl = %d,iLumaQp = %d,iQStep = %d,iTargetBits = %d,iBufferFullnessSkip =%"PRId64",iMaxTh=%d,iMinTh = %d,iFrameComplexity= %d,iCmplxRatio=%"PRId64,
|
||||
"[Rc]P iTl = %d,iLumaQp = %d,iQStep = %d,iTargetBits = %d,iBufferFullnessSkip =%"PRId64",iMaxTh=%d,iMinTh = %d,iFrameComplexity= %lld,iCmplxRatio=%"PRId64,
|
||||
iTl, iLumaQp, pWelsSvcRc->iQStep, pWelsSvcRc->iTargetBits, pWelsSvcRc->iBufferFullnessSkip, iMaxTh, iMinTh,
|
||||
pEncCtx->pVaa->sComplexityAnalysisParam.iFrameComplexity, iCmplxRatio);
|
||||
}
|
||||
|
@ -955,13 +955,13 @@ void CWelsPreProcess::InitRefJudgement (SRefJudgement* pRefJudgement) {
|
||||
pRefJudgement->iMinFrameQp = INT_MAX;
|
||||
}
|
||||
bool CWelsPreProcess::JudgeBestRef (SPicture* pRefPic, const SRefJudgement& sRefJudgement,
|
||||
const int32_t iFrameComplexity, const bool bIsClosestLtrFrame) {
|
||||
const int64_t iFrameComplexity, const bool bIsClosestLtrFrame) {
|
||||
return (bIsClosestLtrFrame ? (iFrameComplexity < sRefJudgement.iMinFrameComplexity11) :
|
||||
((iFrameComplexity < sRefJudgement.iMinFrameComplexity08) || ((iFrameComplexity <= sRefJudgement.iMinFrameComplexity11)
|
||||
&& (pRefPic->iFrameAverageQp < sRefJudgement.iMinFrameQp))));
|
||||
}
|
||||
|
||||
void CWelsPreProcess::SaveBestRefToJudgement (const int32_t iRefPictureAvQP, const int32_t iComplexity,
|
||||
void CWelsPreProcess::SaveBestRefToJudgement (const int32_t iRefPictureAvQP, const int64_t iComplexity,
|
||||
SRefJudgement* pRefJudgement) {
|
||||
pRefJudgement->iMinFrameQp = iRefPictureAvQP;
|
||||
pRefJudgement->iMinFrameComplexity = iComplexity;
|
||||
@ -1077,7 +1077,7 @@ ESceneChangeIdc CWelsPreProcess::DetectSceneChangeScreen (sWelsEncCtx* pCtx, SPi
|
||||
if (ret == 0) {
|
||||
m_pInterfaceVp->Get (iSceneChangeMethodIdx, (void*)&sSceneChangeResult);
|
||||
|
||||
const int32_t iFrameComplexity = sSceneChangeResult.iFrameComplexity;
|
||||
const int64_t iFrameComplexity = sSceneChangeResult.iFrameComplexity;
|
||||
const int32_t iSceneDetectIdc = sSceneChangeResult.eSceneChangeIdc;
|
||||
const int32_t iMotionBlockNum = sSceneChangeResult.iMotionBlockNum;
|
||||
|
||||
|
@ -163,7 +163,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
ESceneChangeIdc eSceneChangeIdc; // SIMILAR_SCENE, MEDIUM_CHANGED_SCENE, LARGE_CHANGED_SCENE
|
||||
int iMotionBlockNum; // Number of motion blocks
|
||||
int iFrameComplexity; // frame complexity
|
||||
long long iFrameComplexity; // frame complexity
|
||||
unsigned char* pStaticBlockIdc; // static block idc
|
||||
SScrollDetectionParam sScrollResult; //results from scroll detection
|
||||
} SSceneChangeResult;
|
||||
@ -222,7 +222,7 @@ typedef struct {
|
||||
int iComplexityAnalysisMode;
|
||||
int iCalcBgd;
|
||||
int iMbNumInGom;
|
||||
int iFrameComplexity;
|
||||
long long iFrameComplexity;
|
||||
int* pGomComplexity;
|
||||
int* pGomForegroundBlockNum;
|
||||
signed char* pBackgroundMbFlag;
|
||||
@ -234,7 +234,7 @@ typedef struct {
|
||||
int iMbRowInGom;
|
||||
int* pGomComplexity;
|
||||
int iGomNumInFrame;
|
||||
int iFrameComplexity;
|
||||
long long iFrameComplexity; //255*255(MaxMbSAD)*36864(MaxFS) make the highest bit of 32-bit integer 1
|
||||
int iIdrFlag;
|
||||
SScrollDetectionParam sScrollResult;
|
||||
} SComplexityAnalysisScreenParam;
|
||||
|
@ -3262,14 +3262,14 @@ struct EncodeOptionParam {
|
||||
};
|
||||
|
||||
static const EncodeOptionParam kOptionParamArray[] = {
|
||||
{0, 30, 600, 460, 1, 400, 15.0, 1},
|
||||
{0, 30, 600, 460, 1, 450, 15.0, 1},
|
||||
{1, 30, 340, 96, 24, 1000, 30.0, 1},
|
||||
{2, 30, 140, 196, 51, 500, 7.5, 1},
|
||||
{3, 30, 110, 296, 50, 500, 7.5, 1},
|
||||
{4, 30, 104, 416, 44, 500, 7.5, 1},
|
||||
{5, 30, 16, 16, 2, 500, 7.5, 1},
|
||||
{6, 30, 32, 16, 2, 500, 7.5, 1},
|
||||
{7, 30, 600, 460, 1, 400, 15.0, 4},
|
||||
{7, 30, 600, 460, 1, 450, 15.0, 4},
|
||||
{8, 30, 340, 96, 24, 1000, 30.0, 2},
|
||||
{9, 30, 140, 196, 51, 500, 7.5, 3},
|
||||
{10, 30, 110, 296, 50, 500, 7.5, 2},
|
||||
|
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