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