use function pointer as refactoring for further strategy adjustment

This commit is contained in:
Sijia Chen 2014-09-19 14:48:45 +08:00
parent 25cad576b3
commit c480ffdad5
4 changed files with 14 additions and 10 deletions

View File

@ -98,7 +98,7 @@ bool CheckCurMarkFrameNumUsed (sWelsEncCtx* pCtx);
*/ */
void WelsMarkPic (void* pCtx); void WelsMarkPic (void* pCtx);
void InitRefListMgrFunc (SWelsFuncPtrList* pFuncList, EUsageType eUsageType); void InitRefListMgrFunc (SWelsFuncPtrList* pFuncList, const bool bScreenContent);
#ifdef LONG_TERM_REF_DUMP #ifdef LONG_TERM_REF_DUMP
void DumpRef (sWelsEncCtx* ctx); void DumpRef (sWelsEncCtx* ctx);

View File

@ -195,6 +195,7 @@ typedef void (*PUpdateMbMvFunc) (SMVUnitXY* pMvUnit, const SMVUnitXY ksMv);
typedef bool (*PBuildRefListFunc) (void* pCtx, const int32_t iPOC, int32_t iBestLtrRefIdx); typedef bool (*PBuildRefListFunc) (void* pCtx, const int32_t iPOC, int32_t iBestLtrRefIdx);
typedef void (*PMarkPicFunc) (void* pCtx); typedef void (*PMarkPicFunc) (void* pCtx);
typedef bool (*PUpdateRefListFunc) (void* pCtx); typedef bool (*PUpdateRefListFunc) (void* pCtx);
typedef void (*PEndofUpdateRefListFunc) (void* pCtx);
typedef int32_t (*PCavlcParamCalFunc) (int16_t* pCoff, uint8_t* pRun, int16_t* pLevel, int32_t* pTotalCoeffs, typedef int32_t (*PCavlcParamCalFunc) (int16_t* pCoff, uint8_t* pRun, int16_t* pLevel, int32_t* pTotalCoeffs,
int32_t iEndIdx); int32_t iEndIdx);
@ -291,6 +292,7 @@ struct TagWelsFuncPointerList {
PBuildRefListFunc pBuildRefList; PBuildRefListFunc pBuildRefList;
PMarkPicFunc pMarkPic; PMarkPicFunc pMarkPic;
PUpdateRefListFunc pUpdateRefList; PUpdateRefListFunc pUpdateRefList;
PEndofUpdateRefListFunc pEndofUpdateRefList;
PCavlcParamCalFunc pfCavlcParamCal; PCavlcParamCalFunc pfCavlcParamCal;
}; };

View File

@ -218,7 +218,7 @@ int32_t InitFunctionPointers (SWelsFuncPtrList* pFuncList, SWelsSvcCodingParam*
WelsBlockFuncInit (&pFuncList->pfSetNZCZero, uiCpuFlag); WelsBlockFuncInit (&pFuncList->pfSetNZCZero, uiCpuFlag);
InitFillNeighborCacheInterFunc (pFuncList, pParam->bEnableBackgroundDetection); InitFillNeighborCacheInterFunc (pFuncList, pParam->bEnableBackgroundDetection);
InitRefListMgrFunc (pFuncList, pParam->iUsageType); InitRefListMgrFunc (pFuncList, bScreenContent);
return iReturn; return iReturn;
} }

View File

