2014-03-14 09:40:02 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "utils/DataGenerator.h"
|
|
|
|
#include "md.h"
|
|
|
|
#include "sample.h"
|
|
|
|
#include "svc_motion_estimate.h"
|
|
|
|
#include "wels_func_ptr_def.h"
|
2014-03-28 03:22:11 +01:00
|
|
|
#include "cpu.h"
|
2014-03-14 09:40:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
using namespace WelsSVCEnc;
|
|
|
|
|
|
|
|
void CopyTargetBlock( uint8_t* pSrcBlock, const int32_t kiBlockSize, SMVUnitXY sTargetMv, const int32_t kiRefPicStride,
|
2014-04-01 07:55:22 +02:00
|
|
|
uint8_t* pRefPic) {
|
2014-03-14 09:40:02 +01:00
|
|
|
uint8_t* pTargetPos = pRefPic+sTargetMv.iMvY*kiRefPicStride+sTargetMv.iMvX;
|
|
|
|
uint8_t* pSourcePos = pSrcBlock;
|
|
|
|
|
|
|
|
for (int i = 0; i<kiBlockSize; i++) {
|
|
|
|
memcpy( pSourcePos, pTargetPos, kiBlockSize*sizeof(uint8_t) );
|
|
|
|
pTargetPos += kiRefPicStride;
|
|
|
|
pSourcePos += kiBlockSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InitMe( const uint8_t kuiQp, const uint32_t kuiMvdTableMiddle, const uint32_t kuiMvdTableStride,
|
2014-04-01 07:55:22 +02:00
|
|
|
uint16_t* pMvdCostTable, SWelsME* pMe) {
|
2014-03-14 09:40:02 +01:00
|
|
|
MvdCostInit( pMvdCostTable, kuiMvdTableStride );
|
|
|
|
pMe->pMvdCost = &pMvdCostTable[kuiQp*kuiMvdTableStride + kuiMvdTableMiddle];
|
|
|
|
pMe->sMvp.iMvX = pMe->sMvp.iMvY = 0;
|
|
|
|
pMe->sMvBase.iMvX = pMe->sMvBase.iMvY = 0;
|
|
|
|
pMe->sMv.iMvX = pMe->sMv.iMvY = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
class MotionEstimateTest : public ::testing::Test {
|
|
|
|
public:
|
|
|
|
virtual void SetUp() {
|
|
|
|
m_pRefPic = NULL;
|
|
|
|
m_pSrcBlock = NULL;
|
|
|
|
m_pMvdCostTable = NULL;
|
|
|
|
|
|
|
|
m_iWidth = 64;//size of search window
|
|
|
|
m_iHeight = 64;//size of search window
|
|
|
|
m_iMaxSearchBlock = 16;
|
|
|
|
m_uiMvdTableSize = (1 + (648 << 1));
|
|
|
|
|
2014-03-28 03:22:11 +01:00
|
|
|
pMa = new CMemoryAlign(0);
|
2014-03-14 09:40:02 +01:00
|
|
|
m_pRefPic = static_cast<uint8_t *>
|
2014-03-28 03:22:11 +01:00
|
|
|
(pMa->WelsMalloc(m_iWidth*m_iHeight, "RefPic"));
|
2014-03-14 09:40:02 +01:00
|
|
|
ASSERT_TRUE( NULL != m_pRefPic );
|
|
|
|
m_pSrcBlock = static_cast<uint8_t *>
|
2014-03-28 03:22:11 +01:00
|
|
|
(pMa->WelsMalloc(m_iMaxSearchBlock*m_iMaxSearchBlock, "SrcBlock"));
|
2014-03-14 09:40:02 +01:00
|
|
|
ASSERT_TRUE( NULL != m_pSrcBlock );
|
|
|
|
m_pMvdCostTable=new uint16_t[52*m_uiMvdTableSize];
|
|
|
|
ASSERT_TRUE( NULL != m_pMvdCostTable );
|
|
|
|
}
|
|
|
|
virtual void TearDown() {
|
|
|
|
delete [] m_pMvdCostTable;
|
2014-03-28 03:22:11 +01:00
|
|
|
pMa->WelsFree( m_pRefPic, "RefPic");
|
|
|
|
pMa->WelsFree( m_pSrcBlock, "SrcBlock");
|
|
|
|
delete pMa;
|
2014-03-14 09:40:02 +01:00
|
|
|
}
|
|
|
|
public:
|
|
|
|
uint8_t *m_pRefPic;
|
|
|
|
uint8_t *m_pSrcBlock;
|
|
|
|
uint32_t m_uiMvdTableSize;
|
|
|
|
uint16_t *m_pMvdCostTable;
|
|
|
|
|
|
|
|
int32_t m_iWidth;
|
|
|
|
int32_t m_iHeight;
|
|
|
|
int32_t m_iMaxSearchBlock;
|
2014-03-28 03:22:11 +01:00
|
|
|
CMemoryAlign *pMa;
|
2014-03-14 09:40:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-04-01 07:55:22 +02:00
|
|
|
TEST_F(MotionEstimateTest, TestDiamondSearch) {
|
2014-03-14 09:40:02 +01:00
|
|
|
#define TEST_POS (5)
|
|
|
|
const int32_t kiPositionToCheck[TEST_POS][2] = {{0,0}, {0,1}, {1,0}, {0,-1}, {-1,0}};
|
|
|
|
const int32_t kiMaxBlock16Sad = 72000;//a rough number
|
|
|
|
SWelsFuncPtrList sFuncList;
|
|
|
|
SWelsME sMe;
|
2014-04-02 04:12:39 +02:00
|
|
|
SSlice sSlice;
|
2014-03-14 09:40:02 +01:00
|
|
|
|
|
|
|
srand((uint32_t)time(NULL));
|
|
|
|
const uint8_t kuiQp = rand()%52;
|
|
|
|
InitMe(kuiQp, 648, m_uiMvdTableSize, m_pMvdCostTable, &sMe);
|
|
|
|
|
|
|
|
SMVUnitXY sTargetMv;
|
|
|
|
WelsInitSampleSadFunc( &sFuncList, 0 );//test c functions
|
|
|
|
|
|
|
|
uint8_t *pRefPicCenter = m_pRefPic+(m_iHeight/2)*m_iWidth+(m_iWidth/2);
|
|
|
|
bool bDataGeneratorSucceed = false;
|
|
|
|
bool bFoundMatch = false;
|
2014-03-14 14:15:57 +01:00
|
|
|
int32_t i, iTryTimes;
|
2014-03-14 09:40:02 +01:00
|
|
|
for (i=0;i<TEST_POS;i++) {
|
|
|
|
sTargetMv.iMvX = kiPositionToCheck[i][0];
|
|
|
|
sTargetMv.iMvY = kiPositionToCheck[i][1];
|
|
|
|
iTryTimes = 100;
|
|
|
|
bDataGeneratorSucceed = false;
|
|
|
|
bFoundMatch = false;
|
|
|
|
while (!bFoundMatch && (iTryTimes--)>0) {
|
|
|
|
if (!YUVPixelDataGenerator( m_pRefPic, m_iWidth, m_iHeight, m_iWidth ))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
bDataGeneratorSucceed = true;
|
|
|
|
CopyTargetBlock( m_pSrcBlock, 16, sTargetMv, m_iWidth, pRefPicCenter);
|
|
|
|
|
|
|
|
//clean the sMe status
|
2014-03-26 09:23:44 +01:00
|
|
|
sMe.uiBlockSize = rand()%5;
|
2014-03-14 09:40:02 +01:00
|
|
|
sMe.pEncMb = m_pSrcBlock;
|
|
|
|
sMe.pRefMb = pRefPicCenter;
|
|
|
|
sMe.sMv.iMvX = sMe.sMv.iMvY = 0;
|
|
|
|
sMe.uiSadCost = sMe.uiSatdCost = kiMaxBlock16Sad;
|
2014-04-02 04:12:39 +02:00
|
|
|
WelsDiamondSearch (&sFuncList, &sMe, &sSlice, m_iMaxSearchBlock, m_iWidth);
|
2014-03-14 09:40:02 +01:00
|
|
|
|
|
|
|
//the last selection may be affected by MVDcost, that is when (0,0) will be better
|
|
|
|
//when comparing (1,1) and (1,0), due to the difference between MVD cost, it is possible that (1,0) is selected while the best match is (1,1)
|
2014-03-25 04:03:37 +01:00
|
|
|
bFoundMatch = ((sMe.sMv.iMvX==(sTargetMv.iMvX))||(sMe.sMv.iMvX==0)) && ((sMe.sMv.iMvY==(sTargetMv.iMvY))||(sMe.sMv.iMvY==0));
|
2014-03-14 09:40:02 +01:00
|
|
|
}
|
|
|
|
if (bDataGeneratorSucceed) {
|
|
|
|
//if DataGenerator never succeed, there is no meaning to check iTryTimes
|
|
|
|
ASSERT_TRUE(iTryTimes > 0);
|
|
|
|
//it is possible that ref at differnt position is identical, but that should be under a low probability
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-26 09:23:44 +01:00
|
|
|
|
|
|
|
|
2014-04-01 07:55:22 +02:00
|
|
|
TEST_F(MotionEstimateTest, TestVerticalSearch) {
|
2014-03-26 09:23:44 +01:00
|
|
|
const int32_t kiMaxBlock16Sad = 72000;//a rough number
|
|
|
|
SWelsFuncPtrList sFuncList;
|
|
|
|
SWelsME sMe;
|
|
|
|
|
|
|
|
srand((uint32_t)time(NULL));
|
|
|
|
const uint8_t kuiQp = rand()%52;
|
|
|
|
InitMe(kuiQp, 648, m_uiMvdTableSize, m_pMvdCostTable, &sMe);
|
|
|
|
|
|
|
|
SMVUnitXY sTargetMv;
|
|
|
|
WelsInitSampleSadFunc( &sFuncList, 0 );//test c functions
|
|
|
|
|
|
|
|
uint8_t *pRefPicCenter = m_pRefPic+(m_iHeight/2)*m_iWidth+(m_iWidth/2);
|
|
|
|
sMe.iCurMeBlockPixX = (m_iWidth/2);
|
|
|
|
sMe.iCurMeBlockPixY = (m_iHeight/2);
|
|
|
|
|
|
|
|
bool bDataGeneratorSucceed = false;
|
|
|
|
bool bFoundMatch = false;
|
|
|
|
int32_t iTryTimes=100;
|
|
|
|
|
|
|
|
sTargetMv.iMvX = 0;
|
|
|
|
sTargetMv.iMvY = WELS_MAX(INTPEL_NEEDED_MARGIN, rand()%m_iHeight-INTPEL_NEEDED_MARGIN);
|
|
|
|
bDataGeneratorSucceed = false;
|
|
|
|
bFoundMatch = false;
|
|
|
|
while (!bFoundMatch && (iTryTimes--)>0) {
|
|
|
|
if (!YUVPixelDataGenerator( m_pRefPic, m_iWidth, m_iHeight, m_iWidth ))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
bDataGeneratorSucceed = true;
|
|
|
|
CopyTargetBlock( m_pSrcBlock, 16, sTargetMv, m_iWidth, pRefPicCenter);
|
|
|
|
|
|
|
|
//clean the sMe status
|
|
|
|
sMe.uiBlockSize = rand()%5;
|
|
|
|
sMe.pEncMb = m_pSrcBlock;
|
|
|
|
sMe.pRefMb = pRefPicCenter;
|
|
|
|
sMe.pColoRefMb = pRefPicCenter;
|
|
|
|
sMe.sMv.iMvX = sMe.sMv.iMvY = 0;
|
|
|
|
sMe.uiSadCost = sMe.uiSatdCost = kiMaxBlock16Sad;
|
|
|
|
const int32_t iCurMeBlockPixX = sMe.iCurMeBlockPixX;
|
|
|
|
const int32_t iCurMeBlockQpelPixX = ((iCurMeBlockPixX)<<2);
|
|
|
|
const int32_t iCurMeBlockPixY = sMe.iCurMeBlockPixY;
|
|
|
|
const int32_t iCurMeBlockQpelPixY = ((iCurMeBlockPixY)<<2);
|
|
|
|
uint16_t* pMvdCostX = sMe.pMvdCost - iCurMeBlockQpelPixX - sMe.sMvp.iMvX; //do the offset here
|
|
|
|
uint16_t* pMvdCostY = sMe.pMvdCost - iCurMeBlockQpelPixY - sMe.sMvp.iMvY;
|
2014-03-26 09:52:53 +01:00
|
|
|
LineFullSearch_c ( &sFuncList, &sMe,
|
2014-03-26 09:23:44 +01:00
|
|
|
pMvdCostY, pMvdCostX[ iCurMeBlockQpelPixX ],
|
|
|
|
m_iMaxSearchBlock, m_iWidth,
|
|
|
|
INTPEL_NEEDED_MARGIN,
|
|
|
|
m_iHeight-INTPEL_NEEDED_MARGIN, true );
|
|
|
|
|
|
|
|
//the last selection may be affected by MVDcost, that is when smaller MvY will be better
|
|
|
|
bFoundMatch = (sMe.sMv.iMvX==0
|
|
|
|
&&(sMe.sMv.iMvY==sTargetMv.iMvY||abs(sMe.sMv.iMvY)<abs(sTargetMv.iMvY)));
|
|
|
|
//printf("TestVerticalSearch Target: %d,%d\n", sTargetMv.iMvX, sTargetMv.iMvY);
|
|
|
|
}
|
|
|
|
if (bDataGeneratorSucceed) {
|
|
|
|
//if DataGenerator never succeed, there is no meaning to check iTryTimes
|
|
|
|
ASSERT_TRUE(iTryTimes > 0);
|
|
|
|
//it is possible that ref at differnt position is identical, but that should be under a low probability
|
|
|
|
}
|
|
|
|
}
|
2014-04-01 07:55:22 +02:00
|
|
|
TEST_F(MotionEstimateTest, TestHorizontalSearch) {
|
2014-03-26 09:23:44 +01:00
|
|
|
const int32_t kiMaxBlock16Sad = 72000;//a rough number
|
|
|
|
SWelsFuncPtrList sFuncList;
|
|
|
|
SWelsME sMe;
|
|
|
|
|
|
|
|
srand((uint32_t)time(NULL));
|
|
|
|
const uint8_t kuiQp = rand()%52;
|
|
|
|
InitMe(kuiQp, 648, m_uiMvdTableSize, m_pMvdCostTable, &sMe);
|
|
|
|
|
|
|
|
SMVUnitXY sTargetMv;
|
|
|
|
WelsInitSampleSadFunc( &sFuncList, 0 );//test c functions
|
|
|
|
|
|
|
|
uint8_t *pRefPicCenter = m_pRefPic+(m_iHeight/2)*m_iWidth+(m_iWidth/2);
|
|
|
|
sMe.iCurMeBlockPixX = (m_iWidth/2);
|
|
|
|
sMe.iCurMeBlockPixY = (m_iHeight/2);
|
|
|
|
|
|
|
|
bool bDataGeneratorSucceed = false;
|
|
|
|
bool bFoundMatch = false;
|
|
|
|
int32_t iTryTimes=100;
|
|
|
|
|
|
|
|
sTargetMv.iMvX = WELS_MAX(INTPEL_NEEDED_MARGIN, rand()%m_iWidth-INTPEL_NEEDED_MARGIN);
|
|
|
|
sTargetMv.iMvY = 0;
|
|
|
|
bDataGeneratorSucceed = false;
|
|
|
|
bFoundMatch = false;
|
|
|
|
while (!bFoundMatch && (iTryTimes--)>0) {
|
|
|
|
if (!YUVPixelDataGenerator( m_pRefPic, m_iWidth, m_iHeight, m_iWidth ))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
bDataGeneratorSucceed = true;
|
|
|
|
CopyTargetBlock( m_pSrcBlock, 16, sTargetMv, m_iWidth, pRefPicCenter);
|
|
|
|
|
|
|
|
//clean the sMe status
|
|
|
|
sMe.uiBlockSize = rand()%5;
|
|
|
|
sMe.pEncMb = m_pSrcBlock;
|
|
|
|
sMe.pRefMb = pRefPicCenter;
|
|
|
|
sMe.pColoRefMb = pRefPicCenter;
|
|
|
|
sMe.sMv.iMvX = sMe.sMv.iMvY = 0;
|
|
|
|
sMe.uiSadCost = sMe.uiSatdCost = kiMaxBlock16Sad;
|
|
|
|
const int32_t iCurMeBlockPixX = sMe.iCurMeBlockPixX;
|
|
|
|
const int32_t iCurMeBlockQpelPixX = ((iCurMeBlockPixX)<<2);
|
|
|
|
const int32_t iCurMeBlockPixY = sMe.iCurMeBlockPixY;
|
|
|
|
const int32_t iCurMeBlockQpelPixY = ((iCurMeBlockPixY)<<2);
|
|
|
|
uint16_t* pMvdCostX = sMe.pMvdCost - iCurMeBlockQpelPixX - sMe.sMvp.iMvX; //do the offset here
|
|
|
|
uint16_t* pMvdCostY = sMe.pMvdCost - iCurMeBlockQpelPixY - sMe.sMvp.iMvY;
|
2014-03-26 09:52:53 +01:00
|
|
|
LineFullSearch_c ( &sFuncList, &sMe,
|
2014-03-26 09:23:44 +01:00
|
|
|
pMvdCostX, pMvdCostY[ iCurMeBlockQpelPixY ],
|
|
|
|
m_iMaxSearchBlock, m_iWidth,
|
|
|
|
INTPEL_NEEDED_MARGIN,
|
|
|
|
m_iWidth-INTPEL_NEEDED_MARGIN, false );
|
|
|
|
|
|
|
|
//the last selection may be affected by MVDcost, that is when smaller MvY will be better
|
|
|
|
bFoundMatch = (sMe.sMv.iMvY==0
|
|
|
|
&&(sMe.sMv.iMvX==sTargetMv.iMvX||abs(sMe.sMv.iMvX)<abs(sTargetMv.iMvX)));
|
|
|
|
//printf("TestHorizontalSearch Target: %d,%d\n", sTargetMv.iMvX, sTargetMv.iMvY);
|
|
|
|
}
|
|
|
|
if (bDataGeneratorSucceed) {
|
|
|
|
//if DataGenerator never succeed, there is no meaning to check iTryTimes
|
|
|
|
ASSERT_TRUE(iTryTimes > 0);
|
|
|
|
//it is possible that ref at differnt position is identical, but that should be under a low probability
|
|
|
|
}
|
2014-03-28 03:22:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef X86_ASM
|
|
|
|
TEST_F(MotionEstimateTest, TestVerticalSearch_SSE41)
|
|
|
|
{
|
|
|
|
const int32_t kiMaxBlock16Sad = 72000;//a rough number
|
|
|
|
SWelsFuncPtrList sFuncList;
|
|
|
|
SWelsME sMe;
|
|
|
|
|
|
|
|
srand((uint32_t)time(NULL));
|
|
|
|
const uint8_t kuiQp = rand()%52;
|
|
|
|
InitMe(kuiQp, 648, m_uiMvdTableSize, m_pMvdCostTable, &sMe);
|
2014-04-10 04:41:54 +02:00
|
|
|
int32_t iTmp = 1;
|
|
|
|
uint32_t uiCPUFlags = WelsCPUFeatureDetect( &iTmp);
|
|
|
|
if ((uiCPUFlags & WELS_CPU_SSE41) == 0) return ;
|
2014-03-28 03:22:11 +01:00
|
|
|
|
|
|
|
SMVUnitXY sTargetMv;
|
|
|
|
WelsInitSampleSadFunc( &sFuncList, 0 );//test c functions
|
|
|
|
WelsInitMeFunc(&sFuncList, WELS_CPU_SSE41, 1);
|
|
|
|
|
|
|
|
uint8_t *pRefPicCenter = m_pRefPic+(m_iHeight/2)*m_iWidth+(m_iWidth/2);
|
|
|
|
sMe.iCurMeBlockPixX = (m_iWidth/2);
|
|
|
|
sMe.iCurMeBlockPixY = (m_iHeight/2);
|
|
|
|
|
|
|
|
bool bDataGeneratorSucceed = false;
|
|
|
|
bool bFoundMatch = false;
|
|
|
|
int32_t iTryTimes=100;
|
|
|
|
|
|
|
|
sTargetMv.iMvX = 0;
|
|
|
|
sTargetMv.iMvY = WELS_MAX(INTPEL_NEEDED_MARGIN, rand()%m_iHeight-INTPEL_NEEDED_MARGIN);
|
|
|
|
bDataGeneratorSucceed = false;
|
|
|
|
bFoundMatch = false;
|
|
|
|
while (!bFoundMatch && (iTryTimes--)>0) {
|
|
|
|
if (!YUVPixelDataGenerator( m_pRefPic, m_iWidth, m_iHeight, m_iWidth ))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
bDataGeneratorSucceed = true;
|
|
|
|
CopyTargetBlock( m_pSrcBlock, 16, sTargetMv, m_iWidth, pRefPicCenter);
|
|
|
|
|
|
|
|
//clean the sMe status
|
|
|
|
sMe.uiBlockSize = rand()%5;
|
|
|
|
sMe.pEncMb = m_pSrcBlock;
|
|
|
|
sMe.pRefMb = pRefPicCenter;
|
|
|
|
sMe.pColoRefMb = pRefPicCenter;
|
|
|
|
sMe.sMv.iMvX = sMe.sMv.iMvY = 0;
|
|
|
|
sMe.uiSadCost = sMe.uiSatdCost = kiMaxBlock16Sad;
|
|
|
|
const int32_t iCurMeBlockPixX = sMe.iCurMeBlockPixX;
|
|
|
|
const int32_t iCurMeBlockQpelPixX = ((iCurMeBlockPixX)<<2);
|
|
|
|
const int32_t iCurMeBlockPixY = sMe.iCurMeBlockPixY;
|
|
|
|
const int32_t iCurMeBlockQpelPixY = ((iCurMeBlockPixY)<<2);
|
|
|
|
uint16_t* pMvdCostX = sMe.pMvdCost - iCurMeBlockQpelPixX - sMe.sMvp.iMvX; //do the offset here
|
|
|
|
uint16_t* pMvdCostY = sMe.pMvdCost - iCurMeBlockQpelPixY - sMe.sMvp.iMvY;
|
|
|
|
VerticalFullSearchUsingSSE41 ( &sFuncList, &sMe,
|
|
|
|
pMvdCostY, pMvdCostX[ iCurMeBlockQpelPixX ],
|
|
|
|
m_iMaxSearchBlock, m_iWidth,
|
|
|
|
INTPEL_NEEDED_MARGIN,
|
|
|
|
m_iHeight-INTPEL_NEEDED_MARGIN, true );
|
|
|
|
|
|
|
|
//the last selection may be affected by MVDcost, that is when smaller MvY will be better
|
|
|
|
bFoundMatch = (sMe.sMv.iMvX==0
|
|
|
|
&&(sMe.sMv.iMvY==sTargetMv.iMvY||abs(sMe.sMv.iMvY)<abs(sTargetMv.iMvY)));
|
|
|
|
//printf("TestVerticalSearch Target: %d,%d\n", sTargetMv.iMvX, sTargetMv.iMvY);
|
|
|
|
}
|
|
|
|
if (bDataGeneratorSucceed) {
|
|
|
|
//if DataGenerator never succeed, there is no meaning to check iTryTimes
|
|
|
|
ASSERT_TRUE(iTryTimes > 0);
|
|
|
|
//it is possible that ref at differnt position is identical, but that should be under a low probability
|
|
|
|
}
|
|
|
|
}
|
2014-04-18 05:55:27 +02:00
|
|
|
/*
|
2014-03-28 03:22:11 +01:00
|
|
|
TEST_F(MotionEstimateTest, TestHorizontalSearch_SSE41)
|
|
|
|
{
|
|
|
|
const int32_t kiMaxBlock16Sad = 72000;//a rough number
|
|
|
|
SWelsFuncPtrList sFuncList;
|
|
|
|
SWelsME sMe;
|
|
|
|
|
|
|
|
srand((uint32_t)time(NULL));
|
|
|
|
const uint8_t kuiQp = rand()%52;
|
|
|
|
InitMe(kuiQp, 648, m_uiMvdTableSize, m_pMvdCostTable, &sMe);
|
2014-04-10 04:41:54 +02:00
|
|
|
int32_t iTmp = 1;
|
|
|
|
uint32_t uiCPUFlags = WelsCPUFeatureDetect( &iTmp);
|
|
|
|
if ((uiCPUFlags & WELS_CPU_SSE41) == 0) return ;
|
2014-03-28 03:22:11 +01:00
|
|
|
SMVUnitXY sTargetMv;
|
|
|
|
WelsInitSampleSadFunc( &sFuncList, 0 );//test c functions
|
|
|
|
WelsInitMeFunc(&sFuncList, WELS_CPU_SSE41, 1);
|
|
|
|
|
|
|
|
uint8_t *pRefPicCenter = m_pRefPic+(m_iHeight/2)*m_iWidth+(m_iWidth/2);
|
|
|
|
sMe.iCurMeBlockPixX = (m_iWidth/2);
|
|
|
|
sMe.iCurMeBlockPixY = (m_iHeight/2);
|
|
|
|
|
|
|
|
bool bDataGeneratorSucceed = false;
|
|
|
|
bool bFoundMatch = false;
|
|
|
|
int32_t iTryTimes=100;
|
|
|
|
|
|
|
|
sTargetMv.iMvX = WELS_MAX(INTPEL_NEEDED_MARGIN, rand()%m_iWidth-INTPEL_NEEDED_MARGIN);
|
|
|
|
sTargetMv.iMvY = 0;
|
|
|
|
bDataGeneratorSucceed = false;
|
|
|
|
bFoundMatch = false;
|
|
|
|
while (!bFoundMatch && (iTryTimes--)>0) {
|
|
|
|
if (!YUVPixelDataGenerator( m_pRefPic, m_iWidth, m_iHeight, m_iWidth ))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
bDataGeneratorSucceed = true;
|
|
|
|
CopyTargetBlock( m_pSrcBlock, 16, sTargetMv, m_iWidth, pRefPicCenter);
|
|
|
|
|
|
|
|
//clean the sMe status
|
|
|
|
sMe.uiBlockSize = rand()%5;
|
|
|
|
sMe.pEncMb = m_pSrcBlock;
|
|
|
|
sMe.pRefMb = pRefPicCenter;
|
|
|
|
sMe.pColoRefMb = pRefPicCenter;
|
|
|
|
sMe.sMv.iMvX = sMe.sMv.iMvY = 0;
|
|
|
|
sMe.uiSadCost = sMe.uiSatdCost = kiMaxBlock16Sad;
|
|
|
|
const int32_t iCurMeBlockPixX = sMe.iCurMeBlockPixX;
|
|
|
|
const int32_t iCurMeBlockQpelPixX = ((iCurMeBlockPixX)<<2);
|
|
|
|
const int32_t iCurMeBlockPixY = sMe.iCurMeBlockPixY;
|
|
|
|
const int32_t iCurMeBlockQpelPixY = ((iCurMeBlockPixY)<<2);
|
|
|
|
uint16_t* pMvdCostX = sMe.pMvdCost - iCurMeBlockQpelPixX - sMe.sMvp.iMvX; //do the offset here
|
|
|
|
uint16_t* pMvdCostY = sMe.pMvdCost - iCurMeBlockQpelPixY - sMe.sMvp.iMvY;
|
|
|
|
HorizontalFullSearchUsingSSE41 ( &sFuncList, &sMe,
|
|
|
|
pMvdCostX, pMvdCostY[ iCurMeBlockQpelPixY ],
|
|
|
|
m_iMaxSearchBlock, m_iWidth,
|
|
|
|
INTPEL_NEEDED_MARGIN,
|
|
|
|
m_iWidth-INTPEL_NEEDED_MARGIN, false );
|
|
|
|
|
|
|
|
//the last selection may be affected by MVDcost, that is when smaller MvY will be better
|
|
|
|
bFoundMatch = (sMe.sMv.iMvY==0
|
|
|
|
&&(sMe.sMv.iMvX==sTargetMv.iMvX||abs(sMe.sMv.iMvX)<abs(sTargetMv.iMvX)));
|
|
|
|
//printf("TestHorizontalSearch Target: %d,%d\n", sTargetMv.iMvX, sTargetMv.iMvY);
|
|
|
|
}
|
|
|
|
if (bDataGeneratorSucceed) {
|
|
|
|
//if DataGenerator never succeed, there is no meaning to check iTryTimes
|
|
|
|
ASSERT_TRUE(iTryTimes > 0);
|
|
|
|
//it is possible that ref at differnt position is identical, but that should be under a low probability
|
|
|
|
}
|
|
|
|
}
|
2014-04-18 05:55:27 +02:00
|
|
|
*/
|
2014-03-28 03:22:11 +01:00
|
|
|
#endif
|