| 17 | } |
| 18 | |
| 19 | TEST (ScrollDetectionTest, TestScroll) { |
| 20 | unsigned char* pSrc, *pRef; |
| 21 | int iWidthSets[4] = {640, 1024, 1280, 1980}; |
| 22 | int iHeightSets[4] = {360, 768, 720, 1080}; |
| 23 | int iStride = 0; |
| 24 | |
| 25 | for (int i = 0; i < 4; i++) { |
| 26 | int iWidth = iWidthSets[i]; |
| 27 | int iHeight = iHeightSets[i]; |
| 28 | iStride = iWidth + 16; |
| 29 | pSrc = new unsigned char[iHeight * iStride]; |
| 30 | ASSERT_TRUE (NULL != pSrc); |
| 31 | pRef = new unsigned char[iHeight * iStride]; |
| 32 | ASSERT_MEMORY_FAIL2X (pSrc, pRef) |
| 33 | RandomPixelDataGenerator (pRef, iWidth, iHeight, iStride); |
| 34 | |
| 35 | int iMvRange = iHeight / 3; |
| 36 | int iScrollMv = rand() % (iMvRange << 1) - iMvRange; |
| 37 | unsigned char* pSrcTmp = pSrc; |
| 38 | unsigned char* pRefTmp = pRef; |
| 39 | |
| 40 | for (int j = 0; j < iHeight; j++) { |
| 41 | if ((j + iScrollMv) >= 0 && (j + iScrollMv) < iHeight) |
| 42 | for (int i = 0; i < iWidth; i++) { |
| 43 | memcpy (pSrcTmp , &pRefTmp[ (j + iScrollMv)*iStride], iWidth * sizeof (unsigned char)); |
| 44 | } |
| 45 | else { |
| 46 | for (int i = 0; i < iWidth; i++) |
| 47 | pSrcTmp[i] = rand() % 256; |
| 48 | } |
| 49 | pSrcTmp += iStride; |
| 50 | } |
| 51 | |
| 52 | |
| 53 | SPixMap sSrcMap = { { 0 } }; |
| 54 | SPixMap sRefMap = { { 0 } }; |
| 55 | |
| 56 | sSrcMap.pPixel[0] = pSrc; |
| 57 | sRefMap.pPixel[0] = pRef; |
| 58 | sSrcMap.iStride[0] = sRefMap.iStride[0] = iStride; |
| 59 | sSrcMap.sRect.iRectWidth = sRefMap.sRect.iRectWidth = iWidth; |
| 60 | sSrcMap.sRect.iRectHeight = sRefMap.sRect.iRectHeight = iHeight; |
| 61 | |
| 62 | SScrollDetectionParam sScrollDetectionResult; |
| 63 | WelsMemset (&sScrollDetectionResult, 0, sizeof (sScrollDetectionResult)); |
| 64 | int iCoreNum = 1; |
| 65 | unsigned int uiCPUFlag = WelsCPUFeatureDetect (&iCoreNum); |
| 66 | |
| 67 | CScrollDetection* pTest = new CScrollDetection (uiCPUFlag); |
| 68 | int iMethodIdx = METHOD_SCROLL_DETECTION; |
| 69 | |
| 70 | pTest->Set (iMethodIdx, (&sScrollDetectionResult)); |
| 71 | int ret = pTest->Process (iMethodIdx, &sSrcMap, &sRefMap); |
| 72 | EXPECT_EQ (ret, 0); |
| 73 | pTest->Get (iMethodIdx, (&sScrollDetectionResult)); |
| 74 | |
| 75 | EXPECT_EQ (sScrollDetectionResult.bScrollDetectFlag, true); |
| 76 | EXPECT_EQ (sScrollDetectionResult.iScrollMvY, iScrollMv); |
nothing calls this directly
no test coverage detected