Showing the changes to test/processing (2 of 8 files). Show all
Unified · Split
| @@ -0,0 +1,76 @@ | |||
| 1 | #include <gtest/gtest.h> | ||
| 2 | #include <math.h> | ||
| 3 | #include <string.h> | ||
| 4 | #include "cpu.h" | ||
| 5 | #include "cpu_core.h" | ||
| 6 | #include "util.h" | ||
| 7 | #include "macros.h" | ||
| 8 | #include "IWelsVP.h" | ||
| 9 | #include "AdaptiveQuantization.h" | ||
| 10 | |||
| 11 | |||
| 12 | using namespace nsWelsVP; | ||
| 13 | |||
| 14 | static void FillWithRandomData (uint8_t* p, int32_t Len) { | ||
| 15 | for (int32_t i = 0; i < Len; i++) { | ||
| 16 | p[i] = rand() % 256; | ||
| 17 | } | ||
| 18 | } | ||
| 19 | |||
| 20 | void SampleVariance16x16_ref (uint8_t* pRefY, int32_t iRefStride, uint8_t* pSrcY, int32_t iSrcStride, | ||
| 21 | SMotionTextureUnit* pMotionTexture) { | ||
| 22 | uint32_t uiCurSquare = 0, uiSquare = 0; | ||
| 23 | uint16_t uiCurSum = 0, uiSum = 0; | ||
| 24 | |||
| 25 | for (int32_t y = 0; y < MB_WIDTH_LUMA; y++) { | ||
| 26 | for (int32_t x = 0; x < MB_WIDTH_LUMA; x++) { | ||
| 27 | uint32_t uiDiff = WELS_ABS (pRefY[x] - pSrcY[x]); | ||
| 28 | uiSum += uiDiff; | ||
| 29 | uiSquare += uiDiff * uiDiff; | ||
| 30 | |||
| 31 | uiCurSum += pSrcY[x]; | ||
| 32 | uiCurSquare += pSrcY[x] * pSrcY[x]; | ||
| 33 | } | ||
| 34 | pRefY += iRefStride; | ||
| 35 | pSrcY += iSrcStride; | ||
| 36 | } | ||
| 37 | |||
| 38 | uiSum = uiSum >> 8; | ||
| 39 | pMotionTexture->uiMotionIndex = (uiSquare >> 8) - (uiSum * uiSum); | ||
| 40 | |||
| 41 | uiCurSum = uiCurSum >> 8; | ||
| 42 | pMotionTexture->uiTextureIndex = (uiCurSquare >> 8) - (uiCurSum * uiCurSum); | ||
| 43 | } | ||
| 44 | |||
| 45 | #define GENERATE_AQTEST(method) \ | ||
| 46 | TEST (AdaptiveQuantization, method) {\ | ||
| 47 | ENFORCE_STACK_ALIGN_1D (uint8_t, pRefY,32*16,16)\ | ||
| 48 | ENFORCE_STACK_ALIGN_1D (uint8_t, pSrcY,48*16,16)\ | ||
| 49 | SMotionTextureUnit pMotionTexture[2];\ | ||
| 50 | FillWithRandomData (pRefY,32*16);\ | ||
| 51 | FillWithRandomData (pSrcY,48*16);\ | ||
| 52 | SampleVariance16x16_ref (pRefY,32,pSrcY,48,&pMotionTexture[0]);\ | ||
| 53 | method(pRefY,32,pSrcY,48,&pMotionTexture[1]);\ | ||
| 54 | ASSERT_EQ(pMotionTexture[0].uiMotionIndex,pMotionTexture[1].uiMotionIndex);\ | ||
| 55 | ASSERT_EQ(pMotionTexture[0].uiMotionIndex,pMotionTexture[1].uiMotionIndex);\ | ||
| 56 | memset (pRefY,0,32*16);\ | ||
| 57 | memset (pSrcY,255,48*16);\ | ||
| 58 | SampleVariance16x16_ref (pRefY,32,pSrcY,48,&pMotionTexture[0]);\ | ||
| 59 | method(pRefY,32,pSrcY,48,&pMotionTexture[1]);\ | ||
| 60 | ASSERT_EQ(pMotionTexture[0].uiMotionIndex,pMotionTexture[1].uiMotionIndex);\ | ||
| 61 | ASSERT_EQ(pMotionTexture[0].uiMotionIndex,pMotionTexture[1].uiMotionIndex);\ | ||
| 62 | } | ||
| 63 | |||
| 64 | GENERATE_AQTEST (SampleVariance16x16_c) | ||
| 65 | #if defined(X86_ASM) | ||
| 66 | GENERATE_AQTEST (SampleVariance16x16_sse2) | ||
| 67 | #endif | ||
| 68 | |||
| 69 | #if defined(HAVE_NEON) | ||
| 70 | GENERATE_AQTEST (SampleVariance16x16_neon) | ||
| 71 | #endif | ||
| 72 | |||
| 73 | #if defined(HAVE_NEON_AARCH64) | ||
| 74 | GENERATE_AQTEST (SampleVariance16x16_AArch64_neon) | ||
| 75 | #endif | ||
| 76 | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | PROCESSING_UNITTEST_SRCDIR=test/processing | 1 | PROCESSING_UNITTEST_SRCDIR=test/processing |
| 2 | PROCESSING_UNITTEST_CPP_SRCS=\ | 2 | PROCESSING_UNITTEST_CPP_SRCS=\ |
| 3 | $(PROCESSING_UNITTEST_SRCDIR)/ProcessUT_AdaptiveQuantization.cpp\ | ||
| 3 | $(PROCESSING_UNITTEST_SRCDIR)/ProcessUT_ScrollDetection.cpp\ | 4 | $(PROCESSING_UNITTEST_SRCDIR)/ProcessUT_ScrollDetection.cpp\ |
| 4 | 5 | ||
| 5 | PROCESSING_UNITTEST_OBJS += $(PROCESSING_UNITTEST_CPP_SRCS:.cpp=.$(OBJ)) | 6 | PROCESSING_UNITTEST_OBJS += $(PROCESSING_UNITTEST_CPP_SRCS:.cpp=.$(OBJ)) |