xref: /aosp_15_r20/external/libaom/test/comp_avg_pred_test.cc (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2018, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker  *
4*77c1e3ccSAndroid Build Coastguard Worker  * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker  * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker  * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker  */
11*77c1e3ccSAndroid Build Coastguard Worker 
12*77c1e3ccSAndroid Build Coastguard Worker #include <tuple>
13*77c1e3ccSAndroid Build Coastguard Worker 
14*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_dsp_rtcd.h"
15*77c1e3ccSAndroid Build Coastguard Worker #include "config/av1_rtcd.h"
16*77c1e3ccSAndroid Build Coastguard Worker 
17*77c1e3ccSAndroid Build Coastguard Worker #include "gtest/gtest.h"
18*77c1e3ccSAndroid Build Coastguard Worker #include "test/acm_random.h"
19*77c1e3ccSAndroid Build Coastguard Worker #include "test/util.h"
20*77c1e3ccSAndroid Build Coastguard Worker #include "test/register_state_check.h"
21*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/common_data.h"
22*77c1e3ccSAndroid Build Coastguard Worker #include "aom_ports/aom_timer.h"
23*77c1e3ccSAndroid Build Coastguard Worker 
24*77c1e3ccSAndroid Build Coastguard Worker using libaom_test::ACMRandom;
25*77c1e3ccSAndroid Build Coastguard Worker using std::make_tuple;
26*77c1e3ccSAndroid Build Coastguard Worker using std::tuple;
27*77c1e3ccSAndroid Build Coastguard Worker 
28*77c1e3ccSAndroid Build Coastguard Worker namespace {
29*77c1e3ccSAndroid Build Coastguard Worker 
30*77c1e3ccSAndroid Build Coastguard Worker const int kMaxSize = 128 + 32;  // padding
31*77c1e3ccSAndroid Build Coastguard Worker 
32*77c1e3ccSAndroid Build Coastguard Worker typedef void (*distwtdcompavg_func)(uint8_t *comp_pred, const uint8_t *pred,
33*77c1e3ccSAndroid Build Coastguard Worker                                     int width, int height, const uint8_t *ref,
34*77c1e3ccSAndroid Build Coastguard Worker                                     int ref_stride,
35*77c1e3ccSAndroid Build Coastguard Worker                                     const DIST_WTD_COMP_PARAMS *jcp_param);
36*77c1e3ccSAndroid Build Coastguard Worker 
37*77c1e3ccSAndroid Build Coastguard Worker typedef void (*distwtdcompavgupsampled_func)(
38*77c1e3ccSAndroid Build Coastguard Worker     MACROBLOCKD *xd, const struct AV1Common *const cm, int mi_row, int mi_col,
39*77c1e3ccSAndroid Build Coastguard Worker     const MV *const mv, uint8_t *comp_pred, const uint8_t *pred, int width,
40*77c1e3ccSAndroid Build Coastguard Worker     int height, int subpel_x_q3, int subpel_y_q3, const uint8_t *ref,
41*77c1e3ccSAndroid Build Coastguard Worker     int ref_stride, const DIST_WTD_COMP_PARAMS *jcp_param, int subpel_search);
42*77c1e3ccSAndroid Build Coastguard Worker 
43*77c1e3ccSAndroid Build Coastguard Worker typedef void (*DistWtdCompAvgFunc)(uint8_t *comp_pred, const uint8_t *pred,
44*77c1e3ccSAndroid Build Coastguard Worker                                    int width, int height, const uint8_t *ref,
45*77c1e3ccSAndroid Build Coastguard Worker                                    int ref_stride,
46*77c1e3ccSAndroid Build Coastguard Worker                                    const DIST_WTD_COMP_PARAMS *jcp_param);
47*77c1e3ccSAndroid Build Coastguard Worker 
48*77c1e3ccSAndroid Build Coastguard Worker typedef std::tuple<distwtdcompavg_func, BLOCK_SIZE> AV1DistWtdCompAvgParam;
49*77c1e3ccSAndroid Build Coastguard Worker 
50*77c1e3ccSAndroid Build Coastguard Worker typedef std::tuple<int, int, DistWtdCompAvgFunc, int> DistWtdCompAvgParam;
51*77c1e3ccSAndroid Build Coastguard Worker 
52*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
53*77c1e3ccSAndroid Build Coastguard Worker typedef void (*highbddistwtdcompavgupsampled_func)(
54*77c1e3ccSAndroid Build Coastguard Worker     MACROBLOCKD *xd, const struct AV1Common *const cm, int mi_row, int mi_col,
55*77c1e3ccSAndroid Build Coastguard Worker     const MV *const mv, uint8_t *comp_pred8, const uint8_t *pred8, int width,
56*77c1e3ccSAndroid Build Coastguard Worker     int height, int subpel_x_q3, int subpel_y_q3, const uint8_t *ref8,
57*77c1e3ccSAndroid Build Coastguard Worker     int ref_stride, int bd, const DIST_WTD_COMP_PARAMS *jcp_param,
58*77c1e3ccSAndroid Build Coastguard Worker     int subpel_search);
59*77c1e3ccSAndroid Build Coastguard Worker 
60*77c1e3ccSAndroid Build Coastguard Worker typedef std::tuple<int, highbddistwtdcompavgupsampled_func, BLOCK_SIZE>
61*77c1e3ccSAndroid Build Coastguard Worker     HighbdDistWtdCompAvgUpsampledParam;
62*77c1e3ccSAndroid Build Coastguard Worker 
63*77c1e3ccSAndroid Build Coastguard Worker typedef std::tuple<int, distwtdcompavg_func, BLOCK_SIZE>
64*77c1e3ccSAndroid Build Coastguard Worker     HighbdDistWtdCompAvgParam;
65*77c1e3ccSAndroid Build Coastguard Worker 
66*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE2 || HAVE_NEON
BuildParams(distwtdcompavg_func filter,int is_hbd)67*77c1e3ccSAndroid Build Coastguard Worker ::testing::internal::ParamGenerator<HighbdDistWtdCompAvgParam> BuildParams(
68*77c1e3ccSAndroid Build Coastguard Worker     distwtdcompavg_func filter, int is_hbd) {
69*77c1e3ccSAndroid Build Coastguard Worker   (void)is_hbd;
70*77c1e3ccSAndroid Build Coastguard Worker   return ::testing::Combine(::testing::Range(8, 13, 2),
71*77c1e3ccSAndroid Build Coastguard Worker                             ::testing::Values(filter),
72*77c1e3ccSAndroid Build Coastguard Worker                             ::testing::Range(BLOCK_4X4, BLOCK_SIZES_ALL));
73*77c1e3ccSAndroid Build Coastguard Worker }
74*77c1e3ccSAndroid Build Coastguard Worker 
75*77c1e3ccSAndroid Build Coastguard Worker ::testing::internal::ParamGenerator<HighbdDistWtdCompAvgUpsampledParam>
BuildParams(highbddistwtdcompavgupsampled_func filter)76*77c1e3ccSAndroid Build Coastguard Worker BuildParams(highbddistwtdcompavgupsampled_func filter) {
77*77c1e3ccSAndroid Build Coastguard Worker   return ::testing::Combine(::testing::Range(8, 13, 2),
78*77c1e3ccSAndroid Build Coastguard Worker                             ::testing::Values(filter),
79*77c1e3ccSAndroid Build Coastguard Worker                             ::testing::Range(BLOCK_4X4, BLOCK_SIZES_ALL));
80*77c1e3ccSAndroid Build Coastguard Worker }
81*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_SSE2 || HAVE_NEON
82*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
83*77c1e3ccSAndroid Build Coastguard Worker 
84*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSSE3
BuildParams(distwtdcompavg_func filter)85*77c1e3ccSAndroid Build Coastguard Worker ::testing::internal::ParamGenerator<AV1DistWtdCompAvgParam> BuildParams(
86*77c1e3ccSAndroid Build Coastguard Worker     distwtdcompavg_func filter) {
87*77c1e3ccSAndroid Build Coastguard Worker   return ::testing::Combine(::testing::Values(filter),
88*77c1e3ccSAndroid Build Coastguard Worker                             ::testing::Range(BLOCK_4X4, BLOCK_SIZES_ALL));
89*77c1e3ccSAndroid Build Coastguard Worker }
90*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_SSSE3
91*77c1e3ccSAndroid Build Coastguard Worker 
92*77c1e3ccSAndroid Build Coastguard Worker class AV1DistWtdCompAvgTest
93*77c1e3ccSAndroid Build Coastguard Worker     : public ::testing::TestWithParam<AV1DistWtdCompAvgParam> {
94*77c1e3ccSAndroid Build Coastguard Worker  public:
95*77c1e3ccSAndroid Build Coastguard Worker   ~AV1DistWtdCompAvgTest() override = default;
SetUp()96*77c1e3ccSAndroid Build Coastguard Worker   void SetUp() override { rnd_.Reset(ACMRandom::DeterministicSeed()); }
97*77c1e3ccSAndroid Build Coastguard Worker 
98*77c1e3ccSAndroid Build Coastguard Worker  protected:
RunCheckOutput(distwtdcompavg_func test_impl)99*77c1e3ccSAndroid Build Coastguard Worker   void RunCheckOutput(distwtdcompavg_func test_impl) {
100*77c1e3ccSAndroid Build Coastguard Worker     const int w = kMaxSize, h = kMaxSize;
101*77c1e3ccSAndroid Build Coastguard Worker     const int block_idx = GET_PARAM(1);
102*77c1e3ccSAndroid Build Coastguard Worker 
103*77c1e3ccSAndroid Build Coastguard Worker     uint8_t pred8[kMaxSize * kMaxSize];
104*77c1e3ccSAndroid Build Coastguard Worker     uint8_t ref8[kMaxSize * kMaxSize];
105*77c1e3ccSAndroid Build Coastguard Worker     uint8_t output[kMaxSize * kMaxSize];
106*77c1e3ccSAndroid Build Coastguard Worker     uint8_t output2[kMaxSize * kMaxSize];
107*77c1e3ccSAndroid Build Coastguard Worker 
108*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < h; ++i)
109*77c1e3ccSAndroid Build Coastguard Worker       for (int j = 0; j < w; ++j) {
110*77c1e3ccSAndroid Build Coastguard Worker         pred8[i * w + j] = rnd_.Rand8();
111*77c1e3ccSAndroid Build Coastguard Worker         ref8[i * w + j] = rnd_.Rand8();
112*77c1e3ccSAndroid Build Coastguard Worker       }
113*77c1e3ccSAndroid Build Coastguard Worker     const int in_w = block_size_wide[block_idx];
114*77c1e3ccSAndroid Build Coastguard Worker     const int in_h = block_size_high[block_idx];
115*77c1e3ccSAndroid Build Coastguard Worker 
116*77c1e3ccSAndroid Build Coastguard Worker     DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
117*77c1e3ccSAndroid Build Coastguard Worker     dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
118*77c1e3ccSAndroid Build Coastguard Worker 
119*77c1e3ccSAndroid Build Coastguard Worker     for (int ii = 0; ii < 2; ii++) {
120*77c1e3ccSAndroid Build Coastguard Worker       for (int jj = 0; jj < 4; jj++) {
121*77c1e3ccSAndroid Build Coastguard Worker         dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[jj][ii];
122*77c1e3ccSAndroid Build Coastguard Worker         dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[jj][1 - ii];
123*77c1e3ccSAndroid Build Coastguard Worker 
124*77c1e3ccSAndroid Build Coastguard Worker         const int offset_r = 3 + rnd_.PseudoUniform(h - in_h - 7);
125*77c1e3ccSAndroid Build Coastguard Worker         const int offset_c = 3 + rnd_.PseudoUniform(w - in_w - 7);
126*77c1e3ccSAndroid Build Coastguard Worker         aom_dist_wtd_comp_avg_pred_c(output, pred8 + offset_r * w + offset_c,
127*77c1e3ccSAndroid Build Coastguard Worker                                      in_w, in_h, ref8 + offset_r * w + offset_c,
128*77c1e3ccSAndroid Build Coastguard Worker                                      in_w, &dist_wtd_comp_params);
129*77c1e3ccSAndroid Build Coastguard Worker         test_impl(output2, pred8 + offset_r * w + offset_c, in_w, in_h,
130*77c1e3ccSAndroid Build Coastguard Worker                   ref8 + offset_r * w + offset_c, in_w, &dist_wtd_comp_params);
131*77c1e3ccSAndroid Build Coastguard Worker 
132*77c1e3ccSAndroid Build Coastguard Worker         for (int i = 0; i < in_h; ++i) {
133*77c1e3ccSAndroid Build Coastguard Worker           for (int j = 0; j < in_w; ++j) {
134*77c1e3ccSAndroid Build Coastguard Worker             int idx = i * in_w + j;
135*77c1e3ccSAndroid Build Coastguard Worker             ASSERT_EQ(output[idx], output2[idx])
136*77c1e3ccSAndroid Build Coastguard Worker                 << "Mismatch at unit tests for AV1DistWtdCompAvgTest\n"
137*77c1e3ccSAndroid Build Coastguard Worker                 << in_w << "x" << in_h << " Pixel mismatch at index " << idx
138*77c1e3ccSAndroid Build Coastguard Worker                 << " = (" << i << ", " << j << ")";
139*77c1e3ccSAndroid Build Coastguard Worker           }
140*77c1e3ccSAndroid Build Coastguard Worker         }
141*77c1e3ccSAndroid Build Coastguard Worker       }
142*77c1e3ccSAndroid Build Coastguard Worker     }
143*77c1e3ccSAndroid Build Coastguard Worker   }
RunSpeedTest(distwtdcompavg_func test_impl)144*77c1e3ccSAndroid Build Coastguard Worker   void RunSpeedTest(distwtdcompavg_func test_impl) {
145*77c1e3ccSAndroid Build Coastguard Worker     const int w = kMaxSize, h = kMaxSize;
146*77c1e3ccSAndroid Build Coastguard Worker     const int block_idx = GET_PARAM(1);
147*77c1e3ccSAndroid Build Coastguard Worker 
148*77c1e3ccSAndroid Build Coastguard Worker     uint8_t pred8[kMaxSize * kMaxSize];
149*77c1e3ccSAndroid Build Coastguard Worker     uint8_t ref8[kMaxSize * kMaxSize];
150*77c1e3ccSAndroid Build Coastguard Worker     uint8_t output[kMaxSize * kMaxSize];
151*77c1e3ccSAndroid Build Coastguard Worker     uint8_t output2[kMaxSize * kMaxSize];
152*77c1e3ccSAndroid Build Coastguard Worker 
153*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < h; ++i)
154*77c1e3ccSAndroid Build Coastguard Worker       for (int j = 0; j < w; ++j) {
155*77c1e3ccSAndroid Build Coastguard Worker         pred8[i * w + j] = rnd_.Rand8();
156*77c1e3ccSAndroid Build Coastguard Worker         ref8[i * w + j] = rnd_.Rand8();
157*77c1e3ccSAndroid Build Coastguard Worker       }
158*77c1e3ccSAndroid Build Coastguard Worker     const int in_w = block_size_wide[block_idx];
159*77c1e3ccSAndroid Build Coastguard Worker     const int in_h = block_size_high[block_idx];
160*77c1e3ccSAndroid Build Coastguard Worker 
161*77c1e3ccSAndroid Build Coastguard Worker     DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
162*77c1e3ccSAndroid Build Coastguard Worker     dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
163*77c1e3ccSAndroid Build Coastguard Worker 
164*77c1e3ccSAndroid Build Coastguard Worker     dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[0][0];
165*77c1e3ccSAndroid Build Coastguard Worker     dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[0][1];
166*77c1e3ccSAndroid Build Coastguard Worker 
167*77c1e3ccSAndroid Build Coastguard Worker     const int num_loops = 1000000000 / (in_w + in_h);
168*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
169*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
170*77c1e3ccSAndroid Build Coastguard Worker 
171*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_loops; ++i)
172*77c1e3ccSAndroid Build Coastguard Worker       aom_dist_wtd_comp_avg_pred_c(output, pred8, in_w, in_h, ref8, in_w,
173*77c1e3ccSAndroid Build Coastguard Worker                                    &dist_wtd_comp_params);
174*77c1e3ccSAndroid Build Coastguard Worker 
175*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
176*77c1e3ccSAndroid Build Coastguard Worker     const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
177*77c1e3ccSAndroid Build Coastguard Worker     printf("distwtdcompavg c_code %3dx%-3d: %7.2f us\n", in_w, in_h,
178*77c1e3ccSAndroid Build Coastguard Worker            1000.0 * elapsed_time / num_loops);
179*77c1e3ccSAndroid Build Coastguard Worker 
180*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer1;
181*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer1);
182*77c1e3ccSAndroid Build Coastguard Worker 
183*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_loops; ++i)
184*77c1e3ccSAndroid Build Coastguard Worker       test_impl(output2, pred8, in_w, in_h, ref8, in_w, &dist_wtd_comp_params);
185*77c1e3ccSAndroid Build Coastguard Worker 
186*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer1);
187*77c1e3ccSAndroid Build Coastguard Worker     const int elapsed_time1 = static_cast<int>(aom_usec_timer_elapsed(&timer1));
188*77c1e3ccSAndroid Build Coastguard Worker     printf("distwtdcompavg test_code %3dx%-3d: %7.2f us\n", in_w, in_h,
189*77c1e3ccSAndroid Build Coastguard Worker            1000.0 * elapsed_time1 / num_loops);
190*77c1e3ccSAndroid Build Coastguard Worker   }
191*77c1e3ccSAndroid Build Coastguard Worker 
192*77c1e3ccSAndroid Build Coastguard Worker   libaom_test::ACMRandom rnd_;
193*77c1e3ccSAndroid Build Coastguard Worker };  // class AV1DistWtdCompAvgTest
194*77c1e3ccSAndroid Build Coastguard Worker 
195*77c1e3ccSAndroid Build Coastguard Worker GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AV1DistWtdCompAvgTest);
196*77c1e3ccSAndroid Build Coastguard Worker 
197*77c1e3ccSAndroid Build Coastguard Worker class DistWtdCompAvgTest
198*77c1e3ccSAndroid Build Coastguard Worker     : public ::testing::WithParamInterface<DistWtdCompAvgParam>,
199*77c1e3ccSAndroid Build Coastguard Worker       public ::testing::Test {
200*77c1e3ccSAndroid Build Coastguard Worker  public:
DistWtdCompAvgTest()201*77c1e3ccSAndroid Build Coastguard Worker   DistWtdCompAvgTest()
202*77c1e3ccSAndroid Build Coastguard Worker       : width_(GET_PARAM(0)), height_(GET_PARAM(1)), bd_(GET_PARAM(3)) {}
203*77c1e3ccSAndroid Build Coastguard Worker 
SetUpTestSuite()204*77c1e3ccSAndroid Build Coastguard Worker   static void SetUpTestSuite() {
205*77c1e3ccSAndroid Build Coastguard Worker     reference_data8_ = reinterpret_cast<uint8_t *>(
206*77c1e3ccSAndroid Build Coastguard Worker         aom_memalign(kDataAlignment, kDataBufferSize));
207*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_NE(reference_data8_, nullptr);
208*77c1e3ccSAndroid Build Coastguard Worker     second_pred8_ =
209*77c1e3ccSAndroid Build Coastguard Worker         reinterpret_cast<uint8_t *>(aom_memalign(kDataAlignment, 128 * 128));
210*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_NE(second_pred8_, nullptr);
211*77c1e3ccSAndroid Build Coastguard Worker     comp_pred8_ =
212*77c1e3ccSAndroid Build Coastguard Worker         reinterpret_cast<uint8_t *>(aom_memalign(kDataAlignment, 128 * 128));
213*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_NE(comp_pred8_, nullptr);
214*77c1e3ccSAndroid Build Coastguard Worker     comp_pred8_test_ =
215*77c1e3ccSAndroid Build Coastguard Worker         reinterpret_cast<uint8_t *>(aom_memalign(kDataAlignment, 128 * 128));
216*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_NE(comp_pred8_test_, nullptr);
217*77c1e3ccSAndroid Build Coastguard Worker     reference_data16_ = reinterpret_cast<uint16_t *>(
218*77c1e3ccSAndroid Build Coastguard Worker         aom_memalign(kDataAlignment, kDataBufferSize * sizeof(uint16_t)));
219*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_NE(reference_data16_, nullptr);
220*77c1e3ccSAndroid Build Coastguard Worker     second_pred16_ = reinterpret_cast<uint16_t *>(
221*77c1e3ccSAndroid Build Coastguard Worker         aom_memalign(kDataAlignment, 128 * 128 * sizeof(uint16_t)));
222*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_NE(second_pred16_, nullptr);
223*77c1e3ccSAndroid Build Coastguard Worker     comp_pred16_ = reinterpret_cast<uint16_t *>(
224*77c1e3ccSAndroid Build Coastguard Worker         aom_memalign(kDataAlignment, 128 * 128 * sizeof(uint16_t)));
225*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_NE(comp_pred16_, nullptr);
226*77c1e3ccSAndroid Build Coastguard Worker     comp_pred16_test_ = reinterpret_cast<uint16_t *>(
227*77c1e3ccSAndroid Build Coastguard Worker         aom_memalign(kDataAlignment, 128 * 128 * sizeof(uint16_t)));
228*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_NE(comp_pred16_test_, nullptr);
229*77c1e3ccSAndroid Build Coastguard Worker   }
230*77c1e3ccSAndroid Build Coastguard Worker 
TearDownTestSuite()231*77c1e3ccSAndroid Build Coastguard Worker   static void TearDownTestSuite() {
232*77c1e3ccSAndroid Build Coastguard Worker     aom_free(reference_data8_);
233*77c1e3ccSAndroid Build Coastguard Worker     reference_data8_ = nullptr;
234*77c1e3ccSAndroid Build Coastguard Worker     aom_free(second_pred8_);
235*77c1e3ccSAndroid Build Coastguard Worker     second_pred8_ = nullptr;
236*77c1e3ccSAndroid Build Coastguard Worker     aom_free(comp_pred8_);
237*77c1e3ccSAndroid Build Coastguard Worker     comp_pred8_ = nullptr;
238*77c1e3ccSAndroid Build Coastguard Worker     aom_free(comp_pred8_test_);
239*77c1e3ccSAndroid Build Coastguard Worker     comp_pred8_test_ = nullptr;
240*77c1e3ccSAndroid Build Coastguard Worker     aom_free(reference_data16_);
241*77c1e3ccSAndroid Build Coastguard Worker     reference_data16_ = nullptr;
242*77c1e3ccSAndroid Build Coastguard Worker     aom_free(second_pred16_);
243*77c1e3ccSAndroid Build Coastguard Worker     second_pred16_ = nullptr;
244*77c1e3ccSAndroid Build Coastguard Worker     aom_free(comp_pred16_);
245*77c1e3ccSAndroid Build Coastguard Worker     comp_pred16_ = nullptr;
246*77c1e3ccSAndroid Build Coastguard Worker     aom_free(comp_pred16_test_);
247*77c1e3ccSAndroid Build Coastguard Worker     comp_pred16_test_ = nullptr;
248*77c1e3ccSAndroid Build Coastguard Worker   }
249*77c1e3ccSAndroid Build Coastguard Worker 
250*77c1e3ccSAndroid Build Coastguard Worker  protected:
251*77c1e3ccSAndroid Build Coastguard Worker   // Handle up to 4 128x128 blocks, with stride up to 256
252*77c1e3ccSAndroid Build Coastguard Worker   static const int kDataAlignment = 16;
253*77c1e3ccSAndroid Build Coastguard Worker   static const int kDataBlockSize = 128 * 256;
254*77c1e3ccSAndroid Build Coastguard Worker   static const int kDataBufferSize = 4 * kDataBlockSize;
255*77c1e3ccSAndroid Build Coastguard Worker 
SetUp()256*77c1e3ccSAndroid Build Coastguard Worker   void SetUp() override {
257*77c1e3ccSAndroid Build Coastguard Worker     if (bd_ == -1) {
258*77c1e3ccSAndroid Build Coastguard Worker       use_high_bit_depth_ = false;
259*77c1e3ccSAndroid Build Coastguard Worker       bit_depth_ = AOM_BITS_8;
260*77c1e3ccSAndroid Build Coastguard Worker       reference_data_ = reference_data8_;
261*77c1e3ccSAndroid Build Coastguard Worker       second_pred_ = second_pred8_;
262*77c1e3ccSAndroid Build Coastguard Worker       comp_pred_ = comp_pred8_;
263*77c1e3ccSAndroid Build Coastguard Worker       comp_pred_test_ = comp_pred8_test_;
264*77c1e3ccSAndroid Build Coastguard Worker     } else {
265*77c1e3ccSAndroid Build Coastguard Worker       use_high_bit_depth_ = true;
266*77c1e3ccSAndroid Build Coastguard Worker       bit_depth_ = static_cast<aom_bit_depth_t>(bd_);
267*77c1e3ccSAndroid Build Coastguard Worker       reference_data_ = CONVERT_TO_BYTEPTR(reference_data16_);
268*77c1e3ccSAndroid Build Coastguard Worker       second_pred_ = CONVERT_TO_BYTEPTR(second_pred16_);
269*77c1e3ccSAndroid Build Coastguard Worker       comp_pred_ = CONVERT_TO_BYTEPTR(comp_pred16_);
270*77c1e3ccSAndroid Build Coastguard Worker       comp_pred_test_ = CONVERT_TO_BYTEPTR(comp_pred16_test_);
271*77c1e3ccSAndroid Build Coastguard Worker     }
272*77c1e3ccSAndroid Build Coastguard Worker     mask_ = (1 << bit_depth_) - 1;
273*77c1e3ccSAndroid Build Coastguard Worker     reference_stride_ = width_ * 2;
274*77c1e3ccSAndroid Build Coastguard Worker     rnd_.Reset(ACMRandom::DeterministicSeed());
275*77c1e3ccSAndroid Build Coastguard Worker   }
276*77c1e3ccSAndroid Build Coastguard Worker 
GetReference(int block_idx)277*77c1e3ccSAndroid Build Coastguard Worker   virtual uint8_t *GetReference(int block_idx) {
278*77c1e3ccSAndroid Build Coastguard Worker     if (use_high_bit_depth_)
279*77c1e3ccSAndroid Build Coastguard Worker       return CONVERT_TO_BYTEPTR(CONVERT_TO_SHORTPTR(reference_data_) +
280*77c1e3ccSAndroid Build Coastguard Worker                                 block_idx * kDataBlockSize);
281*77c1e3ccSAndroid Build Coastguard Worker     return reference_data_ + block_idx * kDataBlockSize;
282*77c1e3ccSAndroid Build Coastguard Worker   }
283*77c1e3ccSAndroid Build Coastguard Worker 
ReferenceDistWtdCompAvg(int block_idx)284*77c1e3ccSAndroid Build Coastguard Worker   void ReferenceDistWtdCompAvg(int block_idx) {
285*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *const reference8 = GetReference(block_idx);
286*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *const second_pred8 = second_pred_;
287*77c1e3ccSAndroid Build Coastguard Worker     uint8_t *const comp_pred8 = comp_pred_;
288*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *const reference16 =
289*77c1e3ccSAndroid Build Coastguard Worker         CONVERT_TO_SHORTPTR(GetReference(block_idx));
290*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *const second_pred16 = CONVERT_TO_SHORTPTR(second_pred_);
291*77c1e3ccSAndroid Build Coastguard Worker     uint16_t *const comp_pred16 = CONVERT_TO_SHORTPTR(comp_pred_);
292*77c1e3ccSAndroid Build Coastguard Worker     for (int h = 0; h < height_; ++h) {
293*77c1e3ccSAndroid Build Coastguard Worker       for (int w = 0; w < width_; ++w) {
294*77c1e3ccSAndroid Build Coastguard Worker         if (!use_high_bit_depth_) {
295*77c1e3ccSAndroid Build Coastguard Worker           const int tmp =
296*77c1e3ccSAndroid Build Coastguard Worker               second_pred8[h * width_ + w] * jcp_param_.bck_offset +
297*77c1e3ccSAndroid Build Coastguard Worker               reference8[h * reference_stride_ + w] * jcp_param_.fwd_offset;
298*77c1e3ccSAndroid Build Coastguard Worker           comp_pred8[h * width_ + w] = ROUND_POWER_OF_TWO(tmp, 4);
299*77c1e3ccSAndroid Build Coastguard Worker         } else {
300*77c1e3ccSAndroid Build Coastguard Worker           const int tmp =
301*77c1e3ccSAndroid Build Coastguard Worker               second_pred16[h * width_ + w] * jcp_param_.bck_offset +
302*77c1e3ccSAndroid Build Coastguard Worker               reference16[h * reference_stride_ + w] * jcp_param_.fwd_offset;
303*77c1e3ccSAndroid Build Coastguard Worker           comp_pred16[h * width_ + w] = ROUND_POWER_OF_TWO(tmp, 4);
304*77c1e3ccSAndroid Build Coastguard Worker         }
305*77c1e3ccSAndroid Build Coastguard Worker       }
306*77c1e3ccSAndroid Build Coastguard Worker     }
307*77c1e3ccSAndroid Build Coastguard Worker   }
308*77c1e3ccSAndroid Build Coastguard Worker 
FillConstant(uint8_t * data,int stride,uint16_t fill_constant)309*77c1e3ccSAndroid Build Coastguard Worker   void FillConstant(uint8_t *data, int stride, uint16_t fill_constant) {
310*77c1e3ccSAndroid Build Coastguard Worker     uint8_t *data8 = data;
311*77c1e3ccSAndroid Build Coastguard Worker     uint16_t *data16 = CONVERT_TO_SHORTPTR(data);
312*77c1e3ccSAndroid Build Coastguard Worker     for (int h = 0; h < height_; ++h) {
313*77c1e3ccSAndroid Build Coastguard Worker       for (int w = 0; w < width_; ++w) {
314*77c1e3ccSAndroid Build Coastguard Worker         if (!use_high_bit_depth_) {
315*77c1e3ccSAndroid Build Coastguard Worker           data8[h * stride + w] = static_cast<uint8_t>(fill_constant);
316*77c1e3ccSAndroid Build Coastguard Worker         } else {
317*77c1e3ccSAndroid Build Coastguard Worker           data16[h * stride + w] = fill_constant;
318*77c1e3ccSAndroid Build Coastguard Worker         }
319*77c1e3ccSAndroid Build Coastguard Worker       }
320*77c1e3ccSAndroid Build Coastguard Worker     }
321*77c1e3ccSAndroid Build Coastguard Worker   }
322*77c1e3ccSAndroid Build Coastguard Worker 
FillRandom(uint8_t * data,int stride)323*77c1e3ccSAndroid Build Coastguard Worker   void FillRandom(uint8_t *data, int stride) {
324*77c1e3ccSAndroid Build Coastguard Worker     uint8_t *data8 = data;
325*77c1e3ccSAndroid Build Coastguard Worker     uint16_t *data16 = CONVERT_TO_SHORTPTR(data);
326*77c1e3ccSAndroid Build Coastguard Worker     for (int h = 0; h < height_; ++h) {
327*77c1e3ccSAndroid Build Coastguard Worker       for (int w = 0; w < width_; ++w) {
328*77c1e3ccSAndroid Build Coastguard Worker         if (!use_high_bit_depth_) {
329*77c1e3ccSAndroid Build Coastguard Worker           data8[h * stride + w] = rnd_.Rand8();
330*77c1e3ccSAndroid Build Coastguard Worker         } else {
331*77c1e3ccSAndroid Build Coastguard Worker           data16[h * stride + w] = rnd_.Rand16() & mask_;
332*77c1e3ccSAndroid Build Coastguard Worker         }
333*77c1e3ccSAndroid Build Coastguard Worker       }
334*77c1e3ccSAndroid Build Coastguard Worker     }
335*77c1e3ccSAndroid Build Coastguard Worker   }
336*77c1e3ccSAndroid Build Coastguard Worker 
dist_wtd_comp_avg(int block_idx)337*77c1e3ccSAndroid Build Coastguard Worker   void dist_wtd_comp_avg(int block_idx) {
338*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *const reference = GetReference(block_idx);
339*77c1e3ccSAndroid Build Coastguard Worker 
340*77c1e3ccSAndroid Build Coastguard Worker     API_REGISTER_STATE_CHECK(GET_PARAM(2)(comp_pred_test_, second_pred_, width_,
341*77c1e3ccSAndroid Build Coastguard Worker                                           height_, reference, reference_stride_,
342*77c1e3ccSAndroid Build Coastguard Worker                                           &jcp_param_));
343*77c1e3ccSAndroid Build Coastguard Worker   }
344*77c1e3ccSAndroid Build Coastguard Worker 
CheckCompAvg()345*77c1e3ccSAndroid Build Coastguard Worker   void CheckCompAvg() {
346*77c1e3ccSAndroid Build Coastguard Worker     for (int j = 0; j < 2; ++j) {
347*77c1e3ccSAndroid Build Coastguard Worker       for (int i = 0; i < 4; ++i) {
348*77c1e3ccSAndroid Build Coastguard Worker         jcp_param_.fwd_offset = quant_dist_lookup_table[i][j];
349*77c1e3ccSAndroid Build Coastguard Worker         jcp_param_.bck_offset = quant_dist_lookup_table[i][1 - j];
350*77c1e3ccSAndroid Build Coastguard Worker 
351*77c1e3ccSAndroid Build Coastguard Worker         ReferenceDistWtdCompAvg(0);
352*77c1e3ccSAndroid Build Coastguard Worker         dist_wtd_comp_avg(0);
353*77c1e3ccSAndroid Build Coastguard Worker 
354*77c1e3ccSAndroid Build Coastguard Worker         for (int y = 0; y < height_; ++y)
355*77c1e3ccSAndroid Build Coastguard Worker           for (int x = 0; x < width_; ++x)
356*77c1e3ccSAndroid Build Coastguard Worker             ASSERT_EQ(comp_pred_[y * width_ + x],
357*77c1e3ccSAndroid Build Coastguard Worker                       comp_pred_test_[y * width_ + x]);
358*77c1e3ccSAndroid Build Coastguard Worker       }
359*77c1e3ccSAndroid Build Coastguard Worker     }
360*77c1e3ccSAndroid Build Coastguard Worker   }
361*77c1e3ccSAndroid Build Coastguard Worker 
362*77c1e3ccSAndroid Build Coastguard Worker   int width_, height_, mask_, bd_;
363*77c1e3ccSAndroid Build Coastguard Worker   aom_bit_depth_t bit_depth_;
364*77c1e3ccSAndroid Build Coastguard Worker   static uint8_t *reference_data_;
365*77c1e3ccSAndroid Build Coastguard Worker   static uint8_t *second_pred_;
366*77c1e3ccSAndroid Build Coastguard Worker   bool use_high_bit_depth_;
367*77c1e3ccSAndroid Build Coastguard Worker   static uint8_t *reference_data8_;
368*77c1e3ccSAndroid Build Coastguard Worker   static uint8_t *second_pred8_;
369*77c1e3ccSAndroid Build Coastguard Worker   static uint16_t *reference_data16_;
370*77c1e3ccSAndroid Build Coastguard Worker   static uint16_t *second_pred16_;
371*77c1e3ccSAndroid Build Coastguard Worker   int reference_stride_;
372*77c1e3ccSAndroid Build Coastguard Worker   static uint8_t *comp_pred_;
373*77c1e3ccSAndroid Build Coastguard Worker   static uint8_t *comp_pred8_;
374*77c1e3ccSAndroid Build Coastguard Worker   static uint16_t *comp_pred16_;
375*77c1e3ccSAndroid Build Coastguard Worker   static uint8_t *comp_pred_test_;
376*77c1e3ccSAndroid Build Coastguard Worker   static uint8_t *comp_pred8_test_;
377*77c1e3ccSAndroid Build Coastguard Worker   static uint16_t *comp_pred16_test_;
378*77c1e3ccSAndroid Build Coastguard Worker   DIST_WTD_COMP_PARAMS jcp_param_;
379*77c1e3ccSAndroid Build Coastguard Worker 
380*77c1e3ccSAndroid Build Coastguard Worker   ACMRandom rnd_;
381*77c1e3ccSAndroid Build Coastguard Worker };
382*77c1e3ccSAndroid Build Coastguard Worker 
383*77c1e3ccSAndroid Build Coastguard Worker uint8_t *DistWtdCompAvgTest::reference_data_ = nullptr;
384*77c1e3ccSAndroid Build Coastguard Worker uint8_t *DistWtdCompAvgTest::second_pred_ = nullptr;
385*77c1e3ccSAndroid Build Coastguard Worker uint8_t *DistWtdCompAvgTest::comp_pred_ = nullptr;
386*77c1e3ccSAndroid Build Coastguard Worker uint8_t *DistWtdCompAvgTest::comp_pred_test_ = nullptr;
387*77c1e3ccSAndroid Build Coastguard Worker uint8_t *DistWtdCompAvgTest::reference_data8_ = nullptr;
388*77c1e3ccSAndroid Build Coastguard Worker uint8_t *DistWtdCompAvgTest::second_pred8_ = nullptr;
389*77c1e3ccSAndroid Build Coastguard Worker uint8_t *DistWtdCompAvgTest::comp_pred8_ = nullptr;
390*77c1e3ccSAndroid Build Coastguard Worker uint8_t *DistWtdCompAvgTest::comp_pred8_test_ = nullptr;
391*77c1e3ccSAndroid Build Coastguard Worker uint16_t *DistWtdCompAvgTest::reference_data16_ = nullptr;
392*77c1e3ccSAndroid Build Coastguard Worker uint16_t *DistWtdCompAvgTest::second_pred16_ = nullptr;
393*77c1e3ccSAndroid Build Coastguard Worker uint16_t *DistWtdCompAvgTest::comp_pred16_ = nullptr;
394*77c1e3ccSAndroid Build Coastguard Worker uint16_t *DistWtdCompAvgTest::comp_pred16_test_ = nullptr;
395*77c1e3ccSAndroid Build Coastguard Worker 
396*77c1e3ccSAndroid Build Coastguard Worker GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DistWtdCompAvgTest);
397*77c1e3ccSAndroid Build Coastguard Worker 
398*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
399*77c1e3ccSAndroid Build Coastguard Worker class AV1HighBDDistWtdCompAvgTest
400*77c1e3ccSAndroid Build Coastguard Worker     : public ::testing::TestWithParam<HighbdDistWtdCompAvgParam> {
401*77c1e3ccSAndroid Build Coastguard Worker  public:
402*77c1e3ccSAndroid Build Coastguard Worker   ~AV1HighBDDistWtdCompAvgTest() override = default;
SetUp()403*77c1e3ccSAndroid Build Coastguard Worker   void SetUp() override { rnd_.Reset(ACMRandom::DeterministicSeed()); }
404*77c1e3ccSAndroid Build Coastguard Worker 
405*77c1e3ccSAndroid Build Coastguard Worker  protected:
RunCheckOutput(distwtdcompavg_func test_impl)406*77c1e3ccSAndroid Build Coastguard Worker   void RunCheckOutput(distwtdcompavg_func test_impl) {
407*77c1e3ccSAndroid Build Coastguard Worker     const int w = kMaxSize, h = kMaxSize;
408*77c1e3ccSAndroid Build Coastguard Worker     const int block_idx = GET_PARAM(2);
409*77c1e3ccSAndroid Build Coastguard Worker     const int bd = GET_PARAM(0);
410*77c1e3ccSAndroid Build Coastguard Worker     uint16_t pred8[kMaxSize * kMaxSize];
411*77c1e3ccSAndroid Build Coastguard Worker     uint16_t ref8[kMaxSize * kMaxSize];
412*77c1e3ccSAndroid Build Coastguard Worker     uint16_t output[kMaxSize * kMaxSize];
413*77c1e3ccSAndroid Build Coastguard Worker     uint16_t output2[kMaxSize * kMaxSize];
414*77c1e3ccSAndroid Build Coastguard Worker 
415*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < h; ++i)
416*77c1e3ccSAndroid Build Coastguard Worker       for (int j = 0; j < w; ++j) {
417*77c1e3ccSAndroid Build Coastguard Worker         pred8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
418*77c1e3ccSAndroid Build Coastguard Worker         ref8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
419*77c1e3ccSAndroid Build Coastguard Worker       }
420*77c1e3ccSAndroid Build Coastguard Worker     const int in_w = block_size_wide[block_idx];
421*77c1e3ccSAndroid Build Coastguard Worker     const int in_h = block_size_high[block_idx];
422*77c1e3ccSAndroid Build Coastguard Worker 
423*77c1e3ccSAndroid Build Coastguard Worker     DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
424*77c1e3ccSAndroid Build Coastguard Worker     dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
425*77c1e3ccSAndroid Build Coastguard Worker 
426*77c1e3ccSAndroid Build Coastguard Worker     for (int ii = 0; ii < 2; ii++) {
427*77c1e3ccSAndroid Build Coastguard Worker       for (int jj = 0; jj < 4; jj++) {
428*77c1e3ccSAndroid Build Coastguard Worker         dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[jj][ii];
429*77c1e3ccSAndroid Build Coastguard Worker         dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[jj][1 - ii];
430*77c1e3ccSAndroid Build Coastguard Worker 
431*77c1e3ccSAndroid Build Coastguard Worker         const int offset_r = 3 + rnd_.PseudoUniform(h - in_h - 7);
432*77c1e3ccSAndroid Build Coastguard Worker         const int offset_c = 3 + rnd_.PseudoUniform(w - in_w - 7);
433*77c1e3ccSAndroid Build Coastguard Worker         aom_highbd_dist_wtd_comp_avg_pred_c(
434*77c1e3ccSAndroid Build Coastguard Worker             CONVERT_TO_BYTEPTR(output),
435*77c1e3ccSAndroid Build Coastguard Worker             CONVERT_TO_BYTEPTR(pred8) + offset_r * w + offset_c, in_w, in_h,
436*77c1e3ccSAndroid Build Coastguard Worker             CONVERT_TO_BYTEPTR(ref8) + offset_r * w + offset_c, in_w,
437*77c1e3ccSAndroid Build Coastguard Worker             &dist_wtd_comp_params);
438*77c1e3ccSAndroid Build Coastguard Worker         test_impl(CONVERT_TO_BYTEPTR(output2),
439*77c1e3ccSAndroid Build Coastguard Worker                   CONVERT_TO_BYTEPTR(pred8) + offset_r * w + offset_c, in_w,
440*77c1e3ccSAndroid Build Coastguard Worker                   in_h, CONVERT_TO_BYTEPTR(ref8) + offset_r * w + offset_c,
441*77c1e3ccSAndroid Build Coastguard Worker                   in_w, &dist_wtd_comp_params);
442*77c1e3ccSAndroid Build Coastguard Worker 
443*77c1e3ccSAndroid Build Coastguard Worker         for (int i = 0; i < in_h; ++i) {
444*77c1e3ccSAndroid Build Coastguard Worker           for (int j = 0; j < in_w; ++j) {
445*77c1e3ccSAndroid Build Coastguard Worker             int idx = i * in_w + j;
446*77c1e3ccSAndroid Build Coastguard Worker             ASSERT_EQ(output[idx], output2[idx])
447*77c1e3ccSAndroid Build Coastguard Worker                 << "Mismatch at unit tests for AV1HighBDDistWtdCompAvgTest\n"
448*77c1e3ccSAndroid Build Coastguard Worker                 << in_w << "x" << in_h << " Pixel mismatch at index " << idx
449*77c1e3ccSAndroid Build Coastguard Worker                 << " = (" << i << ", " << j << ")";
450*77c1e3ccSAndroid Build Coastguard Worker           }
451*77c1e3ccSAndroid Build Coastguard Worker         }
452*77c1e3ccSAndroid Build Coastguard Worker       }
453*77c1e3ccSAndroid Build Coastguard Worker     }
454*77c1e3ccSAndroid Build Coastguard Worker   }
RunSpeedTest(distwtdcompavg_func test_impl)455*77c1e3ccSAndroid Build Coastguard Worker   void RunSpeedTest(distwtdcompavg_func test_impl) {
456*77c1e3ccSAndroid Build Coastguard Worker     const int w = kMaxSize, h = kMaxSize;
457*77c1e3ccSAndroid Build Coastguard Worker     const int block_idx = GET_PARAM(2);
458*77c1e3ccSAndroid Build Coastguard Worker     const int bd = GET_PARAM(0);
459*77c1e3ccSAndroid Build Coastguard Worker     uint16_t pred8[kMaxSize * kMaxSize];
460*77c1e3ccSAndroid Build Coastguard Worker     uint16_t ref8[kMaxSize * kMaxSize];
461*77c1e3ccSAndroid Build Coastguard Worker     uint16_t output[kMaxSize * kMaxSize];
462*77c1e3ccSAndroid Build Coastguard Worker     uint16_t output2[kMaxSize * kMaxSize];
463*77c1e3ccSAndroid Build Coastguard Worker 
464*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < h; ++i)
465*77c1e3ccSAndroid Build Coastguard Worker       for (int j = 0; j < w; ++j) {
466*77c1e3ccSAndroid Build Coastguard Worker         pred8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
467*77c1e3ccSAndroid Build Coastguard Worker         ref8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
468*77c1e3ccSAndroid Build Coastguard Worker       }
469*77c1e3ccSAndroid Build Coastguard Worker     const int in_w = block_size_wide[block_idx];
470*77c1e3ccSAndroid Build Coastguard Worker     const int in_h = block_size_high[block_idx];
471*77c1e3ccSAndroid Build Coastguard Worker 
472*77c1e3ccSAndroid Build Coastguard Worker     DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
473*77c1e3ccSAndroid Build Coastguard Worker     dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
474*77c1e3ccSAndroid Build Coastguard Worker 
475*77c1e3ccSAndroid Build Coastguard Worker     dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[0][0];
476*77c1e3ccSAndroid Build Coastguard Worker     dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[0][1];
477*77c1e3ccSAndroid Build Coastguard Worker 
478*77c1e3ccSAndroid Build Coastguard Worker     const int num_loops = 1000000000 / (in_w + in_h);
479*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
480*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
481*77c1e3ccSAndroid Build Coastguard Worker 
482*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_loops; ++i)
483*77c1e3ccSAndroid Build Coastguard Worker       aom_highbd_dist_wtd_comp_avg_pred_c(
484*77c1e3ccSAndroid Build Coastguard Worker           CONVERT_TO_BYTEPTR(output), CONVERT_TO_BYTEPTR(pred8), in_w, in_h,
485*77c1e3ccSAndroid Build Coastguard Worker           CONVERT_TO_BYTEPTR(ref8), in_w, &dist_wtd_comp_params);
486*77c1e3ccSAndroid Build Coastguard Worker 
487*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
488*77c1e3ccSAndroid Build Coastguard Worker     const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
489*77c1e3ccSAndroid Build Coastguard Worker     printf("highbddistwtdcompavg c_code %3dx%-3d: %7.2f us\n", in_w, in_h,
490*77c1e3ccSAndroid Build Coastguard Worker            1000.0 * elapsed_time / num_loops);
491*77c1e3ccSAndroid Build Coastguard Worker 
492*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer1;
493*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer1);
494*77c1e3ccSAndroid Build Coastguard Worker 
495*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_loops; ++i)
496*77c1e3ccSAndroid Build Coastguard Worker       test_impl(CONVERT_TO_BYTEPTR(output2), CONVERT_TO_BYTEPTR(pred8), in_w,
497*77c1e3ccSAndroid Build Coastguard Worker                 in_h, CONVERT_TO_BYTEPTR(ref8), in_w, &dist_wtd_comp_params);
498*77c1e3ccSAndroid Build Coastguard Worker 
499*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer1);
500*77c1e3ccSAndroid Build Coastguard Worker     const int elapsed_time1 = static_cast<int>(aom_usec_timer_elapsed(&timer1));
501*77c1e3ccSAndroid Build Coastguard Worker     printf("highbddistwtdcompavg test_code %3dx%-3d: %7.2f us\n", in_w, in_h,
502*77c1e3ccSAndroid Build Coastguard Worker            1000.0 * elapsed_time1 / num_loops);
503*77c1e3ccSAndroid Build Coastguard Worker   }
504*77c1e3ccSAndroid Build Coastguard Worker 
505*77c1e3ccSAndroid Build Coastguard Worker   libaom_test::ACMRandom rnd_;
506*77c1e3ccSAndroid Build Coastguard Worker };  // class AV1HighBDDistWtdCompAvgTest
507*77c1e3ccSAndroid Build Coastguard Worker 
508*77c1e3ccSAndroid Build Coastguard Worker GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(AV1HighBDDistWtdCompAvgTest);
509*77c1e3ccSAndroid Build Coastguard Worker 
510*77c1e3ccSAndroid Build Coastguard Worker class AV1HighBDDistWtdCompAvgUpsampledTest
511*77c1e3ccSAndroid Build Coastguard Worker     : public ::testing::TestWithParam<HighbdDistWtdCompAvgUpsampledParam> {
512*77c1e3ccSAndroid Build Coastguard Worker  public:
513*77c1e3ccSAndroid Build Coastguard Worker   ~AV1HighBDDistWtdCompAvgUpsampledTest() override = default;
SetUp()514*77c1e3ccSAndroid Build Coastguard Worker   void SetUp() override { rnd_.Reset(ACMRandom::DeterministicSeed()); }
515*77c1e3ccSAndroid Build Coastguard Worker 
516*77c1e3ccSAndroid Build Coastguard Worker  protected:
RunCheckOutput(highbddistwtdcompavgupsampled_func test_impl)517*77c1e3ccSAndroid Build Coastguard Worker   void RunCheckOutput(highbddistwtdcompavgupsampled_func test_impl) {
518*77c1e3ccSAndroid Build Coastguard Worker     const int w = kMaxSize, h = kMaxSize;
519*77c1e3ccSAndroid Build Coastguard Worker     const int block_idx = GET_PARAM(2);
520*77c1e3ccSAndroid Build Coastguard Worker     const int bd = GET_PARAM(0);
521*77c1e3ccSAndroid Build Coastguard Worker     uint16_t pred8[kMaxSize * kMaxSize];
522*77c1e3ccSAndroid Build Coastguard Worker     uint16_t ref8[kMaxSize * kMaxSize];
523*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, uint16_t, output[kMaxSize * kMaxSize]);
524*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, uint16_t, output2[kMaxSize * kMaxSize]);
525*77c1e3ccSAndroid Build Coastguard Worker 
526*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < h; ++i)
527*77c1e3ccSAndroid Build Coastguard Worker       for (int j = 0; j < w; ++j) {
528*77c1e3ccSAndroid Build Coastguard Worker         pred8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
529*77c1e3ccSAndroid Build Coastguard Worker         ref8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
530*77c1e3ccSAndroid Build Coastguard Worker       }
531*77c1e3ccSAndroid Build Coastguard Worker     const int in_w = block_size_wide[block_idx];
532*77c1e3ccSAndroid Build Coastguard Worker     const int in_h = block_size_high[block_idx];
533*77c1e3ccSAndroid Build Coastguard Worker 
534*77c1e3ccSAndroid Build Coastguard Worker     DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
535*77c1e3ccSAndroid Build Coastguard Worker     dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
536*77c1e3ccSAndroid Build Coastguard Worker     int sub_x_q3, sub_y_q3;
537*77c1e3ccSAndroid Build Coastguard Worker     int subpel_search;
538*77c1e3ccSAndroid Build Coastguard Worker     for (subpel_search = USE_4_TAPS; subpel_search <= USE_8_TAPS;
539*77c1e3ccSAndroid Build Coastguard Worker          ++subpel_search) {
540*77c1e3ccSAndroid Build Coastguard Worker       for (sub_x_q3 = 0; sub_x_q3 < 8; ++sub_x_q3) {
541*77c1e3ccSAndroid Build Coastguard Worker         for (sub_y_q3 = 0; sub_y_q3 < 8; ++sub_y_q3) {
542*77c1e3ccSAndroid Build Coastguard Worker           for (int ii = 0; ii < 2; ii++) {
543*77c1e3ccSAndroid Build Coastguard Worker             for (int jj = 0; jj < 4; jj++) {
544*77c1e3ccSAndroid Build Coastguard Worker               dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[jj][ii];
545*77c1e3ccSAndroid Build Coastguard Worker               dist_wtd_comp_params.bck_offset =
546*77c1e3ccSAndroid Build Coastguard Worker                   quant_dist_lookup_table[jj][1 - ii];
547*77c1e3ccSAndroid Build Coastguard Worker 
548*77c1e3ccSAndroid Build Coastguard Worker               const int offset_r = 3 + rnd_.PseudoUniform(h - in_h - 7);
549*77c1e3ccSAndroid Build Coastguard Worker               const int offset_c = 3 + rnd_.PseudoUniform(w - in_w - 7);
550*77c1e3ccSAndroid Build Coastguard Worker 
551*77c1e3ccSAndroid Build Coastguard Worker               aom_highbd_dist_wtd_comp_avg_upsampled_pred_c(
552*77c1e3ccSAndroid Build Coastguard Worker                   nullptr, nullptr, 0, 0, nullptr, CONVERT_TO_BYTEPTR(output),
553*77c1e3ccSAndroid Build Coastguard Worker                   CONVERT_TO_BYTEPTR(pred8) + offset_r * w + offset_c, in_w,
554*77c1e3ccSAndroid Build Coastguard Worker                   in_h, sub_x_q3, sub_y_q3,
555*77c1e3ccSAndroid Build Coastguard Worker                   CONVERT_TO_BYTEPTR(ref8) + offset_r * w + offset_c, in_w, bd,
556*77c1e3ccSAndroid Build Coastguard Worker                   &dist_wtd_comp_params, subpel_search);
557*77c1e3ccSAndroid Build Coastguard Worker               test_impl(nullptr, nullptr, 0, 0, nullptr,
558*77c1e3ccSAndroid Build Coastguard Worker                         CONVERT_TO_BYTEPTR(output2),
559*77c1e3ccSAndroid Build Coastguard Worker                         CONVERT_TO_BYTEPTR(pred8) + offset_r * w + offset_c,
560*77c1e3ccSAndroid Build Coastguard Worker                         in_w, in_h, sub_x_q3, sub_y_q3,
561*77c1e3ccSAndroid Build Coastguard Worker                         CONVERT_TO_BYTEPTR(ref8) + offset_r * w + offset_c,
562*77c1e3ccSAndroid Build Coastguard Worker                         in_w, bd, &dist_wtd_comp_params, subpel_search);
563*77c1e3ccSAndroid Build Coastguard Worker 
564*77c1e3ccSAndroid Build Coastguard Worker               for (int i = 0; i < in_h; ++i) {
565*77c1e3ccSAndroid Build Coastguard Worker                 for (int j = 0; j < in_w; ++j) {
566*77c1e3ccSAndroid Build Coastguard Worker                   int idx = i * in_w + j;
567*77c1e3ccSAndroid Build Coastguard Worker                   ASSERT_EQ(output[idx], output2[idx])
568*77c1e3ccSAndroid Build Coastguard Worker                       << "Mismatch at unit tests for "
569*77c1e3ccSAndroid Build Coastguard Worker                          "AV1HighBDDistWtdCompAvgUpsampledTest\n"
570*77c1e3ccSAndroid Build Coastguard Worker                       << in_w << "x" << in_h << " Pixel mismatch at index "
571*77c1e3ccSAndroid Build Coastguard Worker                       << idx << " = (" << i << ", " << j
572*77c1e3ccSAndroid Build Coastguard Worker                       << "), sub pixel offset = (" << sub_y_q3 << ", "
573*77c1e3ccSAndroid Build Coastguard Worker                       << sub_x_q3 << ")";
574*77c1e3ccSAndroid Build Coastguard Worker                 }
575*77c1e3ccSAndroid Build Coastguard Worker               }
576*77c1e3ccSAndroid Build Coastguard Worker             }
577*77c1e3ccSAndroid Build Coastguard Worker           }
578*77c1e3ccSAndroid Build Coastguard Worker         }
579*77c1e3ccSAndroid Build Coastguard Worker       }
580*77c1e3ccSAndroid Build Coastguard Worker     }
581*77c1e3ccSAndroid Build Coastguard Worker   }
RunSpeedTest(highbddistwtdcompavgupsampled_func test_impl)582*77c1e3ccSAndroid Build Coastguard Worker   void RunSpeedTest(highbddistwtdcompavgupsampled_func test_impl) {
583*77c1e3ccSAndroid Build Coastguard Worker     const int w = kMaxSize, h = kMaxSize;
584*77c1e3ccSAndroid Build Coastguard Worker     const int block_idx = GET_PARAM(2);
585*77c1e3ccSAndroid Build Coastguard Worker     const int bd = GET_PARAM(0);
586*77c1e3ccSAndroid Build Coastguard Worker     uint16_t pred8[kMaxSize * kMaxSize];
587*77c1e3ccSAndroid Build Coastguard Worker     uint16_t ref8[kMaxSize * kMaxSize];
588*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, uint16_t, output[kMaxSize * kMaxSize]);
589*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(16, uint16_t, output2[kMaxSize * kMaxSize]);
590*77c1e3ccSAndroid Build Coastguard Worker 
591*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < h; ++i)
592*77c1e3ccSAndroid Build Coastguard Worker       for (int j = 0; j < w; ++j) {
593*77c1e3ccSAndroid Build Coastguard Worker         pred8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
594*77c1e3ccSAndroid Build Coastguard Worker         ref8[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
595*77c1e3ccSAndroid Build Coastguard Worker       }
596*77c1e3ccSAndroid Build Coastguard Worker     const int in_w = block_size_wide[block_idx];
597*77c1e3ccSAndroid Build Coastguard Worker     const int in_h = block_size_high[block_idx];
598*77c1e3ccSAndroid Build Coastguard Worker 
599*77c1e3ccSAndroid Build Coastguard Worker     DIST_WTD_COMP_PARAMS dist_wtd_comp_params;
600*77c1e3ccSAndroid Build Coastguard Worker     dist_wtd_comp_params.use_dist_wtd_comp_avg = 1;
601*77c1e3ccSAndroid Build Coastguard Worker 
602*77c1e3ccSAndroid Build Coastguard Worker     dist_wtd_comp_params.fwd_offset = quant_dist_lookup_table[0][0];
603*77c1e3ccSAndroid Build Coastguard Worker     dist_wtd_comp_params.bck_offset = quant_dist_lookup_table[0][1];
604*77c1e3ccSAndroid Build Coastguard Worker     int sub_x_q3 = 0;
605*77c1e3ccSAndroid Build Coastguard Worker     int sub_y_q3 = 0;
606*77c1e3ccSAndroid Build Coastguard Worker     const int num_loops = 1000000000 / (in_w + in_h);
607*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
608*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
609*77c1e3ccSAndroid Build Coastguard Worker     int subpel_search = USE_8_TAPS;  // set to USE_4_TAPS to test 4-tap filter.
610*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_loops; ++i)
611*77c1e3ccSAndroid Build Coastguard Worker       aom_highbd_dist_wtd_comp_avg_upsampled_pred_c(
612*77c1e3ccSAndroid Build Coastguard Worker           nullptr, nullptr, 0, 0, nullptr, CONVERT_TO_BYTEPTR(output),
613*77c1e3ccSAndroid Build Coastguard Worker           CONVERT_TO_BYTEPTR(pred8), in_w, in_h, sub_x_q3, sub_y_q3,
614*77c1e3ccSAndroid Build Coastguard Worker           CONVERT_TO_BYTEPTR(ref8), in_w, bd, &dist_wtd_comp_params,
615*77c1e3ccSAndroid Build Coastguard Worker           subpel_search);
616*77c1e3ccSAndroid Build Coastguard Worker 
617*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
618*77c1e3ccSAndroid Build Coastguard Worker     const int elapsed_time = static_cast<int>(aom_usec_timer_elapsed(&timer));
619*77c1e3ccSAndroid Build Coastguard Worker     printf("highbddistwtdcompavgupsampled c_code %3dx%-3d: %7.2f us\n", in_w,
620*77c1e3ccSAndroid Build Coastguard Worker            in_h, 1000.0 * elapsed_time / num_loops);
621*77c1e3ccSAndroid Build Coastguard Worker 
622*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer1;
623*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer1);
624*77c1e3ccSAndroid Build Coastguard Worker 
625*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_loops; ++i)
626*77c1e3ccSAndroid Build Coastguard Worker       test_impl(nullptr, nullptr, 0, 0, nullptr, CONVERT_TO_BYTEPTR(output2),
627*77c1e3ccSAndroid Build Coastguard Worker                 CONVERT_TO_BYTEPTR(pred8), in_w, in_h, sub_x_q3, sub_y_q3,
628*77c1e3ccSAndroid Build Coastguard Worker                 CONVERT_TO_BYTEPTR(ref8), in_w, bd, &dist_wtd_comp_params,
629*77c1e3ccSAndroid Build Coastguard Worker                 subpel_search);
630*77c1e3ccSAndroid Build Coastguard Worker 
631*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer1);
632*77c1e3ccSAndroid Build Coastguard Worker     const int elapsed_time1 = static_cast<int>(aom_usec_timer_elapsed(&timer1));
633*77c1e3ccSAndroid Build Coastguard Worker     printf("highbddistwtdcompavgupsampled test_code %3dx%-3d: %7.2f us\n", in_w,
634*77c1e3ccSAndroid Build Coastguard Worker            in_h, 1000.0 * elapsed_time1 / num_loops);
635*77c1e3ccSAndroid Build Coastguard Worker   }
636*77c1e3ccSAndroid Build Coastguard Worker 
637*77c1e3ccSAndroid Build Coastguard Worker   libaom_test::ACMRandom rnd_;
638*77c1e3ccSAndroid Build Coastguard Worker };  // class AV1HighBDDistWtdCompAvgUpsampledTest
639*77c1e3ccSAndroid Build Coastguard Worker 
640*77c1e3ccSAndroid Build Coastguard Worker GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(
641*77c1e3ccSAndroid Build Coastguard Worker     AV1HighBDDistWtdCompAvgUpsampledTest);
642*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
643*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1DistWtdCompAvgTest,DISABLED_Speed)644*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1DistWtdCompAvgTest, DISABLED_Speed) { RunSpeedTest(GET_PARAM(0)); }
645*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1DistWtdCompAvgTest,CheckOutput)646*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1DistWtdCompAvgTest, CheckOutput) { RunCheckOutput(GET_PARAM(0)); }
647*77c1e3ccSAndroid Build Coastguard Worker 
648*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSSE3
649*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSSE3, AV1DistWtdCompAvgTest,
650*77c1e3ccSAndroid Build Coastguard Worker                          BuildParams(aom_dist_wtd_comp_avg_pred_ssse3));
651*77c1e3ccSAndroid Build Coastguard Worker #endif
652*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(DistWtdCompAvgTest,MaxRef)653*77c1e3ccSAndroid Build Coastguard Worker TEST_P(DistWtdCompAvgTest, MaxRef) {
654*77c1e3ccSAndroid Build Coastguard Worker   FillConstant(reference_data_, reference_stride_, mask_);
655*77c1e3ccSAndroid Build Coastguard Worker   FillConstant(second_pred_, width_, 0);
656*77c1e3ccSAndroid Build Coastguard Worker   CheckCompAvg();
657*77c1e3ccSAndroid Build Coastguard Worker }
658*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(DistWtdCompAvgTest,MaxSecondPred)659*77c1e3ccSAndroid Build Coastguard Worker TEST_P(DistWtdCompAvgTest, MaxSecondPred) {
660*77c1e3ccSAndroid Build Coastguard Worker   FillConstant(reference_data_, reference_stride_, 0);
661*77c1e3ccSAndroid Build Coastguard Worker   FillConstant(second_pred_, width_, mask_);
662*77c1e3ccSAndroid Build Coastguard Worker   CheckCompAvg();
663*77c1e3ccSAndroid Build Coastguard Worker }
664*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(DistWtdCompAvgTest,ShortRef)665*77c1e3ccSAndroid Build Coastguard Worker TEST_P(DistWtdCompAvgTest, ShortRef) {
666*77c1e3ccSAndroid Build Coastguard Worker   const int tmp_stride = reference_stride_;
667*77c1e3ccSAndroid Build Coastguard Worker   reference_stride_ >>= 1;
668*77c1e3ccSAndroid Build Coastguard Worker   FillRandom(reference_data_, reference_stride_);
669*77c1e3ccSAndroid Build Coastguard Worker   FillRandom(second_pred_, width_);
670*77c1e3ccSAndroid Build Coastguard Worker   CheckCompAvg();
671*77c1e3ccSAndroid Build Coastguard Worker   reference_stride_ = tmp_stride;
672*77c1e3ccSAndroid Build Coastguard Worker }
673*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(DistWtdCompAvgTest,UnalignedRef)674*77c1e3ccSAndroid Build Coastguard Worker TEST_P(DistWtdCompAvgTest, UnalignedRef) {
675*77c1e3ccSAndroid Build Coastguard Worker   // The reference frame, but not the source frame, may be unaligned for
676*77c1e3ccSAndroid Build Coastguard Worker   // certain types of searches.
677*77c1e3ccSAndroid Build Coastguard Worker   const int tmp_stride = reference_stride_;
678*77c1e3ccSAndroid Build Coastguard Worker   reference_stride_ -= 1;
679*77c1e3ccSAndroid Build Coastguard Worker   FillRandom(reference_data_, reference_stride_);
680*77c1e3ccSAndroid Build Coastguard Worker   FillRandom(second_pred_, width_);
681*77c1e3ccSAndroid Build Coastguard Worker   CheckCompAvg();
682*77c1e3ccSAndroid Build Coastguard Worker   reference_stride_ = tmp_stride;
683*77c1e3ccSAndroid Build Coastguard Worker }
684*77c1e3ccSAndroid Build Coastguard Worker 
685*77c1e3ccSAndroid Build Coastguard Worker // TODO(chengchen): add highbd tests
686*77c1e3ccSAndroid Build Coastguard Worker const DistWtdCompAvgParam dist_wtd_comp_avg_c_tests[] = {
687*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(128, 128, &aom_dist_wtd_comp_avg_pred_c, -1),
688*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(128, 64, &aom_dist_wtd_comp_avg_pred_c, -1),
689*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(64, 128, &aom_dist_wtd_comp_avg_pred_c, -1),
690*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(64, 64, &aom_dist_wtd_comp_avg_pred_c, -1),
691*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(64, 32, &aom_dist_wtd_comp_avg_pred_c, -1),
692*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(32, 64, &aom_dist_wtd_comp_avg_pred_c, -1),
693*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(32, 32, &aom_dist_wtd_comp_avg_pred_c, -1),
694*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(32, 16, &aom_dist_wtd_comp_avg_pred_c, -1),
695*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 32, &aom_dist_wtd_comp_avg_pred_c, -1),
696*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 16, &aom_dist_wtd_comp_avg_pred_c, -1),
697*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 8, &aom_dist_wtd_comp_avg_pred_c, -1),
698*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(8, 16, &aom_dist_wtd_comp_avg_pred_c, -1),
699*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(8, 8, &aom_dist_wtd_comp_avg_pred_c, -1),
700*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(8, 4, &aom_dist_wtd_comp_avg_pred_c, -1),
701*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(4, 8, &aom_dist_wtd_comp_avg_pred_c, -1),
702*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(4, 4, &aom_dist_wtd_comp_avg_pred_c, -1),
703*77c1e3ccSAndroid Build Coastguard Worker 
704*77c1e3ccSAndroid Build Coastguard Worker #if !CONFIG_REALTIME_ONLY
705*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(64, 16, &aom_dist_wtd_comp_avg_pred_c, -1),
706*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 64, &aom_dist_wtd_comp_avg_pred_c, -1),
707*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(32, 8, &aom_dist_wtd_comp_avg_pred_c, -1),
708*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(8, 32, &aom_dist_wtd_comp_avg_pred_c, -1),
709*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 4, &aom_dist_wtd_comp_avg_pred_c, -1),
710*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(4, 16, &aom_dist_wtd_comp_avg_pred_c, -1),
711*77c1e3ccSAndroid Build Coastguard Worker #endif
712*77c1e3ccSAndroid Build Coastguard Worker };
713*77c1e3ccSAndroid Build Coastguard Worker 
714*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, DistWtdCompAvgTest,
715*77c1e3ccSAndroid Build Coastguard Worker                          ::testing::ValuesIn(dist_wtd_comp_avg_c_tests));
716*77c1e3ccSAndroid Build Coastguard Worker 
717*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSSE3
718*77c1e3ccSAndroid Build Coastguard Worker const DistWtdCompAvgParam dist_wtd_comp_avg_ssse3_tests[] = {
719*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(128, 128, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
720*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(128, 64, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
721*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(64, 128, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
722*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(64, 64, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
723*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(64, 32, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
724*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(32, 64, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
725*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(32, 32, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
726*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(32, 16, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
727*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 32, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
728*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 16, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
729*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 8, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
730*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(8, 16, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
731*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(8, 8, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
732*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(8, 4, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
733*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(4, 8, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
734*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(4, 4, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
735*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 16, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
736*77c1e3ccSAndroid Build Coastguard Worker #if !CONFIG_REALTIME_ONLY
737*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(64, 16, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
738*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 64, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
739*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(32, 8, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
740*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(8, 32, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
741*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 4, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
742*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(4, 16, &aom_dist_wtd_comp_avg_pred_ssse3, -1),
743*77c1e3ccSAndroid Build Coastguard Worker #endif
744*77c1e3ccSAndroid Build Coastguard Worker };
745*77c1e3ccSAndroid Build Coastguard Worker 
746*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSSE3, DistWtdCompAvgTest,
747*77c1e3ccSAndroid Build Coastguard Worker                          ::testing::ValuesIn(dist_wtd_comp_avg_ssse3_tests));
748*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_SSSE3
749*77c1e3ccSAndroid Build Coastguard Worker 
750*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
751*77c1e3ccSAndroid Build Coastguard Worker const DistWtdCompAvgParam dist_wtd_comp_avg_neon_tests[] = {
752*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(128, 128, &aom_dist_wtd_comp_avg_pred_neon, -1),
753*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(128, 64, &aom_dist_wtd_comp_avg_pred_neon, -1),
754*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(64, 128, &aom_dist_wtd_comp_avg_pred_neon, -1),
755*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(64, 64, &aom_dist_wtd_comp_avg_pred_neon, -1),
756*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(64, 32, &aom_dist_wtd_comp_avg_pred_neon, -1),
757*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(32, 64, &aom_dist_wtd_comp_avg_pred_neon, -1),
758*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(32, 32, &aom_dist_wtd_comp_avg_pred_neon, -1),
759*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(32, 16, &aom_dist_wtd_comp_avg_pred_neon, -1),
760*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 32, &aom_dist_wtd_comp_avg_pred_neon, -1),
761*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 16, &aom_dist_wtd_comp_avg_pred_neon, -1),
762*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 8, &aom_dist_wtd_comp_avg_pred_neon, -1),
763*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(8, 16, &aom_dist_wtd_comp_avg_pred_neon, -1),
764*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(8, 8, &aom_dist_wtd_comp_avg_pred_neon, -1),
765*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(8, 4, &aom_dist_wtd_comp_avg_pred_neon, -1),
766*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(4, 8, &aom_dist_wtd_comp_avg_pred_neon, -1),
767*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(4, 4, &aom_dist_wtd_comp_avg_pred_neon, -1),
768*77c1e3ccSAndroid Build Coastguard Worker #if !CONFIG_REALTIME_ONLY
769*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(64, 16, &aom_dist_wtd_comp_avg_pred_neon, -1),
770*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 64, &aom_dist_wtd_comp_avg_pred_neon, -1),
771*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(32, 8, &aom_dist_wtd_comp_avg_pred_neon, -1),
772*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(8, 32, &aom_dist_wtd_comp_avg_pred_neon, -1),
773*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(16, 4, &aom_dist_wtd_comp_avg_pred_neon, -1),
774*77c1e3ccSAndroid Build Coastguard Worker   make_tuple(4, 16, &aom_dist_wtd_comp_avg_pred_neon, -1),
775*77c1e3ccSAndroid Build Coastguard Worker #endif  // !CONFIG_REALTIME_ONLY
776*77c1e3ccSAndroid Build Coastguard Worker };
777*77c1e3ccSAndroid Build Coastguard Worker 
778*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, DistWtdCompAvgTest,
779*77c1e3ccSAndroid Build Coastguard Worker                          ::testing::ValuesIn(dist_wtd_comp_avg_neon_tests));
780*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_NEON
781*77c1e3ccSAndroid Build Coastguard Worker 
782*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
TEST_P(AV1HighBDDistWtdCompAvgTest,DISABLED_Speed)783*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1HighBDDistWtdCompAvgTest, DISABLED_Speed) {
784*77c1e3ccSAndroid Build Coastguard Worker   RunSpeedTest(GET_PARAM(1));
785*77c1e3ccSAndroid Build Coastguard Worker }
786*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1HighBDDistWtdCompAvgTest,CheckOutput)787*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1HighBDDistWtdCompAvgTest, CheckOutput) {
788*77c1e3ccSAndroid Build Coastguard Worker   RunCheckOutput(GET_PARAM(1));
789*77c1e3ccSAndroid Build Coastguard Worker }
790*77c1e3ccSAndroid Build Coastguard Worker 
791*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE2
792*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE2, AV1HighBDDistWtdCompAvgTest,
793*77c1e3ccSAndroid Build Coastguard Worker                          BuildParams(aom_highbd_dist_wtd_comp_avg_pred_sse2,
794*77c1e3ccSAndroid Build Coastguard Worker                                      1));
795*77c1e3ccSAndroid Build Coastguard Worker #endif
796*77c1e3ccSAndroid Build Coastguard Worker 
797*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
798*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1HighBDDistWtdCompAvgTest,
799*77c1e3ccSAndroid Build Coastguard Worker                          BuildParams(aom_highbd_dist_wtd_comp_avg_pred_neon,
800*77c1e3ccSAndroid Build Coastguard Worker                                      1));
801*77c1e3ccSAndroid Build Coastguard Worker #endif
802*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1HighBDDistWtdCompAvgUpsampledTest,DISABLED_Speed)803*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1HighBDDistWtdCompAvgUpsampledTest, DISABLED_Speed) {
804*77c1e3ccSAndroid Build Coastguard Worker   RunSpeedTest(GET_PARAM(1));
805*77c1e3ccSAndroid Build Coastguard Worker }
806*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1HighBDDistWtdCompAvgUpsampledTest,CheckOutput)807*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1HighBDDistWtdCompAvgUpsampledTest, CheckOutput) {
808*77c1e3ccSAndroid Build Coastguard Worker   RunCheckOutput(GET_PARAM(1));
809*77c1e3ccSAndroid Build Coastguard Worker }
810*77c1e3ccSAndroid Build Coastguard Worker 
811*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE2
812*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
813*77c1e3ccSAndroid Build Coastguard Worker     SSE2, AV1HighBDDistWtdCompAvgUpsampledTest,
814*77c1e3ccSAndroid Build Coastguard Worker     BuildParams(aom_highbd_dist_wtd_comp_avg_upsampled_pred_sse2));
815*77c1e3ccSAndroid Build Coastguard Worker #endif
816*77c1e3ccSAndroid Build Coastguard Worker 
817*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
818*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
819*77c1e3ccSAndroid Build Coastguard Worker     NEON, AV1HighBDDistWtdCompAvgUpsampledTest,
820*77c1e3ccSAndroid Build Coastguard Worker     BuildParams(aom_highbd_dist_wtd_comp_avg_upsampled_pred_neon));
821*77c1e3ccSAndroid Build Coastguard Worker #endif
822*77c1e3ccSAndroid Build Coastguard Worker 
823*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
824*77c1e3ccSAndroid Build Coastguard Worker 
825*77c1e3ccSAndroid Build Coastguard Worker }  // namespace
826