hadamard: Add 4x4 test.
[aom.git] / test / comp_mask_variance_test.cc
blobaade961b58e8f65eb9b8aa9bca1d01cb86c5934e
1 /*
2 * Copyright (c) 2018, Alliance for Open Media. All rights reserved
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.
12 #include <cstdlib>
13 #include <new>
14 #include <tuple>
16 #include "config/aom_config.h"
17 #include "config/aom_dsp_rtcd.h"
19 #include "aom/aom_codec.h"
20 #include "aom/aom_integer.h"
21 #include "aom_dsp/variance.h"
22 #include "aom_mem/aom_mem.h"
23 #include "aom_ports/aom_timer.h"
24 #include "aom_ports/mem.h"
25 #include "av1/common/reconinter.h"
26 #include "av1/encoder/reconinter_enc.h"
27 #include "test/acm_random.h"
28 #include "test/register_state_check.h"
29 #include "test/util.h"
30 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
32 namespace AV1CompMaskVariance {
33 typedef void (*comp_mask_pred_func)(uint8_t *comp_pred, const uint8_t *pred,
34 int width, int height, const uint8_t *ref,
35 int ref_stride, const uint8_t *mask,
36 int mask_stride, int invert_mask);
38 #if HAVE_SSSE3 || HAVE_SSE2 || HAVE_AVX2
39 const BLOCK_SIZE kValidBlockSize[] = {
40 BLOCK_8X8, BLOCK_8X16, BLOCK_8X32, BLOCK_16X8, BLOCK_16X16,
41 BLOCK_16X32, BLOCK_32X8, BLOCK_32X16, BLOCK_32X32, BLOCK_32X64,
42 BLOCK_64X32, BLOCK_64X64, BLOCK_64X128, BLOCK_128X64, BLOCK_128X128,
43 BLOCK_16X64, BLOCK_64X16
45 #endif
46 typedef std::tuple<comp_mask_pred_func, BLOCK_SIZE> CompMaskPredParam;
48 class AV1CompMaskVarianceTest
49 : public ::testing::TestWithParam<CompMaskPredParam> {
50 public:
51 ~AV1CompMaskVarianceTest();
52 void SetUp();
54 void TearDown();
56 protected:
57 void RunCheckOutput(comp_mask_pred_func test_impl, BLOCK_SIZE bsize, int inv);
58 void RunSpeedTest(comp_mask_pred_func test_impl, BLOCK_SIZE bsize);
59 bool CheckResult(int width, int height) {
60 for (int y = 0; y < height; ++y) {
61 for (int x = 0; x < width; ++x) {
62 const int idx = y * width + x;
63 if (comp_pred1_[idx] != comp_pred2_[idx]) {
64 printf("%dx%d mismatch @%d(%d,%d) ", width, height, idx, y, x);
65 printf("%d != %d ", comp_pred1_[idx], comp_pred2_[idx]);
66 return false;
70 return true;
73 libaom_test::ACMRandom rnd_;
74 uint8_t *comp_pred1_;
75 uint8_t *comp_pred2_;
76 uint8_t *pred_;
77 uint8_t *ref_buffer_;
78 uint8_t *ref_;
80 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AV1CompMaskVarianceTest);
82 AV1CompMaskVarianceTest::~AV1CompMaskVarianceTest() { ; }
84 void AV1CompMaskVarianceTest::SetUp() {
85 rnd_.Reset(libaom_test::ACMRandom::DeterministicSeed());
86 av1_init_wedge_masks();
87 comp_pred1_ = (uint8_t *)aom_memalign(16, MAX_SB_SQUARE);
88 ASSERT_NE(comp_pred1_, nullptr);
89 comp_pred2_ = (uint8_t *)aom_memalign(16, MAX_SB_SQUARE);
90 ASSERT_NE(comp_pred2_, nullptr);
91 pred_ = (uint8_t *)aom_memalign(16, MAX_SB_SQUARE);
92 ASSERT_NE(pred_, nullptr);
93 ref_buffer_ = (uint8_t *)aom_memalign(16, MAX_SB_SQUARE + (8 * MAX_SB_SIZE));
94 ASSERT_NE(ref_buffer_, nullptr);
95 ref_ = ref_buffer_ + (8 * MAX_SB_SIZE);
96 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
97 pred_[i] = rnd_.Rand8();
99 for (int i = 0; i < MAX_SB_SQUARE + (8 * MAX_SB_SIZE); ++i) {
100 ref_buffer_[i] = rnd_.Rand8();
104 void AV1CompMaskVarianceTest::TearDown() {
105 aom_free(comp_pred1_);
106 aom_free(comp_pred2_);
107 aom_free(pred_);
108 aom_free(ref_buffer_);
111 void AV1CompMaskVarianceTest::RunCheckOutput(comp_mask_pred_func test_impl,
112 BLOCK_SIZE bsize, int inv) {
113 const int w = block_size_wide[bsize];
114 const int h = block_size_high[bsize];
115 const int wedge_types = get_wedge_types_lookup(bsize);
116 for (int wedge_index = 0; wedge_index < wedge_types; ++wedge_index) {
117 const uint8_t *mask = av1_get_contiguous_soft_mask(wedge_index, 1, bsize);
119 aom_comp_mask_pred_c(comp_pred1_, pred_, w, h, ref_, MAX_SB_SIZE, mask, w,
120 inv);
121 test_impl(comp_pred2_, pred_, w, h, ref_, MAX_SB_SIZE, mask, w, inv);
123 ASSERT_EQ(CheckResult(w, h), true)
124 << " wedge " << wedge_index << " inv " << inv;
128 void AV1CompMaskVarianceTest::RunSpeedTest(comp_mask_pred_func test_impl,
129 BLOCK_SIZE bsize) {
130 const int w = block_size_wide[bsize];
131 const int h = block_size_high[bsize];
132 const int wedge_types = get_wedge_types_lookup(bsize);
133 int wedge_index = wedge_types / 2;
134 const uint8_t *mask = av1_get_contiguous_soft_mask(wedge_index, 1, bsize);
135 const int num_loops = 1000000000 / (w + h);
137 comp_mask_pred_func funcs[2] = { aom_comp_mask_pred_c, test_impl };
138 double elapsed_time[2] = { 0 };
139 for (int i = 0; i < 2; ++i) {
140 aom_usec_timer timer;
141 aom_usec_timer_start(&timer);
142 comp_mask_pred_func func = funcs[i];
143 for (int j = 0; j < num_loops; ++j) {
144 func(comp_pred1_, pred_, w, h, ref_, MAX_SB_SIZE, mask, w, 0);
146 aom_usec_timer_mark(&timer);
147 double time = static_cast<double>(aom_usec_timer_elapsed(&timer));
148 elapsed_time[i] = 1000.0 * time / num_loops;
150 printf("compMask %3dx%-3d: %7.2f/%7.2fns", w, h, elapsed_time[0],
151 elapsed_time[1]);
152 printf("(%3.2f)\n", elapsed_time[0] / elapsed_time[1]);
155 TEST_P(AV1CompMaskVarianceTest, CheckOutput) {
156 // inv = 0, 1
157 RunCheckOutput(GET_PARAM(0), GET_PARAM(1), 0);
158 RunCheckOutput(GET_PARAM(0), GET_PARAM(1), 1);
161 TEST_P(AV1CompMaskVarianceTest, DISABLED_Speed) {
162 RunSpeedTest(GET_PARAM(0), GET_PARAM(1));
165 #if HAVE_SSSE3
166 INSTANTIATE_TEST_SUITE_P(
167 SSSE3, AV1CompMaskVarianceTest,
168 ::testing::Combine(::testing::Values(&aom_comp_mask_pred_ssse3),
169 ::testing::ValuesIn(kValidBlockSize)));
170 #endif
172 #if HAVE_AVX2
173 INSTANTIATE_TEST_SUITE_P(
174 AVX2, AV1CompMaskVarianceTest,
175 ::testing::Combine(::testing::Values(&aom_comp_mask_pred_avx2),
176 ::testing::ValuesIn(kValidBlockSize)));
177 #endif
179 #ifndef aom_comp_mask_pred
180 // can't run this test if aom_comp_mask_pred is defined to aom_comp_mask_pred_c
181 class AV1CompMaskUpVarianceTest : public AV1CompMaskVarianceTest {
182 public:
183 ~AV1CompMaskUpVarianceTest();
185 protected:
186 void RunCheckOutput(comp_mask_pred_func test_impl, BLOCK_SIZE bsize, int inv);
187 void RunSpeedTest(comp_mask_pred_func test_impl, BLOCK_SIZE bsize,
188 int havSub);
191 AV1CompMaskUpVarianceTest::~AV1CompMaskUpVarianceTest() { ; }
193 void AV1CompMaskUpVarianceTest::RunCheckOutput(comp_mask_pred_func test_impl,
194 BLOCK_SIZE bsize, int inv) {
195 const int w = block_size_wide[bsize];
196 const int h = block_size_high[bsize];
197 const int wedge_types = get_wedge_types_lookup(bsize);
198 int subpel_search;
199 for (subpel_search = USE_4_TAPS; subpel_search <= USE_8_TAPS;
200 ++subpel_search) {
201 // loop through subx and suby
202 for (int sub = 0; sub < 8 * 8; ++sub) {
203 int subx = sub & 0x7;
204 int suby = (sub >> 3);
205 for (int wedge_index = 0; wedge_index < wedge_types; ++wedge_index) {
206 const uint8_t *mask =
207 av1_get_contiguous_soft_mask(wedge_index, 1, bsize);
209 // ref
210 aom_comp_mask_upsampled_pred_c(
211 NULL, NULL, 0, 0, NULL, comp_pred1_, pred_, w, h, subx, suby, ref_,
212 MAX_SB_SIZE, mask, w, inv, subpel_search);
214 aom_comp_mask_pred = test_impl; // test
215 aom_comp_mask_upsampled_pred(NULL, NULL, 0, 0, NULL, comp_pred2_, pred_,
216 w, h, subx, suby, ref_, MAX_SB_SIZE, mask,
217 w, inv, subpel_search);
218 ASSERT_EQ(CheckResult(w, h), true)
219 << " wedge " << wedge_index << " inv " << inv << "sub (" << subx
220 << "," << suby << ")";
226 void AV1CompMaskUpVarianceTest::RunSpeedTest(comp_mask_pred_func test_impl,
227 BLOCK_SIZE bsize, int havSub) {
228 const int w = block_size_wide[bsize];
229 const int h = block_size_high[bsize];
230 const int subx = havSub ? 3 : 0;
231 const int suby = havSub ? 4 : 0;
232 const int wedge_types = get_wedge_types_lookup(bsize);
233 int wedge_index = wedge_types / 2;
234 const uint8_t *mask = av1_get_contiguous_soft_mask(wedge_index, 1, bsize);
236 const int num_loops = 1000000000 / (w + h);
237 comp_mask_pred_func funcs[2] = { &aom_comp_mask_pred_c, test_impl };
238 double elapsed_time[2] = { 0 };
239 int subpel_search = USE_8_TAPS; // set to USE_4_TAPS to test 4-tap filter.
240 for (int i = 0; i < 2; ++i) {
241 aom_usec_timer timer;
242 aom_usec_timer_start(&timer);
243 aom_comp_mask_pred = funcs[i];
244 for (int j = 0; j < num_loops; ++j) {
245 aom_comp_mask_upsampled_pred(NULL, NULL, 0, 0, NULL, comp_pred1_, pred_,
246 w, h, subx, suby, ref_, MAX_SB_SIZE, mask, w,
247 0, subpel_search);
249 aom_usec_timer_mark(&timer);
250 double time = static_cast<double>(aom_usec_timer_elapsed(&timer));
251 elapsed_time[i] = 1000.0 * time / num_loops;
253 printf("CompMaskUp[%d] %3dx%-3d:%7.2f/%7.2fns", havSub, w, h, elapsed_time[0],
254 elapsed_time[1]);
255 printf("(%3.2f)\n", elapsed_time[0] / elapsed_time[1]);
258 TEST_P(AV1CompMaskUpVarianceTest, CheckOutput) {
259 // inv mask = 0, 1
260 RunCheckOutput(GET_PARAM(0), GET_PARAM(1), 0);
261 RunCheckOutput(GET_PARAM(0), GET_PARAM(1), 1);
264 TEST_P(AV1CompMaskUpVarianceTest, DISABLED_Speed) {
265 RunSpeedTest(GET_PARAM(0), GET_PARAM(1), 1);
268 #if HAVE_SSSE3
269 INSTANTIATE_TEST_SUITE_P(
270 SSSE3, AV1CompMaskUpVarianceTest,
271 ::testing::Combine(::testing::Values(&aom_comp_mask_pred_ssse3),
272 ::testing::ValuesIn(kValidBlockSize)));
273 #endif
275 #if HAVE_AVX2
276 INSTANTIATE_TEST_SUITE_P(
277 AVX2, AV1CompMaskUpVarianceTest,
278 ::testing::Combine(::testing::Values(&aom_comp_mask_pred_avx2),
279 ::testing::ValuesIn(kValidBlockSize)));
280 #endif
282 #endif // ifndef aom_comp_mask_pred
284 #if CONFIG_AV1_HIGHBITDEPTH
285 typedef void (*highbd_comp_mask_pred_func)(uint8_t *comp_pred8,
286 const uint8_t *pred8, int width,
287 int height, const uint8_t *ref8,
288 int ref_stride, const uint8_t *mask,
289 int mask_stride, int invert_mask);
291 typedef std::tuple<highbd_comp_mask_pred_func, BLOCK_SIZE, int>
292 HighbdCompMaskPredParam;
294 class AV1HighbdCompMaskVarianceTest
295 : public ::testing::TestWithParam<HighbdCompMaskPredParam> {
296 public:
297 ~AV1HighbdCompMaskVarianceTest();
298 void SetUp();
300 void TearDown();
302 protected:
303 void RunCheckOutput(highbd_comp_mask_pred_func test_impl, BLOCK_SIZE bsize,
304 int inv);
305 void RunSpeedTest(highbd_comp_mask_pred_func test_impl, BLOCK_SIZE bsize);
306 bool CheckResult(int width, int height) {
307 for (int y = 0; y < height; ++y) {
308 for (int x = 0; x < width; ++x) {
309 const int idx = y * width + x;
310 if (comp_pred1_[idx] != comp_pred2_[idx]) {
311 printf("%dx%d mismatch @%d(%d,%d) ", width, height, idx, y, x);
312 printf("%d != %d ", comp_pred1_[idx], comp_pred2_[idx]);
313 return false;
317 return true;
320 libaom_test::ACMRandom rnd_;
321 uint16_t *comp_pred1_;
322 uint16_t *comp_pred2_;
323 uint16_t *pred_;
324 uint16_t *ref_buffer_;
325 uint16_t *ref_;
327 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AV1HighbdCompMaskVarianceTest);
329 AV1HighbdCompMaskVarianceTest::~AV1HighbdCompMaskVarianceTest() { ; }
331 void AV1HighbdCompMaskVarianceTest::SetUp() {
332 rnd_.Reset(libaom_test::ACMRandom::DeterministicSeed());
333 av1_init_wedge_masks();
335 comp_pred1_ =
336 (uint16_t *)aom_memalign(16, MAX_SB_SQUARE * sizeof(*comp_pred1_));
337 ASSERT_NE(comp_pred1_, nullptr);
338 comp_pred2_ =
339 (uint16_t *)aom_memalign(16, MAX_SB_SQUARE * sizeof(*comp_pred2_));
340 ASSERT_NE(comp_pred2_, nullptr);
341 pred_ = (uint16_t *)aom_memalign(16, MAX_SB_SQUARE * sizeof(*pred_));
342 ASSERT_NE(pred_, nullptr);
343 ref_buffer_ = (uint16_t *)aom_memalign(
344 16, (MAX_SB_SQUARE + (8 * MAX_SB_SIZE)) * sizeof(*ref_buffer_));
345 ASSERT_NE(ref_buffer_, nullptr);
346 ref_ = ref_buffer_ + (8 * MAX_SB_SIZE);
349 void AV1HighbdCompMaskVarianceTest::TearDown() {
350 aom_free(comp_pred1_);
351 aom_free(comp_pred2_);
352 aom_free(pred_);
353 aom_free(ref_buffer_);
356 void AV1HighbdCompMaskVarianceTest::RunCheckOutput(
357 highbd_comp_mask_pred_func test_impl, BLOCK_SIZE bsize, int inv) {
358 int bd_ = GET_PARAM(2);
359 const int w = block_size_wide[bsize];
360 const int h = block_size_high[bsize];
361 const int wedge_types = get_wedge_types_lookup(bsize);
363 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
364 pred_[i] = rnd_.Rand16() & ((1 << bd_) - 1);
366 for (int i = 0; i < MAX_SB_SQUARE + (8 * MAX_SB_SIZE); ++i) {
367 ref_buffer_[i] = rnd_.Rand16() & ((1 << bd_) - 1);
370 for (int wedge_index = 0; wedge_index < wedge_types; ++wedge_index) {
371 const uint8_t *mask = av1_get_contiguous_soft_mask(wedge_index, 1, bsize);
373 aom_highbd_comp_mask_pred_c(
374 CONVERT_TO_BYTEPTR(comp_pred1_), CONVERT_TO_BYTEPTR(pred_), w, h,
375 CONVERT_TO_BYTEPTR(ref_), MAX_SB_SIZE, mask, w, inv);
377 test_impl(CONVERT_TO_BYTEPTR(comp_pred2_), CONVERT_TO_BYTEPTR(pred_), w, h,
378 CONVERT_TO_BYTEPTR(ref_), MAX_SB_SIZE, mask, w, inv);
380 ASSERT_EQ(CheckResult(w, h), true)
381 << " wedge " << wedge_index << " inv " << inv;
385 void AV1HighbdCompMaskVarianceTest::RunSpeedTest(
386 highbd_comp_mask_pred_func test_impl, BLOCK_SIZE bsize) {
387 int bd_ = GET_PARAM(2);
389 const int w = block_size_wide[bsize];
390 const int h = block_size_high[bsize];
391 const int wedge_types = get_wedge_types_lookup(bsize);
392 int wedge_index = wedge_types / 2;
394 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
395 pred_[i] = rnd_.Rand16() & ((1 << bd_) - 1);
397 for (int i = 0; i < MAX_SB_SQUARE + (8 * MAX_SB_SIZE); ++i) {
398 ref_buffer_[i] = rnd_.Rand16() & ((1 << bd_) - 1);
401 const uint8_t *mask = av1_get_contiguous_soft_mask(wedge_index, 1, bsize);
402 const int num_loops = 1000000000 / (w + h);
404 highbd_comp_mask_pred_func funcs[2] = { aom_highbd_comp_mask_pred_c,
405 test_impl };
406 double elapsed_time[2] = { 0 };
407 for (int i = 0; i < 2; ++i) {
408 aom_usec_timer timer;
409 aom_usec_timer_start(&timer);
410 highbd_comp_mask_pred_func func = funcs[i];
411 for (int j = 0; j < num_loops; ++j) {
412 func(CONVERT_TO_BYTEPTR(comp_pred1_), CONVERT_TO_BYTEPTR(pred_), w, h,
413 CONVERT_TO_BYTEPTR(ref_), MAX_SB_SIZE, mask, w, 0);
415 aom_usec_timer_mark(&timer);
416 double time = static_cast<double>(aom_usec_timer_elapsed(&timer));
417 elapsed_time[i] = 1000.0 * time / num_loops;
419 printf("compMask %3dx%-3d: %7.2f/%7.2fns", w, h, elapsed_time[0],
420 elapsed_time[1]);
421 printf("(%3.2f)\n", elapsed_time[0] / elapsed_time[1]);
424 TEST_P(AV1HighbdCompMaskVarianceTest, CheckOutput) {
425 // inv = 0, 1
426 RunCheckOutput(GET_PARAM(0), GET_PARAM(1), 0);
427 RunCheckOutput(GET_PARAM(0), GET_PARAM(1), 1);
430 TEST_P(AV1HighbdCompMaskVarianceTest, DISABLED_Speed) {
431 RunSpeedTest(GET_PARAM(0), GET_PARAM(1));
434 #if HAVE_AVX2
435 INSTANTIATE_TEST_SUITE_P(
436 AVX2, AV1HighbdCompMaskVarianceTest,
437 ::testing::Combine(::testing::Values(&aom_highbd_comp_mask_pred_avx2),
438 ::testing::ValuesIn(kValidBlockSize),
439 ::testing::Range(8, 13, 2)));
440 #endif
442 #if HAVE_SSE2
443 INSTANTIATE_TEST_SUITE_P(
444 SSE2, AV1HighbdCompMaskVarianceTest,
445 ::testing::Combine(::testing::Values(&aom_highbd_comp_mask_pred_sse2),
446 ::testing::ValuesIn(kValidBlockSize),
447 ::testing::Range(8, 13, 2)));
448 #endif
450 #ifndef aom_highbd_comp_mask_pred
451 // can't run this test if aom_highbd_comp_mask_pred is defined to
452 // aom_highbd_comp_mask_pred_c
453 class AV1HighbdCompMaskUpVarianceTest : public AV1HighbdCompMaskVarianceTest {
454 public:
455 ~AV1HighbdCompMaskUpVarianceTest();
457 protected:
458 void RunCheckOutput(highbd_comp_mask_pred_func test_impl, BLOCK_SIZE bsize,
459 int inv);
460 void RunSpeedTest(highbd_comp_mask_pred_func test_impl, BLOCK_SIZE bsize,
461 int havSub);
464 AV1HighbdCompMaskUpVarianceTest::~AV1HighbdCompMaskUpVarianceTest() { ; }
466 void AV1HighbdCompMaskUpVarianceTest::RunCheckOutput(
467 highbd_comp_mask_pred_func test_impl, BLOCK_SIZE bsize, int inv) {
468 (void)test_impl;
469 int bd_ = GET_PARAM(2);
470 const int w = block_size_wide[bsize];
471 const int h = block_size_high[bsize];
472 const int wedge_types = get_wedge_types_lookup(bsize);
474 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
475 pred_[i] = rnd_.Rand16() & ((1 << bd_) - 1);
477 for (int i = 0; i < MAX_SB_SQUARE + (8 * MAX_SB_SIZE); ++i) {
478 ref_buffer_[i] = rnd_.Rand16() & ((1 << bd_) - 1);
481 int subpel_search;
482 for (subpel_search = 1; subpel_search <= 2; ++subpel_search) {
483 // loop through subx and suby
484 for (int sub = 0; sub < 8 * 8; ++sub) {
485 int subx = sub & 0x7;
486 int suby = (sub >> 3);
487 for (int wedge_index = 0; wedge_index < wedge_types; ++wedge_index) {
488 const uint8_t *mask =
489 av1_get_contiguous_soft_mask(wedge_index, 1, bsize);
491 // ref
492 aom_highbd_upsampled_pred_c(
493 NULL, NULL, 0, 0, NULL, CONVERT_TO_BYTEPTR(comp_pred1_), w, h, subx,
494 suby, CONVERT_TO_BYTEPTR(ref_), MAX_SB_SIZE, bd_, subpel_search);
496 aom_highbd_comp_mask_pred_c(
497 CONVERT_TO_BYTEPTR(comp_pred1_), CONVERT_TO_BYTEPTR(pred_), w, h,
498 CONVERT_TO_BYTEPTR(comp_pred1_), w, mask, w, inv);
500 // test
501 aom_highbd_upsampled_pred(
502 NULL, NULL, 0, 0, NULL, CONVERT_TO_BYTEPTR(comp_pred2_), w, h, subx,
503 suby, CONVERT_TO_BYTEPTR(ref_), MAX_SB_SIZE, bd_, subpel_search);
505 aom_highbd_comp_mask_pred(
506 CONVERT_TO_BYTEPTR(comp_pred2_), CONVERT_TO_BYTEPTR(pred_), w, h,
507 CONVERT_TO_BYTEPTR(comp_pred2_), w, mask, w, inv);
509 ASSERT_EQ(CheckResult(w, h), true)
510 << " wedge " << wedge_index << " inv " << inv << "sub (" << subx
511 << "," << suby << ")";
517 void AV1HighbdCompMaskUpVarianceTest::RunSpeedTest(
518 highbd_comp_mask_pred_func test_impl, BLOCK_SIZE bsize, int havSub) {
519 int bd_ = GET_PARAM(2);
520 const int w = block_size_wide[bsize];
521 const int h = block_size_high[bsize];
522 const int subx = havSub ? 3 : 0;
523 const int suby = havSub ? 4 : 0;
524 const int wedge_types = get_wedge_types_lookup(bsize);
525 int wedge_index = wedge_types / 2;
526 const uint8_t *mask = av1_get_contiguous_soft_mask(wedge_index, 1, bsize);
528 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
529 pred_[i] = rnd_.Rand16() & ((1 << bd_) - 1);
531 for (int i = 0; i < MAX_SB_SQUARE + (8 * MAX_SB_SIZE); ++i) {
532 ref_buffer_[i] = rnd_.Rand16() & ((1 << bd_) - 1);
535 const int num_loops = 1000000000 / (w + h);
536 highbd_comp_mask_pred_func funcs[2] = { &aom_highbd_comp_mask_pred_c,
537 test_impl };
538 double elapsed_time[2] = { 0 };
539 for (int i = 0; i < 2; ++i) {
540 aom_usec_timer timer;
541 aom_usec_timer_start(&timer);
542 aom_highbd_comp_mask_pred = funcs[i];
543 int subpel_search = 2; // set to 1 to test 4-tap filter.
544 for (int j = 0; j < num_loops; ++j) {
545 aom_highbd_comp_mask_upsampled_pred(
546 NULL, NULL, 0, 0, NULL, CONVERT_TO_BYTEPTR(comp_pred1_),
547 CONVERT_TO_BYTEPTR(pred_), w, h, subx, suby, CONVERT_TO_BYTEPTR(ref_),
548 MAX_SB_SIZE, mask, w, 0, bd_, subpel_search);
550 aom_usec_timer_mark(&timer);
551 double time = static_cast<double>(aom_usec_timer_elapsed(&timer));
552 elapsed_time[i] = 1000.0 * time / num_loops;
554 printf("CompMaskUp[%d] %3dx%-3d:%7.2f/%7.2fns", havSub, w, h, elapsed_time[0],
555 elapsed_time[1]);
556 printf("(%3.2f)\n", elapsed_time[0] / elapsed_time[1]);
559 TEST_P(AV1HighbdCompMaskUpVarianceTest, CheckOutput) {
560 // inv mask = 0, 1
561 RunCheckOutput(GET_PARAM(0), GET_PARAM(1), 0);
562 RunCheckOutput(GET_PARAM(0), GET_PARAM(1), 1);
565 TEST_P(AV1HighbdCompMaskUpVarianceTest, DISABLED_Speed) {
566 RunSpeedTest(GET_PARAM(0), GET_PARAM(1), 1);
569 #if HAVE_AVX2
570 INSTANTIATE_TEST_SUITE_P(
571 AVX2, AV1HighbdCompMaskUpVarianceTest,
572 ::testing::Combine(::testing::Values(&aom_highbd_comp_mask_pred_avx2),
573 ::testing::ValuesIn(kValidBlockSize),
574 ::testing::Range(8, 13, 2)));
575 #endif
577 #if HAVE_SSE2
578 INSTANTIATE_TEST_SUITE_P(
579 SSE2, AV1HighbdCompMaskUpVarianceTest,
580 ::testing::Combine(::testing::Values(&aom_highbd_comp_mask_pred_sse2),
581 ::testing::ValuesIn(kValidBlockSize),
582 ::testing::Range(8, 13, 2)));
583 #endif
585 #endif // ifndef aom_highbd_comp_mask_pred
586 #endif // CONFIG_AV1_HIGHBITDEPTH
587 } // namespace AV1CompMaskVariance