1 #include <gtest/gtest.h>
2 #include <stdlib.h>
3
4 #include "get_intra_predictor.h"
5 #include "ls_defines.h"
6 #include "macros.h"
7
8 using namespace WelsEnc;
9
TEST(GetIntraPredictorTest,TestGetI4x4LumaPredV)10 TEST (GetIntraPredictorTest, TestGetI4x4LumaPredV) {
11 uint8_t* pPred = new uint8_t[64];
12 uint8_t* pRef = new uint8_t[64];
13 for (int i = 0; i < 64; i++)
14 pRef[i] = rand() % 256;
15
16 const int32_t kkiStride = 0;
17 WelsI4x4LumaPredV_c (pPred, pRef, kkiStride);
18
19 for (int i = 0; i < 4; i++)
20 EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&pRef[-kkiStride]));
21
22 delete []pRef;
23 delete []pPred;
24 }
25
TEST(GetIntraPredictorTest,TestGetI4x4LumaPredH)26 TEST (GetIntraPredictorTest, TestGetI4x4LumaPredH) {
27 const int32_t kiStride = rand() % 256 + 16;
28 const uint32_t kiStride2 = (kiStride << 1) - 1;
29 const uint32_t kiStride3 = kiStride + kiStride2;
30
31 uint8_t* pPred = new uint8_t[64];
32 uint8_t* pRef = new uint8_t[kiStride3 + 2];
33
34 for (int i = 0; i < (static_cast<int32_t> (kiStride3 + 2)); i++)
35 pRef[i] = rand() % 256;
36
37 pRef++;
38
39 const uint8_t kuiH1 = pRef[-1];
40 const uint8_t kuiH2 = pRef[kiStride - 1];
41 const uint8_t kuiH3 = pRef[kiStride2];
42 const uint8_t kuiH4 = pRef[kiStride3];
43 const uint8_t kuiV1[4] = {kuiH1, kuiH1, kuiH1, kuiH1};
44 const uint8_t kuiV2[4] = {kuiH2, kuiH2, kuiH2, kuiH2};
45 const uint8_t kuiV3[4] = {kuiH3, kuiH3, kuiH3, kuiH3};
46 const uint8_t kuiV4[4] = {kuiH4, kuiH4, kuiH4, kuiH4};
47
48 ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
49 ST32 (&uiV[0], LD32 (kuiV1));
50 ST32 (&uiV[4], LD32 (kuiV2));
51 ST32 (&uiV[8], LD32 (kuiV3));
52 ST32 (&uiV[12], LD32 (kuiV4));
53
54 WelsI4x4LumaPredH_c (pPred, pRef, kiStride);
55
56 for (int i = 0; i < 4; i++)
57 EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
58
59 pRef--;
60
61 delete []pRef;
62 delete []pPred;
63 }
64
TEST(GetIntraPredictorTest,TestGetI4x4LumaPredDDL)65 TEST (GetIntraPredictorTest, TestGetI4x4LumaPredDDL) {
66 const int32_t kiStride = 0;
67
68 uint8_t* pPred = new uint8_t[64];
69 uint8_t* pRef = new uint8_t[64];
70 for (int i = 0; i < 64; i++)
71 pRef[i] = rand() % 256;
72
73 const uint8_t kuiT0 = pRef[-kiStride];
74 const uint8_t kuiT1 = pRef[1 - kiStride];
75 const uint8_t kuiT2 = pRef[2 - kiStride];
76 const uint8_t kuiT3 = pRef[3 - kiStride];
77 const uint8_t kuiT4 = pRef[4 - kiStride];
78 const uint8_t kuiT5 = pRef[5 - kiStride];
79 const uint8_t kuiT6 = pRef[6 - kiStride];
80 const uint8_t kuiT7 = pRef[7 - kiStride];
81 const uint8_t kuiDDL0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2;
82 const uint8_t kuiDDL1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2;
83 const uint8_t kuiDDL2 = (2 + kuiT2 + kuiT4 + (kuiT3 << 1)) >> 2;
84 const uint8_t kuiDDL3 = (2 + kuiT3 + kuiT5 + (kuiT4 << 1)) >> 2;
85 const uint8_t kuiDDL4 = (2 + kuiT4 + kuiT6 + (kuiT5 << 1)) >> 2;
86 const uint8_t kuiDDL5 = (2 + kuiT5 + kuiT7 + (kuiT6 << 1)) >> 2;
87 const uint8_t kuiDDL6 = (2 + kuiT6 + kuiT7 + (kuiT7 << 1)) >> 2;
88 ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
89 uiV[0] = kuiDDL0;
90 uiV[1] = uiV[4] = kuiDDL1;
91 uiV[2] = uiV[5] = uiV[8] = kuiDDL2;
92 uiV[3] = uiV[6] = uiV[9] = uiV[12] = kuiDDL3;
93 uiV[7] = uiV[10] = uiV[13] = kuiDDL4;
94 uiV[11] = uiV[14] = kuiDDL5;
95 uiV[15] = kuiDDL6;
96
97 WelsI4x4LumaPredDDL_c (pPred, pRef, kiStride);
98
99 for (int i = 0; i < 4; i++)
100 EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
101
102 delete []pRef;
103 delete []pPred;
104 }
105
TEST(GetIntraPredictorTest,TestGetI4x4LumaPredDDLTop)106 TEST (GetIntraPredictorTest, TestGetI4x4LumaPredDDLTop) {
107 const int32_t kiStride = 0;
108
109 uint8_t* pPred = new uint8_t[64];
110 uint8_t* pRef = new uint8_t[64];
111 for (int i = 0; i < 64; i++)
112 pRef[i] = rand() % 256;
113
114 const uint8_t kuiT0 = pRef[-kiStride];
115 const uint8_t kuiT1 = pRef[1 - kiStride];
116 const uint8_t kuiT2 = pRef[2 - kiStride];
117 const uint8_t kuiT3 = pRef[3 - kiStride];
118 const uint8_t kuiDLT0 = (2 + kuiT0 + kuiT2 + (kuiT1 << 1)) >> 2;
119 const uint8_t kuiDLT1 = (2 + kuiT1 + kuiT3 + (kuiT2 << 1)) >> 2;
120 const uint8_t kuiDLT2 = (2 + kuiT2 + kuiT3 + (kuiT3 << 1)) >> 2;
121 const uint8_t kuiDLT3 = (2 + (kuiT3 << 2)) >> 2;
122 ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
123 memset (&uiV[6], kuiDLT3, 10 * sizeof (uint8_t));
124 uiV[0] = kuiDLT0;
125 uiV[1] = uiV[4] = kuiDLT1;
126 uiV[2] = uiV[5] = uiV[8] = kuiDLT2;
127 uiV[3] = kuiDLT3;
128
129 WelsI4x4LumaPredDDLTop_c (pPred, pRef, kiStride);
130
131 for (int i = 0; i < 4; i++)
132 EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
133
134 delete []pRef;
135 delete []pPred;
136 }
137
TEST(GetIntraPredictorTest,TestGetI4x4LumaPredDDR)138 TEST (GetIntraPredictorTest, TestGetI4x4LumaPredDDR) {
139 const int32_t kiStride = rand() % 256 + 16;
140 const int32_t kiStride2 = kiStride << 1;
141 const int32_t kiStride3 = kiStride + kiStride2;
142
143 uint8_t* pPred = new uint8_t[64];
144 uint8_t* pRef = new uint8_t[kiStride3 + kiStride + 1];
145
146 for (int i = 0; i < kiStride3 + kiStride + 1; i++)
147 pRef[i] = rand() % 256;
148
149 pRef += kiStride + 1;
150
151 const uint8_t kuiLT = pRef[-kiStride - 1];
152 const uint8_t kuiL0 = pRef[-1];
153 const uint8_t kuiL1 = pRef[kiStride - 1];
154 const uint8_t kuiL2 = pRef[kiStride2 - 1];
155 const uint8_t kuiL3 = pRef[kiStride3 - 1];
156 const uint8_t kuiT0 = pRef[-kiStride];
157 const uint8_t kuiT1 = pRef[1 - kiStride];
158 const uint8_t kuiT2 = pRef[2 - kiStride];
159 const uint8_t kuiT3 = pRef[3 - kiStride];
160 const uint16_t kuiTL0 = 1 + kuiLT + kuiL0;
161 const uint16_t kuiLT0 = 1 + kuiLT + kuiT0;
162 const uint16_t kuiT01 = 1 + kuiT0 + kuiT1;
163 const uint16_t kuiT12 = 1 + kuiT1 + kuiT2;
164 const uint16_t kuiT23 = 1 + kuiT2 + kuiT3;
165 const uint16_t kuiL01 = 1 + kuiL0 + kuiL1;
166 const uint16_t kuiL12 = 1 + kuiL1 + kuiL2;
167 const uint16_t kuiL23 = 1 + kuiL2 + kuiL3;
168 const uint8_t kuiDDR0 = (kuiTL0 + kuiLT0) >> 2;
169 const uint8_t kuiDDR1 = (kuiLT0 + kuiT01) >> 2;
170 const uint8_t kuiDDR2 = (kuiT01 + kuiT12) >> 2;
171 const uint8_t kuiDDR3 = (kuiT12 + kuiT23) >> 2;
172 const uint8_t kuiDDR4 = (kuiTL0 + kuiL01) >> 2;
173 const uint8_t kuiDDR5 = (kuiL01 + kuiL12) >> 2;
174 const uint8_t kuiDDR6 = (kuiL12 + kuiL23) >> 2;
175 ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
176 uiV[0] = uiV[5] = uiV[10] = uiV[15] = kuiDDR0;
177 uiV[1] = uiV[6] = uiV[11] = kuiDDR1;
178 uiV[2] = uiV[7] = kuiDDR2;
179 uiV[3] = kuiDDR3;
180 uiV[4] = uiV[9] = uiV[14] = kuiDDR4;
181 uiV[8] = uiV[13] = kuiDDR5;
182 uiV[12] = kuiDDR6;
183
184 WelsI4x4LumaPredDDR_c (pPred, pRef, kiStride);
185
186 for (int i = 0; i < 4; i++)
187 EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
188
189 pRef -= kiStride + 1;
190
191 delete []pRef;
192 delete []pPred;
193 }
194
TEST(GetIntraPredictorTest,TestGetI4x4LumaPredVL)195 TEST (GetIntraPredictorTest, TestGetI4x4LumaPredVL) {
196 const int32_t kiStride = 0;
197
198 uint8_t* pPred = new uint8_t[64];
199 uint8_t* pRef = new uint8_t[64];
200 for (int i = 0; i < 64; i++)
201 pRef[i] = rand() % 256;
202
203 const uint8_t kuiT0 = pRef[-kiStride];
204 const uint8_t kuiT1 = pRef[1 - kiStride];
205 const uint8_t kuiT2 = pRef[2 - kiStride];
206 const uint8_t kuiT3 = pRef[3 - kiStride];
207 const uint8_t kuiT4 = pRef[4 - kiStride];
208 const uint8_t kuiT5 = pRef[5 - kiStride];
209 const uint8_t kuiT6 = pRef[6 - kiStride];
210 const uint8_t kuiVL0 = (1 + kuiT0 + kuiT1) >> 1;
211 const uint8_t kuiVL1 = (1 + kuiT1 + kuiT2) >> 1;
212 const uint8_t kuiVL2 = (1 + kuiT2 + kuiT3) >> 1;
213 const uint8_t kuiVL3 = (1 + kuiT3 + kuiT4) >> 1;
214 const uint8_t kuiVL4 = (1 + kuiT4 + kuiT5) >> 1;
215 const uint8_t kuiVL5 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2;
216 const uint8_t kuiVL6 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2;
217 const uint8_t kuiVL7 = (2 + kuiT2 + (kuiT3 << 1) + kuiT4) >> 2;
218 const uint8_t kuiVL8 = (2 + kuiT3 + (kuiT4 << 1) + kuiT5) >> 2;
219 const uint8_t kuiVL9 = (2 + kuiT4 + (kuiT5 << 1) + kuiT6) >> 2;
220 ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
221 uiV[0] = kuiVL0;
222 uiV[1] = uiV[8] = kuiVL1;
223 uiV[2] = uiV[9] = kuiVL2;
224 uiV[3] = uiV[10] = kuiVL3;
225 uiV[4] = kuiVL5;
226 uiV[5] = uiV[12] = kuiVL6;
227 uiV[6] = uiV[13] = kuiVL7;
228 uiV[7] = uiV[14] = kuiVL8;
229 uiV[11] = kuiVL4;
230 uiV[15] = kuiVL9;
231
232 WelsI4x4LumaPredVL_c (pPred, pRef, kiStride);
233
234 for (int i = 0; i < 4; i++)
235 EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
236
237 delete []pRef;
238 delete []pPred;
239 }
240
TEST(GetIntraPredictorTest,TestGetI4x4LumaPredVLTop)241 TEST (GetIntraPredictorTest, TestGetI4x4LumaPredVLTop) {
242 const int32_t kiStride = 0;
243
244 uint8_t* pPred = new uint8_t[64];
245 uint8_t* pRef = new uint8_t[64];
246 for (int i = 0; i < 64; i++)
247 pRef[i] = rand() % 256;
248
249 pRef++;
250
251 uint8_t* pTopLeft = &pRef[-kiStride - 1]; // top-left
252
253 const uint8_t kuiT0 = * (pTopLeft + 1);
254 const uint8_t kuiT1 = * (pTopLeft + 2);
255 const uint8_t kuiT2 = * (pTopLeft + 3);
256 const uint8_t kuiT3 = * (pTopLeft + 4);
257 const uint8_t kuiVLT0 = (1 + kuiT0 + kuiT1) >> 1;
258 const uint8_t kuiVLT1 = (1 + kuiT1 + kuiT2) >> 1;
259 const uint8_t kuiVLT2 = (1 + kuiT2 + kuiT3) >> 1;
260 const uint8_t kuiVLT3 = (1 + (kuiT3 << 1)) >> 1;
261 const uint8_t kuiVLT4 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2;
262 const uint8_t kuiVLT5 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2;
263 const uint8_t kuiVLT6 = (2 + kuiT2 + (kuiT3 << 1) + kuiT3) >> 2;
264 const uint8_t kuiVLT7 = (2 + (kuiT3 << 2)) >> 2;
265 ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
266 uiV[0] = kuiVLT0;
267 uiV[1] = uiV[8] = kuiVLT1;
268 uiV[2] = uiV[9] = kuiVLT2;
269 uiV[3] = uiV[10] = uiV[11] = kuiVLT3;
270 uiV[4] = kuiVLT4;
271 uiV[5] = uiV[12] = kuiVLT5;
272 uiV[6] = uiV[13] = kuiVLT6;
273 uiV[7] = uiV[14] = uiV[15] = kuiVLT7;
274
275 WelsI4x4LumaPredVLTop_c (pPred, pRef, kiStride);
276
277 for (int i = 0; i < 4; i++)
278 EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
279
280 pRef--;
281
282 delete []pRef;
283 delete []pPred;
284 }
285
TEST(GetIntraPredictorTest,TestGetI4x4LumaPredVR)286 TEST (GetIntraPredictorTest, TestGetI4x4LumaPredVR) {
287 const int32_t kiStride = rand() % 256 + 16;
288 const int32_t kiStride2 = kiStride << 1;
289
290 uint8_t* pPred = new uint8_t[64];
291 uint8_t* pRef = new uint8_t[kiStride2 + kiStride + 1];
292
293 for (int i = 0; i < kiStride2 + kiStride + 1; i++)
294 pRef[i] = rand() % 256;
295
296 pRef += kiStride + 1;
297
298 const uint8_t kuiLT = pRef[-kiStride - 1]; // top-left
299 const uint8_t kuiL0 = pRef[-1];
300 const uint8_t kuiL1 = pRef[kiStride - 1];
301 const uint8_t kuiL2 = pRef[kiStride2 - 1];
302 const uint8_t kuiT0 = pRef[-kiStride];
303 const uint8_t kuiT1 = pRef[1 - kiStride];
304 const uint8_t kuiT2 = pRef[2 - kiStride];
305 const uint8_t kuiT3 = pRef[3 - kiStride];
306 const uint8_t kuiVR0 = (1 + kuiLT + kuiT0) >> 1;
307 const uint8_t kuiVR1 = (1 + kuiT0 + kuiT1) >> 1;
308 const uint8_t kuiVR2 = (1 + kuiT1 + kuiT2) >> 1;
309 const uint8_t kuiVR3 = (1 + kuiT2 + kuiT3) >> 1;
310 const uint8_t kuiVR4 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2;
311 const uint8_t kuiVR5 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2;
312 const uint8_t kuiVR6 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2;
313 const uint8_t kuiVR7 = (2 + kuiT1 + (kuiT2 << 1) + kuiT3) >> 2;
314 const uint8_t kuiVR8 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2;
315 const uint8_t kuiVR9 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2;
316 ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
317 uiV[0] = uiV[9] = kuiVR0;
318 uiV[1] = uiV[10] = kuiVR1;
319 uiV[2] = uiV[11] = kuiVR2;
320 uiV[3] = kuiVR3;
321 uiV[4] = uiV[13] = kuiVR4;
322 uiV[5] = uiV[14] = kuiVR5;
323 uiV[6] = uiV[15] = kuiVR6;
324 uiV[7] = kuiVR7;
325 uiV[8] = kuiVR8;
326 uiV[12] = kuiVR9;
327
328 WelsI4x4LumaPredVR_c (pPred, pRef, kiStride);
329
330 for (int i = 0; i < 4; i++)
331 EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
332
333 pRef -= kiStride + 1;
334
335 delete []pRef;
336 delete []pPred;
337 }
338
TEST(GetIntraPredictorTest,TestGetI4x4LumaPredHU)339 TEST (GetIntraPredictorTest, TestGetI4x4LumaPredHU) {
340 const int32_t kiStride = rand() % 256 + 16;
341 const int32_t kiStride2 = kiStride << 1;
342 const int32_t kiStride3 = kiStride + kiStride2;
343
344 uint8_t* pPred = new uint8_t[64];
345 uint8_t* pRef = new uint8_t[kiStride3 + 1];
346
347 for (int i = 0; i < kiStride3 + 1; i++)
348 pRef[i] = rand() % 256;
349
350 pRef++;
351
352 const uint8_t kuiL0 = pRef[-1];
353 const uint8_t kuiL1 = pRef[kiStride - 1];
354 const uint8_t kuiL2 = pRef[kiStride2 - 1];
355 const uint8_t kuiL3 = pRef[kiStride3 - 1];
356 const uint16_t kuiL01 = (1 + kuiL0 + kuiL1);
357 const uint16_t kuiL12 = (1 + kuiL1 + kuiL2);
358 const uint16_t kuiL23 = (1 + kuiL2 + kuiL3);
359 const uint8_t kuiHU0 = kuiL01 >> 1;
360 const uint8_t kuiHU1 = (kuiL01 + kuiL12) >> 2;
361 const uint8_t kuiHU2 = kuiL12 >> 1;
362 const uint8_t kuiHU3 = (kuiL12 + kuiL23) >> 2;
363 const uint8_t kuiHU4 = kuiL23 >> 1;
364 const uint8_t kuiHU5 = (1 + kuiL23 + (kuiL3 << 1)) >> 2;
365 ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
366 uiV[0] = kuiHU0;
367 uiV[1] = kuiHU1;
368 uiV[2] = uiV[4] = kuiHU2;
369 uiV[3] = uiV[5] = kuiHU3;
370 uiV[6] = uiV[8] = kuiHU4;
371 uiV[7] = uiV[9] = kuiHU5;
372 memset (&uiV[10], kuiL3, 6 * sizeof (uint8_t));
373
374 WelsI4x4LumaPredHU_c (pPred, pRef, kiStride);
375
376 for (int i = 0; i < 4; i++)
377 EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
378
379 pRef--;
380
381 delete []pRef;
382 delete []pPred;
383 }
384
TEST(GetIntraPredictorTest,TestGetI4x4LumaPredHD)385 TEST (GetIntraPredictorTest, TestGetI4x4LumaPredHD) {
386 const int32_t kiStride = rand() % 256 + 16;
387 const int32_t kiStride2 = kiStride << 1;
388 const int32_t kiStride3 = kiStride + kiStride2;
389
390 uint8_t* pPred = new uint8_t[64];
391 uint8_t* pRef = new uint8_t[kiStride3 + kiStride + 1];
392
393 for (int i = 0; i < kiStride3 + kiStride + 1; i++)
394 pRef[i] = rand() % 256;
395
396 pRef += kiStride + 1;
397
398 const uint8_t kuiLT = pRef[-kiStride - 1]; // top-left
399 const uint8_t kuiL0 = pRef[-1];
400 const uint8_t kuiL1 = pRef[kiStride - 1];
401 const uint8_t kuiL2 = pRef[kiStride2 - 1];
402 const uint8_t kuiL3 = pRef[kiStride3 - 1];
403 const uint8_t kuiT0 = pRef[-kiStride];
404 const uint8_t kuiT1 = pRef[1 - kiStride];
405 const uint8_t kuiT2 = pRef[2 - kiStride];
406 const uint8_t kuiHD0 = (1 + kuiLT + kuiL0) >> 1;
407 const uint8_t kuiHD1 = (2 + kuiL0 + (kuiLT << 1) + kuiT0) >> 2;
408 const uint8_t kuiHD2 = (2 + kuiLT + (kuiT0 << 1) + kuiT1) >> 2;
409 const uint8_t kuiHD3 = (2 + kuiT0 + (kuiT1 << 1) + kuiT2) >> 2;
410 const uint8_t kuiHD4 = (1 + kuiL0 + kuiL1) >> 1;
411 const uint8_t kuiHD5 = (2 + kuiLT + (kuiL0 << 1) + kuiL1) >> 2;
412 const uint8_t kuiHD6 = (1 + kuiL1 + kuiL2) >> 1;
413 const uint8_t kuiHD7 = (2 + kuiL0 + (kuiL1 << 1) + kuiL2) >> 2;
414 const uint8_t kuiHD8 = (1 + kuiL2 + kuiL3) >> 1;
415 const uint8_t kuiHD9 = (2 + kuiL1 + (kuiL2 << 1) + kuiL3) >> 2;
416 ENFORCE_STACK_ALIGN_1D (uint8_t, uiV, 16, 16) // TobeCont'd about assign opt as follows
417 uiV[0] = uiV[6] = kuiHD0;
418 uiV[1] = uiV[7] = kuiHD1;
419 uiV[2] = kuiHD2;
420 uiV[3] = kuiHD3;
421 uiV[4] = uiV[10] = kuiHD4;
422 uiV[5] = uiV[11] = kuiHD5;
423 uiV[8] = uiV[14] = kuiHD6;
424 uiV[9] = uiV[15] = kuiHD7;
425 uiV[12] = kuiHD8;
426 uiV[13] = kuiHD9;
427
428 WelsI4x4LumaPredHD_c (pPred, pRef, kiStride);
429
430 for (int i = 0; i < 4; i++)
431 EXPECT_EQ (LD32 (&pPred[4 * i]), LD32 (&uiV[4 * i]));
432
433 pRef -= kiStride + 1;
434
435 delete []pRef;
436 delete []pPred;
437 }
438
TEST(GetIntraPredictorTest,TestGetIChromaPredV)439 TEST (GetIntraPredictorTest, TestGetIChromaPredV) {
440 uint8_t* pPred = new uint8_t[64];
441 uint8_t* pRef = new uint8_t[64];
442 for (int i = 0; i < 64; i++)
443 pRef[i] = rand() % 256 + 1;
444
445 const int32_t kiStride = 0;
446 WelsIChromaPredV_c (pPred, pRef, kiStride);
447
448 for (int i = 0; i < 8; i++)
449 EXPECT_EQ (LD32 (&pPred[8 * i]), LD32 (&pRef[-kiStride]));
450
451 delete []pRef;
452 delete []pPred;
453 }
454
TEST(GetIntraPredictorTest,TestGetI16x16LumaPredPlane)455 TEST (GetIntraPredictorTest, TestGetI16x16LumaPredPlane) {
456 const int32_t kiStride = rand() % 16 + 16;
457
458 int32_t i, j;
459
460 uint8_t* pPred = new uint8_t[16 * kiStride];
461 uint8_t* pRef = new uint8_t[16 * kiStride + 1];
462 for (i = 0; i < 16 * kiStride + 1; i++)
463 pRef[i] = rand() % 256 + 1;
464
465 pRef += kiStride + 1;
466
467 int32_t iA = 0, iB = 0, iC = 0, iH = 0, iV = 0;
468 uint8_t* pTop = &pRef[-kiStride];
469 uint8_t* pLeft = &pRef[-1];
470 int32_t iPredStride = 16;
471
472 for (i = 0; i < 8; i++) {
473 iH += (i + 1) * (pTop[8 + i] - pTop[6 - i]);
474 iV += (i + 1) * (pLeft[ (8 + i) * kiStride] - pLeft[ (6 - i) * kiStride]);
475 }
476
477 iA = (pLeft[15 * kiStride] + pTop[15]) << 4;
478 iB = (5 * iH + 32) >> 6;
479 iC = (5 * iV + 32) >> 6;
480
481 WelsI16x16LumaPredPlane_c (pPred, pRef, kiStride);
482 for (i = 0; i < 16; i++) {
483 for (j = 0; j < 16; j++) {
484 EXPECT_EQ (pPred[j], (uint8_t)WelsClip1 ((iA + iB * (j - 7) + iC * (i - 7) + 16) >> 5));
485 }
486 pPred += iPredStride;
487 }
488
489 pRef -= kiStride + 1;
490 pPred -= (iPredStride * 16);
491 delete []pRef;
492 delete []pPred;
493 }
494
TEST(GetIntraPredictorTest,TestGetI16x16LumaPredDc)495 TEST (GetIntraPredictorTest, TestGetI16x16LumaPredDc) {
496 const int32_t kiStride = rand() % 16 + 16;
497
498 int i;
499
500 uint8_t* pPred = new uint8_t[256];
501 uint8_t* pRef = new uint8_t[16 * kiStride];
502 for (i = 0; i < 16 * kiStride; i++)
503 pRef[i] = rand() % 256 + 1;
504
505 pRef += kiStride;
506
507 int32_t iTmp = (kiStride << 4) - kiStride;
508 int32_t iSum = 0;
509 i = 15;
510 uint8_t uiMean = 0;
511
512 do {
513 iSum += pRef[-1 + iTmp] + pRef[-kiStride + i];
514 iTmp -= kiStride;
515 } while (i-- > 0);
516 uiMean = (16 + iSum) >> 5;
517
518 WelsI16x16LumaPredDc_c (pPred, pRef, kiStride);
519 for (i = 0; i < 256; i++)
520 EXPECT_EQ (pPred[i], uiMean);
521
522 pRef -= kiStride;
523
524 delete []pRef;
525 delete []pPred;
526 }
527
TEST(GetIntraPredictorTest,TestGetI16x16LumaPredDcTop)528 TEST (GetIntraPredictorTest, TestGetI16x16LumaPredDcTop) {
529 const int32_t kiStride = rand() % 16 + 16;
530
531 int i;
532
533 uint8_t* pPred = new uint8_t[256];
534 uint8_t* pRef = new uint8_t[16 * kiStride];
535 for (i = 0; i < 16 * kiStride; i++)
536 pRef[i] = rand() % 256 + 1;
537
538 pRef += kiStride;
539
540 int32_t iSum = 0;
541 i = 15;
542 uint8_t uiMean = 0;
543 do {
544 iSum += pRef[-kiStride + i];
545 } while (i-- > 0);
546 uiMean = (8 + iSum) >> 4;
547
548 WelsI16x16LumaPredDcTop_c (pPred, pRef, kiStride);
549 for (i = 0; i < 256; i++)
550 EXPECT_EQ (pPred[i], uiMean);
551
552 pRef -= kiStride;
553
554 delete []pRef;
555 delete []pPred;
556 }
557