@ -337,7 +337,8 @@ static inline void LTRMarkProcessScreen (sWelsEncCtx* pCtx) {
pRefList->uiLongRefCount++; pRefList->uiLongRefCount++;
} }
static inline void PrefetchNextBuffer (sWelsEncCtx* pCtx) { static void PrefetchNextBuffer (void* pEncCtx) {
sWelsEncCtx* pCtx = (sWelsEncCtx*)pEncCtx;
SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId]; SRefList* pRefList = pCtx->ppRefPicListExt[pCtx->uiDependencyId];
const int32_t kiNumRef = pCtx->pSvcParam->iNumRefFrame; const int32_t kiNumRef = pCtx->pSvcParam->iNumRefFrame;
int32_t i; int32_t i;
@ -438,7 +439,7 @@ bool WelsUpdateRefList (void* pEncCtx) {
pCtx->pVaa->uiMarkLongTermPicIdx = 0; pCtx->pVaa->uiMarkLongTermPicIdx = 0;
} }
} }
PrefetchNextBuffer (pCtx); pCtx->pFuncList->pEndofUpdateRefList (pCtx);
return true; return true;
} }
@ -679,7 +680,8 @@ void WelsUpdateRefSyntax (sWelsEncCtx* pCtx, const int32_t iPOC, const int32_t u
} }
} }
static int32_t UpdateSrcPicList (sWelsEncCtx* pCtx) { static void UpdateSrcPicList (void* pEncCtx) {
sWelsEncCtx* pCtx = (sWelsEncCtx*)pEncCtx;
int32_t iDIdx = pCtx->uiDependencyId; int32_t iDIdx = pCtx->uiDependencyId;
SPicture** pLongRefList = pCtx->ppRefPicListExt[iDIdx]->pLongRefList; SPicture** pLongRefList = pCtx->ppRefPicListExt[iDIdx]->pLongRefList;
SPicture** pLongRefSrcList = &pCtx->pVpp->m_pSpatialPic[iDIdx][0]; SPicture** pLongRefSrcList = &pCtx->pVpp->m_pSpatialPic[iDIdx][0];
@ -709,8 +711,6 @@ static int32_t UpdateSrcPicList (sWelsEncCtx* pCtx) {
WelsExchangeSpatialPictures (&pCtx->pVpp->m_pSpatialPic[iDIdx][0], WelsExchangeSpatialPictures (&pCtx->pVpp->m_pSpatialPic[iDIdx][0],
&pCtx->pVpp->m_pSpatialPic[iDIdx][1 + pCtx->pVaa->uiMarkLongTermPicIdx]); &pCtx->pVpp->m_pSpatialPic[iDIdx][1 + pCtx->pVaa->uiMarkLongTermPicIdx]);
SetUnref (pCtx->pVpp->m_pSpatialPic[iDIdx][0]); SetUnref (pCtx->pVpp->m_pSpatialPic[iDIdx][0]);
return 0;
} }
bool WelsUpdateRefListScreen (void* pEncCtx) { bool WelsUpdateRefListScreen (void* pEncCtx) {
@ -759,7 +759,7 @@ bool WelsUpdateRefListScreen (void* pEncCtx) {
pCtx->pVaa->uiValidLongTermPicIdx = 0; pCtx->pVaa->uiValidLongTermPicIdx = 0;
} }
UpdateSrcPicList (pCtx); pCtx->pFuncList->pEndofUpdateRefList (pCtx);
return true; return true;
} }
bool WelsBuildRefListScreen (void* pEncCtx, const int32_t iPOC, int32_t iBestLtrRefIdx) { bool WelsBuildRefListScreen (void* pEncCtx, const int32_t iPOC, int32_t iBestLtrRefIdx) {
@ -905,15 +905,17 @@ void WelsMarkPicScreen (void* pEncCtx) {
} }
return; return;
} }
void InitRefListMgrFunc (SWelsFuncPtrList* pFuncList, EUsageType eUsageType) { void InitRefListMgrFunc (SWelsFuncPtrList* pFuncList, const bool bScreenContent) {
if (eUsageType == SCREEN_CONTENT_REAL_TIME) { if (bScreenContent) {
pFuncList->pBuildRefList = WelsBuildRefListScreen; pFuncList->pBuildRefList = WelsBuildRefListScreen;
pFuncList->pMarkPic = WelsMarkPicScreen; pFuncList->pMarkPic = WelsMarkPicScreen;
pFuncList->pUpdateRefList = WelsUpdateRefListScreen; pFuncList->pUpdateRefList = WelsUpdateRefListScreen;
pFuncList->pEndofUpdateRefList = UpdateSrcPicList;
} else { } else {
pFuncList->pBuildRefList = WelsBuildRefList; pFuncList->pBuildRefList = WelsBuildRefList;
pFuncList->pMarkPic = WelsMarkPic; pFuncList->pMarkPic = WelsMarkPic;
pFuncList->pUpdateRefList = WelsUpdateRefList; pFuncList->pUpdateRefList = WelsUpdateRefList;
pFuncList->pEndofUpdateRefList = PrefetchNextBuffer;
} }
} }
} // namespace WelsEnc } // namespace WelsEnc