Merge pull request #1759 from mstorsjo/enc-mc-ut
Add unit tests for encoder MC
This commit is contained in:
commit
d9ee702031
@ -133,10 +133,10 @@ static inline void McCopyWidthEq16_c (const uint8_t* pSrc, int32_t iSrcStride, u
|
|||||||
|
|
||||||
//--------------------Luma sample MC------------------//
|
//--------------------Luma sample MC------------------//
|
||||||
|
|
||||||
static inline int32_t HorFilterInput16bit_c (int16_t* pSrc) {
|
static inline int32_t HorFilterInput16bit_c (const int16_t* pSrc) {
|
||||||
int32_t iPix05 = pSrc[-2] + pSrc[3];
|
int32_t iPix05 = pSrc[0] + pSrc[5];
|
||||||
int32_t iPix14 = pSrc[-1] + pSrc[2];
|
int32_t iPix14 = pSrc[1] + pSrc[4];
|
||||||
int32_t iPix23 = pSrc[ 0] + pSrc[1];
|
int32_t iPix23 = pSrc[2] + pSrc[3];
|
||||||
|
|
||||||
return (iPix05 - (iPix14 * 5) + (iPix23 * 20));
|
return (iPix05 - (iPix14 * 5) + (iPix23 * 20));
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ static inline void McHorVer22_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_
|
|||||||
iTmp[j] = FilterInput8bitWithStride_c (pSrc - 2 + j, iSrcStride);
|
iTmp[j] = FilterInput8bitWithStride_c (pSrc - 2 + j, iSrcStride);
|
||||||
}
|
}
|
||||||
for (k = 0; k < iWidth; k++) {
|
for (k = 0; k < iWidth; k++) {
|
||||||
pDst[k] = WelsClip1 ((HorFilterInput16bit_c (&iTmp[2 + k]) + 512) >> 10);
|
pDst[k] = WelsClip1 ((HorFilterInput16bit_c (&iTmp[k]) + 512) >> 10);
|
||||||
}
|
}
|
||||||
pSrc += iSrcStride;
|
pSrc += iSrcStride;
|
||||||
pDst += iDstStride;
|
pDst += iDstStride;
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
//x y means dx(mv[0] & 3) and dy(mv[1] & 3)
|
//x y means dx(mv[0] & 3) and dy(mv[1] & 3)
|
||||||
|
|
||||||
namespace WelsEnc {
|
namespace WelsEnc {
|
||||||
void WelsInitMcFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag);
|
void WelsInitMcFuncs (SMcFunc* pMcFuncs, uint32_t uiCpuFlag);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif//WELS_MC_H__
|
#endif//WELS_MC_H__
|
||||||
|
@ -75,7 +75,7 @@ typedef int32_t (*PQuantizationHadamardFunc) (int16_t* pRes, const int16_t kiFF,
|
|||||||
int16_t* pBlock);
|
int16_t* pBlock);
|
||||||
|
|
||||||
typedef void (*PWelsMcFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
typedef void (*PWelsMcFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||||
SMVUnitXY mv, int32_t iWidth, int32_t iHeight);
|
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight);
|
||||||
|
|
||||||
typedef void (*PWelsLumaHalfpelMcFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
typedef void (*PWelsLumaHalfpelMcFunc) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||||
int32_t iWidth, int32_t iHeight);
|
int32_t iWidth, int32_t iHeight);
|
||||||
|
@ -209,7 +209,7 @@ int32_t InitFunctionPointers (sWelsEncCtx* pEncCtx, SWelsSvcCodingParam* pParam,
|
|||||||
/* Motion compensation */
|
/* Motion compensation */
|
||||||
/*init pixel average function*/
|
/*init pixel average function*/
|
||||||
/*get one column or row pixel when refinement*/
|
/*get one column or row pixel when refinement*/
|
||||||
WelsInitMcFuncs (pFuncList, uiCpuFlag);
|
WelsInitMcFuncs (&pFuncList->sMcFuncs, uiCpuFlag);
|
||||||
InitCoeffFunc (pFuncList,uiCpuFlag,pParam->iEntropyCodingModeFlag);
|
InitCoeffFunc (pFuncList,uiCpuFlag,pParam->iEntropyCodingModeFlag);
|
||||||
|
|
||||||
WelsInitEncodingFuncs (pFuncList, uiCpuFlag);
|
WelsInitEncodingFuncs (pFuncList, uiCpuFlag);
|
||||||
|
@ -125,10 +125,10 @@ static inline int32_t HorFilter_c (const uint8_t* pSrc) {
|
|||||||
return (iPix05 - ((iPix14 << 2) + iPix14) + (iPix23 << 4) + (iPix23 << 2));
|
return (iPix05 - ((iPix14 << 2) + iPix14) + (iPix23 << 4) + (iPix23 << 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int32_t HorFilterInput16bit1_c (int16_t* pSrc) {
|
static inline int32_t HorFilterInput16bit1_c (const int16_t* pSrc) {
|
||||||
int32_t iPix05 = pSrc[-2] + pSrc[3];
|
int32_t iPix05 = pSrc[0] + pSrc[5];
|
||||||
int32_t iPix14 = pSrc[-1] + pSrc[2];
|
int32_t iPix14 = pSrc[1] + pSrc[4];
|
||||||
int32_t iPix23 = pSrc[ 0] + pSrc[1];
|
int32_t iPix23 = pSrc[2] + pSrc[3];
|
||||||
|
|
||||||
return (iPix05 - ((iPix14 << 2) + iPix14) + (iPix23 << 4) + (iPix23 << 2));
|
return (iPix05 - ((iPix14 << 2) + iPix14) + (iPix23 << 4) + (iPix23 << 2));
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ static inline void McHorVer22WidthEq16_c (const uint8_t* pSrc, int32_t iSrcStrid
|
|||||||
pTmp[j] = VerFilter_c (pSrc - 2 + j, iSrcStride);
|
pTmp[j] = VerFilter_c (pSrc - 2 + j, iSrcStride);
|
||||||
}
|
}
|
||||||
for (k = 0; k < 16; k++) {
|
for (k = 0; k < 16; k++) {
|
||||||
pDst[k] = WelsClip1 ((HorFilterInput16bit1_c (&pTmp[2 + k]) + 512) >> 10);
|
pDst[k] = WelsClip1 ((HorFilterInput16bit1_c (&pTmp[k]) + 512) >> 10);
|
||||||
}
|
}
|
||||||
pSrc += iSrcStride;
|
pSrc += iSrcStride;
|
||||||
pDst += iDstStride;
|
pDst += iDstStride;
|
||||||
@ -342,7 +342,7 @@ static inline void McHorVer22_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_
|
|||||||
pTmp[j] = VerFilter_c (pSrc - 2 + j, iSrcStride);
|
pTmp[j] = VerFilter_c (pSrc - 2 + j, iSrcStride);
|
||||||
}
|
}
|
||||||
for (k = 0; k < iWidth; k++) {
|
for (k = 0; k < iWidth; k++) {
|
||||||
pDst[k] = WelsClip1 ((HorFilterInput16bit1_c (&pTmp[2 + k]) + 512) >> 10);
|
pDst[k] = WelsClip1 ((HorFilterInput16bit1_c (&pTmp[k]) + 512) >> 10);
|
||||||
}
|
}
|
||||||
pSrc += iSrcStride;
|
pSrc += iSrcStride;
|
||||||
pDst += iDstStride;
|
pDst += iDstStride;
|
||||||
@ -367,11 +367,11 @@ static inline void McCopy_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* p
|
|||||||
}
|
}
|
||||||
|
|
||||||
void McChroma_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
void McChroma_c (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||||
SMVUnitXY mv, int32_t iWidth, int32_t iHeight)
|
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight)
|
||||||
//pSrc has been added the offset of mv
|
//pSrc has been added the offset of mv
|
||||||
{
|
{
|
||||||
const int32_t kiDx = mv.iMvX & 0x07;
|
const int32_t kiDx = iMvX & 0x07;
|
||||||
const int32_t kiDy = mv.iMvY & 0x07;
|
const int32_t kiDy = iMvY & 0x07;
|
||||||
|
|
||||||
if (0 == kiDx && 0 == kiDy) {
|
if (0 == kiDx && 0 == kiDy) {
|
||||||
McCopy_c (pSrc, iSrcStride, pDst, iDstStride, iWidth, iHeight);
|
McCopy_c (pSrc, iSrcStride, pDst, iDstStride, iWidth, iHeight);
|
||||||
@ -543,9 +543,9 @@ static inline void McCopy_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t
|
|||||||
typedef void (*McChromaWidthEqx) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
typedef void (*McChromaWidthEqx) (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||||
const uint8_t* pABCD, int32_t iHeigh);
|
const uint8_t* pABCD, int32_t iHeigh);
|
||||||
void McChroma_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
void McChroma_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||||
SMVUnitXY sMv, int32_t iWidth, int32_t iHeight) {
|
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight) {
|
||||||
const int32_t kiD8x = sMv.iMvX & 0x07;
|
const int32_t kiD8x = iMvX & 0x07;
|
||||||
const int32_t kiD8y = sMv.iMvY & 0x07;
|
const int32_t kiD8y = iMvY & 0x07;
|
||||||
static const McChromaWidthEqx kpfFuncs[2] = {
|
static const McChromaWidthEqx kpfFuncs[2] = {
|
||||||
McChromaWidthEq4_mmx,
|
McChromaWidthEq4_mmx,
|
||||||
McChromaWidthEq8_sse2
|
McChromaWidthEq8_sse2
|
||||||
@ -559,9 +559,9 @@ void McChroma_sse2 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int3
|
|||||||
}
|
}
|
||||||
|
|
||||||
void McChroma_ssse3 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
void McChroma_ssse3 (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||||
SMVUnitXY sMv, int32_t iWidth, int32_t iHeight) {
|
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight) {
|
||||||
const int32_t kiD8x = sMv.iMvX & 0x07;
|
const int32_t kiD8x = iMvX & 0x07;
|
||||||
const int32_t kiD8y = sMv.iMvY & 0x07;
|
const int32_t kiD8y = iMvY & 0x07;
|
||||||
|
|
||||||
static const McChromaWidthEqx kpfFuncs[2] = {
|
static const McChromaWidthEqx kpfFuncs[2] = {
|
||||||
McChromaWidthEq4_mmx,
|
McChromaWidthEq4_mmx,
|
||||||
@ -651,9 +651,9 @@ void EncMcHorVer33_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst,
|
|||||||
PixelAvgWidthEq16_neon (pDst, iDstStride, pTmp, &pTmp[256], iHeight);
|
PixelAvgWidthEq16_neon (pDst, iDstStride, pTmp, &pTmp[256], iHeight);
|
||||||
}
|
}
|
||||||
void EncMcChroma_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
void EncMcChroma_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||||
SMVUnitXY sMv, int32_t iWidth, int32_t iHeight) {
|
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight) {
|
||||||
const int32_t kiD8x = sMv.iMvX & 0x07;
|
const int32_t kiD8x = iMvX & 0x07;
|
||||||
const int32_t kiD8y = sMv.iMvY & 0x07;
|
const int32_t kiD8y = iMvY & 0x07;
|
||||||
if (0 == kiD8x && 0 == kiD8y) {
|
if (0 == kiD8x && 0 == kiD8y) {
|
||||||
if (8 == iWidth)
|
if (8 == iWidth)
|
||||||
McCopyWidthEq8_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
McCopyWidthEq8_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||||
@ -748,9 +748,9 @@ void EncMcHorVer33_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_
|
|||||||
PixelAvgWidthEq16_AArch64_neon (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
PixelAvgWidthEq16_AArch64_neon (pDst, iDstStride, pTmp, 16, &pTmp[256], 16, iHeight);
|
||||||
}
|
}
|
||||||
void EncMcChroma_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
void EncMcChroma_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||||
SMVUnitXY sMv, int32_t iWidth, int32_t iHeight) {
|
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight) {
|
||||||
const int32_t kiD8x = sMv.iMvX & 0x07;
|
const int32_t kiD8x = iMvX & 0x07;
|
||||||
const int32_t kiD8y = sMv.iMvY & 0x07;
|
const int32_t kiD8y = iMvY & 0x07;
|
||||||
if (0 == kiD8x && 0 == kiD8y) {
|
if (0 == kiD8x && 0 == kiD8y) {
|
||||||
if (8 == iWidth)
|
if (8 == iWidth)
|
||||||
McCopyWidthEq8_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
McCopyWidthEq8_AArch64_neon (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||||
@ -765,9 +765,8 @@ void EncMcChroma_AArch64_neon (const uint8_t* pSrc, int32_t iSrcStride, uint8_t*
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void (*PixelAvgFunc) (uint8_t*, int32_t, const uint8_t*, int32_t, const uint8_t*, int32_t, int32_t);
|
void WelsInitMcFuncs (SMcFunc* pMcFuncs, uint32_t uiCpuFlag) {
|
||||||
void WelsInitMcFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag) {
|
static const PWelsSampleAveragingFunc pfPixAvgFunc[2] = {PixelAvgWidthEq8_c, PixelAvgWidthEq16_c};
|
||||||
static const PixelAvgFunc pfPixAvgFunc[2] = {PixelAvgWidthEq8_c, PixelAvgWidthEq16_c};
|
|
||||||
|
|
||||||
static const PWelsLumaQuarpelMcFunc pWelsMcFuncWidthEq16[16] = { //[y*4+x]
|
static const PWelsLumaQuarpelMcFunc pWelsMcFuncWidthEq16[16] = { //[y*4+x]
|
||||||
McCopyWidthEq16_c, McHorVer10WidthEq16_c, McHorVer20WidthEq16_c, McHorVer30WidthEq16_c,
|
McCopyWidthEq16_c, McHorVer10WidthEq16_c, McHorVer20WidthEq16_c, McHorVer30WidthEq16_c,
|
||||||
@ -799,50 +798,50 @@ void WelsInitMcFuncs (SWelsFuncPtrList* pFuncList, uint32_t uiCpuFlag) {
|
|||||||
McHorVer03WidthEq16_AArch64_neon, EncMcHorVer13_AArch64_neon, EncMcHorVer23_AArch64_neon, EncMcHorVer33_AArch64_neon
|
McHorVer03WidthEq16_AArch64_neon, EncMcHorVer13_AArch64_neon, EncMcHorVer23_AArch64_neon, EncMcHorVer33_AArch64_neon
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
pFuncList->sMcFuncs.pfLumaHalfpelHor = McHorVer20_c;
|
pMcFuncs->pfLumaHalfpelHor = McHorVer20_c;
|
||||||
pFuncList->sMcFuncs.pfLumaHalfpelVer = McHorVer02_c;
|
pMcFuncs->pfLumaHalfpelVer = McHorVer02_c;
|
||||||
pFuncList->sMcFuncs.pfLumaHalfpelCen = McHorVer22_c;
|
pMcFuncs->pfLumaHalfpelCen = McHorVer22_c;
|
||||||
memcpy (pFuncList->sMcFuncs.pfSampleAveraging, pfPixAvgFunc, sizeof (pfPixAvgFunc));
|
memcpy (pMcFuncs->pfSampleAveraging, pfPixAvgFunc, sizeof (pfPixAvgFunc));
|
||||||
pFuncList->sMcFuncs.pfChromaMc = McChroma_c;
|
pMcFuncs->pfChromaMc = McChroma_c;
|
||||||
memcpy (pFuncList->sMcFuncs.pfLumaQuarpelMc, pWelsMcFuncWidthEq16, sizeof (pWelsMcFuncWidthEq16));
|
memcpy (pMcFuncs->pfLumaQuarpelMc, pWelsMcFuncWidthEq16, sizeof (pWelsMcFuncWidthEq16));
|
||||||
#if defined (X86_ASM)
|
#if defined (X86_ASM)
|
||||||
if (uiCpuFlag & WELS_CPU_SSE2) {
|
if (uiCpuFlag & WELS_CPU_SSE2) {
|
||||||
pFuncList->sMcFuncs.pfLumaHalfpelHor = McHorVer20Width9Or17_sse2;
|
pMcFuncs->pfLumaHalfpelHor = McHorVer20Width9Or17_sse2;
|
||||||
pFuncList->sMcFuncs.pfLumaHalfpelVer = McHorVer02Height9Or17_sse2;
|
pMcFuncs->pfLumaHalfpelVer = McHorVer02Height9Or17_sse2;
|
||||||
pFuncList->sMcFuncs.pfLumaHalfpelCen = McHorVer22Width9Or17Height9Or17_sse2;
|
pMcFuncs->pfLumaHalfpelCen = McHorVer22Width9Or17Height9Or17_sse2;
|
||||||
pFuncList->sMcFuncs.pfSampleAveraging[0] = PixelAvgWidthEq8_mmx;
|
pMcFuncs->pfSampleAveraging[0] = PixelAvgWidthEq8_mmx;
|
||||||
pFuncList->sMcFuncs.pfSampleAveraging[1] = PixelAvgWidthEq16_sse2;
|
pMcFuncs->pfSampleAveraging[1] = PixelAvgWidthEq16_sse2;
|
||||||
pFuncList->sMcFuncs.pfChromaMc = McChroma_sse2;
|
pMcFuncs->pfChromaMc = McChroma_sse2;
|
||||||
memcpy (pFuncList->sMcFuncs.pfLumaQuarpelMc, pWelsMcFuncWidthEq16_sse2, sizeof (pWelsMcFuncWidthEq16_sse2));
|
memcpy (pMcFuncs->pfLumaQuarpelMc, pWelsMcFuncWidthEq16_sse2, sizeof (pWelsMcFuncWidthEq16_sse2));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiCpuFlag & WELS_CPU_SSSE3) {
|
if (uiCpuFlag & WELS_CPU_SSSE3) {
|
||||||
pFuncList->sMcFuncs.pfChromaMc = McChroma_ssse3;
|
pMcFuncs->pfChromaMc = McChroma_ssse3;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //(X86_ASM)
|
#endif //(X86_ASM)
|
||||||
|
|
||||||
#if defined(HAVE_NEON)
|
#if defined(HAVE_NEON)
|
||||||
if (uiCpuFlag & WELS_CPU_NEON) {
|
if (uiCpuFlag & WELS_CPU_NEON) {
|
||||||
memcpy (pFuncList->sMcFuncs.pfLumaQuarpelMc, pWelsMcFuncWidthEq16_neon, sizeof (pWelsMcFuncWidthEq16_neon));
|
memcpy (pMcFuncs->pfLumaQuarpelMc, pWelsMcFuncWidthEq16_neon, sizeof (pWelsMcFuncWidthEq16_neon));
|
||||||
pFuncList->sMcFuncs.pfChromaMc = EncMcChroma_neon;
|
pMcFuncs->pfChromaMc = EncMcChroma_neon;
|
||||||
pFuncList->sMcFuncs.pfSampleAveraging[0] = PixStrideAvgWidthEq8_neon;
|
pMcFuncs->pfSampleAveraging[0] = PixStrideAvgWidthEq8_neon;
|
||||||
pFuncList->sMcFuncs.pfSampleAveraging[1] = PixStrideAvgWidthEq16_neon;
|
pMcFuncs->pfSampleAveraging[1] = PixStrideAvgWidthEq16_neon;
|
||||||
pFuncList->sMcFuncs.pfLumaHalfpelHor = McHorVer20Width9Or17_neon;//iWidth+1:8/16
|
pMcFuncs->pfLumaHalfpelHor = McHorVer20Width9Or17_neon;//iWidth+1:8/16
|
||||||
pFuncList->sMcFuncs.pfLumaHalfpelVer = McHorVer02Height9Or17_neon;//heigh+1:8/16
|
pMcFuncs->pfLumaHalfpelVer = McHorVer02Height9Or17_neon;//heigh+1:8/16
|
||||||
pFuncList->sMcFuncs.pfLumaHalfpelCen = McHorVer22Width9Or17Height9Or17_neon;//iWidth+1/heigh+1
|
pMcFuncs->pfLumaHalfpelCen = McHorVer22Width9Or17Height9Or17_neon;//iWidth+1/heigh+1
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_NEON_AARCH64)
|
#if defined(HAVE_NEON_AARCH64)
|
||||||
if (uiCpuFlag & WELS_CPU_NEON) {
|
if (uiCpuFlag & WELS_CPU_NEON) {
|
||||||
memcpy (pFuncList->sMcFuncs.pfLumaQuarpelMc, pWelsMcFuncWidthEq16_AArch64_neon,
|
memcpy (pMcFuncs->pfLumaQuarpelMc, pWelsMcFuncWidthEq16_AArch64_neon,
|
||||||
sizeof (pWelsMcFuncWidthEq16_AArch64_neon));
|
sizeof (pWelsMcFuncWidthEq16_AArch64_neon));
|
||||||
pFuncList->sMcFuncs.pfChromaMc = EncMcChroma_AArch64_neon;
|
pMcFuncs->pfChromaMc = EncMcChroma_AArch64_neon;
|
||||||
pFuncList->sMcFuncs.pfSampleAveraging[0] = PixStrideAvgWidthEq8_AArch64_neon;
|
pMcFuncs->pfSampleAveraging[0] = PixStrideAvgWidthEq8_AArch64_neon;
|
||||||
pFuncList->sMcFuncs.pfSampleAveraging[1] = PixStrideAvgWidthEq16_AArch64_neon;
|
pMcFuncs->pfSampleAveraging[1] = PixStrideAvgWidthEq16_AArch64_neon;
|
||||||
pFuncList->sMcFuncs.pfLumaHalfpelHor = McHorVer20Width9Or17_AArch64_neon;//iWidth+1:8/16
|
pMcFuncs->pfLumaHalfpelHor = McHorVer20Width9Or17_AArch64_neon;//iWidth+1:8/16
|
||||||
pFuncList->sMcFuncs.pfLumaHalfpelVer = McHorVer02Height9Or17_AArch64_neon;//heigh+1:8/16
|
pMcFuncs->pfLumaHalfpelVer = McHorVer02Height9Or17_AArch64_neon;//heigh+1:8/16
|
||||||
pFuncList->sMcFuncs.pfLumaHalfpelCen = McHorVer22Width9Or17Height9Or17_AArch64_neon;//iWidth+1/heigh+1
|
pMcFuncs->pfLumaHalfpelCen = McHorVer22Width9Or17Height9Or17_AArch64_neon;//iWidth+1/heigh+1
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1248,8 +1248,8 @@ void WelsMdBackgroundMbEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb,
|
|||||||
}
|
}
|
||||||
//MC
|
//MC
|
||||||
pFunc->sMcFuncs.pfLumaQuarpelMc[0] (pRefLuma, iLineSizeY, pDstLuma, 16, 16);
|
pFunc->sMcFuncs.pfLumaQuarpelMc[0] (pRefLuma, iLineSizeY, pDstLuma, 16, 16);
|
||||||
pFunc->sMcFuncs.pfChromaMc (pRefCb, iLineSizeUV, pDstCb, 8, sMvp, 8, 8); //Cb
|
pFunc->sMcFuncs.pfChromaMc (pRefCb, iLineSizeUV, pDstCb, 8, sMvp.iMvX, sMvp.iMvY, 8, 8); //Cb
|
||||||
pFunc->sMcFuncs.pfChromaMc (pRefCr, iLineSizeUV, pDstCr, 8, sMvp, 8, 8); //Cr
|
pFunc->sMcFuncs.pfChromaMc (pRefCr, iLineSizeUV, pDstCr, 8, sMvp.iMvX, sMvp.iMvY, 8, 8); //Cr
|
||||||
|
|
||||||
pCurMb->uiCbp = 0;
|
pCurMb->uiCbp = 0;
|
||||||
pMbCache->bCollocatedPredFlag = true;
|
pMbCache->bCollocatedPredFlag = true;
|
||||||
@ -1350,12 +1350,12 @@ bool WelsMdPSkipEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCac
|
|||||||
|
|
||||||
const int32_t iStrideUV = (sQpelMvp.iMvY >> 1) * iLineSizeUV + (sQpelMvp.iMvX >> 1);
|
const int32_t iStrideUV = (sQpelMvp.iMvY >> 1) * iLineSizeUV + (sQpelMvp.iMvX >> 1);
|
||||||
pRefCb += iStrideUV;
|
pRefCb += iStrideUV;
|
||||||
pFunc->sMcFuncs.pfChromaMc (pRefCb, iLineSizeUV, pDstCb, 8, sMvp, 8, 8); //Cb
|
pFunc->sMcFuncs.pfChromaMc (pRefCb, iLineSizeUV, pDstCb, 8, sMvp.iMvX, sMvp.iMvY, 8, 8); //Cb
|
||||||
iSadCostChroma = pFunc->sSampleDealingFuncs.pfSampleSad[BLOCK_8x8] (pMbCache->SPicData.pEncMb[1],
|
iSadCostChroma = pFunc->sSampleDealingFuncs.pfSampleSad[BLOCK_8x8] (pMbCache->SPicData.pEncMb[1],
|
||||||
pCurLayer->iEncStride[1], pDstCb, 8);
|
pCurLayer->iEncStride[1], pDstCb, 8);
|
||||||
|
|
||||||
pRefCr += iStrideUV;
|
pRefCr += iStrideUV;
|
||||||
pFunc->sMcFuncs.pfChromaMc (pRefCr, iLineSizeUV, pDstCr, 8, sMvp, 8, 8); //Cr
|
pFunc->sMcFuncs.pfChromaMc (pRefCr, iLineSizeUV, pDstCr, 8, sMvp.iMvX, sMvp.iMvY, 8, 8); //Cr
|
||||||
iSadCostChroma += pFunc->sSampleDealingFuncs.pfSampleSad[BLOCK_8x8] (pMbCache->SPicData.pEncMb[2],
|
iSadCostChroma += pFunc->sSampleDealingFuncs.pfSampleSad[BLOCK_8x8] (pMbCache->SPicData.pEncMb[2],
|
||||||
pCurLayer->iEncStride[2], pDstCr, 8);
|
pCurLayer->iEncStride[2], pDstCr, 8);
|
||||||
|
|
||||||
@ -1463,8 +1463,8 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
|
|||||||
iMvStride = (pMv->iMvY >> 3) * iLineSizeRefUV + (pMv->iMvX >> 3);
|
iMvStride = (pMv->iMvY >> 3) * iLineSizeRefUV + (pMv->iMvX >> 3);
|
||||||
pTmpRefCb = pRefCb + iMvStride;
|
pTmpRefCb = pRefCb + iMvStride;
|
||||||
pTmpRefCr = pRefCr + iMvStride;
|
pTmpRefCr = pRefCr + iMvStride;
|
||||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCb, iLineSizeRefUV, pDstCb, 8, *pMv, 8, 8); //Cb
|
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCb, iLineSizeRefUV, pDstCb, 8, pMv->iMvX, pMv->iMvY, 8, 8); //Cb
|
||||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCr, iLineSizeRefUV, pDstCr, 8, *pMv, 8, 8); //Cr
|
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCr, iLineSizeRefUV, pDstCr, 8, pMv->iMvX, pMv->iMvY, 8, 8); //Cr
|
||||||
|
|
||||||
pWelsMd->iCostSkipMb = pEncCtx->pFuncList->sSampleDealingFuncs.pfSampleSad[BLOCK_16x16] (pMbCache->SPicData.pEncMb[0],
|
pWelsMd->iCostSkipMb = pEncCtx->pFuncList->sSampleDealingFuncs.pfSampleSad[BLOCK_16x16] (pMbCache->SPicData.pEncMb[0],
|
||||||
pCurDqLayer->iEncStride[0], pDstLuma, 16);
|
pCurDqLayer->iEncStride[0], pDstLuma, 16);
|
||||||
@ -1498,8 +1498,8 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
|
|||||||
pTmpRefCr = pRefCr + iRefBlk4Stride + iMvStride;
|
pTmpRefCr = pRefCr + iRefBlk4Stride + iMvStride;
|
||||||
pTmpDstCb = pDstCb + iDstBlk4Stride;
|
pTmpDstCb = pDstCb + iDstBlk4Stride;
|
||||||
pTmpDstCr = pDstCr + iDstBlk4Stride;
|
pTmpDstCr = pDstCr + iDstBlk4Stride;
|
||||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCb, iLineSizeRefUV, pTmpDstCb, 8, *pMv, 8, 4); //Cb
|
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCb, iLineSizeRefUV, pTmpDstCb, 8, pMv->iMvX, pMv->iMvY, 8, 4); //Cb
|
||||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCr, iLineSizeRefUV, pTmpDstCr, 8, *pMv, 8, 4); //Cr
|
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCr, iLineSizeRefUV, pTmpDstCr, 8, pMv->iMvX, pMv->iMvY, 8, 4); //Cr
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1526,8 +1526,8 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
|
|||||||
pTmpRefCr = pRefCr + iRefBlk4Stride + iMvStride;
|
pTmpRefCr = pRefCr + iRefBlk4Stride + iMvStride;
|
||||||
pTmpDstCb = pDstCb + iRefBlk4Stride;
|
pTmpDstCb = pDstCb + iRefBlk4Stride;
|
||||||
pTmpDstCr = pDstCr + iRefBlk4Stride;
|
pTmpDstCr = pDstCr + iRefBlk4Stride;
|
||||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCb, iLineSizeRefUV, pTmpDstCb, 8, *pMv, 4, 8); //Cb
|
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCb, iLineSizeRefUV, pTmpDstCb, 8, pMv->iMvX, pMv->iMvY, 4, 8); //Cb
|
||||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCr, iLineSizeRefUV, pTmpDstCr, 8, *pMv, 4, 8); //Cr
|
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCr, iLineSizeRefUV, pTmpDstCr, 8, pMv->iMvX, pMv->iMvY, 4, 8); //Cr
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1560,8 +1560,8 @@ void WelsMdInterMbRefinement (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurM
|
|||||||
pTmpDstCb = pDstCb + iDstBlk4Stride;
|
pTmpDstCb = pDstCb + iDstBlk4Stride;
|
||||||
pTmpRefCr = pRefCr + iRefBlk4Stride;
|
pTmpRefCr = pRefCr + iRefBlk4Stride;
|
||||||
pTmpDstCr = pDstCr + iDstBlk4Stride;
|
pTmpDstCr = pDstCr + iDstBlk4Stride;
|
||||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCb + iMvStride, iLineSizeRefUV, pTmpDstCb, 8, *pMv, 4, 4); //Cb
|
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCb + iMvStride, iLineSizeRefUV, pTmpDstCb, 8, pMv->iMvX, pMv->iMvY, 4, 4); //Cb
|
||||||
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCr + iMvStride, iLineSizeRefUV, pTmpDstCr, 8, *pMv, 4, 4); //Cr
|
pEncCtx->pFuncList->sMcFuncs.pfChromaMc (pTmpRefCr + iMvStride, iLineSizeRefUV, pTmpDstCr, 8, pMv->iMvX, pMv->iMvY, 4, 4); //Cr
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -415,8 +415,8 @@ void SvcMdSCDMbEnc (sWelsEncCtx* pEncCtx, SWelsMD* pWelsMd, SMB* pCurMb, SMbCach
|
|||||||
}
|
}
|
||||||
//MC
|
//MC
|
||||||
pFunc->sMcFuncs.pfLumaQuarpelMc[0] (pRefLuma + iOffsetY, iLineSizeY, pDstLuma, 16, 16);
|
pFunc->sMcFuncs.pfLumaQuarpelMc[0] (pRefLuma + iOffsetY, iLineSizeY, pDstLuma, 16, 16);
|
||||||
pFunc->sMcFuncs.pfChromaMc (pRefCb + iOffsetUV, iLineSizeUV, pDstCb, 8, sMvp, 8, 8);
|
pFunc->sMcFuncs.pfChromaMc (pRefCb + iOffsetUV, iLineSizeUV, pDstCb, 8, sMvp.iMvX, sMvp.iMvY, 8, 8);
|
||||||
pFunc->sMcFuncs.pfChromaMc (pRefCr + iOffsetUV, iLineSizeUV, pDstCr, 8, sMvp, 8, 8);
|
pFunc->sMcFuncs.pfChromaMc (pRefCr + iOffsetUV, iLineSizeUV, pDstCr, 8, sMvp.iMvX, sMvp.iMvY, 8, 8);
|
||||||
|
|
||||||
pCurMb->uiCbp = 0;
|
pCurMb->uiCbp = 0;
|
||||||
pWelsMd->iCostLuma = 0;
|
pWelsMd->iCostLuma = 0;
|
||||||
|
@ -414,6 +414,10 @@
|
|||||||
RelativePath="..\..\..\encoder\EncUT_MemoryZero.cpp"
|
RelativePath="..\..\..\encoder\EncUT_MemoryZero.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\..\encoder\EncUT_MotionCompensation.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\..\encoder\EncUT_MotionEstimate.cpp"
|
RelativePath="..\..\..\encoder\EncUT_MotionEstimate.cpp"
|
||||||
>
|
>
|
||||||
|
@ -1,365 +1,39 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include "codec_def.h"
|
#include "codec_def.h"
|
||||||
#include "mc.h"
|
#include "mc.h"
|
||||||
#include "mem_align.h"
|
|
||||||
#include "cpu_core.h"
|
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
using namespace WelsDec;
|
using namespace WelsDec;
|
||||||
|
|
||||||
#define MC_BUFF_SRC_STRIDE 32
|
#define LUMA_FUNC(funcs, src, srcstride, dst, dststride, mvx, mvy, width, height) \
|
||||||
#define MC_BUFF_DST_STRIDE 32
|
sMcFunc.pMcLumaFunc (src, srcstride, dst, dststride, mvx, mvy, width, height)
|
||||||
#define MC_BUFF_HEIGHT 30
|
|
||||||
|
|
||||||
/**********************MC Unit Test Anchor Code Begin******************************/
|
#define CHROMA_FUNC sMcFunc.pMcChromaFunc
|
||||||
bool bQpelNeeded[4][4] = {
|
|
||||||
{ false, true, false, true },
|
|
||||||
{ true, true, true, true },
|
|
||||||
{ false, true, false, true },
|
|
||||||
{ true, true, true, true }
|
|
||||||
};
|
|
||||||
int32_t iHpelRef0Array[4][4] = {
|
|
||||||
{ 0, 1, 1, 1 },
|
|
||||||
{ 0, 1, 1, 1 },
|
|
||||||
{ 2, 3, 3, 3 },
|
|
||||||
{ 0, 1, 1, 1 }
|
|
||||||
};
|
|
||||||
int32_t iHpelRef1Array[4][4] = {
|
|
||||||
{ 0, 0, 0, 0 },
|
|
||||||
{ 2, 2, 3, 2 },
|
|
||||||
{ 2, 2, 3, 2 },
|
|
||||||
{ 2, 2, 3, 2 }
|
|
||||||
};
|
|
||||||
#define FILTER6TAP(pPixBuff, x, iStride) ((pPixBuff)[x-2*iStride] + (pPixBuff)[x+3*iStride] - 5*((pPixBuff)[x-iStride] + (pPixBuff)[x+2*iStride]) + 20*((pPixBuff)[x] + (pPixBuff)[x+iStride]))
|
|
||||||
static inline uint8_t Clip255 (int32_t x) {
|
|
||||||
return ((x & ~255) ? (-x) >> 31 & 255 : x);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MCCopyAnchor (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
#include "mc_test_common.h"
|
||||||
int32_t iHeight) {
|
|
||||||
for (int32_t y = 0; y < iHeight; y++) {
|
|
||||||
memcpy (pDst, pSrc, iWidth * sizeof (uint8_t));
|
|
||||||
pSrc += iSrcStride;
|
|
||||||
pDst += iDstStride;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MCHalfPelFilterAnchor (uint8_t* pDstH, uint8_t* pDstV, uint8_t* pDstHV, uint8_t* pSrc,
|
DEF_MCCOPYTEST (, 2, 2, 1)
|
||||||
int32_t iStride, int32_t iWidth, int32_t iHeight, int16_t* pBuf) {
|
DEF_MCCOPYTEST (, 2, 4, 1)
|
||||||
for (int32_t y = 0; y < iHeight; y++) {
|
DEF_MCCOPYTEST (, 4, 2, 0)
|
||||||
for (int32_t x = 0; x < iWidth; x++)
|
DEF_MCCOPYTEST (, 4, 4, 0)
|
||||||
pDstH[x] = Clip255 ((FILTER6TAP (pSrc, x, 1) + 16) >> 5);
|
DEF_MCCOPYTEST (, 4, 8, 0)
|
||||||
for (int32_t x = -2; x < iWidth + 3; x++) {
|
DEF_MCCOPYTEST (, 8, 4, 0)
|
||||||
int32_t v = FILTER6TAP (pSrc, x, iStride);
|
DEF_MCCOPYTEST (, 8, 8, 0)
|
||||||
pDstV[x] = Clip255 ((v + 16) >> 5);
|
DEF_MCCOPYTEST (, 16, 8, 0)
|
||||||
pBuf[x + 2] = v;
|
DEF_MCCOPYTEST (, 8, 16, 0)
|
||||||
}
|
DEF_MCCOPYTEST (, 16, 16, 0)
|
||||||
for (int32_t x = 0; x < iWidth; x++)
|
|
||||||
pDstHV[x] = Clip255 ((FILTER6TAP (pBuf + 2, x, 1) + 512) >> 10);
|
|
||||||
pDstH += iStride;
|
|
||||||
pDstV += iStride;
|
|
||||||
pDstHV += iStride;
|
|
||||||
pSrc += iStride;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PixelAvgAnchor (uint8_t* pDst, int32_t iDstStride,
|
DEF_LUMA_MCTEST (, 4, 4)
|
||||||
uint8_t* pSrc1, int32_t iSrc1Stride,
|
DEF_LUMA_MCTEST (, 4, 8)
|
||||||
uint8_t* pSrc2, int32_t iSrc2Stride, int32_t iWidth, int32_t iHeight) {
|
DEF_LUMA_MCTEST (, 8, 4)
|
||||||
for (int32_t y = 0; y < iHeight; y++) {
|
DEF_LUMA_MCTEST (, 8, 8)
|
||||||
for (int32_t x = 0; x < iWidth; x++)
|
DEF_LUMA_MCTEST (, 16, 8)
|
||||||
pDst[x] = (pSrc1[x] + pSrc2[x] + 1) >> 1;
|
DEF_LUMA_MCTEST (, 8, 16)
|
||||||
pDst += iDstStride;
|
DEF_LUMA_MCTEST (, 16, 16)
|
||||||
pSrc1 += iSrc1Stride;
|
|
||||||
pSrc2 += iSrc2Stride;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MCLumaAnchor (uint8_t* pDst, int32_t iDstStride, uint8_t* pSrc[4], int32_t iSrcStride,
|
DEF_CHROMA_MCTEST (, 2, 2)
|
||||||
int32_t iMvX, int32_t iMvY, int32_t iWidth, int32_t iHeight) {
|
DEF_CHROMA_MCTEST (, 2, 4)
|
||||||
int32_t iMvXIdx = iMvX & 3;
|
DEF_CHROMA_MCTEST (, 4, 2)
|
||||||
int32_t iMvYIdx = iMvY & 3;
|
DEF_CHROMA_MCTEST (, 4, 4)
|
||||||
int32_t iOffset = (iMvY >> 2) * iSrcStride + (iMvX >> 2);
|
DEF_CHROMA_MCTEST (, 4, 8)
|
||||||
uint8_t* pSrc1 = pSrc[iHpelRef0Array[iMvYIdx][iMvXIdx]] + iOffset + ((iMvYIdx) == 3) * iSrcStride;
|
DEF_CHROMA_MCTEST (, 8, 4)
|
||||||
|
DEF_CHROMA_MCTEST (, 8, 8)
|
||||||
if (bQpelNeeded[iMvYIdx][iMvXIdx]) {
|
|
||||||
uint8_t* pSrc2 = pSrc[iHpelRef1Array[iMvYIdx][iMvXIdx]] + iOffset + ((iMvXIdx) == 3);
|
|
||||||
PixelAvgAnchor (pDst, iDstStride, pSrc1, iSrcStride, pSrc2, iSrcStride, iWidth, iHeight);
|
|
||||||
} else {
|
|
||||||
MCCopyAnchor (pSrc1, iSrcStride, pDst, iDstStride, iWidth, iHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MCChromaAnchor (uint8_t* pDstU, uint8_t* pDstV, int32_t iDstStride, uint8_t* pSrc, int32_t iSrcStride,
|
|
||||||
int32_t iMvX, int32_t iMvY, int32_t iWidth, int32_t iHeight) {
|
|
||||||
uint8_t* pSrcTmp;
|
|
||||||
pSrc += (iMvY >> 3) * iSrcStride + (iMvX >> 3) * 2;
|
|
||||||
pSrcTmp = &pSrc[iSrcStride];
|
|
||||||
|
|
||||||
int32_t iMvXIdx = iMvX & 0x07;
|
|
||||||
int32_t iMvYIdx = iMvY & 0x07;
|
|
||||||
int32_t iBiPara0 = (8 - iMvXIdx) * (8 - iMvYIdx);
|
|
||||||
int32_t iBiPara1 = iMvXIdx * (8 - iMvYIdx);
|
|
||||||
int32_t iBiPara2 = (8 - iMvXIdx) * iMvYIdx;
|
|
||||||
int32_t iBiPara3 = iMvXIdx * iMvYIdx;
|
|
||||||
for (int32_t y = 0; y < iHeight; y++) {
|
|
||||||
for (int32_t x = 0; x < iWidth; x++) {
|
|
||||||
pDstU[x] = (iBiPara0 * pSrc[2 * x] + iBiPara1 * pSrc[2 * x + 2] +
|
|
||||||
iBiPara2 * pSrcTmp[2 * x] + iBiPara3 * pSrcTmp[2 * x + 2] + 32) >> 6;
|
|
||||||
pDstV[x] = (iBiPara0 * pSrc[2 * x + 1] + iBiPara1 * pSrc[2 * x + 3] +
|
|
||||||
iBiPara2 * pSrcTmp[2 * x + 1] + iBiPara3 * pSrcTmp[2 * x + 3] + 32) >> 6;
|
|
||||||
}
|
|
||||||
pSrc = pSrcTmp;
|
|
||||||
pSrcTmp += iSrcStride;
|
|
||||||
pDstU += iDstStride;
|
|
||||||
pDstV += iDstStride;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************MC Unit Test OPENH264 Code Begin******************************/
|
|
||||||
#define DEF_MCCOPYTEST(iH,iW, forceC) \
|
|
||||||
TEST(McCopy_c,iW##x##iH) \
|
|
||||||
{ \
|
|
||||||
SMcFunc sMcFunc; \
|
|
||||||
int32_t iCpuCores = 1; \
|
|
||||||
uint32_t uiCpuFlag;\
|
|
||||||
for(int32_t k =0; k<2; k++)\
|
|
||||||
{\
|
|
||||||
if(k==0||forceC!=0)\
|
|
||||||
{\
|
|
||||||
uiCpuFlag = 0;\
|
|
||||||
}else \
|
|
||||||
{\
|
|
||||||
uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); \
|
|
||||||
}\
|
|
||||||
InitMcFunc(&sMcFunc, uiCpuFlag); \
|
|
||||||
uint8_t uSrcAnchor[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
|
|
||||||
uint8_t uSrcTest[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
|
|
||||||
ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
|
|
||||||
ENFORCE_STACK_ALIGN_2D(uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
|
|
||||||
for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
|
|
||||||
{ \
|
|
||||||
for(int32_t i=0;i<MC_BUFF_SRC_STRIDE;i++) \
|
|
||||||
{ \
|
|
||||||
uSrcAnchor[j][i] = uSrcTest[j][i] = rand()%256; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
memset(uDstAnchor,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE);\
|
|
||||||
memset(uDstTest,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
|
|
||||||
MCCopyAnchor(uSrcAnchor[0],MC_BUFF_SRC_STRIDE,uDstAnchor[0],MC_BUFF_DST_STRIDE,iW,iH); \
|
|
||||||
sMcFunc.pMcLumaFunc(uSrcTest[0],MC_BUFF_SRC_STRIDE,uDstTest[0],MC_BUFF_DST_STRIDE,0,0,iW,iH); \
|
|
||||||
for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
|
|
||||||
{ \
|
|
||||||
for(int32_t i=0;i<MC_BUFF_DST_STRIDE;i++) \
|
|
||||||
{ \
|
|
||||||
ASSERT_EQ(uDstAnchor[j][i],uDstTest[j][i]); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
}\
|
|
||||||
}
|
|
||||||
|
|
||||||
DEF_MCCOPYTEST (2, 2, 1)
|
|
||||||
DEF_MCCOPYTEST (2, 4, 0)
|
|
||||||
DEF_MCCOPYTEST (4, 2, 1)
|
|
||||||
DEF_MCCOPYTEST (4, 4, 0)
|
|
||||||
DEF_MCCOPYTEST (4, 8, 0)
|
|
||||||
DEF_MCCOPYTEST (8, 4, 0)
|
|
||||||
DEF_MCCOPYTEST (8, 8, 0)
|
|
||||||
DEF_MCCOPYTEST (16, 8, 0)
|
|
||||||
DEF_MCCOPYTEST (8, 16, 0)
|
|
||||||
DEF_MCCOPYTEST (16, 16, 0)
|
|
||||||
|
|
||||||
#define DEF_LUMA_MCTEST_SUBCASE(a,b,iW,iH) \
|
|
||||||
TEST(McHorVer##a##b##_c,iW##x##iH) \
|
|
||||||
{ \
|
|
||||||
SMcFunc sMcFunc; \
|
|
||||||
uint8_t uSrcAnchor[4][MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
|
|
||||||
uint8_t uSrcTest[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
|
|
||||||
ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
|
|
||||||
ENFORCE_STACK_ALIGN_2D(uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
|
|
||||||
uint8_t* uSrcInputAnchor[4]; \
|
|
||||||
int16_t pBuf[MC_BUFF_DST_STRIDE]; \
|
|
||||||
uSrcInputAnchor[0] = &uSrcAnchor[0][4][4]; \
|
|
||||||
uSrcInputAnchor[1] = &uSrcAnchor[1][4][4]; \
|
|
||||||
uSrcInputAnchor[2] = &uSrcAnchor[2][4][4]; \
|
|
||||||
uSrcInputAnchor[3] = &uSrcAnchor[3][4][4]; \
|
|
||||||
for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
|
|
||||||
{\
|
|
||||||
for(int32_t i=0;i<MC_BUFF_SRC_STRIDE;i++) \
|
|
||||||
{\
|
|
||||||
uSrcAnchor[0][j][i] = uSrcTest[j][i] = rand()%256; \
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
int32_t iCpuCores = 1; \
|
|
||||||
uint32_t uiCpuFlag;\
|
|
||||||
for(int32_t k =0; k<2; k++)\
|
|
||||||
{\
|
|
||||||
if(k==0)\
|
|
||||||
{\
|
|
||||||
uiCpuFlag = 0;\
|
|
||||||
}else \
|
|
||||||
{\
|
|
||||||
uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); \
|
|
||||||
}\
|
|
||||||
InitMcFunc(&sMcFunc,uiCpuFlag);\
|
|
||||||
memset(uDstAnchor,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
|
|
||||||
memset(uDstTest,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
|
|
||||||
MCHalfPelFilterAnchor(uSrcInputAnchor[1],uSrcInputAnchor[2],uSrcInputAnchor[3],uSrcInputAnchor[0],MC_BUFF_SRC_STRIDE,iW+1,iH+1,pBuf+4); \
|
|
||||||
MCLumaAnchor(uDstAnchor[0],MC_BUFF_DST_STRIDE,uSrcInputAnchor,MC_BUFF_SRC_STRIDE,a,b,iW,iH); \
|
|
||||||
sMcFunc.pMcLumaFunc(&uSrcTest[4][4],MC_BUFF_SRC_STRIDE,uDstTest[0],MC_BUFF_DST_STRIDE,a,b,iW,iH);\
|
|
||||||
for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
|
|
||||||
{ \
|
|
||||||
for(int32_t i=0;i<MC_BUFF_DST_STRIDE;i++) \
|
|
||||||
{ \
|
|
||||||
ASSERT_EQ(uDstAnchor[j][i],uDstTest[j][i]); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
}\
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DEF_LUMA_MCTEST(a,b) \
|
|
||||||
DEF_LUMA_MCTEST_SUBCASE(a,b,4,4) \
|
|
||||||
DEF_LUMA_MCTEST_SUBCASE(a,b,4,8) \
|
|
||||||
DEF_LUMA_MCTEST_SUBCASE(a,b,8,4) \
|
|
||||||
DEF_LUMA_MCTEST_SUBCASE(a,b,8,8) \
|
|
||||||
DEF_LUMA_MCTEST_SUBCASE(a,b,16,8) \
|
|
||||||
DEF_LUMA_MCTEST_SUBCASE(a,b,8,16) \
|
|
||||||
DEF_LUMA_MCTEST_SUBCASE(a,b,16,16)
|
|
||||||
|
|
||||||
DEF_LUMA_MCTEST (0, 1)
|
|
||||||
DEF_LUMA_MCTEST (0, 2)
|
|
||||||
DEF_LUMA_MCTEST (0, 3)
|
|
||||||
DEF_LUMA_MCTEST (1, 0)
|
|
||||||
DEF_LUMA_MCTEST (1, 1)
|
|
||||||
DEF_LUMA_MCTEST (1, 2)
|
|
||||||
DEF_LUMA_MCTEST (1, 3)
|
|
||||||
DEF_LUMA_MCTEST (2, 0)
|
|
||||||
DEF_LUMA_MCTEST (2, 1)
|
|
||||||
DEF_LUMA_MCTEST (2, 2)
|
|
||||||
DEF_LUMA_MCTEST (2, 3)
|
|
||||||
DEF_LUMA_MCTEST (3, 0)
|
|
||||||
DEF_LUMA_MCTEST (3, 1)
|
|
||||||
DEF_LUMA_MCTEST (3, 2)
|
|
||||||
DEF_LUMA_MCTEST (3, 3)
|
|
||||||
|
|
||||||
#define DEF_CHROMA_MCTEST_SUBCASE(a,b,iW,iH) \
|
|
||||||
TEST(McChromaWithFragMv_##a##b##_c,iW##x##iH) \
|
|
||||||
{ \
|
|
||||||
SMcFunc sMcFunc; \
|
|
||||||
uint8_t uSrcAnchor[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE*2]; \
|
|
||||||
uint8_t uSrcTest[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
|
|
||||||
ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor1, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
|
|
||||||
ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor2, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
|
|
||||||
ENFORCE_STACK_ALIGN_2D(uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
|
|
||||||
for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
|
|
||||||
{\
|
|
||||||
for(int32_t i=0;i<MC_BUFF_SRC_STRIDE;i++) \
|
|
||||||
{\
|
|
||||||
uSrcAnchor[j][i*2] = uSrcTest[j][i] = rand()%256; \
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
int32_t iCpuCores = 1; \
|
|
||||||
uint32_t uiCpuFlag;\
|
|
||||||
for(int32_t k =0; k<2; k++)\
|
|
||||||
{\
|
|
||||||
if(k==0)\
|
|
||||||
{\
|
|
||||||
uiCpuFlag = 0;\
|
|
||||||
}else \
|
|
||||||
{\
|
|
||||||
uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); \
|
|
||||||
}\
|
|
||||||
InitMcFunc(&sMcFunc,uiCpuFlag);\
|
|
||||||
memset(uDstAnchor1,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
|
|
||||||
memset(uDstAnchor2,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
|
|
||||||
memset(uDstTest,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
|
|
||||||
MCChromaAnchor(uDstAnchor1[0],uDstAnchor2[0],MC_BUFF_DST_STRIDE,uSrcAnchor[0],MC_BUFF_SRC_STRIDE*2,a,b,iW,iH); \
|
|
||||||
sMcFunc.pMcChromaFunc(uSrcTest[0],MC_BUFF_SRC_STRIDE,uDstTest[0],MC_BUFF_DST_STRIDE,a,b,iW,iH);\
|
|
||||||
for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
|
|
||||||
{ \
|
|
||||||
for(int32_t i=0;i<MC_BUFF_DST_STRIDE;i++) \
|
|
||||||
{ \
|
|
||||||
ASSERT_EQ(uDstAnchor1[j][i],uDstTest[j][i]); \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
}\
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DEF_CHROMA_MCTEST(a,b) \
|
|
||||||
DEF_CHROMA_MCTEST_SUBCASE(a,b,2,2) \
|
|
||||||
DEF_CHROMA_MCTEST_SUBCASE(a,b,2,4) \
|
|
||||||
DEF_CHROMA_MCTEST_SUBCASE(a,b,4,2) \
|
|
||||||
DEF_CHROMA_MCTEST_SUBCASE(a,b,4,4) \
|
|
||||||
DEF_CHROMA_MCTEST_SUBCASE(a,b,4,8) \
|
|
||||||
DEF_CHROMA_MCTEST_SUBCASE(a,b,8,4) \
|
|
||||||
DEF_CHROMA_MCTEST_SUBCASE(a,b,8,8)
|
|
||||||
|
|
||||||
DEF_CHROMA_MCTEST (0, 1)
|
|
||||||
DEF_CHROMA_MCTEST (0, 2)
|
|
||||||
DEF_CHROMA_MCTEST (0, 3)
|
|
||||||
DEF_CHROMA_MCTEST (0, 4)
|
|
||||||
DEF_CHROMA_MCTEST (0, 5)
|
|
||||||
DEF_CHROMA_MCTEST (0, 6)
|
|
||||||
DEF_CHROMA_MCTEST (0, 7)
|
|
||||||
|
|
||||||
DEF_CHROMA_MCTEST (1, 0)
|
|
||||||
DEF_CHROMA_MCTEST (1, 1)
|
|
||||||
DEF_CHROMA_MCTEST (1, 2)
|
|
||||||
DEF_CHROMA_MCTEST (1, 3)
|
|
||||||
DEF_CHROMA_MCTEST (1, 4)
|
|
||||||
DEF_CHROMA_MCTEST (1, 5)
|
|
||||||
DEF_CHROMA_MCTEST (1, 6)
|
|
||||||
DEF_CHROMA_MCTEST (1, 7)
|
|
||||||
|
|
||||||
DEF_CHROMA_MCTEST (2, 0)
|
|
||||||
DEF_CHROMA_MCTEST (2, 1)
|
|
||||||
DEF_CHROMA_MCTEST (2, 2)
|
|
||||||
DEF_CHROMA_MCTEST (2, 3)
|
|
||||||
DEF_CHROMA_MCTEST (2, 4)
|
|
||||||
DEF_CHROMA_MCTEST (2, 5)
|
|
||||||
DEF_CHROMA_MCTEST (2, 6)
|
|
||||||
DEF_CHROMA_MCTEST (2, 7)
|
|
||||||
|
|
||||||
DEF_CHROMA_MCTEST (3, 0)
|
|
||||||
DEF_CHROMA_MCTEST (3, 1)
|
|
||||||
DEF_CHROMA_MCTEST (3, 2)
|
|
||||||
DEF_CHROMA_MCTEST (3, 3)
|
|
||||||
DEF_CHROMA_MCTEST (3, 4)
|
|
||||||
DEF_CHROMA_MCTEST (3, 5)
|
|
||||||
DEF_CHROMA_MCTEST (3, 6)
|
|
||||||
DEF_CHROMA_MCTEST (3, 7)
|
|
||||||
|
|
||||||
DEF_CHROMA_MCTEST (4, 0)
|
|
||||||
DEF_CHROMA_MCTEST (4, 1)
|
|
||||||
DEF_CHROMA_MCTEST (4, 2)
|
|
||||||
DEF_CHROMA_MCTEST (4, 3)
|
|
||||||
DEF_CHROMA_MCTEST (4, 4)
|
|
||||||
DEF_CHROMA_MCTEST (4, 5)
|
|
||||||
DEF_CHROMA_MCTEST (4, 6)
|
|
||||||
DEF_CHROMA_MCTEST (4, 7)
|
|
||||||
|
|
||||||
DEF_CHROMA_MCTEST (5, 0)
|
|
||||||
DEF_CHROMA_MCTEST (5, 1)
|
|
||||||
DEF_CHROMA_MCTEST (5, 2)
|
|
||||||
DEF_CHROMA_MCTEST (5, 3)
|
|
||||||
DEF_CHROMA_MCTEST (5, 4)
|
|
||||||
DEF_CHROMA_MCTEST (5, 5)
|
|
||||||
DEF_CHROMA_MCTEST (5, 6)
|
|
||||||
DEF_CHROMA_MCTEST (5, 7)
|
|
||||||
|
|
||||||
DEF_CHROMA_MCTEST (6, 0)
|
|
||||||
DEF_CHROMA_MCTEST (6, 1)
|
|
||||||
DEF_CHROMA_MCTEST (6, 2)
|
|
||||||
DEF_CHROMA_MCTEST (6, 3)
|
|
||||||
DEF_CHROMA_MCTEST (6, 4)
|
|
||||||
DEF_CHROMA_MCTEST (6, 5)
|
|
||||||
DEF_CHROMA_MCTEST (6, 6)
|
|
||||||
DEF_CHROMA_MCTEST (6, 7)
|
|
||||||
|
|
||||||
DEF_CHROMA_MCTEST (7, 0)
|
|
||||||
DEF_CHROMA_MCTEST (7, 1)
|
|
||||||
DEF_CHROMA_MCTEST (7, 2)
|
|
||||||
DEF_CHROMA_MCTEST (7, 3)
|
|
||||||
DEF_CHROMA_MCTEST (7, 4)
|
|
||||||
DEF_CHROMA_MCTEST (7, 5)
|
|
||||||
DEF_CHROMA_MCTEST (7, 6)
|
|
||||||
DEF_CHROMA_MCTEST (7, 7)
|
|
||||||
|
114
test/encoder/EncUT_MotionCompensation.cpp
Normal file
114
test/encoder/EncUT_MotionCompensation.cpp
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include "codec_def.h"
|
||||||
|
#include "mc.h"
|
||||||
|
#include "cpu.h"
|
||||||
|
using namespace WelsEnc;
|
||||||
|
|
||||||
|
static void McLumaFunc (SMcFunc* pFuncs, const uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride,
|
||||||
|
int16_t iMvX, int16_t iMvY, int32_t iWidth, int32_t iHeight) {
|
||||||
|
uint8_t uiMvpIdx = ((iMvY & 0x03) << 2) + (iMvX & 0x03);
|
||||||
|
ASSERT_EQ (iWidth, 16);
|
||||||
|
pFuncs->pfLumaQuarpelMc[uiMvpIdx] (pSrc, iSrcStride, pDst, iDstStride, iHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define InitMcFunc WelsInitMcFuncs
|
||||||
|
|
||||||
|
#define LUMA_FUNC(funcs, src, srcstride, dst, dststride, mvx, mvy, width, height) \
|
||||||
|
McLumaFunc (funcs, src, srcstride, dst, dststride, mvx, mvy, width, height)
|
||||||
|
|
||||||
|
#define CHROMA_FUNC sMcFunc.pfChromaMc
|
||||||
|
|
||||||
|
#include "mc_test_common.h"
|
||||||
|
|
||||||
|
DEF_MCCOPYTEST (Enc, 16, 8, 0)
|
||||||
|
DEF_MCCOPYTEST (Enc, 16, 16, 0)
|
||||||
|
|
||||||
|
DEF_LUMA_MCTEST (Enc, 16, 8)
|
||||||
|
DEF_LUMA_MCTEST (Enc, 16, 16)
|
||||||
|
|
||||||
|
DEF_CHROMA_MCTEST (Enc, 4, 2)
|
||||||
|
DEF_CHROMA_MCTEST (Enc, 4, 4)
|
||||||
|
DEF_CHROMA_MCTEST (Enc, 4, 8)
|
||||||
|
DEF_CHROMA_MCTEST (Enc, 8, 4)
|
||||||
|
DEF_CHROMA_MCTEST (Enc, 8, 8)
|
||||||
|
|
||||||
|
TEST (EncMcAvg, PixelAvg) {
|
||||||
|
SMcFunc sMcFunc;
|
||||||
|
for (int32_t k = 0; k < 2; k++) {
|
||||||
|
for (int32_t w = 0; w < 2; w++) {
|
||||||
|
int32_t width = 8 << w;
|
||||||
|
int32_t height = 16;
|
||||||
|
uint32_t uiCpuFlag = k == 0 ? 0 : WelsCPUFeatureDetect (NULL);
|
||||||
|
WelsInitMcFuncs (&sMcFunc, uiCpuFlag);
|
||||||
|
uint8_t uSrc1[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE];
|
||||||
|
uint8_t uSrc2[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE];
|
||||||
|
ENFORCE_STACK_ALIGN_2D (uint8_t, uDstAnchor, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16);
|
||||||
|
ENFORCE_STACK_ALIGN_2D (uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16);
|
||||||
|
for (int32_t j = 0; j < MC_BUFF_HEIGHT; j++) {
|
||||||
|
for (int32_t i = 0; i < MC_BUFF_SRC_STRIDE; i++) {
|
||||||
|
uSrc1[j][i] = rand() % 256;
|
||||||
|
uSrc2[j][i] = rand() % 256;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PixelAvgAnchor (uDstAnchor[0], MC_BUFF_DST_STRIDE, uSrc1[0], MC_BUFF_SRC_STRIDE, uSrc2[0], MC_BUFF_SRC_STRIDE, width,
|
||||||
|
height);
|
||||||
|
sMcFunc.pfSampleAveraging[w] (uDstTest[0], MC_BUFF_DST_STRIDE, uSrc1[0], MC_BUFF_SRC_STRIDE, uSrc2[0],
|
||||||
|
MC_BUFF_SRC_STRIDE, height);
|
||||||
|
for (int32_t j = 0; j < height; j++) {
|
||||||
|
for (int32_t i = 0; i < width; i++) {
|
||||||
|
ASSERT_EQ (uDstAnchor[j][i], uDstTest[j][i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST (EncMcHalfpel, LumaHalfpel) {
|
||||||
|
SMcFunc sMcFunc;
|
||||||
|
for (int32_t k = 0; k < 2; k++) {
|
||||||
|
for (int32_t w = 0; w < 2; w++) {
|
||||||
|
int32_t width = 8 << w;
|
||||||
|
int32_t height = 16;
|
||||||
|
uint8_t uAnchor[4][MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE];
|
||||||
|
uint8_t uSrcTest[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE];
|
||||||
|
ENFORCE_STACK_ALIGN_2D (uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16);
|
||||||
|
uint8_t* uAnchors[4];
|
||||||
|
int16_t pBuf[MC_BUFF_DST_STRIDE];
|
||||||
|
uAnchors[0] = &uAnchor[0][4][4];
|
||||||
|
uAnchors[1] = &uAnchor[1][4][4];
|
||||||
|
uAnchors[2] = &uAnchor[2][4][4];
|
||||||
|
uAnchors[3] = &uAnchor[3][4][4];
|
||||||
|
|
||||||
|
memset (uAnchor, 0, 4 * sizeof (uint8_t)*MC_BUFF_HEIGHT * MC_BUFF_DST_STRIDE);
|
||||||
|
memset (uDstTest, 0, sizeof (uint8_t)*MC_BUFF_HEIGHT * MC_BUFF_DST_STRIDE);
|
||||||
|
for (int32_t j = 0; j < MC_BUFF_HEIGHT; j++) {
|
||||||
|
for (int32_t i = 0; i < MC_BUFF_SRC_STRIDE; i++) {
|
||||||
|
uAnchor[0][j][i] = uSrcTest[j][i] = rand() % 256;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t uiCpuFlag = k == 0 ? 0 : WelsCPUFeatureDetect (NULL);
|
||||||
|
WelsInitMcFuncs (&sMcFunc, uiCpuFlag);
|
||||||
|
|
||||||
|
MCHalfPelFilterAnchor (uAnchors[1], uAnchors[2], uAnchors[3], uAnchors[0], MC_BUFF_SRC_STRIDE, width, height, pBuf + 4);
|
||||||
|
sMcFunc.pfLumaHalfpelHor (&uSrcTest[4][4], MC_BUFF_SRC_STRIDE, uDstTest[0], MC_BUFF_DST_STRIDE, width + 1, height);
|
||||||
|
for (int32_t j = 0; j < height; j++) {
|
||||||
|
for (int32_t i = 0; i < width; i++) {
|
||||||
|
ASSERT_EQ (uAnchor[1][4 + j][4 + i], uDstTest[j][i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sMcFunc.pfLumaHalfpelVer (&uSrcTest[4][4], MC_BUFF_SRC_STRIDE, uDstTest[0], MC_BUFF_DST_STRIDE, width, height + 1);
|
||||||
|
for (int32_t j = 0; j < height; j++) {
|
||||||
|
for (int32_t i = 0; i < width; i++) {
|
||||||
|
ASSERT_EQ (uAnchor[2][4 + j][4 + i], uDstTest[j][i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sMcFunc.pfLumaHalfpelCen (&uSrcTest[4][4], MC_BUFF_SRC_STRIDE, uDstTest[0], MC_BUFF_DST_STRIDE, width + 1, height + 1);
|
||||||
|
for (int32_t j = 0; j < height; j++) {
|
||||||
|
for (int32_t i = 0; i < width; i++) {
|
||||||
|
ASSERT_EQ (uAnchor[3][4 + j][4 + i], uDstTest[j][i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ ENCODER_UNITTEST_CPP_SRCS=\
|
|||||||
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MBCopy.cpp\
|
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MBCopy.cpp\
|
||||||
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MemoryAlloc.cpp\
|
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MemoryAlloc.cpp\
|
||||||
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MemoryZero.cpp\
|
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MemoryZero.cpp\
|
||||||
|
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MotionCompensation.cpp\
|
||||||
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MotionEstimate.cpp\
|
$(ENCODER_UNITTEST_SRCDIR)/EncUT_MotionEstimate.cpp\
|
||||||
$(ENCODER_UNITTEST_SRCDIR)/EncUT_ParameterSetStrategy.cpp\
|
$(ENCODER_UNITTEST_SRCDIR)/EncUT_ParameterSetStrategy.cpp\
|
||||||
$(ENCODER_UNITTEST_SRCDIR)/EncUT_Reconstruct.cpp\
|
$(ENCODER_UNITTEST_SRCDIR)/EncUT_Reconstruct.cpp\
|
||||||
|
249
test/mc_test_common.h
Normal file
249
test/mc_test_common.h
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
#define MC_BUFF_SRC_STRIDE 32
|
||||||
|
#define MC_BUFF_DST_STRIDE 32
|
||||||
|
#define MC_BUFF_HEIGHT 30
|
||||||
|
|
||||||
|
/**********************MC Unit Test Anchor Code Begin******************************/
|
||||||
|
static bool bQpelNeeded[4][4] = {
|
||||||
|
{ false, true, false, true },
|
||||||
|
{ true, true, true, true },
|
||||||
|
{ false, true, false, true },
|
||||||
|
{ true, true, true, true }
|
||||||
|
};
|
||||||
|
static int32_t iHpelRef0Array[4][4] = {
|
||||||
|
{ 0, 1, 1, 1 },
|
||||||
|
{ 0, 1, 1, 1 },
|
||||||
|
{ 2, 3, 3, 3 },
|
||||||
|
{ 0, 1, 1, 1 }
|
||||||
|
};
|
||||||
|
static int32_t iHpelRef1Array[4][4] = {
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 2, 2, 3, 2 },
|
||||||
|
{ 2, 2, 3, 2 },
|
||||||
|
{ 2, 2, 3, 2 }
|
||||||
|
};
|
||||||
|
#define FILTER6TAP(pPixBuff, x, iStride) ((pPixBuff)[x-2*iStride] + (pPixBuff)[x+3*iStride] - 5*((pPixBuff)[x-iStride] + (pPixBuff)[x+2*iStride]) + 20*((pPixBuff)[x] + (pPixBuff)[x+iStride]))
|
||||||
|
static inline uint8_t Clip255 (int32_t x) {
|
||||||
|
return ((x & ~255) ? (-x) >> 31 & 255 : x);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MCCopyAnchor (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
|
||||||
|
int32_t iHeight) {
|
||||||
|
for (int32_t y = 0; y < iHeight; y++) {
|
||||||
|
memcpy (pDst, pSrc, iWidth * sizeof (uint8_t));
|
||||||
|
pSrc += iSrcStride;
|
||||||
|
pDst += iDstStride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MCHalfPelFilterAnchor (uint8_t* pDstH, uint8_t* pDstV, uint8_t* pDstHV, uint8_t* pSrc,
|
||||||
|
int32_t iStride, int32_t iWidth, int32_t iHeight, int16_t* pBuf) {
|
||||||
|
for (int32_t y = 0; y < iHeight; y++) {
|
||||||
|
for (int32_t x = 0; x < iWidth; x++)
|
||||||
|
pDstH[x] = Clip255 ((FILTER6TAP (pSrc, x, 1) + 16) >> 5);
|
||||||
|
for (int32_t x = -2; x < iWidth + 3; x++) {
|
||||||
|
int32_t v = FILTER6TAP (pSrc, x, iStride);
|
||||||
|
pDstV[x] = Clip255 ((v + 16) >> 5);
|
||||||
|
pBuf[x + 2] = v;
|
||||||
|
}
|
||||||
|
for (int32_t x = 0; x < iWidth; x++)
|
||||||
|
pDstHV[x] = Clip255 ((FILTER6TAP (pBuf + 2, x, 1) + 512) >> 10);
|
||||||
|
pDstH += iStride;
|
||||||
|
pDstV += iStride;
|
||||||
|
pDstHV += iStride;
|
||||||
|
pSrc += iStride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PixelAvgAnchor (uint8_t* pDst, int32_t iDstStride,
|
||||||
|
uint8_t* pSrc1, int32_t iSrc1Stride,
|
||||||
|
uint8_t* pSrc2, int32_t iSrc2Stride, int32_t iWidth, int32_t iHeight) {
|
||||||
|
for (int32_t y = 0; y < iHeight; y++) {
|
||||||
|
for (int32_t x = 0; x < iWidth; x++)
|
||||||
|
pDst[x] = (pSrc1[x] + pSrc2[x] + 1) >> 1;
|
||||||
|
pDst += iDstStride;
|
||||||
|
pSrc1 += iSrc1Stride;
|
||||||
|
pSrc2 += iSrc2Stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MCLumaAnchor (uint8_t* pDst, int32_t iDstStride, uint8_t* pSrc[4], int32_t iSrcStride,
|
||||||
|
int32_t iMvX, int32_t iMvY, int32_t iWidth, int32_t iHeight) {
|
||||||
|
int32_t iMvXIdx = iMvX & 3;
|
||||||
|
int32_t iMvYIdx = iMvY & 3;
|
||||||
|
int32_t iOffset = (iMvY >> 2) * iSrcStride + (iMvX >> 2);
|
||||||
|
uint8_t* pSrc1 = pSrc[iHpelRef0Array[iMvYIdx][iMvXIdx]] + iOffset + ((iMvYIdx) == 3) * iSrcStride;
|
||||||
|
|
||||||
|
if (bQpelNeeded[iMvYIdx][iMvXIdx]) {
|
||||||
|
uint8_t* pSrc2 = pSrc[iHpelRef1Array[iMvYIdx][iMvXIdx]] + iOffset + ((iMvXIdx) == 3);
|
||||||
|
PixelAvgAnchor (pDst, iDstStride, pSrc1, iSrcStride, pSrc2, iSrcStride, iWidth, iHeight);
|
||||||
|
} else {
|
||||||
|
MCCopyAnchor (pSrc1, iSrcStride, pDst, iDstStride, iWidth, iHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MCChromaAnchor (uint8_t* pDstU, uint8_t* pDstV, int32_t iDstStride, uint8_t* pSrc, int32_t iSrcStride,
|
||||||
|
int32_t iMvX, int32_t iMvY, int32_t iWidth, int32_t iHeight) {
|
||||||
|
uint8_t* pSrcTmp;
|
||||||
|
pSrc += (iMvY >> 3) * iSrcStride + (iMvX >> 3) * 2;
|
||||||
|
pSrcTmp = &pSrc[iSrcStride];
|
||||||
|
|
||||||
|
int32_t iMvXIdx = iMvX & 0x07;
|
||||||
|
int32_t iMvYIdx = iMvY & 0x07;
|
||||||
|
int32_t iBiPara0 = (8 - iMvXIdx) * (8 - iMvYIdx);
|
||||||
|
int32_t iBiPara1 = iMvXIdx * (8 - iMvYIdx);
|
||||||
|
int32_t iBiPara2 = (8 - iMvXIdx) * iMvYIdx;
|
||||||
|
int32_t iBiPara3 = iMvXIdx * iMvYIdx;
|
||||||
|
for (int32_t y = 0; y < iHeight; y++) {
|
||||||
|
for (int32_t x = 0; x < iWidth; x++) {
|
||||||
|
pDstU[x] = (iBiPara0 * pSrc[2 * x] + iBiPara1 * pSrc[2 * x + 2] +
|
||||||
|
iBiPara2 * pSrcTmp[2 * x] + iBiPara3 * pSrcTmp[2 * x + 2] + 32) >> 6;
|
||||||
|
pDstV[x] = (iBiPara0 * pSrc[2 * x + 1] + iBiPara1 * pSrc[2 * x + 3] +
|
||||||
|
iBiPara2 * pSrcTmp[2 * x + 1] + iBiPara3 * pSrcTmp[2 * x + 3] + 32) >> 6;
|
||||||
|
}
|
||||||
|
pSrc = pSrcTmp;
|
||||||
|
pSrcTmp += iSrcStride;
|
||||||
|
pDstU += iDstStride;
|
||||||
|
pDstV += iDstStride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************MC Unit Test OPENH264 Code Begin******************************/
|
||||||
|
#define DEF_MCCOPYTEST(pfx, iW,iH, forceC) \
|
||||||
|
TEST(pfx##McCopy_c,iW##x##iH) \
|
||||||
|
{ \
|
||||||
|
SMcFunc sMcFunc; \
|
||||||
|
int32_t iCpuCores = 1; \
|
||||||
|
uint32_t uiCpuFlag;\
|
||||||
|
for(int32_t k =0; k<2; k++)\
|
||||||
|
{\
|
||||||
|
if(k==0||forceC!=0)\
|
||||||
|
{\
|
||||||
|
uiCpuFlag = 0;\
|
||||||
|
}else \
|
||||||
|
{\
|
||||||
|
uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); \
|
||||||
|
}\
|
||||||
|
InitMcFunc(&sMcFunc, uiCpuFlag); \
|
||||||
|
uint8_t uSrcAnchor[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
|
||||||
|
uint8_t uSrcTest[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
|
||||||
|
ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
|
||||||
|
ENFORCE_STACK_ALIGN_2D(uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
|
||||||
|
for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
|
||||||
|
{ \
|
||||||
|
for(int32_t i=0;i<MC_BUFF_SRC_STRIDE;i++) \
|
||||||
|
{ \
|
||||||
|
uSrcAnchor[j][i] = uSrcTest[j][i] = rand()%256; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
memset(uDstAnchor,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE);\
|
||||||
|
memset(uDstTest,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
|
||||||
|
MCCopyAnchor(uSrcAnchor[0],MC_BUFF_SRC_STRIDE,uDstAnchor[0],MC_BUFF_DST_STRIDE,iW,iH); \
|
||||||
|
LUMA_FUNC(&sMcFunc,uSrcTest[0],MC_BUFF_SRC_STRIDE,uDstTest[0],MC_BUFF_DST_STRIDE,0,0,iW,iH); \
|
||||||
|
for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
|
||||||
|
{ \
|
||||||
|
for(int32_t i=0;i<MC_BUFF_DST_STRIDE;i++) \
|
||||||
|
{ \
|
||||||
|
ASSERT_EQ(uDstAnchor[j][i],uDstTest[j][i]); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}\
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DEF_LUMA_MCTEST(pfx,iW,iH) \
|
||||||
|
TEST(pfx##McHorVer,iW##x##iH) \
|
||||||
|
{ \
|
||||||
|
for (int32_t a = 0; a < 4; a++) { \
|
||||||
|
for (int32_t b = 0; b < 4; b++) { \
|
||||||
|
SMcFunc sMcFunc; \
|
||||||
|
uint8_t uSrcAnchor[4][MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
|
||||||
|
uint8_t uSrcTest[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
|
||||||
|
ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
|
||||||
|
ENFORCE_STACK_ALIGN_2D(uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
|
||||||
|
uint8_t* uSrcInputAnchor[4]; \
|
||||||
|
int16_t pBuf[MC_BUFF_DST_STRIDE]; \
|
||||||
|
uSrcInputAnchor[0] = &uSrcAnchor[0][4][4]; \
|
||||||
|
uSrcInputAnchor[1] = &uSrcAnchor[1][4][4]; \
|
||||||
|
uSrcInputAnchor[2] = &uSrcAnchor[2][4][4]; \
|
||||||
|
uSrcInputAnchor[3] = &uSrcAnchor[3][4][4]; \
|
||||||
|
for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
|
||||||
|
{\
|
||||||
|
for(int32_t i=0;i<MC_BUFF_SRC_STRIDE;i++) \
|
||||||
|
{\
|
||||||
|
uSrcAnchor[0][j][i] = uSrcTest[j][i] = rand()%256; \
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
int32_t iCpuCores = 1; \
|
||||||
|
uint32_t uiCpuFlag;\
|
||||||
|
for(int32_t k =0; k<2; k++)\
|
||||||
|
{\
|
||||||
|
if(k==0)\
|
||||||
|
{\
|
||||||
|
uiCpuFlag = 0;\
|
||||||
|
}else \
|
||||||
|
{\
|
||||||
|
uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); \
|
||||||
|
}\
|
||||||
|
InitMcFunc(&sMcFunc,uiCpuFlag);\
|
||||||
|
memset(uDstAnchor,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
|
||||||
|
memset(uDstTest,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
|
||||||
|
MCHalfPelFilterAnchor(uSrcInputAnchor[1],uSrcInputAnchor[2],uSrcInputAnchor[3],uSrcInputAnchor[0],MC_BUFF_SRC_STRIDE,iW+1,iH+1,pBuf+4); \
|
||||||
|
MCLumaAnchor(uDstAnchor[0],MC_BUFF_DST_STRIDE,uSrcInputAnchor,MC_BUFF_SRC_STRIDE,a,b,iW,iH); \
|
||||||
|
LUMA_FUNC(&sMcFunc,&uSrcTest[4][4],MC_BUFF_SRC_STRIDE,uDstTest[0],MC_BUFF_DST_STRIDE,a,b,iW,iH);\
|
||||||
|
for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
|
||||||
|
{ \
|
||||||
|
for(int32_t i=0;i<MC_BUFF_DST_STRIDE;i++) \
|
||||||
|
{ \
|
||||||
|
ASSERT_EQ(uDstAnchor[j][i],uDstTest[j][i]); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DEF_CHROMA_MCTEST(pfx,iW,iH) \
|
||||||
|
TEST(pfx##McChroma,iW##x##iH) \
|
||||||
|
{ \
|
||||||
|
for (int32_t a = 0; a < 8; a++) { \
|
||||||
|
for (int32_t b = 0; b < 8; b++) { \
|
||||||
|
SMcFunc sMcFunc; \
|
||||||
|
uint8_t uSrcAnchor[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE*2]; \
|
||||||
|
uint8_t uSrcTest[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
|
||||||
|
ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor1, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
|
||||||
|
ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor2, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
|
||||||
|
ENFORCE_STACK_ALIGN_2D(uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
|
||||||
|
for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
|
||||||
|
{\
|
||||||
|
for(int32_t i=0;i<MC_BUFF_SRC_STRIDE;i++) \
|
||||||
|
{\
|
||||||
|
uSrcAnchor[j][i*2] = uSrcTest[j][i] = rand()%256; \
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
int32_t iCpuCores = 1; \
|
||||||
|
uint32_t uiCpuFlag;\
|
||||||
|
for(int32_t k =0; k<2; k++)\
|
||||||
|
{\
|
||||||
|
if(k==0)\
|
||||||
|
{\
|
||||||
|
uiCpuFlag = 0;\
|
||||||
|
}else \
|
||||||
|
{\
|
||||||
|
uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); \
|
||||||
|
}\
|
||||||
|
InitMcFunc(&sMcFunc,uiCpuFlag);\
|
||||||
|
memset(uDstAnchor1,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
|
||||||
|
memset(uDstAnchor2,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
|
||||||
|
memset(uDstTest,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
|
||||||
|
MCChromaAnchor(uDstAnchor1[0],uDstAnchor2[0],MC_BUFF_DST_STRIDE,uSrcAnchor[0],MC_BUFF_SRC_STRIDE*2,a,b,iW,iH); \
|
||||||
|
CHROMA_FUNC(uSrcTest[0],MC_BUFF_SRC_STRIDE,uDstTest[0],MC_BUFF_DST_STRIDE,a,b,iW,iH);\
|
||||||
|
for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
|
||||||
|
{ \
|
||||||
|
for(int32_t i=0;i<MC_BUFF_DST_STRIDE;i++) \
|
||||||
|
{ \
|
||||||
|
ASSERT_EQ(uDstAnchor1[j][i],uDstTest[j][i]); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user