History

Add unit tests for special cased MC functions in the encoder

Martin Storsjö committed 11 years ago

Commit ca97f781 parent 8084a2c1 file · +81 −0Browse files

Showing the changes to test/encoder/EncUT_MotionCompensation.cpp (1 of 1 file). Show all

Unified · Split

test/encoder/EncUT_MotionCompensation.cpp+81−0
@@ -36,3 +36,84 @@ DEF_CHROMA_MCTEST_SUBCASE(pfx,a,b,8,4) \ · 35 unmodified lines
36DEF_CHROMA_MCTEST_SUBCASE(pfx,a,b,8,8)36DEF_CHROMA_MCTEST_SUBCASE(pfx,a,b,8,8)
37 37
38#include "mc_test_common.h"38#include "mc_test_common.h"
39
40TEST (EncMcAvg, PixelAvg) {
41 SMcFunc sMcFunc;
42 for (int32_t k = 0; k < 2; k++) {
43 for (int32_t w = 0; w < 2; w++) {
44 int32_t width = 8 << w;
45 int32_t height = 16;
46 uint32_t uiCpuFlag = k == 0 ? 0 : WelsCPUFeatureDetect (NULL);
47 WelsInitMcFuncs (&sMcFunc, uiCpuFlag);
48 uint8_t uSrc1[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE];
49 uint8_t uSrc2[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE];
50 ENFORCE_STACK_ALIGN_2D (uint8_t, uDstAnchor, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16);
51 ENFORCE_STACK_ALIGN_2D (uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16);
52 for (int32_t j = 0; j < MC_BUFF_HEIGHT; j++) {
53 for (int32_t i = 0; i < MC_BUFF_SRC_STRIDE; i++) {
54 uSrc1[j][i] = rand() % 256;
55 uSrc2[j][i] = rand() % 256;
56 }
57 }
58 PixelAvgAnchor (uDstAnchor[0], MC_BUFF_DST_STRIDE, uSrc1[0], MC_BUFF_SRC_STRIDE, uSrc2[0], MC_BUFF_SRC_STRIDE, width,
59 height);
60 sMcFunc.pfSampleAveraging[w] (uDstTest[0], MC_BUFF_DST_STRIDE, uSrc1[0], MC_BUFF_SRC_STRIDE, uSrc2[0],
61 MC_BUFF_SRC_STRIDE, height);
62 for (int32_t j = 0; j < height; j++) {
63 for (int32_t i = 0; i < width; i++) {
64 ASSERT_EQ (uDstAnchor[j][i], uDstTest[j][i]);
65 }
66 }
67 }
68 }
69}
70
71TEST (EncMcHalfpel, LumaHalfpel) {
72 SMcFunc sMcFunc;
73 for (int32_t k = 0; k < 2; k++) {
74 for (int32_t w = 0; w < 2; w++) {
75 int32_t width = 8 << w;
76 int32_t height = 16;
77 uint8_t uAnchor[4][MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE];
78 uint8_t uSrcTest[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE];
79 ENFORCE_STACK_ALIGN_2D (uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16);
80 uint8_t* uAnchors[4];
81 int16_t pBuf[MC_BUFF_DST_STRIDE];
82 uAnchors[0] = &uAnchor[0][4][4];
83 uAnchors[1] = &uAnchor[1][4][4];
84 uAnchors[2] = &uAnchor[2][4][4];
85 uAnchors[3] = &uAnchor[3][4][4];
86
87 memset (uAnchor, 0, 4 * sizeof (uint8_t)*MC_BUFF_HEIGHT * MC_BUFF_DST_STRIDE);
88 memset (uDstTest, 0, sizeof (uint8_t)*MC_BUFF_HEIGHT * MC_BUFF_DST_STRIDE);
89 for (int32_t j = 0; j < MC_BUFF_HEIGHT; j++) {
90 for (int32_t i = 0; i < MC_BUFF_SRC_STRIDE; i++) {
91 uAnchor[0][j][i] = uSrcTest[j][i] = rand() % 256;
92 }
93 }
94
95 uint32_t uiCpuFlag = k == 0 ? 0 : WelsCPUFeatureDetect (NULL);
96 WelsInitMcFuncs (&sMcFunc, uiCpuFlag);
97
98 MCHalfPelFilterAnchor (uAnchors[1], uAnchors[2], uAnchors[3], uAnchors[0], MC_BUFF_SRC_STRIDE, width, height, pBuf + 4);
99 sMcFunc.pfLumaHalfpelHor (&uSrcTest[4][4], MC_BUFF_SRC_STRIDE, uDstTest[0], MC_BUFF_DST_STRIDE, width + 1, height);
100 for (int32_t j = 0; j < height; j++) {
101 for (int32_t i = 0; i < width; i++) {
102 ASSERT_EQ (uAnchor[1][4 + j][4 + i], uDstTest[j][i]);
103 }
104 }
105 sMcFunc.pfLumaHalfpelVer (&uSrcTest[4][4], MC_BUFF_SRC_STRIDE, uDstTest[0], MC_BUFF_DST_STRIDE, width, height + 1);
106 for (int32_t j = 0; j < height; j++) {
107 for (int32_t i = 0; i < width; i++) {
108 ASSERT_EQ (uAnchor[2][4 + j][4 + i], uDstTest[j][i]);
109 }
110 }
111 sMcFunc.pfLumaHalfpelCen (&uSrcTest[4][4], MC_BUFF_SRC_STRIDE, uDstTest[0], MC_BUFF_DST_STRIDE, width + 1, height + 1);
112 for (int32_t j = 0; j < height; j++) {
113 for (int32_t i = 0; i < width; i++) {
114 ASSERT_EQ (uAnchor[3][4 + j][4 + i], uDstTest[j][i]);
115 }
116 }
117 }
118 }
119}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t