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 #include "config/av1_rtcd.h"
19
20 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
21 #include "test/acm_random.h"
22 #include "test/util.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()); }
95
96 protected:
RunCheckOutput(distwtdcompavg_func test_impl)97 void RunCheckOutput(distwtdcompavg_func test_impl) {
98 const int w = kMaxSize, h = kMaxSize;
99 const int block_idx = GET_PARAM(1);
100
101 uint8_t pred8[kMaxSize * kMaxSize];
102 uint8_t ref8[kMaxSize * kMaxSize];
103 uint8_t output[kMaxSize * kMaxSize];
104 uint8_t output2[kMaxSize * kMaxSize];
105
106 for (int i = 0; i < h; ++i)
107 for (int j = 0; j < w; ++j) {
108 pred8[i * w + j] = rnd_.Rand8();
109 ref8[i * w + j] = rnd_.Rand8();
110 }
111 const int in_w = block_size_wide[block_idx];
112 const int in_h = block_size_high[block_idx];
113
114 DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
115 dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
116
117 for (int ii = 0; ii < 2; ii++) {
118 for (int jj = 0; jj < 4; jj++) {
119 dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[jj][ii];
120 dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[jj][1 - ii];
121
122 const int offset_r = 3 + rnd_.PseudoUniform(h - in_h - 7);
123 const int offset_c = 3 + rnd_.PseudoUniform(w - in_w - 7);
124 aom_dist_wtd_comp_avg_pred_c(output, pred8 + offset_r * w + offset_c,
125 in_w, in_h, ref8 + offset_r * w + offset_c,
126 in_w, &dist_wtd_comp_params);
127 test_impl(output2, pred8 + offset_r * w + offset_c, in_w, in_h,
128 ref8 + offset_r * w + offset_c, in_w, &dist_wtd_comp_params);
129
130 for (int i = 0; i < in_h; ++i) {
131 for (int j = 0; j < in_w; ++j) {
132 int idx = i * in_w + j;
133 ASSERT_EQ(output[idx], output2[idx])
134 << "Mismatch at unit tests for AV1DISTWTDCOMPAVGTest\n"
135 << in_w << "x" << in_h << " Pixel mismatch at index " << idx
136 << " = (" << i << ", " << j << ")";
137 }
138 }
139 }
140 }
141 }
RunSpeedTest(distwtdcompavg_func test_impl)142 void RunSpeedTest(distwtdcompavg_func test_impl) {
143 const int w = kMaxSize, h = kMaxSize;
144 const int block_idx = GET_PARAM(1);
145
146 uint8_t pred8[kMaxSize * kMaxSize];
147 uint8_t ref8[kMaxSize * kMaxSize];
148 uint8_t output[kMaxSize * kMaxSize];
149 uint8_t output2[kMaxSize * kMaxSize];
150
151 for (int i = 0; i < h; ++i)
152 for (int j = 0; j < w; ++j) {
153 pred8[i * w + j] = rnd_.Rand8();
154 ref8[i * w + j] = rnd_.Rand8();
155 }
156 const int in_w = block_size_wide[block_idx];
157 const int in_h = block_size_high[block_idx];
158
159 DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
160 dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
161
162 dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[0][0];
163 dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[0][1];
164
165 const int num_loops = 1000000000 / (in_w + in_h);
166 aom_usec_timer timer;
167 aom_usec_timer_start(&timer);
168
169 for (int i = 0; i < num_loops; ++i)
170 aom_dist_wtd_comp_avg_pred_c(output, pred8, in_w, in_h, ref8, in_w,
171 &dist_wtd_comp_params);
172
173 aom_usec_timer_mark(&timer);
174 const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
175 printf("distwtdcompavg c_code %3dx%-3d: %7.2f us\n", in_w, in_h,
176 1000.0 * elapsed_time / num_loops);
177
178 aom_usec_timer timer1;
179 aom_usec_timer_start(&timer1);
180
181 for (int i = 0; i < num_loops; ++i)
182 test_impl(output2, pred8, in_w, in_h, ref8, in_w, &dist_wtd_comp_params);
183
184 aom_usec_timer_mark(&timer1);
185 const int elapsed_time1 = static_cast<int>(aom_usec_timer_elapsed(&timer1));
186 printf("distwtdcompavg test_code %3dx%-3d: %7.2f us\n", in_w, in_h,
187 1000.0 * elapsed_time1 / num_loops);
188 }
189
190 libaom_test::ACMRandom rnd_;
191 }; // class AV1DISTWTDCOMPAVGTest
192
193 class AV1DISTWTDCOMPAVGUPSAMPLEDTest
194 : public ::testing::TestWithParam<DISTWTDCOMPAVGUPSAMPLEDParam> {
195 public:
~AV1DISTWTDCOMPAVGUPSAMPLEDTest()196 ~AV1DISTWTDCOMPAVGUPSAMPLEDTest() {}
SetUp()197 void SetUp() { rnd_.Reset(ACMRandom::DeterministicSeed()); }
198
199 protected:
RunCheckOutput(distwtdcompavgupsampled_func test_impl)200 void RunCheckOutput(distwtdcompavgupsampled_func test_impl) {
201 const int w = kMaxSize, h = kMaxSize;
202 const int block_idx = GET_PARAM(1);
203
204 uint8_t pred8[kMaxSize * kMaxSize];
205 uint8_t ref8[kMaxSize * kMaxSize];
206 DECLARE_ALIGNED(16, uint8_t, output[MAX_SB_SQUARE]);
207 DECLARE_ALIGNED(16, uint8_t, output2[MAX_SB_SQUARE]);
208
209 for (int i = 0; i < h; ++i)
210 for (int j = 0; j < w; ++j) {
211 pred8[i * w + j] = rnd_.Rand8();
212 ref8[i * w + j] = rnd_.Rand8();
213 }
214 const int in_w = block_size_wide[block_idx];
215 const int in_h = block_size_high[block_idx];
216
217 DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
218 dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
219 int sub_x_q3, sub_y_q3;
220 int subpel_search;
221 for (subpel_search = USE_4_TAPS; subpel_search <= USE_8_TAPS;
222 ++subpel_search) {
223 for (sub_x_q3 = 0; sub_x_q3 < 8; ++sub_x_q3) {
224 for (sub_y_q3 = 0; sub_y_q3 < 8; ++sub_y_q3) {
225 for (int ii = 0; ii < 2; ii++) {
226 for (int jj = 0; jj < 4; jj++) {
227 dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[jj][ii];
228 dist_wtd_comp_params.bck_offset =
229 quant_dist_lookup_table[jj][1 - ii];
230
231 const int offset_r = 3 + rnd_.PseudoUniform(h - in_h - 7);
232 const int offset_c = 3 + rnd_.PseudoUniform(w - in_w - 7);
233
234 aom_dist_wtd_comp_avg_upsampled_pred_c(
235 nullptr, nullptr, 0, 0, nullptr, output,
236 pred8 + offset_r * w + offset_c, in_w, in_h, sub_x_q3,
237 sub_y_q3, ref8 + offset_r * w + offset_c, in_w,
238 &dist_wtd_comp_params, subpel_search);
239 test_impl(nullptr, nullptr, 0, 0, nullptr, output2,
240 pred8 + offset_r * w + offset_c, in_w, in_h, sub_x_q3,
241 sub_y_q3, ref8 + offset_r * w + offset_c, in_w,
242 &dist_wtd_comp_params, subpel_search);
243
244 for (int i = 0; i < in_h; ++i) {
245 for (int j = 0; j < in_w; ++j) {
246 int idx = i * in_w + j;
247 ASSERT_EQ(output[idx], output2[idx])
248 << "Mismatch at unit tests for "
249 "AV1DISTWTDCOMPAVGUPSAMPLEDTest\n"
250 << in_w << "x" << in_h << " Pixel mismatch at index "
251 << idx << " = (" << i << ", " << j
252 << "), sub pixel offset = (" << sub_y_q3 << ", "
253 << sub_x_q3 << ")";
254 }
255 }
256 }
257 }
258 }
259 }
260 }
261 }
RunSpeedTest(distwtdcompavgupsampled_func test_impl)262 void RunSpeedTest(distwtdcompavgupsampled_func test_impl) {
263 const int w = kMaxSize, h = kMaxSize;
264 const int block_idx = GET_PARAM(1);
265
266 uint8_t pred8[kMaxSize * kMaxSize];
267 uint8_t ref8[kMaxSize * kMaxSize];
268 DECLARE_ALIGNED(16, uint8_t, output[MAX_SB_SQUARE]);
269 DECLARE_ALIGNED(16, uint8_t, output2[MAX_SB_SQUARE]);
270
271 for (int i = 0; i < h; ++i)
272 for (int j = 0; j < w; ++j) {
273 pred8[i * w + j] = rnd_.Rand8();
274 ref8[i * w + j] = rnd_.Rand8();
275 }
276 const int in_w = block_size_wide[block_idx];
277 const int in_h = block_size_high[block_idx];
278
279 DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
280 dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
281
282 dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[0][0];
283 dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[0][1];
284
285 int sub_x_q3 = 0;
286 int sub_y_q3 = 0;
287
288 const int num_loops = 1000000000 / (in_w + in_h);
289 aom_usec_timer timer;
290 aom_usec_timer_start(&timer);
291 int subpel_search = USE_8_TAPS; // set to USE_4_TAPS to test 4-tap filter.
292
293 for (int i = 0; i < num_loops; ++i)
294 aom_dist_wtd_comp_avg_upsampled_pred_c(
295 nullptr, nullptr, 0, 0, nullptr, output, pred8, in_w, in_h, sub_x_q3,
296 sub_y_q3, ref8, in_w, &dist_wtd_comp_params, subpel_search);
297
298 aom_usec_timer_mark(&timer);
299 const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
300 printf("distwtdcompavgupsampled c_code %3dx%-3d: %7.2f us\n", in_w, in_h,
301 1000.0 * elapsed_time / num_loops);
302
303 aom_usec_timer timer1;
304 aom_usec_timer_start(&timer1);
305
306 for (int i = 0; i < num_loops; ++i)
307 test_impl(nullptr, nullptr, 0, 0, nullptr, output2, pred8, in_w, in_h,
308 sub_x_q3, sub_y_q3, ref8, in_w, &dist_wtd_comp_params,
309 subpel_search);
310
311 aom_usec_timer_mark(&timer1);
312 const int elapsed_time1 = static_cast<int>(aom_usec_timer_elapsed(&timer1));
313 printf("distwtdcompavgupsampled test_code %3dx%-3d: %7.2f us\n", in_w, in_h,
314 1000.0 * elapsed_time1 / num_loops);
315 }
316
317 libaom_test::ACMRandom rnd_;
318 }; // class AV1DISTWTDCOMPAVGUPSAMPLEDTest
319
320 #if CONFIG_AV1_HIGHBITDEPTH
321 class AV1HighBDDISTWTDCOMPAVGTest
322 : public ::testing::TestWithParam<HighbdDISTWTDCOMPAVGParam> {
323 public:
~AV1HighBDDISTWTDCOMPAVGTest()324 ~AV1HighBDDISTWTDCOMPAVGTest() {}
SetUp()325 void SetUp() { rnd_.Reset(ACMRandom::DeterministicSeed()); }
326
327 protected:
RunCheckOutput(distwtdcompavg_func test_impl)328 void RunCheckOutput(distwtdcompavg_func test_impl) {
329 const int w = kMaxSize, h = kMaxSize;
330 const int block_idx = GET_PARAM(2);
331 const int bd = GET_PARAM(0);
332 uint16_t pred8[kMaxSize * kMaxSize];
333 uint16_t ref8[kMaxSize * kMaxSize];
334 uint16_t output[kMaxSize * kMaxSize];
335 uint16_t output2[kMaxSize * kMaxSize];
336
337 for (int i = 0; i < h; ++i)
338 for (int j = 0; j < w; ++j) {
339 pred8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
340 ref8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
341 }
342 const int in_w = block_size_wide[block_idx];
343 const int in_h = block_size_high[block_idx];
344
345 DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
346 dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
347
348 for (int ii = 0; ii < 2; ii++) {
349 for (int jj = 0; jj < 4; jj++) {
350 dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[jj][ii];
351 dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[jj][1 - ii];
352
353 const int offset_r = 3 + rnd_.PseudoUniform(h - in_h - 7);
354 const int offset_c = 3 + rnd_.PseudoUniform(w - in_w - 7);
355 aom_highbd_dist_wtd_comp_avg_pred_c(
356 CONVERT_TO_BYTEPTR(output),
357 CONVERT_TO_BYTEPTR(pred8) + offset_r * w + offset_c, in_w, in_h,
358 CONVERT_TO_BYTEPTR(ref8) + offset_r * w + offset_c, in_w,
359 &dist_wtd_comp_params);
360 test_impl(CONVERT_TO_BYTEPTR(output2),
361 CONVERT_TO_BYTEPTR(pred8) + offset_r * w + offset_c, in_w,
362 in_h, CONVERT_TO_BYTEPTR(ref8) + offset_r * w + offset_c,
363 in_w, &dist_wtd_comp_params);
364
365 for (int i = 0; i < in_h; ++i) {
366 for (int j = 0; j < in_w; ++j) {
367 int idx = i * in_w + j;
368 ASSERT_EQ(output[idx], output2[idx])
369 << "Mismatch at unit tests for AV1HighBDDISTWTDCOMPAVGTest\n"
370 << in_w << "x" << in_h << " Pixel mismatch at index " << idx
371 << " = (" << i << ", " << j << ")";
372 }
373 }
374 }
375 }
376 }
RunSpeedTest(distwtdcompavg_func test_impl)377 void RunSpeedTest(distwtdcompavg_func test_impl) {
378 const int w = kMaxSize, h = kMaxSize;
379 const int block_idx = GET_PARAM(2);
380 const int bd = GET_PARAM(0);
381 uint16_t pred8[kMaxSize * kMaxSize];
382 uint16_t ref8[kMaxSize * kMaxSize];
383 uint16_t output[kMaxSize * kMaxSize];
384 uint16_t output2[kMaxSize * kMaxSize];
385
386 for (int i = 0; i < h; ++i)
387 for (int j = 0; j < w; ++j) {
388 pred8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
389 ref8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
390 }
391 const int in_w = block_size_wide[block_idx];
392 const int in_h = block_size_high[block_idx];
393
394 DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
395 dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
396
397 dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[0][0];
398 dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[0][1];
399
400 const int num_loops = 1000000000 / (in_w + in_h);
401 aom_usec_timer timer;
402 aom_usec_timer_start(&timer);
403
404 for (int i = 0; i < num_loops; ++i)
405 aom_highbd_dist_wtd_comp_avg_pred_c(
406 CONVERT_TO_BYTEPTR(output), CONVERT_TO_BYTEPTR(pred8), in_w, in_h,
407 CONVERT_TO_BYTEPTR(ref8), in_w, &dist_wtd_comp_params);
408
409 aom_usec_timer_mark(&timer);
410 const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
411 printf("highbddistwtdcompavg c_code %3dx%-3d: %7.2f us\n", in_w, in_h,
412 1000.0 * elapsed_time / num_loops);
413
414 aom_usec_timer timer1;
415 aom_usec_timer_start(&timer1);
416
417 for (int i = 0; i < num_loops; ++i)
418 test_impl(CONVERT_TO_BYTEPTR(output2), CONVERT_TO_BYTEPTR(pred8), in_w,
419 in_h, CONVERT_TO_BYTEPTR(ref8), in_w, &dist_wtd_comp_params);
420
421 aom_usec_timer_mark(&timer1);
422 const int elapsed_time1 = static_cast<int>(aom_usec_timer_elapsed(&timer1));
423 printf("highbddistwtdcompavg test_code %3dx%-3d: %7.2f us\n", in_w, in_h,
424 1000.0 * elapsed_time1 / num_loops);
425 }
426
427 libaom_test::ACMRandom rnd_;
428 }; // class AV1HighBDDISTWTDCOMPAVGTest
429
430 class AV1HighBDDISTWTDCOMPAVGUPSAMPLEDTest
431 : public ::testing::TestWithParam<HighbdDISTWTDCOMPAVGUPSAMPLEDParam> {
432 public:
~AV1HighBDDISTWTDCOMPAVGUPSAMPLEDTest()433 ~AV1HighBDDISTWTDCOMPAVGUPSAMPLEDTest() {}
SetUp()434 void SetUp() { rnd_.Reset(ACMRandom::DeterministicSeed()); }
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 = quant_dist_lookup_table[jj][ii];
465 dist_wtd_comp_params.bck_offset =
466 quant_dist_lookup_table[jj][1 - ii];
467
468 const int offset_r = 3 + rnd_.PseudoUniform(h - in_h - 7);
469 const int offset_c = 3 + rnd_.PseudoUniform(w - in_w - 7);
470
471 aom_highbd_dist_wtd_comp_avg_upsampled_pred_c(
472 nullptr, nullptr, 0, 0, nullptr, CONVERT_TO_BYTEPTR(output),
473 CONVERT_TO_BYTEPTR(pred8) + offset_r * w + offset_c, in_w,
474 in_h, sub_x_q3, sub_y_q3,
475 CONVERT_TO_BYTEPTR(ref8) + offset_r * w + offset_c, in_w, bd,
476 &dist_wtd_comp_params, subpel_search);
477 test_impl(nullptr, nullptr, 0, 0, nullptr,
478 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];
523 dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[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 nullptr, nullptr, 0, 0, nullptr, 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(nullptr, nullptr, 0, 0, nullptr, 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 #endif // CONFIG_AV1_HIGHBITDEPTH
560
561 } // namespace AV1DISTWTDCOMPAVG
562 } // namespace libaom_test
563
564 #endif // AOM_TEST_COMP_AVG_PRED_TEST_H_
565