add function pointer
This commit is contained in:
parent
c1817891b5
commit
a60af6a750
@ -84,7 +84,9 @@ SMVUnitXY sMv;
|
|||||||
|
|
||||||
#define COST_MVD(table, mx, my) (table[mx] + table[my])
|
#define COST_MVD(table, mx, my) (table[mx] + table[my])
|
||||||
|
|
||||||
|
// Function definitions below
|
||||||
|
|
||||||
|
void WelsInitMeFunc( SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag, bool bScreenContent );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief BL mb motion estimate search
|
* \brief BL mb motion estimate search
|
||||||
|
@ -134,11 +134,16 @@ typedef int32_t (*PIntraPred8x8Combined3Func) (uint8_t*, int32_t, uint8_t*, int3
|
|||||||
uint8_t*, uint8_t*);
|
uint8_t*, uint8_t*);
|
||||||
|
|
||||||
typedef void (*PMotionSearchFunc) (SWelsFuncPtrList* pFuncList, void* pCurDqLayer, void* pMe,
|
typedef void (*PMotionSearchFunc) (SWelsFuncPtrList* pFuncList, void* pCurDqLayer, void* pMe,
|
||||||
void* pSlice); // here after reset all function pointers, will set as right parameter type
|
void* pSlice);
|
||||||
typedef void (*PCalculateSatdFunc) ( PSampleSadSatdCostFunc pSatd, void * vpMe, const int32_t kiEncStride, const int32_t kiRefStride );
|
typedef void (*PCalculateSatdFunc) ( PSampleSadSatdCostFunc pSatd, void * vpMe, const int32_t kiEncStride, const int32_t kiRefStride );
|
||||||
typedef bool (*PCheckDirectionalMv) (PSampleSadSatdCostFunc pSad, void * vpMe,
|
typedef bool (*PCheckDirectionalMv) (PSampleSadSatdCostFunc pSad, void * vpMe,
|
||||||
const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
|
const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
|
||||||
int32_t& iBestSadCost);
|
int32_t& iBestSadCost);
|
||||||
|
typedef void (*PLineFullSearchFunc) ( void *pFunc, void *vpMe,
|
||||||
|
uint16_t* pMvdTable, const int32_t kiFixedMvd,
|
||||||
|
const int32_t kiEncStride, const int32_t kiRefStride,
|
||||||
|
const int32_t kiMinPos, const int32_t kiMaxPos,
|
||||||
|
const bool bVerticalSearch );
|
||||||
|
|
||||||
#define MAX_BLOCK_TYPE 5 // prev 7
|
#define MAX_BLOCK_TYPE 5 // prev 7
|
||||||
typedef struct TagSampleDealingFunc {
|
typedef struct TagSampleDealingFunc {
|
||||||
@ -192,6 +197,7 @@ struct TagWelsFuncPointerList {
|
|||||||
pfMotionSearch; //svc_encode_slice.c svc_mode_decision.c svc_enhance_layer_md.c svc_base_layer_md.c
|
pfMotionSearch; //svc_encode_slice.c svc_mode_decision.c svc_enhance_layer_md.c svc_base_layer_md.c
|
||||||
PCalculateSatdFunc pfCalculateSatd;
|
PCalculateSatdFunc pfCalculateSatd;
|
||||||
PCheckDirectionalMv pfCheckDirectionalMv;
|
PCheckDirectionalMv pfCheckDirectionalMv;
|
||||||
|
PLineFullSearchFunc pfLineFullSearch;
|
||||||
|
|
||||||
PCopyFunc pfCopy16x16Aligned; //svc_encode_slice.c svc_mode_decision.c svc_base_layer_md.c
|
PCopyFunc pfCopy16x16Aligned; //svc_encode_slice.c svc_mode_decision.c svc_base_layer_md.c
|
||||||
PCopyFunc pfCopy16x16NotAligned; //md.c
|
PCopyFunc pfCopy16x16NotAligned; //md.c
|
||||||
|
@ -185,6 +185,9 @@ int32_t InitFunctionPointers (SWelsFuncPtrList* pFuncList, SWelsSvcCodingParam*
|
|||||||
WelsInitFillingPredFuncs (uiCpuFlag);
|
WelsInitFillingPredFuncs (uiCpuFlag);
|
||||||
WelsInitIntraPredFuncs (pFuncList, uiCpuFlag);
|
WelsInitIntraPredFuncs (pFuncList, uiCpuFlag);
|
||||||
|
|
||||||
|
/* ME func */
|
||||||
|
WelsInitMeFunc(pFuncList, uiCpuFlag, SCREEN_CONTENT_REAL_TIME==pParam->iUsageType);
|
||||||
|
|
||||||
/* sad, satd, average */
|
/* sad, satd, average */
|
||||||
WelsInitSampleSadFunc (pFuncList, uiCpuFlag);
|
WelsInitSampleSadFunc (pFuncList, uiCpuFlag);
|
||||||
|
|
||||||
|
@ -2515,7 +2515,6 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) {
|
|||||||
pFuncList->pfMotionSearch = WelsMotionEstimateSearch;
|
pFuncList->pfMotionSearch = WelsMotionEstimateSearch;
|
||||||
pFuncList->pfFirstIntraMode = WelsMdFirstIntraMode;
|
pFuncList->pfFirstIntraMode = WelsMdFirstIntraMode;
|
||||||
pFuncList->sSampleDealingFuncs.pfMeCost = pCtx->pFuncList->sSampleDealingFuncs.pfSampleSatd;
|
pFuncList->sSampleDealingFuncs.pfMeCost = pCtx->pFuncList->sSampleDealingFuncs.pfSampleSatd;
|
||||||
pFuncList->pfCheckDirectionalMv = CheckDirectionalMvFalse;
|
|
||||||
if (kbHighestSpatialLayer) {
|
if (kbHighestSpatialLayer) {
|
||||||
pFuncList->pfCalculateSatd = NotCalculateSatdCost;
|
pFuncList->pfCalculateSatd = NotCalculateSatdCost;
|
||||||
pFuncList->pfInterFineMd = WelsMdInterFinePartitionVaa;
|
pFuncList->pfInterFineMd = WelsMdInterFinePartitionVaa;
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
*************************************************************************************
|
*************************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "cpu_core.h"
|
||||||
#include "sample.h"
|
#include "sample.h"
|
||||||
#include "svc_motion_estimate.h"
|
#include "svc_motion_estimate.h"
|
||||||
|
|
||||||
@ -58,6 +58,19 @@ static inline void MeEndIntepelSearch( SWelsME * pMe )
|
|||||||
pMe->uiSatdCost = pMe->uiSadCost;
|
pMe->uiSatdCost = pMe->uiSadCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WelsInitMeFunc( SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag, bool bScreenContent ) {
|
||||||
|
if (!bScreenContent) {
|
||||||
|
pFuncList->pfCheckDirectionalMv = CheckDirectionalMvFalse;
|
||||||
|
} else {
|
||||||
|
pFuncList->pfCheckDirectionalMv = CheckDirectionalMv;
|
||||||
|
|
||||||
|
//for cross serarch
|
||||||
|
pFuncList->pfLineFullSearch = LineFullSearch_c;
|
||||||
|
pFuncList->pfLineFullSearch = LineFullSearch_c;
|
||||||
|
if ( uiCpuFlag & WELS_CPU_SSE41 ) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief BL mb motion estimate search
|
* \brief BL mb motion estimate search
|
||||||
@ -234,22 +247,21 @@ void WelsMotionEstimateIterativeSearch (SWelsFuncPtrList* pFuncList, SWelsME* pM
|
|||||||
pMe->pRefMb = pRefMb;
|
pMe->pRefMb = pRefMb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalculateSatdCost( PSampleSadSatdCostFunc pSatd, void * vpMe, const int32_t kiEncStride, const int32_t kiRefStride )
|
void CalculateSatdCost( PSampleSadSatdCostFunc pSatd, void * vpMe,
|
||||||
{
|
const int32_t kiEncStride, const int32_t kiRefStride ) {
|
||||||
SWelsME* pMe = static_cast<SWelsME *>(vpMe);
|
SWelsME* pMe = static_cast<SWelsME *>(vpMe);
|
||||||
pMe->uSadPredISatd.uiSatd = pSatd(pMe->pEncMb, kiEncStride, pMe->pRefMb, kiRefStride);
|
pMe->uSadPredISatd.uiSatd = pSatd(pMe->pEncMb, kiEncStride, pMe->pRefMb, kiRefStride);
|
||||||
pMe->uiSatdCost = pMe->uSadPredISatd.uiSatd + COST_MVD (pMe->pMvdCost, pMe->sMv.iMvX - pMe->sMvp.iMvX,
|
pMe->uiSatdCost = pMe->uSadPredISatd.uiSatd + COST_MVD (pMe->pMvdCost, pMe->sMv.iMvX - pMe->sMvp.iMvX,
|
||||||
pMe->sMv.iMvY - pMe->sMvp.iMvY);
|
pMe->sMv.iMvY - pMe->sMvp.iMvY);
|
||||||
}
|
}
|
||||||
void NotCalculateSatdCost( PSampleSadSatdCostFunc pSatd, void * vpMe, const int32_t kiEncStride, const int32_t kiRefStride )
|
void NotCalculateSatdCost( PSampleSadSatdCostFunc pSatd, void * vpMe,
|
||||||
{
|
const int32_t kiEncStride, const int32_t kiRefStride ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CheckDirectionalMv(PSampleSadSatdCostFunc pSad, void * vpMe,
|
bool CheckDirectionalMv(PSampleSadSatdCostFunc pSad, void * vpMe,
|
||||||
const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
|
const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
|
||||||
int32_t& iBestSadCost)
|
int32_t& iBestSadCost) {
|
||||||
{
|
|
||||||
SWelsME* pMe = static_cast<SWelsME *>(vpMe);
|
SWelsME* pMe = static_cast<SWelsME *>(vpMe);
|
||||||
const int16_t kiMvX = pMe->sDirectionalMv.iMvX;
|
const int16_t kiMvX = pMe->sDirectionalMv.iMvX;
|
||||||
const int16_t kiMvY = pMe->sDirectionalMv.iMvY;
|
const int16_t kiMvY = pMe->sDirectionalMv.iMvY;
|
||||||
@ -257,13 +269,11 @@ bool CheckDirectionalMv(PSampleSadSatdCostFunc pSad, void * vpMe,
|
|||||||
//Check MV from scrolling detection
|
//Check MV from scrolling detection
|
||||||
if ( (BLOCK_16x16!=pMe->uiBlockSize) //scrolled_MV with P16x16 is checked SKIP checking function
|
if ( (BLOCK_16x16!=pMe->uiBlockSize) //scrolled_MV with P16x16 is checked SKIP checking function
|
||||||
&& ( kiMvX | kiMvY ) //(0,0) checked in ordinary initial point checking
|
&& ( kiMvX | kiMvY ) //(0,0) checked in ordinary initial point checking
|
||||||
&& CheckMvInRange( pMe->sDirectionalMv, ksMinMv, ksMaxMv ) )
|
&& CheckMvInRange( pMe->sDirectionalMv, ksMinMv, ksMaxMv ) ) {
|
||||||
{
|
|
||||||
uint8_t* pRef = &pMe->pColoRefMb[kiMvY * kiRefStride + kiMvX];
|
uint8_t* pRef = &pMe->pColoRefMb[kiMvY * kiRefStride + kiMvX];
|
||||||
uint32_t uiCurrentSadCost = pSad( pMe->pEncMb, kiEncStride, pRef, kiRefStride ) +
|
uint32_t uiCurrentSadCost = pSad( pMe->pEncMb, kiEncStride, pRef, kiRefStride ) +
|
||||||
COST_MVD(pMe->pMvdCost, (kiMvX<<2) - pMe->sMvp.iMvX, (kiMvY<<2) - pMe->sMvp.iMvY );
|
COST_MVD(pMe->pMvdCost, (kiMvX<<2) - pMe->sMvp.iMvX, (kiMvY<<2) - pMe->sMvp.iMvY );
|
||||||
if( uiCurrentSadCost < pMe->uiSadCost )
|
if( uiCurrentSadCost < pMe->uiSadCost ) {
|
||||||
{
|
|
||||||
iBestSadCost = uiCurrentSadCost;
|
iBestSadCost = uiCurrentSadCost;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -273,8 +283,7 @@ bool CheckDirectionalMv(PSampleSadSatdCostFunc pSad, void * vpMe,
|
|||||||
|
|
||||||
bool CheckDirectionalMvFalse(PSampleSadSatdCostFunc pSad, void * vpMe,
|
bool CheckDirectionalMvFalse(PSampleSadSatdCostFunc pSad, void * vpMe,
|
||||||
const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
|
const SMVUnitXY ksMinMv, const SMVUnitXY ksMaxMv, const int32_t kiEncStride, const int32_t kiRefStride,
|
||||||
int32_t& iBestSadCost)
|
int32_t& iBestSadCost) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,8 +291,7 @@ void VerticalFullSearchUsingSSE41( void *pFunc, void *vpMe,
|
|||||||
uint16_t* pMvdTable, const int32_t kiFixedMvd,
|
uint16_t* pMvdTable, const int32_t kiFixedMvd,
|
||||||
const int32_t kiEncStride, const int32_t kiRefStride,
|
const int32_t kiEncStride, const int32_t kiRefStride,
|
||||||
const int32_t kiMinPos, const int32_t kiMaxPos,
|
const int32_t kiMinPos, const int32_t kiMaxPos,
|
||||||
const bool bVerticalSearch )
|
const bool bVerticalSearch ) {
|
||||||
{
|
|
||||||
SWelsFuncPtrList *pFuncList = static_cast<SWelsFuncPtrList *>(pFunc);
|
SWelsFuncPtrList *pFuncList = static_cast<SWelsFuncPtrList *>(pFunc);
|
||||||
SWelsME *pMe = static_cast<SWelsME *>(vpMe);
|
SWelsME *pMe = static_cast<SWelsME *>(vpMe);
|
||||||
}
|
}
|
||||||
@ -291,8 +299,7 @@ void LineFullSearch_c( void *pFunc, void *vpMe,
|
|||||||
uint16_t* pMvdTable, const int32_t kiFixedMvd,
|
uint16_t* pMvdTable, const int32_t kiFixedMvd,
|
||||||
const int32_t kiEncStride, const int32_t kiRefStride,
|
const int32_t kiEncStride, const int32_t kiRefStride,
|
||||||
const int32_t kiMinPos, const int32_t kiMaxPos,
|
const int32_t kiMinPos, const int32_t kiMaxPos,
|
||||||
const bool bVerticalSearch )
|
const bool bVerticalSearch ) {
|
||||||
{
|
|
||||||
SWelsFuncPtrList *pFuncList = static_cast<SWelsFuncPtrList *>(pFunc);
|
SWelsFuncPtrList *pFuncList = static_cast<SWelsFuncPtrList *>(pFunc);
|
||||||
SWelsME *pMe = static_cast<SWelsME *>(vpMe);
|
SWelsME *pMe = static_cast<SWelsME *>(vpMe);
|
||||||
PSampleSadSatdCostFunc pSad = pFuncList->sSampleDealingFuncs.pfSampleSad[pMe->uiBlockSize];
|
PSampleSadSatdCostFunc pSad = pFuncList->sSampleDealingFuncs.pfSampleSad[pMe->uiBlockSize];
|
||||||
@ -323,11 +330,9 @@ void LineFullSearch_c( void *pFunc, void *vpMe,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WelsMotionCrossSearch(SWelsFuncPtrList *pFuncList, SDqLayer* pCurLayer, SWelsME * pMe,
|
void WelsMotionCrossSearch(SWelsFuncPtrList *pFuncList, SDqLayer* pCurLayer, SWelsME * pMe,
|
||||||
const SSlice* pSlice)
|
const SSlice* pSlice) {
|
||||||
{
|
PLineFullSearchFunc pfVerticalFullSearchFunc = pFuncList->pfLineFullSearch;
|
||||||
//TODO:
|
PLineFullSearchFunc pfHorizontalFullSearchFunc = pFuncList->pfLineFullSearch;
|
||||||
//PMOTION_VERFULL_SEARCH VerticalFullSearchFunc = pFuncList->VerticalFullSearch_c;
|
|
||||||
//PMOTION_HORFULL_SEARCH HorizontalFullSearchFunc = pFuncList->HorizontalFullSearch_c;
|
|
||||||
const int32_t kiEncStride = pCurLayer->iEncStride[0];
|
const int32_t kiEncStride = pCurLayer->iEncStride[0];
|
||||||
const int32_t kiRefStride = pCurLayer->pRefPic->iLineSize[0];
|
const int32_t kiRefStride = pCurLayer->pRefPic->iLineSize[0];
|
||||||
|
|
||||||
@ -339,7 +344,7 @@ void WelsMotionCrossSearch(SWelsFuncPtrList *pFuncList, SDqLayer* pCurLayer, SW
|
|||||||
uint16_t* pMvdCostY = pMe->pMvdCost - iCurMeBlockQpelPixY - pMe->sMvp.iMvY;//do the offset here instead of in the search
|
uint16_t* pMvdCostY = pMe->pMvdCost - iCurMeBlockQpelPixY - pMe->sMvp.iMvY;//do the offset here instead of in the search
|
||||||
|
|
||||||
//vertical search
|
//vertical search
|
||||||
LineFullSearch_c( pFuncList, pMe,
|
pfVerticalFullSearchFunc( pFuncList, pMe,
|
||||||
pMvdCostY, pMvdCostX[ iCurMeBlockQpelPixX ],
|
pMvdCostY, pMvdCostX[ iCurMeBlockQpelPixX ],
|
||||||
kiEncStride, kiRefStride,
|
kiEncStride, kiRefStride,
|
||||||
iCurMeBlockPixY + pSlice->sMvStartMin.iMvY,
|
iCurMeBlockPixY + pSlice->sMvStartMin.iMvY,
|
||||||
@ -347,7 +352,7 @@ void WelsMotionCrossSearch(SWelsFuncPtrList *pFuncList, SDqLayer* pCurLayer, SW
|
|||||||
|
|
||||||
//horizontal search
|
//horizontal search
|
||||||
if (pMe->uiSadCost >= pMe->uiSadCostThreshold) {
|
if (pMe->uiSadCost >= pMe->uiSadCostThreshold) {
|
||||||
LineFullSearch_c( pFuncList, pMe,
|
pfHorizontalFullSearchFunc( pFuncList, pMe,
|
||||||
pMvdCostX, pMvdCostY[ iCurMeBlockQpelPixY ],
|
pMvdCostX, pMvdCostY[ iCurMeBlockQpelPixY ],
|
||||||
kiEncStride, kiRefStride,
|
kiEncStride, kiRefStride,
|
||||||
iCurMeBlockPixX + pSlice->sMvStartMin.iMvX,
|
iCurMeBlockPixX + pSlice->sMvStartMin.iMvX,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user