34ad719cf2
commit f73d6cf0fcae5f401fc2817ab736af996113ca09 Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Thu Apr 24 15:02:21 2014 +0800 remove comments commit 75416c2cf6c1ebb7aabf9e8c52d8c7163a8009b7 Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Thu Apr 24 14:52:09 2014 +0800 for test commit 7dfb65ce514edcff892bfb3919921cadcce1d055 Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Thu Apr 24 14:12:31 2014 +0800 for test commit eff771645e8c349dc4e454ab1751530b3cef18ed Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Thu Apr 24 10:51:34 2014 +0800 for test commit 9c42b9a7a04068e70be94529941f549b58e63780 Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Wed Apr 23 17:46:59 2014 +0800 update cpu_flag commit cce3fccc0a4249b82ab2e0e92fe53579ef942799 Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Wed Apr 23 17:26:56 2014 +0800 for test commit 3d292995b3c4437a2674a687cc4e8da1b5fb83f5 Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Wed Apr 23 16:45:57 2014 +0800 remove space commit c608c2ba7cf010f1dcf8c0344f68536c48e181cb Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Wed Apr 23 16:42:43 2014 +0800 remove tabs commit 3b769342a06e25ad23a2c86f23a94d0d7ca1a4c8 Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Wed Apr 23 16:33:55 2014 +0800 refine UT case commit 89b869f0c8f8c9bbd61e9de32caa77877aeae064 Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Tue Apr 22 13:40:50 2014 +0800 Squashed commit of the following: commit abe55494134ef8342ffe9566df4e1b3265fe21b6 Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Tue Apr 22 10:50:07 2014 +0800 set MV range commit 8c7f70c351e50d945c29118bed8b3781c22b7dbc Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Mon Apr 21 16:53:10 2014 +0800 refinement commit bf35f19a7dc88743aacf8e89e681e0ef3302d40a Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Fri Apr 18 17:24:31 2014 +0800 correct tabs commit 130b7f895d7020bfc571d910966891da93150242 Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Fri Apr 18 17:17:06 2014 +0800 correct format commit 0429703b0844363559dd2b3d44e45034232a9d8f Author: lyao2 <lyao2@LYAO2-WS01.cisco.com> Date: Fri Apr 18 15:12:44 2014 +0800 add scroll UT
85 lines
2.4 KiB
C++
85 lines
2.4 KiB
C++
#include <gtest/gtest.h>
|
|
#include <math.h>
|
|
#include <string.h>
|
|
#include "cpu.h"
|
|
#include "cpu_core.h"
|
|
#include "typedef.h"
|
|
#include "IWelsVP.h"
|
|
#include "ScrollDetection.h"
|
|
#include "ScrollDetectionFuncs.h"
|
|
#include "utils/DataGenerator.h"
|
|
|
|
using namespace nsWelsVP;
|
|
|
|
#define ASSERT_MEMORY_FAIL2X(A, B) \
|
|
if (NULL == B) { \
|
|
delete []A;\
|
|
ASSERT_TRUE(0); \
|
|
}
|
|
|
|
TEST(ScrollDetectionTest,TestScroll)
|
|
{
|
|
uint8_t* pSrc, *pRef;
|
|
int32_t iWidthSets[4] = {640,1024,1280,1980};
|
|
int32_t iHeightSets[4] = {360,768,720,1080};
|
|
int32_t iStride = 0;
|
|
int32_t iIdx = 0;
|
|
|
|
for(int32_t i=0; i<4; i++){
|
|
int32_t iWidth = iWidthSets[i];
|
|
int32_t iHeight = iHeightSets[i];
|
|
iStride = iWidth + 16;
|
|
pSrc = new uint8_t[iHeight*iStride];
|
|
ASSERT_TRUE(NULL != pSrc);
|
|
pRef = new uint8_t[iHeight*iStride];
|
|
ASSERT_MEMORY_FAIL2X(pSrc, pRef)
|
|
RandomPixelDataGenerator(pRef, iWidth, iHeight, iStride, iIdx );
|
|
|
|
int32_t iMvRange = iHeight/3;
|
|
int32_t iScrollMv = rand()%(iMvRange<<1) - iMvRange;
|
|
uint8_t* pSrcTmp = pSrc;
|
|
uint8_t* pRefTmp = pRef;
|
|
|
|
for (int32_t j=0;j<iHeight;j++) {
|
|
if ((j+iScrollMv)>=0 && (j+iScrollMv)<iHeight)
|
|
for (int32_t i=0;i<iWidth;i++) {
|
|
memcpy(pSrcTmp , &pRefTmp[(j+iScrollMv)*iStride], iWidth*sizeof(uint8_t));
|
|
} else {
|
|
for (int32_t i=0;i<iWidth;i++)
|
|
pSrcTmp[i] = rand()%256;
|
|
}
|
|
pSrcTmp += iStride;
|
|
}
|
|
|
|
|
|
SPixMap sSrcMap = { { 0 } };
|
|
SPixMap sRefMap = { { 0 } };
|
|
|
|
sSrcMap.pPixel[0] = pSrc;
|
|
sRefMap.pPixel[0] = pRef;
|
|
sSrcMap.iStride[0] = sRefMap.iStride[0] = iStride;
|
|
sSrcMap.sRect.iRectWidth = sRefMap.sRect.iRectWidth = iWidth;
|
|
sSrcMap.sRect.iRectHeight = sRefMap.sRect.iRectHeight = iHeight;
|
|
|
|
SScrollDetectionParam sScrollDetectionResult;
|
|
WelsMemset (&sScrollDetectionResult, 0, sizeof (sScrollDetectionResult));
|
|
int32_t iCoreNum = 1;
|
|
uint32_t uiCPUFlag = WelsCPUFeatureDetect (&iCoreNum);
|
|
|
|
CScrollDetection *pTest =new CScrollDetection(uiCPUFlag);
|
|
int32_t iMethodIdx = METHOD_SCROLL_DETECTION;
|
|
|
|
pTest->Set(iMethodIdx, (&sScrollDetectionResult));
|
|
int32_t ret = pTest->Process(iMethodIdx,&sSrcMap, &sRefMap);
|
|
EXPECT_EQ(ret,0);
|
|
pTest->Get(iMethodIdx, (&sScrollDetectionResult));
|
|
|
|
EXPECT_EQ(sScrollDetectionResult.bScrollDetectFlag,1);
|
|
EXPECT_EQ(sScrollDetectionResult.iScrollMvY,iScrollMv);
|
|
|
|
delete pTest;
|
|
delete []pSrc;
|
|
delete []pRef;
|
|
}
|
|
}
|