xref: /aosp_15_r20/external/libaom/test/obmc_sad_test.cc (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2016, 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 "gtest/gtest.h"
13*77c1e3ccSAndroid Build Coastguard Worker 
14*77c1e3ccSAndroid Build Coastguard Worker #include "test/function_equivalence_test.h"
15*77c1e3ccSAndroid Build Coastguard Worker #include "test/register_state_check.h"
16*77c1e3ccSAndroid Build Coastguard Worker 
17*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_config.h"
18*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_dsp_rtcd.h"
19*77c1e3ccSAndroid Build Coastguard Worker 
20*77c1e3ccSAndroid Build Coastguard Worker #include "aom/aom_integer.h"
21*77c1e3ccSAndroid Build Coastguard Worker 
22*77c1e3ccSAndroid Build Coastguard Worker #define MAX_SB_SQUARE (MAX_SB_SIZE * MAX_SB_SIZE)
23*77c1e3ccSAndroid Build Coastguard Worker 
24*77c1e3ccSAndroid Build Coastguard Worker using libaom_test::FunctionEquivalenceTest;
25*77c1e3ccSAndroid Build Coastguard Worker 
26*77c1e3ccSAndroid Build Coastguard Worker namespace {
27*77c1e3ccSAndroid Build Coastguard Worker 
28*77c1e3ccSAndroid Build Coastguard Worker static const int kIterations = 1000;
29*77c1e3ccSAndroid Build Coastguard Worker static const int kMaskMax = 64;
30*77c1e3ccSAndroid Build Coastguard Worker 
31*77c1e3ccSAndroid Build Coastguard Worker typedef unsigned int (*ObmcSadF)(const uint8_t *pre, int pre_stride,
32*77c1e3ccSAndroid Build Coastguard Worker                                  const int32_t *wsrc, const int32_t *mask);
33*77c1e3ccSAndroid Build Coastguard Worker typedef libaom_test::FuncParam<ObmcSadF> TestFuncs;
34*77c1e3ccSAndroid Build Coastguard Worker 
35*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////////////////////////////////////
36*77c1e3ccSAndroid Build Coastguard Worker // 8 bit
37*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////////////////////////////////////
38*77c1e3ccSAndroid Build Coastguard Worker 
39*77c1e3ccSAndroid Build Coastguard Worker class ObmcSadTest : public FunctionEquivalenceTest<ObmcSadF> {};
40*77c1e3ccSAndroid Build Coastguard Worker GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ObmcSadTest);
41*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(ObmcSadTest,RandomValues)42*77c1e3ccSAndroid Build Coastguard Worker TEST_P(ObmcSadTest, RandomValues) {
43*77c1e3ccSAndroid Build Coastguard Worker   DECLARE_ALIGNED(32, uint8_t, pre[MAX_SB_SQUARE]);
44*77c1e3ccSAndroid Build Coastguard Worker   DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
45*77c1e3ccSAndroid Build Coastguard Worker   DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
46*77c1e3ccSAndroid Build Coastguard Worker 
47*77c1e3ccSAndroid Build Coastguard Worker   for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
48*77c1e3ccSAndroid Build Coastguard Worker     const int pre_stride = rng_(MAX_SB_SIZE + 1);
49*77c1e3ccSAndroid Build Coastguard Worker 
50*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < MAX_SB_SQUARE; ++i) {
51*77c1e3ccSAndroid Build Coastguard Worker       pre[i] = rng_.Rand8();
52*77c1e3ccSAndroid Build Coastguard Worker       wsrc[i] = rng_.Rand8() * rng_(kMaskMax * kMaskMax + 1);
53*77c1e3ccSAndroid Build Coastguard Worker       mask[i] = rng_(kMaskMax * kMaskMax + 1);
54*77c1e3ccSAndroid Build Coastguard Worker     }
55*77c1e3ccSAndroid Build Coastguard Worker 
56*77c1e3ccSAndroid Build Coastguard Worker     const unsigned int ref_res = params_.ref_func(pre, pre_stride, wsrc, mask);
57*77c1e3ccSAndroid Build Coastguard Worker     unsigned int tst_res;
58*77c1e3ccSAndroid Build Coastguard Worker     API_REGISTER_STATE_CHECK(tst_res =
59*77c1e3ccSAndroid Build Coastguard Worker                                  params_.tst_func(pre, pre_stride, wsrc, mask));
60*77c1e3ccSAndroid Build Coastguard Worker 
61*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_EQ(ref_res, tst_res);
62*77c1e3ccSAndroid Build Coastguard Worker   }
63*77c1e3ccSAndroid Build Coastguard Worker }
64*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(ObmcSadTest,ExtremeValues)65*77c1e3ccSAndroid Build Coastguard Worker TEST_P(ObmcSadTest, ExtremeValues) {
66*77c1e3ccSAndroid Build Coastguard Worker   DECLARE_ALIGNED(32, uint8_t, pre[MAX_SB_SQUARE]);
67*77c1e3ccSAndroid Build Coastguard Worker   DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
68*77c1e3ccSAndroid Build Coastguard Worker   DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
69*77c1e3ccSAndroid Build Coastguard Worker 
70*77c1e3ccSAndroid Build Coastguard Worker   for (int iter = 0; iter < MAX_SB_SIZE && !HasFatalFailure(); ++iter) {
71*77c1e3ccSAndroid Build Coastguard Worker     const int pre_stride = iter;
72*77c1e3ccSAndroid Build Coastguard Worker 
73*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < MAX_SB_SQUARE; ++i) {
74*77c1e3ccSAndroid Build Coastguard Worker       pre[i] = UINT8_MAX;
75*77c1e3ccSAndroid Build Coastguard Worker       wsrc[i] = UINT8_MAX * kMaskMax * kMaskMax;
76*77c1e3ccSAndroid Build Coastguard Worker       mask[i] = kMaskMax * kMaskMax;
77*77c1e3ccSAndroid Build Coastguard Worker     }
78*77c1e3ccSAndroid Build Coastguard Worker 
79*77c1e3ccSAndroid Build Coastguard Worker     const unsigned int ref_res = params_.ref_func(pre, pre_stride, wsrc, mask);
80*77c1e3ccSAndroid Build Coastguard Worker     unsigned int tst_res;
81*77c1e3ccSAndroid Build Coastguard Worker     API_REGISTER_STATE_CHECK(tst_res =
82*77c1e3ccSAndroid Build Coastguard Worker                                  params_.tst_func(pre, pre_stride, wsrc, mask));
83*77c1e3ccSAndroid Build Coastguard Worker 
84*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_EQ(ref_res, tst_res);
85*77c1e3ccSAndroid Build Coastguard Worker   }
86*77c1e3ccSAndroid Build Coastguard Worker }
87*77c1e3ccSAndroid Build Coastguard Worker 
88*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE4_1
89*77c1e3ccSAndroid Build Coastguard Worker const ObmcSadTest::ParamType sse4_functions[] = {
90*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad128x128_c, aom_obmc_sad128x128_sse4_1),
91*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad128x64_c, aom_obmc_sad128x64_sse4_1),
92*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad64x128_c, aom_obmc_sad64x128_sse4_1),
93*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad64x64_c, aom_obmc_sad64x64_sse4_1),
94*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad64x32_c, aom_obmc_sad64x32_sse4_1),
95*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad32x64_c, aom_obmc_sad32x64_sse4_1),
96*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad32x32_c, aom_obmc_sad32x32_sse4_1),
97*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad32x16_c, aom_obmc_sad32x16_sse4_1),
98*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x32_c, aom_obmc_sad16x32_sse4_1),
99*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x16_c, aom_obmc_sad16x16_sse4_1),
100*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x8_c, aom_obmc_sad16x8_sse4_1),
101*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad8x16_c, aom_obmc_sad8x16_sse4_1),
102*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad8x8_c, aom_obmc_sad8x8_sse4_1),
103*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad8x4_c, aom_obmc_sad8x4_sse4_1),
104*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad4x8_c, aom_obmc_sad4x8_sse4_1),
105*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad4x4_c, aom_obmc_sad4x4_sse4_1),
106*77c1e3ccSAndroid Build Coastguard Worker 
107*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad64x16_c, aom_obmc_sad64x16_sse4_1),
108*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x64_c, aom_obmc_sad16x64_sse4_1),
109*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad32x8_c, aom_obmc_sad32x8_sse4_1),
110*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad8x32_c, aom_obmc_sad8x32_sse4_1),
111*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x4_c, aom_obmc_sad16x4_sse4_1),
112*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad4x16_c, aom_obmc_sad4x16_sse4_1),
113*77c1e3ccSAndroid Build Coastguard Worker };
114*77c1e3ccSAndroid Build Coastguard Worker 
115*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE4_1, ObmcSadTest,
116*77c1e3ccSAndroid Build Coastguard Worker                          ::testing::ValuesIn(sse4_functions));
117*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_SSE4_1
118*77c1e3ccSAndroid Build Coastguard Worker 
119*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
120*77c1e3ccSAndroid Build Coastguard Worker const ObmcSadTest::ParamType avx2_functions[] = {
121*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad128x128_c, aom_obmc_sad128x128_avx2),
122*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad128x64_c, aom_obmc_sad128x64_avx2),
123*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad64x128_c, aom_obmc_sad64x128_avx2),
124*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad64x64_c, aom_obmc_sad64x64_avx2),
125*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad64x32_c, aom_obmc_sad64x32_avx2),
126*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad32x64_c, aom_obmc_sad32x64_avx2),
127*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad32x32_c, aom_obmc_sad32x32_avx2),
128*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad32x16_c, aom_obmc_sad32x16_avx2),
129*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x32_c, aom_obmc_sad16x32_avx2),
130*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x16_c, aom_obmc_sad16x16_avx2),
131*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x8_c, aom_obmc_sad16x8_avx2),
132*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad8x16_c, aom_obmc_sad8x16_avx2),
133*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad8x8_c, aom_obmc_sad8x8_avx2),
134*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad8x4_c, aom_obmc_sad8x4_avx2),
135*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad4x8_c, aom_obmc_sad4x8_avx2),
136*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad4x4_c, aom_obmc_sad4x4_avx2),
137*77c1e3ccSAndroid Build Coastguard Worker 
138*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad64x16_c, aom_obmc_sad64x16_avx2),
139*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x64_c, aom_obmc_sad16x64_avx2),
140*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad32x8_c, aom_obmc_sad32x8_avx2),
141*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad8x32_c, aom_obmc_sad8x32_avx2),
142*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x4_c, aom_obmc_sad16x4_avx2),
143*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad4x16_c, aom_obmc_sad4x16_avx2),
144*77c1e3ccSAndroid Build Coastguard Worker };
145*77c1e3ccSAndroid Build Coastguard Worker 
146*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, ObmcSadTest,
147*77c1e3ccSAndroid Build Coastguard Worker                          ::testing::ValuesIn(avx2_functions));
148*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_AVX2
149*77c1e3ccSAndroid Build Coastguard Worker 
150*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
151*77c1e3ccSAndroid Build Coastguard Worker const ObmcSadTest::ParamType neon_functions[] = {
152*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad128x128_c, aom_obmc_sad128x128_neon),
153*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad128x64_c, aom_obmc_sad128x64_neon),
154*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad64x128_c, aom_obmc_sad64x128_neon),
155*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad64x64_c, aom_obmc_sad64x64_neon),
156*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad64x32_c, aom_obmc_sad64x32_neon),
157*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad32x64_c, aom_obmc_sad32x64_neon),
158*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad32x32_c, aom_obmc_sad32x32_neon),
159*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad32x16_c, aom_obmc_sad32x16_neon),
160*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x32_c, aom_obmc_sad16x32_neon),
161*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x16_c, aom_obmc_sad16x16_neon),
162*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x8_c, aom_obmc_sad16x8_neon),
163*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad8x16_c, aom_obmc_sad8x16_neon),
164*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad8x8_c, aom_obmc_sad8x8_neon),
165*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad8x4_c, aom_obmc_sad8x4_neon),
166*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad4x8_c, aom_obmc_sad4x8_neon),
167*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad4x4_c, aom_obmc_sad4x4_neon),
168*77c1e3ccSAndroid Build Coastguard Worker 
169*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad64x16_c, aom_obmc_sad64x16_neon),
170*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x64_c, aom_obmc_sad16x64_neon),
171*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad32x8_c, aom_obmc_sad32x8_neon),
172*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad8x32_c, aom_obmc_sad8x32_neon),
173*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad16x4_c, aom_obmc_sad16x4_neon),
174*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_obmc_sad4x16_c, aom_obmc_sad4x16_neon),
175*77c1e3ccSAndroid Build Coastguard Worker };
176*77c1e3ccSAndroid Build Coastguard Worker 
177*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, ObmcSadTest,
178*77c1e3ccSAndroid Build Coastguard Worker                          ::testing::ValuesIn(neon_functions));
179*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_NEON
180*77c1e3ccSAndroid Build Coastguard Worker 
181*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
182*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////////////////////////////////////
183*77c1e3ccSAndroid Build Coastguard Worker // High bit-depth
184*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////////////////////////////////////
185*77c1e3ccSAndroid Build Coastguard Worker 
186*77c1e3ccSAndroid Build Coastguard Worker class ObmcSadHBDTest : public FunctionEquivalenceTest<ObmcSadF> {};
187*77c1e3ccSAndroid Build Coastguard Worker GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ObmcSadHBDTest);
188*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(ObmcSadHBDTest,RandomValues)189*77c1e3ccSAndroid Build Coastguard Worker TEST_P(ObmcSadHBDTest, RandomValues) {
190*77c1e3ccSAndroid Build Coastguard Worker   DECLARE_ALIGNED(32, uint16_t, pre[MAX_SB_SQUARE]);
191*77c1e3ccSAndroid Build Coastguard Worker   DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
192*77c1e3ccSAndroid Build Coastguard Worker   DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
193*77c1e3ccSAndroid Build Coastguard Worker 
194*77c1e3ccSAndroid Build Coastguard Worker   for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
195*77c1e3ccSAndroid Build Coastguard Worker     const int pre_stride = rng_(MAX_SB_SIZE + 1);
196*77c1e3ccSAndroid Build Coastguard Worker 
197*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < MAX_SB_SQUARE; ++i) {
198*77c1e3ccSAndroid Build Coastguard Worker       pre[i] = rng_(1 << 12);
199*77c1e3ccSAndroid Build Coastguard Worker       wsrc[i] = rng_(1 << 12) * rng_(kMaskMax * kMaskMax + 1);
200*77c1e3ccSAndroid Build Coastguard Worker       mask[i] = rng_(kMaskMax * kMaskMax + 1);
201*77c1e3ccSAndroid Build Coastguard Worker     }
202*77c1e3ccSAndroid Build Coastguard Worker 
203*77c1e3ccSAndroid Build Coastguard Worker     const unsigned int ref_res =
204*77c1e3ccSAndroid Build Coastguard Worker         params_.ref_func(CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask);
205*77c1e3ccSAndroid Build Coastguard Worker     unsigned int tst_res;
206*77c1e3ccSAndroid Build Coastguard Worker     API_REGISTER_STATE_CHECK(
207*77c1e3ccSAndroid Build Coastguard Worker         tst_res =
208*77c1e3ccSAndroid Build Coastguard Worker             params_.tst_func(CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask));
209*77c1e3ccSAndroid Build Coastguard Worker 
210*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_EQ(ref_res, tst_res);
211*77c1e3ccSAndroid Build Coastguard Worker   }
212*77c1e3ccSAndroid Build Coastguard Worker }
213*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(ObmcSadHBDTest,ExtremeValues)214*77c1e3ccSAndroid Build Coastguard Worker TEST_P(ObmcSadHBDTest, ExtremeValues) {
215*77c1e3ccSAndroid Build Coastguard Worker   DECLARE_ALIGNED(32, uint16_t, pre[MAX_SB_SQUARE]);
216*77c1e3ccSAndroid Build Coastguard Worker   DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
217*77c1e3ccSAndroid Build Coastguard Worker   DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
218*77c1e3ccSAndroid Build Coastguard Worker 
219*77c1e3ccSAndroid Build Coastguard Worker   for (int iter = 0; iter < MAX_SB_SIZE && !HasFatalFailure(); ++iter) {
220*77c1e3ccSAndroid Build Coastguard Worker     const int pre_stride = iter;
221*77c1e3ccSAndroid Build Coastguard Worker 
222*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < MAX_SB_SQUARE; ++i) {
223*77c1e3ccSAndroid Build Coastguard Worker       pre[i] = (1 << 12) - 1;
224*77c1e3ccSAndroid Build Coastguard Worker       wsrc[i] = ((1 << 12) - 1) * kMaskMax * kMaskMax;
225*77c1e3ccSAndroid Build Coastguard Worker       mask[i] = kMaskMax * kMaskMax;
226*77c1e3ccSAndroid Build Coastguard Worker     }
227*77c1e3ccSAndroid Build Coastguard Worker 
228*77c1e3ccSAndroid Build Coastguard Worker     const unsigned int ref_res =
229*77c1e3ccSAndroid Build Coastguard Worker         params_.ref_func(CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask);
230*77c1e3ccSAndroid Build Coastguard Worker     unsigned int tst_res;
231*77c1e3ccSAndroid Build Coastguard Worker     API_REGISTER_STATE_CHECK(
232*77c1e3ccSAndroid Build Coastguard Worker         tst_res =
233*77c1e3ccSAndroid Build Coastguard Worker             params_.tst_func(CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask));
234*77c1e3ccSAndroid Build Coastguard Worker 
235*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_EQ(ref_res, tst_res);
236*77c1e3ccSAndroid Build Coastguard Worker   }
237*77c1e3ccSAndroid Build Coastguard Worker }
238*77c1e3ccSAndroid Build Coastguard Worker 
239*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
240*77c1e3ccSAndroid Build Coastguard Worker ObmcSadHBDTest::ParamType neon_functions_hbd[] = {
241*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad128x128_c, aom_highbd_obmc_sad128x128_neon),
242*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad128x64_c, aom_highbd_obmc_sad128x64_neon),
243*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad64x128_c, aom_highbd_obmc_sad64x128_neon),
244*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad64x64_c, aom_highbd_obmc_sad64x64_neon),
245*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad64x32_c, aom_highbd_obmc_sad64x32_neon),
246*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad32x64_c, aom_highbd_obmc_sad32x64_neon),
247*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad32x32_c, aom_highbd_obmc_sad32x32_neon),
248*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad32x16_c, aom_highbd_obmc_sad32x16_neon),
249*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x32_c, aom_highbd_obmc_sad16x32_neon),
250*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x16_c, aom_highbd_obmc_sad16x16_neon),
251*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x8_c, aom_highbd_obmc_sad16x8_neon),
252*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad8x16_c, aom_highbd_obmc_sad8x16_neon),
253*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad8x8_c, aom_highbd_obmc_sad8x8_neon),
254*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad8x4_c, aom_highbd_obmc_sad8x4_neon),
255*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad4x8_c, aom_highbd_obmc_sad4x8_neon),
256*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad4x4_c, aom_highbd_obmc_sad4x4_neon),
257*77c1e3ccSAndroid Build Coastguard Worker #if !CONFIG_REALTIME_ONLY
258*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad64x16_c, aom_highbd_obmc_sad64x16_neon),
259*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x64_c, aom_highbd_obmc_sad16x64_neon),
260*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad32x8_c, aom_highbd_obmc_sad32x8_neon),
261*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad8x32_c, aom_highbd_obmc_sad8x32_neon),
262*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x4_c, aom_highbd_obmc_sad16x4_neon),
263*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad4x16_c, aom_highbd_obmc_sad4x16_neon),
264*77c1e3ccSAndroid Build Coastguard Worker #endif  // !CONFIG_REALTIME_ONLY
265*77c1e3ccSAndroid Build Coastguard Worker };
266*77c1e3ccSAndroid Build Coastguard Worker 
267*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, ObmcSadHBDTest,
268*77c1e3ccSAndroid Build Coastguard Worker                          ::testing::ValuesIn(neon_functions_hbd));
269*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_NEON
270*77c1e3ccSAndroid Build Coastguard Worker 
271*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE4_1
272*77c1e3ccSAndroid Build Coastguard Worker ObmcSadHBDTest::ParamType sse4_functions_hbd[] = {
273*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad128x128_c, aom_highbd_obmc_sad128x128_sse4_1),
274*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad128x64_c, aom_highbd_obmc_sad128x64_sse4_1),
275*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad64x128_c, aom_highbd_obmc_sad64x128_sse4_1),
276*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad64x64_c, aom_highbd_obmc_sad64x64_sse4_1),
277*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad64x32_c, aom_highbd_obmc_sad64x32_sse4_1),
278*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad32x64_c, aom_highbd_obmc_sad32x64_sse4_1),
279*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad32x32_c, aom_highbd_obmc_sad32x32_sse4_1),
280*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad32x16_c, aom_highbd_obmc_sad32x16_sse4_1),
281*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x32_c, aom_highbd_obmc_sad16x32_sse4_1),
282*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x16_c, aom_highbd_obmc_sad16x16_sse4_1),
283*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x8_c, aom_highbd_obmc_sad16x8_sse4_1),
284*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad8x16_c, aom_highbd_obmc_sad8x16_sse4_1),
285*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad8x8_c, aom_highbd_obmc_sad8x8_sse4_1),
286*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad8x4_c, aom_highbd_obmc_sad8x4_sse4_1),
287*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad4x8_c, aom_highbd_obmc_sad4x8_sse4_1),
288*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad4x4_c, aom_highbd_obmc_sad4x4_sse4_1),
289*77c1e3ccSAndroid Build Coastguard Worker 
290*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad64x16_c, aom_highbd_obmc_sad64x16_sse4_1),
291*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x64_c, aom_highbd_obmc_sad16x64_sse4_1),
292*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad32x8_c, aom_highbd_obmc_sad32x8_sse4_1),
293*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad8x32_c, aom_highbd_obmc_sad8x32_sse4_1),
294*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x4_c, aom_highbd_obmc_sad16x4_sse4_1),
295*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad4x16_c, aom_highbd_obmc_sad4x16_sse4_1),
296*77c1e3ccSAndroid Build Coastguard Worker };
297*77c1e3ccSAndroid Build Coastguard Worker 
298*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE4_1, ObmcSadHBDTest,
299*77c1e3ccSAndroid Build Coastguard Worker                          ::testing::ValuesIn(sse4_functions_hbd));
300*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_SSE4_1
301*77c1e3ccSAndroid Build Coastguard Worker 
302*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
303*77c1e3ccSAndroid Build Coastguard Worker ObmcSadHBDTest::ParamType avx2_functions_hbd[] = {
304*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad128x128_c, aom_highbd_obmc_sad128x128_avx2),
305*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad128x64_c, aom_highbd_obmc_sad128x64_avx2),
306*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad64x128_c, aom_highbd_obmc_sad64x128_avx2),
307*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad64x64_c, aom_highbd_obmc_sad64x64_avx2),
308*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad64x32_c, aom_highbd_obmc_sad64x32_avx2),
309*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad32x64_c, aom_highbd_obmc_sad32x64_avx2),
310*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad32x32_c, aom_highbd_obmc_sad32x32_avx2),
311*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad32x16_c, aom_highbd_obmc_sad32x16_avx2),
312*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x32_c, aom_highbd_obmc_sad16x32_avx2),
313*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x16_c, aom_highbd_obmc_sad16x16_avx2),
314*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x8_c, aom_highbd_obmc_sad16x8_avx2),
315*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad8x16_c, aom_highbd_obmc_sad8x16_avx2),
316*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad8x8_c, aom_highbd_obmc_sad8x8_avx2),
317*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad8x4_c, aom_highbd_obmc_sad8x4_avx2),
318*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad4x8_c, aom_highbd_obmc_sad4x8_avx2),
319*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad4x4_c, aom_highbd_obmc_sad4x4_avx2),
320*77c1e3ccSAndroid Build Coastguard Worker 
321*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad64x16_c, aom_highbd_obmc_sad64x16_avx2),
322*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x64_c, aom_highbd_obmc_sad16x64_avx2),
323*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad32x8_c, aom_highbd_obmc_sad32x8_avx2),
324*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad8x32_c, aom_highbd_obmc_sad8x32_avx2),
325*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad16x4_c, aom_highbd_obmc_sad16x4_avx2),
326*77c1e3ccSAndroid Build Coastguard Worker   TestFuncs(aom_highbd_obmc_sad4x16_c, aom_highbd_obmc_sad4x16_avx2),
327*77c1e3ccSAndroid Build Coastguard Worker };
328*77c1e3ccSAndroid Build Coastguard Worker 
329*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, ObmcSadHBDTest,
330*77c1e3ccSAndroid Build Coastguard Worker                          ::testing::ValuesIn(avx2_functions_hbd));
331*77c1e3ccSAndroid Build Coastguard Worker #endif  // HAVE_AVX2
332*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
333*77c1e3ccSAndroid Build Coastguard Worker }  // namespace
334