#include #include #include #include "cpu.h" #include "cpu_core.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) { unsigned char* pSrc, *pRef; int iWidthSets[4] = {640,1024,1280,1980}; int iHeightSets[4] = {360,768,720,1080}; int iStride = 0; int iIdx = 0; for(int i=0; i<4; i++){ int iWidth = iWidthSets[i]; int iHeight = iHeightSets[i]; iStride = iWidth + 16; pSrc = new unsigned char[iHeight*iStride]; ASSERT_TRUE(NULL != pSrc); pRef = new unsigned char[iHeight*iStride]; ASSERT_MEMORY_FAIL2X(pSrc, pRef) RandomPixelDataGenerator(pRef, iWidth, iHeight, iStride, iIdx ); int iMvRange = iHeight/3; int iScrollMv = rand()%(iMvRange<<1) - iMvRange; unsigned char* pSrcTmp = pSrc; unsigned char* pRefTmp = pRef; for (int j=0;j=0 && (j+iScrollMv)Set(iMethodIdx, (&sScrollDetectionResult)); int 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; } }