using function pointer to make different branch for different rc
This commit is contained in:
parent
c1752e2818
commit
e3bf63db59
@ -252,6 +252,10 @@ typedef void (*PWelsRCPictureDelayJudgeFunc) (void* pCtx, EVideoFrameType eFram
|
||||
typedef void (*PWelsRCPictureInfoUpdateFunc) (void* pCtx, int32_t iLayerSize);
|
||||
typedef void (*PWelsRCMBInfoUpdateFunc) (void* pCtx, SMB* pCurMb, int32_t iCostLuma, SSlice* pSlice);
|
||||
typedef void (*PWelsRCMBInitFunc) (void* pCtx, SMB* pCurMb, SSlice* pSlice);
|
||||
typedef bool (*PWelsCheckFrameSkipBasedMaxbrFunc) (void* pCtx, int32_t iSpatialNum, EVideoFrameType eFrameType,
|
||||
const uint32_t uiTimeStamp);
|
||||
typedef void (*PWelsUpdateBufferWhenFrameSkippedFunc)(void* pCtx, int32_t iSpatialNum);
|
||||
typedef void (*PWelsUpdateMaxBrCheckWindowStatusFunc)(void* pCtx, int32_t iSpatialNum, const long long uiTimeStamp);
|
||||
|
||||
typedef struct WelsRcFunc_s {
|
||||
PWelsRCPictureInitFunc pfWelsRcPictureInit;
|
||||
@ -259,6 +263,9 @@ PWelsRCPictureDelayJudgeFunc pfWelsRcPicDelayJudge;
|
||||
PWelsRCPictureInfoUpdateFunc pfWelsRcPictureInfoUpdate;
|
||||
PWelsRCMBInitFunc pfWelsRcMbInit;
|
||||
PWelsRCMBInfoUpdateFunc pfWelsRcMbInfoUpdate;
|
||||
PWelsCheckFrameSkipBasedMaxbrFunc pfWelsCheckSkipBasedMaxbr;
|
||||
PWelsUpdateBufferWhenFrameSkippedFunc pfWelsUpdateBufferWhenSkip;
|
||||
PWelsUpdateMaxBrCheckWindowStatusFunc pfWelsUpdateMaxBrWindowStatus;
|
||||
} SWelsRcFunc;
|
||||
|
||||
bool CheckFrameSkipBasedMaxbr (void* pCtx, int32_t iSpatialNum, EVideoFrameType eFrameType,
|
||||
|
@ -3101,8 +3101,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
||||
// perform csc/denoise/downsample/padding, generate spatial layers
|
||||
iSpatialNum = pCtx->pVpp->BuildSpatialPicList (pCtx, pSrcPic);
|
||||
|
||||
if (pCtx->pSvcParam->bEnableFrameSkip) {
|
||||
UpdateMaxBrCheckWindowStatus (pCtx, iSpatialNum, pSrcPic->uiTimeStamp);
|
||||
if (pCtx->pFuncList->pfRc.pfWelsUpdateMaxBrWindowStatus) {
|
||||
pCtx->pFuncList->pfRc.pfWelsUpdateMaxBrWindowStatus (pCtx, iSpatialNum, pSrcPic->uiTimeStamp);
|
||||
}
|
||||
|
||||
if (iSpatialNum < 1) { // skip due to temporal layer settings (different frame rate)
|
||||
@ -3115,7 +3115,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
||||
|
||||
eFrameType = DecideFrameType (pCtx, iSpatialNum);
|
||||
if (eFrameType == videoFrameTypeSkip) {
|
||||
UpdateBufferWhenFrameSkipped (pCtx, iSpatialNum);
|
||||
if (pCtx->pFuncList->pfRc.pfWelsUpdateBufferWhenSkip)
|
||||
pCtx->pFuncList->pfRc.pfWelsUpdateBufferWhenSkip (pCtx, iSpatialNum);
|
||||
pFbi->eFrameType = eFrameType;
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, skip one frame, continual skipped %d frames",
|
||||
pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames);
|
||||
@ -3123,11 +3124,15 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
|
||||
}
|
||||
|
||||
//loop each layer to check if have skip frame when RC and frame skip enable
|
||||
if (CheckFrameSkipBasedMaxbr (pCtx, iSpatialNum, eFrameType, (uint32_t)pSrcPic->uiTimeStamp)) {
|
||||
pFbi->eFrameType = videoFrameTypeSkip;
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, skip one frame, continual skipped %d frames",
|
||||
pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames);
|
||||
return ENC_RETURN_SUCCESS;
|
||||
if (pCtx->pFuncList->pfRc.pfWelsCheckSkipBasedMaxbr) {
|
||||
bool bSkip = pCtx->pFuncList->pfRc.pfWelsCheckSkipBasedMaxbr (pCtx, iSpatialNum, eFrameType,
|
||||
(uint32_t)pSrcPic->uiTimeStamp);
|
||||
if (bSkip) {
|
||||
pFbi->eFrameType = videoFrameTypeSkip;
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG, "[Rc] Frame timestamp = %lld, skip one frame, continual skipped %d frames",
|
||||
pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames);
|
||||
return ENC_RETURN_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
pCtx->iContinualSkipFrames = 0;
|
||||
|
@ -1296,6 +1296,9 @@ void WelsRcInitModule (void* pCtx, RC_MODES iRcMode) {
|
||||
pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateDisable;
|
||||
pRcf->pfWelsRcMbInit = WelsRcMbInitDisable;
|
||||
pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateDisable;
|
||||
pRcf->pfWelsCheckSkipBasedMaxbr = NULL;
|
||||
pRcf->pfWelsUpdateBufferWhenSkip = NULL;
|
||||
pRcf->pfWelsUpdateMaxBrWindowStatus = NULL;
|
||||
break;
|
||||
case RC_BUFFERBASED_MODE:
|
||||
pRcf->pfWelsRcPictureInit = WelRcPictureInitBufferBasedQp;
|
||||
@ -1303,6 +1306,10 @@ void WelsRcInitModule (void* pCtx, RC_MODES iRcMode) {
|
||||
pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateDisable;
|
||||
pRcf->pfWelsRcMbInit = WelsRcMbInitDisable;
|
||||
pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateDisable;
|
||||
pRcf->pfWelsCheckSkipBasedMaxbr = NULL;
|
||||
pRcf->pfWelsUpdateBufferWhenSkip = NULL;
|
||||
pRcf->pfWelsUpdateMaxBrWindowStatus = NULL;
|
||||
|
||||
break;
|
||||
case RC_BITRATE_MODE:
|
||||
if (pEncCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) {
|
||||
@ -1311,6 +1318,10 @@ void WelsRcInitModule (void* pCtx, RC_MODES iRcMode) {
|
||||
pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateScc;
|
||||
pRcf->pfWelsRcMbInit = WelsRcMbInitScc;
|
||||
pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateDisable;
|
||||
pRcf->pfWelsCheckSkipBasedMaxbr = CheckFrameSkipBasedMaxbr;
|
||||
pRcf->pfWelsUpdateBufferWhenSkip = NULL;
|
||||
pRcf->pfWelsUpdateMaxBrWindowStatus = NULL;
|
||||
|
||||
InitRcModuleScc (pEncCtx);
|
||||
|
||||
} else {
|
||||
@ -1319,6 +1330,10 @@ void WelsRcInitModule (void* pCtx, RC_MODES iRcMode) {
|
||||
pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateGom;
|
||||
pRcf->pfWelsRcMbInit = WelsRcMbInitGom;
|
||||
pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateGom;
|
||||
pRcf->pfWelsCheckSkipBasedMaxbr = CheckFrameSkipBasedMaxbr;
|
||||
pRcf->pfWelsUpdateBufferWhenSkip = UpdateBufferWhenFrameSkipped;
|
||||
pRcf->pfWelsUpdateMaxBrWindowStatus = UpdateMaxBrCheckWindowStatus;
|
||||
|
||||
}
|
||||
break;
|
||||
case RC_QUALITY_MODE:
|
||||
@ -1328,6 +1343,10 @@ void WelsRcInitModule (void* pCtx, RC_MODES iRcMode) {
|
||||
pRcf->pfWelsRcPictureInfoUpdate = WelsRcPictureInfoUpdateGom;
|
||||
pRcf->pfWelsRcMbInit = WelsRcMbInitGom;
|
||||
pRcf->pfWelsRcMbInfoUpdate = WelsRcMbInfoUpdateGom;
|
||||
pRcf->pfWelsCheckSkipBasedMaxbr = CheckFrameSkipBasedMaxbr;
|
||||
pRcf->pfWelsUpdateBufferWhenSkip = UpdateBufferWhenFrameSkipped;
|
||||
pRcf->pfWelsUpdateMaxBrWindowStatus = UpdateMaxBrCheckWindowStatus;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
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