1 /*
2 * Copyright (c) 2018, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11
12 #ifndef AOM_TEST_COMP_AVG_PRED_TEST_H_
13 #define AOM_TEST_COMP_AVG_PRED_TEST_H_
14
15 #include "config/aom_dsp_rtcd.h"
16
17 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
18 #include "test/acm_random.h"
19 #include "test/util.h"
20 #include "test/clear_system_state.h"
21 #include "test/register_state_check.h"
22 #include "av1/common/common_data.h"
23 #include "aom_ports/aom_timer.h"
24
25 namespace libaom_test {
26 const int kMaxSize = 128 + 32; // padding
27
28 namespace AV1DISTWTDCOMPAVG {
29
30 typedef void (*distwtdcompavg_func)(uint8_t *comp_pred, const uint8_t *pred,
31 int width, int height, const uint8_t *ref,
32 int ref_stride,
33 const DIST_WTD_COMP_PARAMS *jcp_param);
34
35 typedef void (*distwtdcompavgupsampled_func)(
36 MACROBLOCKD *xd, const struct AV1Common *const cm, int mi_row, int mi_col,
37 const MV *const mv, uint8_t *comp_pred, const uint8_t *pred, int width,
38 int height, int subpel_x_q3, int subpel_y_q3, const uint8_t *ref,
39 int ref_stride, const DIST_WTD_COMP_PARAMS *jcp_param, int subpel_search);
40
41 typedef void (*highbddistwtdcompavgupsampled_func)(
42 MACROBLOCKD *xd, const struct AV1Common *const cm, int mi_row, int mi_col,
43 const MV *const mv, uint8_t *comp_pred8, const uint8_t *pred8, int width,
44 int height, int subpel_x_q3, int subpel_y_q3, const uint8_t *ref8,
45 int ref_stride, int bd, const DIST_WTD_COMP_PARAMS *jcp_param,
46 int subpel_search);
47
48 typedef ::testing::tuple<distwtdcompavg_func, BLOCK_SIZE> DISTWTDCOMPAVGParam;
49
50 typedef ::testing::tuple<distwtdcompavgupsampled_func, BLOCK_SIZE>
51 DISTWTDCOMPAVGUPSAMPLEDParam;
52
53 typedef ::testing::tuple<int, distwtdcompavg_func, BLOCK_SIZE>
54 HighbdDISTWTDCOMPAVGParam;
55
56 typedef ::testing::tuple<int, highbddistwtdcompavgupsampled_func, BLOCK_SIZE>
57 HighbdDISTWTDCOMPAVGUPSAMPLEDParam;
58
BuildParams(distwtdcompavg_func filter)59 ::testing::internal::ParamGenerator<DISTWTDCOMPAVGParam> BuildParams(
60 distwtdcompavg_func filter) {
61 return ::testing::Combine(::testing::Values(filter),
62 ::testing::Range(BLOCK_4X4, BLOCK_SIZES_ALL));
63 }
64
BuildParams(distwtdcompavgupsampled_func filter)65 ::testing::internal::ParamGenerator<DISTWTDCOMPAVGUPSAMPLEDParam> BuildParams(
66 distwtdcompavgupsampled_func filter) {
67 return ::testing::Combine(::testing::Values(filter),
68 ::testing::Range(BLOCK_4X4, BLOCK_SIZES_ALL));
69 }
70
BuildParams(distwtdcompavg_func filter,int is_hbd)71 ::testing::internal::ParamGenerator<HighbdDISTWTDCOMPAVGParam> BuildParams(
72 distwtdcompavg_func filter, int is_hbd) {
73 (void)is_hbd;
74 return ::testing::Combine(::testing::Range(8, 13, 2),
75 ::testing::Values(filter),
76 ::testing::Range(BLOCK_4X4, BLOCK_SIZES_ALL));
77 }
78
79 ::testing::internal::ParamGenerator<HighbdDISTWTDCOMPAVGUPSAMPLEDParam>
BuildParams(highbddistwtdcompavgupsampled_func filter)80 BuildParams(highbddistwtdcompavgupsampled_func filter) {
81 return ::testing::Combine(::testing::Range(8, 13, 2),
82 ::testing::Values(filter),
83 ::testing::Range(BLOCK_4X4, BLOCK_SIZES_ALL));
84 }
85
86 class AV1DISTWTDCOMPAVGTest
87 : public ::testing::TestWithParam<DISTWTDCOMPAVGParam> {
88 public:
~AV1DISTWTDCOMPAVGTest()89 ~AV1DISTWTDCOMPAVGTest() {}
SetUp()90 void SetUp() { rnd_.Reset(ACMRandom::DeterministicSeed()); }
TearDown()91 void TearDown() { libaom_test::ClearSystemState(); }
92
93 protected:
RunCheckOutput(distwtdcompavg_func test_impl)94 void RunCheckOutput(distwtdcompavg_func test_impl) {
95 const int w = kMaxSize, h = kMaxSize;
96 const int block_idx = GET_PARAM(1);
97
98 uint8_t pred8[kMaxSize * kMaxSize];
99 uint8_t ref8[kMaxSize * kMaxSize];
100 uint8_t output[kMaxSize * kMaxSize];
101 uint8_t output2[kMaxSize * kMaxSize];
102
103 for (int i = 0; i < h; ++i)
104 for (int j = 0; j < w; ++j) {
105 pred8[i * w + j] = rnd_.Rand8();
106 ref8[i * w + j] = rnd_.Rand8();
107 }
108 const int in_w = block_size_wide[block_idx];
109 const int in_h = block_size_high[block_idx];
110
111 DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
112 dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
113
114 for (int ii = 0; ii < 2; ii++) {
115 for (int jj = 0; jj < 4; jj++) {
116 dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[ii][jj][0];
117 dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[ii][jj][1];
118
119 const int offset_r = 3 + rnd_.PseudoUniform(h - in_h - 7);
120 const int offset_c = 3 + rnd_.PseudoUniform(w - in_w - 7);
121 aom_dist_wtd_comp_avg_pred_c(output, pred8 + offset_r * w + offset_c,
122 in_w, in_h, ref8 + offset_r * w + offset_c,
123 in_w, &dist_wtd_comp_params);
124 test_impl(output2, pred8 + offset_r * w + offset_c, in_w, in_h,
125 ref8 + offset_r * w + offset_c, in_w, &dist_wtd_comp_params);
126
127 for (int i = 0; i < in_h; ++i) {
128 for (int j = 0; j < in_w; ++j) {
129 int idx = i * in_w + j;
130 ASSERT_EQ(output[idx], output2[idx])
131 << "Mismatch at unit tests for AV1DISTWTDCOMPAVGTest\n"
132 << in_w << "x" << in_h << " Pixel mismatch at index " << idx
133 << " = (" << i << ", " << j << ")";
134 }
135 }
136 }
137 }
138 }
RunSpeedTest(distwtdcompavg_func test_impl)139 void RunSpeedTest(distwtdcompavg_func test_impl) {
140 const int w = kMaxSize, h = kMaxSize;
141 const int block_idx = GET_PARAM(1);
142
143 uint8_t pred8[kMaxSize * kMaxSize];
144 uint8_t ref8[kMaxSize * kMaxSize];
145 uint8_t output[kMaxSize * kMaxSize];
146 uint8_t output2[kMaxSize * kMaxSize];
147
148 for (int i = 0; i < h; ++i)
149 for (int j = 0; j < w; ++j) {
150 pred8[i * w + j] = rnd_.Rand8();
151 ref8[i * w + j] = rnd_.Rand8();
152 }
153 const int in_w = block_size_wide[block_idx];
154 const int in_h = block_size_high[block_idx];
155
156 DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
157 dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
158
159 dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[0][0][0];
160 dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[0][0][1];
161
162 const int num_loops = 1000000000 / (in_w + in_h);
163 aom_usec_timer timer;
164 aom_usec_timer_start(&timer);
165
166 for (int i = 0; i < num_loops; ++i)
167 aom_dist_wtd_comp_avg_pred_c(output, pred8, in_w, in_h, ref8, in_w,
168 &dist_wtd_comp_params);
169
170 aom_usec_timer_mark(&timer);
171 const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
172 printf("distwtdcompavg c_code %3dx%-3d: %7.2f us\n", in_w, in_h,
173 1000.0 * elapsed_time / num_loops);
174
175 aom_usec_timer timer1;
176 aom_usec_timer_start(&timer1);
177
178 for (int i = 0; i < num_loops; ++i)
179 test_impl(output2, pred8, in_w, in_h, ref8, in_w, &dist_wtd_comp_params);
180
181 aom_usec_timer_mark(&timer1);
182 const int elapsed_time1 = static_cast<int>(aom_usec_timer_elapsed(&timer1));
183 printf("distwtdcompavg test_code %3dx%-3d: %7.2f us\n", in_w, in_h,
184 1000.0 * elapsed_time1 / num_loops);
185 }
186
187 libaom_test::ACMRandom rnd_;
188 }; // class AV1DISTWTDCOMPAVGTest
189
190 class AV1DISTWTDCOMPAVGUPSAMPLEDTest
191 : public ::testing::TestWithParam<DISTWTDCOMPAVGUPSAMPLEDParam> {
192 public:
~AV1DISTWTDCOMPAVGUPSAMPLEDTest()193 ~AV1DISTWTDCOMPAVGUPSAMPLEDTest() {}
SetUp()194 void SetUp() { rnd_.Reset(ACMRandom::DeterministicSeed()); }
TearDown()195 void TearDown() { libaom_test::ClearSystemState(); }
196
197 protected:
RunCheckOutput(distwtdcompavgupsampled_func test_impl)198 void RunCheckOutput(distwtdcompavgupsampled_func test_impl) {
199 const int w = kMaxSize, h = kMaxSize;
200 const int block_idx = GET_PARAM(1);
201
202 uint8_t pred8[kMaxSize * kMaxSize];
203 uint8_t ref8[kMaxSize * kMaxSize];
204 DECLARE_ALIGNED(16, uint8_t, output[MAX_SB_SQUARE]);
205 DECLARE_ALIGNED(16, uint8_t, output2[MAX_SB_SQUARE]);
206
207 for (int i = 0; i < h; ++i)
208 for (int j = 0; j < w; ++j) {
209 pred8[i * w + j] = rnd_.Rand8();
210 ref8[i * w + j] = rnd_.Rand8();
211 }
212 const int in_w = block_size_wide[block_idx];
213 const int in_h = block_size_high[block_idx];
214
215 DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
216 dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
217 int sub_x_q3, sub_y_q3;
218 int subpel_search;
219 for (subpel_search = USE_4_TAPS; subpel_search <= USE_8_TAPS;
220 ++subpel_search) {
221 for (sub_x_q3 = 0; sub_x_q3 < 8; ++sub_x_q3) {
222 for (sub_y_q3 = 0; sub_y_q3 < 8; ++sub_y_q3) {
223 for (int ii = 0; ii < 2; ii++) {
224 for (int jj = 0; jj < 4; jj++) {
225 dist_wtd_comp_params.fwd_offset =
226 quant_dist_lookup_table[ii][jj][0];
227 dist_wtd_comp_params.bck_offset =
228 quant_dist_lookup_table[ii][jj][1];
229
230 const int offset_r = 3 + rnd_.PseudoUniform(h - in_h - 7);
231 const int offset_c = 3 + rnd_.PseudoUniform(w - in_w - 7);
232
233 aom_dist_wtd_comp_avg_upsampled_pred_c(
234 NULL, NULL, 0, 0, NULL, output,
235 pred8 + offset_r * w + offset_c, in_w, in_h, sub_x_q3,
236 sub_y_q3, ref8 + offset_r * w + offset_c, in_w,
237 &dist_wtd_comp_params, subpel_search);
238 test_impl(NULL, NULL, 0, 0, NULL, output2,
239 pred8 + offset_r * w + offset_c, in_w, in_h, sub_x_q3,
240 sub_y_q3, ref8 + offset_r * w + offset_c, in_w,
241 &dist_wtd_comp_params, subpel_search);
242
243 for (int i = 0; i < in_h; ++i) {
244 for (int j = 0; j < in_w; ++j) {
245 int idx = i * in_w + j;
246 ASSERT_EQ(output[idx], output2[idx])
247 << "Mismatch at unit tests for "
248 "AV1DISTWTDCOMPAVGUPSAMPLEDTest\n"
249 << in_w << "x" << in_h << " Pixel mismatch at index "
250 << idx << " = (" << i << ", " << j
251 << "), sub pixel offset = (" << sub_y_q3 << ", "
252 << sub_x_q3 << ")";
253 }
254 }
255 }
256 }
257 }
258 }
259 }
260 }
RunSpeedTest(distwtdcompavgupsampled_func test_impl)261 void RunSpeedTest(distwtdcompavgupsampled_func test_impl) {
262 const int w = kMaxSize, h = kMaxSize;
263 const int block_idx = GET_PARAM(1);
264
265 uint8_t pred8[kMaxSize * kMaxSize];
266 uint8_t ref8[kMaxSize * kMaxSize];
267 DECLARE_ALIGNED(16, uint8_t, output[MAX_SB_SQUARE]);
268 DECLARE_ALIGNED(16, uint8_t, output2[MAX_SB_SQUARE]);
269
270 for (int i = 0; i < h; ++i)
271 for (int j = 0; j < w; ++j) {
272 pred8[i * w + j] = rnd_.Rand8();
273 ref8[i * w + j] = rnd_.Rand8();
274 }
275 const int in_w = block_size_wide[block_idx];
276 const int in_h = block_size_high[block_idx];
277
278 DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
279 dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
280
281 dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[0][0][0];
282 dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[0][0][1];
283
284 int sub_x_q3 = 0;
285 int sub_y_q3 = 0;
286
287 const int num_loops = 1000000000 / (in_w + in_h);
288 aom_usec_timer timer;
289 aom_usec_timer_start(&timer);
290 int subpel_search = USE_8_TAPS; // set to USE_4_TAPS to test 4-tap filter.
291
292 for (int i = 0; i < num_loops; ++i)
293 aom_dist_wtd_comp_avg_upsampled_pred_c(
294 NULL, NULL, 0, 0, NULL, output, pred8, in_w, in_h, sub_x_q3, sub_y_q3,
295 ref8, in_w, &dist_wtd_comp_params, subpel_search);
296
297 aom_usec_timer_mark(&timer);
298 const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
299 printf("distwtdcompavgupsampled c_code %3dx%-3d: %7.2f us\n", in_w, in_h,
300 1000.0 * elapsed_time / num_loops);
301
302 aom_usec_timer timer1;
303 aom_usec_timer_start(&timer1);
304
305 for (int i = 0; i < num_loops; ++i)
306 test_impl(NULL, NULL, 0, 0, NULL, output2, pred8, in_w, in_h, sub_x_q3,
307 sub_y_q3, ref8, in_w, &dist_wtd_comp_params, subpel_search);
308
309 aom_usec_timer_mark(&timer1);
310 const int elapsed_time1 = static_cast<int>(aom_usec_timer_elapsed(&timer1));
311 printf("distwtdcompavgupsampled test_code %3dx%-3d: %7.2f us\n", in_w, in_h,
312 1000.0 * elapsed_time1 / num_loops);
313 }
314
315 libaom_test::ACMRandom rnd_;
316 }; // class AV1DISTWTDCOMPAVGUPSAMPLEDTest
317
318 class AV1HighBDDISTWTDCOMPAVGTest
319 : public ::testing::TestWithParam<HighbdDISTWTDCOMPAVGParam> {
320 public:
~AV1HighBDDISTWTDCOMPAVGTest()321 ~AV1HighBDDISTWTDCOMPAVGTest() {}
SetUp()322 void SetUp() { rnd_.Reset(ACMRandom::DeterministicSeed()); }
323
TearDown()324 void TearDown() { libaom_test::ClearSystemState(); }
325
326 protected:
RunCheckOutput(distwtdcompavg_func test_impl)327 void RunCheckOutput(distwtdcompavg_func test_impl) {
328 const int w = kMaxSize, h = kMaxSize;
329 const int block_idx = GET_PARAM(2);
330 const int bd = GET_PARAM(0);
331 uint16_t pred8[kMaxSize * kMaxSize];
332 uint16_t ref8[kMaxSize * kMaxSize];
333 uint16_t output[kMaxSize * kMaxSize];
334 uint16_t output2[kMaxSize * kMaxSize];
335
336 for (int i = 0; i < h; ++i)
337 for (int j = 0; j < w; ++j) {
338 pred8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
339 ref8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
340 }
341 const int in_w = block_size_wide[block_idx];
342 const int in_h = block_size_high[block_idx];
343
344 DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
345 dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
346
347 for (int ii = 0; ii < 2; ii++) {
348 for (int jj = 0; jj < 4; jj++) {
349 dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[ii][jj][0];
350 dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[ii][jj][1];
351
352 const int offset_r = 3 + rnd_.PseudoUniform(h - in_h - 7);
353 const int offset_c = 3 + rnd_.PseudoUniform(w - in_w - 7);
354 aom_highbd_dist_wtd_comp_avg_pred_c(
355 CONVERT_TO_BYTEPTR(output),
356 CONVERT_TO_BYTEPTR(pred8) + offset_r * w + offset_c, in_w, in_h,
357 CONVERT_TO_BYTEPTR(ref8) + offset_r * w + offset_c, in_w,
358 &dist_wtd_comp_params);
359 test_impl(CONVERT_TO_BYTEPTR(output2),
360 CONVERT_TO_BYTEPTR(pred8) + offset_r * w + offset_c, in_w,
361 in_h, CONVERT_TO_BYTEPTR(ref8) + offset_r * w + offset_c,
362 in_w, &dist_wtd_comp_params);
363
364 for (int i = 0; i < in_h; ++i) {
365 for (int j = 0; j < in_w; ++j) {
366 int idx = i * in_w + j;
367 ASSERT_EQ(output[idx], output2[idx])
368 << "Mismatch at unit tests for AV1HighBDDISTWTDCOMPAVGTest\n"
369 << in_w << "x" << in_h << " Pixel mismatch at index " << idx
370 << " = (" << i << ", " << j << ")";
371 }
372 }
373 }
374 }
375 }
RunSpeedTest(distwtdcompavg_func test_impl)376 void RunSpeedTest(distwtdcompavg_func test_impl) {
377 const int w = kMaxSize, h = kMaxSize;
378 const int block_idx = GET_PARAM(2);
379 const int bd = GET_PARAM(0);
380 uint16_t pred8[kMaxSize * kMaxSize];
381 uint16_t ref8[kMaxSize * kMaxSize];
382 uint16_t output[kMaxSize * kMaxSize];
383 uint16_t output2[kMaxSize * kMaxSize];
384
385 for (int i = 0; i < h; ++i)
386 for (int j = 0; j < w; ++j) {
387 pred8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
388 ref8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
389 }
390 const int in_w = block_size_wide[block_idx];
391 const int in_h = block_size_high[block_idx];
392
393 DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
394 dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
395
396 dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[0][0][0];
397 dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[0][0][1];
398
399 const int num_loops = 1000000000 / (in_w + in_h);
400 aom_usec_timer timer;
401 aom_usec_timer_start(&timer);
402
403 for (int i = 0; i < num_loops; ++i)
404 aom_highbd_dist_wtd_comp_avg_pred_c(
405 CONVERT_TO_BYTEPTR(output), CONVERT_TO_BYTEPTR(pred8), in_w, in_h,
406 CONVERT_TO_BYTEPTR(ref8), in_w, &dist_wtd_comp_params);
407
408 aom_usec_timer_mark(&timer);
409 const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
410 printf("highbddistwtdcompavg c_code %3dx%-3d: %7.2f us\n", in_w, in_h,
411 1000.0 * elapsed_time / num_loops);
412
413 aom_usec_timer timer1;
414 aom_usec_timer_start(&timer1);
415
416 for (int i = 0; i < num_loops; ++i)
417 test_impl(CONVERT_TO_BYTEPTR(output2), CONVERT_TO_BYTEPTR(pred8), in_w,
418 in_h, CONVERT_TO_BYTEPTR(ref8), in_w, &dist_wtd_comp_params);
419
420 aom_usec_timer_mark(&timer1);
421 const int elapsed_time1 = static_cast<int>(aom_usec_timer_elapsed(&timer1));
422 printf("highbddistwtdcompavg test_code %3dx%-3d: %7.2f us\n", in_w, in_h,
423 1000.0 * elapsed_time1 / num_loops);
424 }
425
426 libaom_test::ACMRandom rnd_;
427 }; // class AV1HighBDDISTWTDCOMPAVGTest
428
429 class AV1HighBDDISTWTDCOMPAVGUPSAMPLEDTest
430 : public ::testing::TestWithParam<HighbdDISTWTDCOMPAVGUPSAMPLEDParam> {
431 public:
~AV1HighBDDISTWTDCOMPAVGUPSAMPLEDTest()432 ~AV1HighBDDISTWTDCOMPAVGUPSAMPLEDTest() {}
SetUp()433 void SetUp() { rnd_.Reset(ACMRandom::DeterministicSeed()); }
TearDown()434 void TearDown() { libaom_test::ClearSystemState(); }
435
436 protected:
RunCheckOutput(highbddistwtdcompavgupsampled_func test_impl)437 void RunCheckOutput(highbddistwtdcompavgupsampled_func test_impl) {
438 const int w = kMaxSize, h = kMaxSize;
439 const int block_idx = GET_PARAM(2);
440 const int bd = GET_PARAM(0);
441 uint16_t pred8[kMaxSize * kMaxSize];
442 uint16_t ref8[kMaxSize * kMaxSize];
443 DECLARE_ALIGNED(16, uint16_t, output[kMaxSize * kMaxSize]);
444 DECLARE_ALIGNED(16, uint16_t, output2[kMaxSize * kMaxSize]);
445
446 for (int i = 0; i < h; ++i)
447 for (int j = 0; j < w; ++j) {
448 pred8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
449 ref8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
450 }
451 const int in_w = block_size_wide[block_idx];
452 const int in_h = block_size_high[block_idx];
453
454 DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
455 dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
456 int sub_x_q3, sub_y_q3;
457 int subpel_search;
458 for (subpel_search = USE_4_TAPS; subpel_search <= USE_8_TAPS;
459 ++subpel_search) {
460 for (sub_x_q3 = 0; sub_x_q3 < 8; ++sub_x_q3) {
461 for (sub_y_q3 = 0; sub_y_q3 < 8; ++sub_y_q3) {
462 for (int ii = 0; ii < 2; ii++) {
463 for (int jj = 0; jj < 4; jj++) {
464 dist_wtd_comp_params.fwd_offset =
465 quant_dist_lookup_table[ii][jj][0];
466 dist_wtd_comp_params.bck_offset =
467 quant_dist_lookup_table[ii][jj][1];
468
469 const int offset_r = 3 + rnd_.PseudoUniform(h - in_h - 7);
470 const int offset_c = 3 + rnd_.PseudoUniform(w - in_w - 7);
471
472 aom_highbd_dist_wtd_comp_avg_upsampled_pred_c(
473 NULL, NULL, 0, 0, NULL, CONVERT_TO_BYTEPTR(output),
474 CONVERT_TO_BYTEPTR(pred8) + offset_r * w + offset_c, in_w,
475 in_h, sub_x_q3, sub_y_q3,
476 CONVERT_TO_BYTEPTR(ref8) + offset_r * w + offset_c, in_w, bd,
477 &dist_wtd_comp_params, subpel_search);
478 test_impl(NULL, NULL, 0, 0, NULL, CONVERT_TO_BYTEPTR(output2),
479 CONVERT_TO_BYTEPTR(pred8) + offset_r * w + offset_c,
480 in_w, in_h, sub_x_q3, sub_y_q3,
481 CONVERT_TO_BYTEPTR(ref8) + offset_r * w + offset_c,
482 in_w, bd, &dist_wtd_comp_params, subpel_search);
483
484 for (int i = 0; i < in_h; ++i) {
485 for (int j = 0; j < in_w; ++j) {
486 int idx = i * in_w + j;
487 ASSERT_EQ(output[idx], output2[idx])
488 << "Mismatch at unit tests for "
489 "AV1HighBDDISTWTDCOMPAVGUPSAMPLEDTest\n"
490 << in_w << "x" << in_h << " Pixel mismatch at index "
491 << idx << " = (" << i << ", " << j
492 << "), sub pixel offset = (" << sub_y_q3 << ", "
493 << sub_x_q3 << ")";
494 }
495 }
496 }
497 }
498 }
499 }
500 }
501 }
RunSpeedTest(highbddistwtdcompavgupsampled_func test_impl)502 void RunSpeedTest(highbddistwtdcompavgupsampled_func test_impl) {
503 const int w = kMaxSize, h = kMaxSize;
504 const int block_idx = GET_PARAM(2);
505 const int bd = GET_PARAM(0);
506 uint16_t pred8[kMaxSize * kMaxSize];
507 uint16_t ref8[kMaxSize * kMaxSize];
508 DECLARE_ALIGNED(16, uint16_t, output[kMaxSize * kMaxSize]);
509 DECLARE_ALIGNED(16, uint16_t, output2[kMaxSize * kMaxSize]);
510
511 for (int i = 0; i < h; ++i)
512 for (int j = 0; j < w; ++j) {
513 pred8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
514 ref8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
515 }
516 const int in_w = block_size_wide[block_idx];
517 const int in_h = block_size_high[block_idx];
518
519 DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
520 dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
521
522 dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[0][0][0];
523 dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[0][0][1];
524 int sub_x_q3 = 0;
525 int sub_y_q3 = 0;
526 const int num_loops = 1000000000 / (in_w + in_h);
527 aom_usec_timer timer;
528 aom_usec_timer_start(&timer);
529 int subpel_search = USE_8_TAPS; // set to USE_4_TAPS to test 4-tap filter.
530 for (int i = 0; i < num_loops; ++i)
531 aom_highbd_dist_wtd_comp_avg_upsampled_pred_c(
532 NULL, NULL, 0, 0, NULL, CONVERT_TO_BYTEPTR(output),
533 CONVERT_TO_BYTEPTR(pred8), in_w, in_h, sub_x_q3, sub_y_q3,
534 CONVERT_TO_BYTEPTR(ref8), in_w, bd, &dist_wtd_comp_params,
535 subpel_search);
536
537 aom_usec_timer_mark(&timer);
538 const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
539 printf("highbddistwtdcompavgupsampled c_code %3dx%-3d: %7.2f us\n", in_w,
540 in_h, 1000.0 * elapsed_time / num_loops);
541
542 aom_usec_timer timer1;
543 aom_usec_timer_start(&timer1);
544
545 for (int i = 0; i < num_loops; ++i)
546 test_impl(NULL, NULL, 0, 0, NULL, CONVERT_TO_BYTEPTR(output2),
547 CONVERT_TO_BYTEPTR(pred8), in_w, in_h, sub_x_q3, sub_y_q3,
548 CONVERT_TO_BYTEPTR(ref8), in_w, bd, &dist_wtd_comp_params,
549 subpel_search);
550
551 aom_usec_timer_mark(&timer1);
552 const int elapsed_time1 = static_cast<int>(aom_usec_timer_elapsed(&timer1));
553 printf("highbddistwtdcompavgupsampled test_code %3dx%-3d: %7.2f us\n", in_w,
554 in_h, 1000.0 * elapsed_time1 / num_loops);
555 }
556
557 libaom_test::ACMRandom rnd_;
558 }; // class AV1HighBDDISTWTDCOMPAVGUPSAMPLEDTest
559
560 } // namespace AV1DISTWTDCOMPAVG
561 } // namespace libaom_test
562
563 #endif // AOM_TEST_COMP_AVG_PRED_TEST_H_
564