History

Remove the now unnecessary mc_test_common.h

Martin Storsjö committed 11 years ago

Commit 605f2fb1 parent f03edd72 files · +250 −250Browse files

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

Unified · Split

test/encoder/EncUT_MotionCompensation.cpp+250−1
@@ -5,7 +5,156 @@ · 4 unmodified lines
5#include "cpu.h"5#include "cpu.h"
6using namespace WelsCommon;6using namespace WelsCommon;
7 7
8#include "mc_test_common.h"8#define MC_BUFF_SRC_STRIDE 32
9#define MC_BUFF_DST_STRIDE 32
10#define MC_BUFF_HEIGHT 30
11
12/**********************MC Unit Test Anchor Code Begin******************************/
13static bool bQpelNeeded[4][4] = {
14 { false, true, false, true },
15 { true, true, true, true },
16 { false, true, false, true },
17 { true, true, true, true }
18};
19static int32_t iHpelRef0Array[4][4] = {
20 { 0, 1, 1, 1 },
21 { 0, 1, 1, 1 },
22 { 2, 3, 3, 3 },
23 { 0, 1, 1, 1 }
24};
25static int32_t iHpelRef1Array[4][4] = {
26 { 0, 0, 0, 0 },
27 { 2, 2, 3, 2 },
28 { 2, 2, 3, 2 },
29 { 2, 2, 3, 2 }
30};
31#define FILTER6TAP(pPixBuff, x, iStride) ((pPixBuff)[x-2*iStride] + (pPixBuff)[x+3*iStride] - 5*((pPixBuff)[x-iStride] + (pPixBuff)[x+2*iStride]) + 20*((pPixBuff)[x] + (pPixBuff)[x+iStride]))
32static inline uint8_t Clip255 (int32_t x) {
33 return ((x & ~255) ? (-x) >> 31 & 255 : x);
34}
35
36static void MCCopyAnchor (uint8_t* pSrc, int32_t iSrcStride, uint8_t* pDst, int32_t iDstStride, int32_t iWidth,
37 int32_t iHeight) {
38 for (int32_t y = 0; y < iHeight; y++) {
39 memcpy (pDst, pSrc, iWidth * sizeof (uint8_t));
40 pSrc += iSrcStride;
41 pDst += iDstStride;
42 }
43}
44
45static void MCHalfPelFilterAnchor (uint8_t* pDstH, uint8_t* pDstV, uint8_t* pDstHV, uint8_t* pSrc,
46 int32_t iStride, int32_t iWidth, int32_t iHeight, int16_t* pBuf) {
47 for (int32_t y = 0; y < iHeight; y++) {
48 for (int32_t x = 0; x < iWidth; x++)
49 pDstH[x] = Clip255 ((FILTER6TAP (pSrc, x, 1) + 16) >> 5);
50 for (int32_t x = -2; x < iWidth + 3; x++) {
51 int32_t v = FILTER6TAP (pSrc, x, iStride);
52 pDstV[x] = Clip255 ((v + 16) >> 5);
53 pBuf[x + 2] = v;
54 }
55 for (int32_t x = 0; x < iWidth; x++)
56 pDstHV[x] = Clip255 ((FILTER6TAP (pBuf + 2, x, 1) + 512) >> 10);
57 pDstH += iStride;
58 pDstV += iStride;
59 pDstHV += iStride;
60 pSrc += iStride;
61 }
62}
63
64static void PixelAvgAnchor (uint8_t* pDst, int32_t iDstStride,
65 uint8_t* pSrc1, int32_t iSrc1Stride,
66 uint8_t* pSrc2, int32_t iSrc2Stride, int32_t iWidth, int32_t iHeight) {
67 for (int32_t y = 0; y < iHeight; y++) {
68 for (int32_t x = 0; x < iWidth; x++)
69 pDst[x] = (pSrc1[x] + pSrc2[x] + 1) >> 1;
70 pDst += iDstStride;
71 pSrc1 += iSrc1Stride;
72 pSrc2 += iSrc2Stride;
73 }
74}
75
76static void MCLumaAnchor (uint8_t* pDst, int32_t iDstStride, uint8_t* pSrc[4], int32_t iSrcStride,
77 int32_t iMvX, int32_t iMvY, int32_t iWidth, int32_t iHeight) {
78 int32_t iMvXIdx = iMvX & 3;
79 int32_t iMvYIdx = iMvY & 3;
80 int32_t iOffset = (iMvY >> 2) * iSrcStride + (iMvX >> 2);
81 uint8_t* pSrc1 = pSrc[iHpelRef0Array[iMvYIdx][iMvXIdx]] + iOffset + ((iMvYIdx) == 3) * iSrcStride;
82
83 if (bQpelNeeded[iMvYIdx][iMvXIdx]) {
84 uint8_t* pSrc2 = pSrc[iHpelRef1Array[iMvYIdx][iMvXIdx]] + iOffset + ((iMvXIdx) == 3);
85 PixelAvgAnchor (pDst, iDstStride, pSrc1, iSrcStride, pSrc2, iSrcStride, iWidth, iHeight);
86 } else {
87 MCCopyAnchor (pSrc1, iSrcStride, pDst, iDstStride, iWidth, iHeight);
88 }
89}
90
91static void MCChromaAnchor (uint8_t* pDstU, uint8_t* pDstV, int32_t iDstStride, uint8_t* pSrc, int32_t iSrcStride,
92 int32_t iMvX, int32_t iMvY, int32_t iWidth, int32_t iHeight) {
93 uint8_t* pSrcTmp;
94 pSrc += (iMvY >> 3) * iSrcStride + (iMvX >> 3) * 2;
95 pSrcTmp = &pSrc[iSrcStride];
96
97 int32_t iMvXIdx = iMvX & 0x07;
98 int32_t iMvYIdx = iMvY & 0x07;
99 int32_t iBiPara0 = (8 - iMvXIdx) * (8 - iMvYIdx);
100 int32_t iBiPara1 = iMvXIdx * (8 - iMvYIdx);
101 int32_t iBiPara2 = (8 - iMvXIdx) * iMvYIdx;
102 int32_t iBiPara3 = iMvXIdx * iMvYIdx;
103 for (int32_t y = 0; y < iHeight; y++) {
104 for (int32_t x = 0; x < iWidth; x++) {
105 pDstU[x] = (iBiPara0 * pSrc[2 * x] + iBiPara1 * pSrc[2 * x + 2] +
106 iBiPara2 * pSrcTmp[2 * x] + iBiPara3 * pSrcTmp[2 * x + 2] + 32) >> 6;
107 pDstV[x] = (iBiPara0 * pSrc[2 * x + 1] + iBiPara1 * pSrc[2 * x + 3] +
108 iBiPara2 * pSrcTmp[2 * x + 1] + iBiPara3 * pSrcTmp[2 * x + 3] + 32) >> 6;
109 }
110 pSrc = pSrcTmp;
111 pSrcTmp += iSrcStride;
112 pDstU += iDstStride;
113 pDstV += iDstStride;
114 }
115}
116
117/**********************MC Unit Test OPENH264 Code Begin******************************/
118#define DEF_MCCOPYTEST(iW,iH) \
119TEST(McCopy_c,iW##x##iH) \
120{ \
121 SMcFunc sMcFunc; \
122 int32_t iCpuCores = 1; \
123 uint32_t uiCpuFlag;\
124 for(int32_t k =0; k<2; k++)\
125 {\
126 if(k==0)\
127 {\
128 uiCpuFlag = 0;\
129 }else \
130 {\
131 uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); \
132 }\
133 InitMcFunc(&sMcFunc, uiCpuFlag); \
134 uint8_t uSrcAnchor[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
135 uint8_t uSrcTest[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
136 ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
137 ENFORCE_STACK_ALIGN_2D(uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
138 for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
139 { \
140 for(int32_t i=0;i<MC_BUFF_SRC_STRIDE;i++) \
141 { \
142 uSrcAnchor[j][i] = uSrcTest[j][i] = rand()%256; \
143 } \
144 } \
145 memset(uDstAnchor,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE);\
146 memset(uDstTest,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
147 MCCopyAnchor(uSrcAnchor[0],MC_BUFF_SRC_STRIDE,uDstAnchor[0],MC_BUFF_DST_STRIDE,iW,iH); \
148 sMcFunc.pMcLumaFunc(uSrcTest[0],MC_BUFF_SRC_STRIDE,uDstTest[0],MC_BUFF_DST_STRIDE,0,0,iW,iH); \
149 for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
150 { \
151 for(int32_t i=0;i<MC_BUFF_DST_STRIDE;i++) \
152 { \
153 ASSERT_EQ(uDstAnchor[j][i],uDstTest[j][i]); \
154 } \
155 } \
156 }\
157}
9 158
10DEF_MCCOPYTEST (2, 2)159DEF_MCCOPYTEST (2, 2)
11DEF_MCCOPYTEST (2, 4)160DEF_MCCOPYTEST (2, 4)
@@ -18,6 +167,59 @@ DEF_MCCOPYTEST (16, 8) · 6 unmodified lines
18DEF_MCCOPYTEST (8, 16)167DEF_MCCOPYTEST (8, 16)
19DEF_MCCOPYTEST (16, 16)168DEF_MCCOPYTEST (16, 16)
20 169
170#define DEF_LUMA_MCTEST(iW,iH) \
171TEST(McHorVer,iW##x##iH) \
172{ \
173 for (int32_t a = 0; a < 4; a++) { \
174 for (int32_t b = 0; b < 4; b++) { \
175 SMcFunc sMcFunc; \
176 uint8_t uSrcAnchor[4][MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
177 uint8_t uSrcTest[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
178 ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
179 ENFORCE_STACK_ALIGN_2D(uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
180 uint8_t* uSrcInputAnchor[4]; \
181 int16_t pBuf[MC_BUFF_DST_STRIDE]; \
182 uSrcInputAnchor[0] = &uSrcAnchor[0][4][4]; \
183 uSrcInputAnchor[1] = &uSrcAnchor[1][4][4]; \
184 uSrcInputAnchor[2] = &uSrcAnchor[2][4][4]; \
185 uSrcInputAnchor[3] = &uSrcAnchor[3][4][4]; \
186 for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
187 {\
188 for(int32_t i=0;i<MC_BUFF_SRC_STRIDE;i++) \
189 {\
190 uSrcAnchor[0][j][i] = uSrcTest[j][i] = rand()%256; \
191 }\
192 }\
193 int32_t iCpuCores = 1; \
194 uint32_t uiCpuFlag;\
195 for(int32_t k =0; k<2; k++)\
196 {\
197 if(k==0)\
198 {\
199 uiCpuFlag = 0;\
200 }else \
201 {\
202 uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); \
203 }\
204 InitMcFunc(&sMcFunc,uiCpuFlag);\
205 memset(uDstAnchor,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
206 memset(uDstTest,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
207 MCHalfPelFilterAnchor(uSrcInputAnchor[1],uSrcInputAnchor[2],uSrcInputAnchor[3],uSrcInputAnchor[0],MC_BUFF_SRC_STRIDE,iW+1,iH+1,pBuf+4); \
208 MCLumaAnchor(uDstAnchor[0],MC_BUFF_DST_STRIDE,uSrcInputAnchor,MC_BUFF_SRC_STRIDE,a,b,iW,iH); \
209 sMcFunc.pMcLumaFunc(&uSrcTest[4][4],MC_BUFF_SRC_STRIDE,uDstTest[0],MC_BUFF_DST_STRIDE,a,b,iW,iH);\
210 for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
211 { \
212 for(int32_t i=0;i<MC_BUFF_DST_STRIDE;i++) \
213 { \
214 ASSERT_EQ(uDstAnchor[j][i],uDstTest[j][i]); \
215 } \
216 } \
217 }\
218 }\
219 }\
220}
221
222
21DEF_LUMA_MCTEST (4, 4)223DEF_LUMA_MCTEST (4, 4)
22DEF_LUMA_MCTEST (4, 8)224DEF_LUMA_MCTEST (4, 8)
23DEF_LUMA_MCTEST (8, 4)225DEF_LUMA_MCTEST (8, 4)
@@ -26,6 +228,53 @@ DEF_LUMA_MCTEST (16, 8) · 2 unmodified lines
26DEF_LUMA_MCTEST (8, 16)228DEF_LUMA_MCTEST (8, 16)
27DEF_LUMA_MCTEST (16, 16)229DEF_LUMA_MCTEST (16, 16)
28 230
231#define DEF_CHROMA_MCTEST(iW,iH) \
232TEST(McChroma,iW##x##iH) \
233{ \
234 for (int32_t a = 0; a < 8; a++) { \
235 for (int32_t b = 0; b < 8; b++) { \
236 SMcFunc sMcFunc; \
237 uint8_t uSrcAnchor[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE*2]; \
238 uint8_t uSrcTest[MC_BUFF_HEIGHT][MC_BUFF_SRC_STRIDE]; \
239 ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor1, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
240 ENFORCE_STACK_ALIGN_2D(uint8_t, uDstAnchor2, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
241 ENFORCE_STACK_ALIGN_2D(uint8_t, uDstTest, MC_BUFF_HEIGHT, MC_BUFF_DST_STRIDE, 16); \
242 for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
243 {\
244 for(int32_t i=0;i<MC_BUFF_SRC_STRIDE;i++) \
245 {\
246 uSrcAnchor[j][i*2] = uSrcTest[j][i] = rand()%256; \
247 }\
248 }\
249 int32_t iCpuCores = 1; \
250 uint32_t uiCpuFlag;\
251 for(int32_t k =0; k<2; k++)\
252 {\
253 if(k==0)\
254 {\
255 uiCpuFlag = 0;\
256 }else \
257 {\
258 uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); \
259 }\
260 InitMcFunc(&sMcFunc,uiCpuFlag);\
261 memset(uDstAnchor1,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
262 memset(uDstAnchor2,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
263 memset(uDstTest,0,sizeof(uint8_t)*MC_BUFF_HEIGHT*MC_BUFF_DST_STRIDE); \
264 MCChromaAnchor(uDstAnchor1[0],uDstAnchor2[0],MC_BUFF_DST_STRIDE,uSrcAnchor[0],MC_BUFF_SRC_STRIDE*2,a,b,iW,iH); \
265 sMcFunc.pMcChromaFunc(uSrcTest[0],MC_BUFF_SRC_STRIDE,uDstTest[0],MC_BUFF_DST_STRIDE,a,b,iW,iH);\
266 for(int32_t j=0;j<MC_BUFF_HEIGHT;j++) \
267 { \
268 for(int32_t i=0;i<MC_BUFF_DST_STRIDE;i++) \
269 { \
270 ASSERT_EQ(uDstAnchor1[j][i],uDstTest[j][i]); \
271 } \
272 } \
273 }\
274 }\
275 }\
276}
277
29DEF_CHROMA_MCTEST (2, 2)278DEF_CHROMA_MCTEST (2, 2)
30DEF_CHROMA_MCTEST (2, 4)279DEF_CHROMA_MCTEST (2, 4)
31DEF_CHROMA_MCTEST (4, 2)280DEF_CHROMA_MCTEST (4, 2)

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