2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
12 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
14 #include "test/function_equivalence_test.h"
15 #include "test/register_state_check.h"
17 #include "config/aom_config.h"
18 #include "config/aom_dsp_rtcd.h"
20 #include "aom/aom_integer.h"
22 #define MAX_SB_SQUARE (MAX_SB_SIZE * MAX_SB_SIZE)
24 using libaom_test::FunctionEquivalenceTest
;
28 static const int kIterations
= 1000;
29 static const int kMaskMax
= 64;
31 typedef unsigned int (*ObmcSadF
)(const uint8_t *pre
, int pre_stride
,
32 const int32_t *wsrc
, const int32_t *mask
);
33 typedef libaom_test::FuncParam
<ObmcSadF
> TestFuncs
;
35 ////////////////////////////////////////////////////////////////////////////////
37 ////////////////////////////////////////////////////////////////////////////////
39 class ObmcSadTest
: public FunctionEquivalenceTest
<ObmcSadF
> {};
40 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ObmcSadTest
);
42 TEST_P(ObmcSadTest
, RandomValues
) {
43 DECLARE_ALIGNED(32, uint8_t, pre
[MAX_SB_SQUARE
]);
44 DECLARE_ALIGNED(32, int32_t, wsrc
[MAX_SB_SQUARE
]);
45 DECLARE_ALIGNED(32, int32_t, mask
[MAX_SB_SQUARE
]);
47 for (int iter
= 0; iter
< kIterations
&& !HasFatalFailure(); ++iter
) {
48 const int pre_stride
= rng_(MAX_SB_SIZE
+ 1);
50 for (int i
= 0; i
< MAX_SB_SQUARE
; ++i
) {
51 pre
[i
] = rng_
.Rand8();
52 wsrc
[i
] = rng_
.Rand8() * rng_(kMaskMax
* kMaskMax
+ 1);
53 mask
[i
] = rng_(kMaskMax
* kMaskMax
+ 1);
56 const unsigned int ref_res
= params_
.ref_func(pre
, pre_stride
, wsrc
, mask
);
58 API_REGISTER_STATE_CHECK(tst_res
=
59 params_
.tst_func(pre
, pre_stride
, wsrc
, mask
));
61 ASSERT_EQ(ref_res
, tst_res
);
65 TEST_P(ObmcSadTest
, ExtremeValues
) {
66 DECLARE_ALIGNED(32, uint8_t, pre
[MAX_SB_SQUARE
]);
67 DECLARE_ALIGNED(32, int32_t, wsrc
[MAX_SB_SQUARE
]);
68 DECLARE_ALIGNED(32, int32_t, mask
[MAX_SB_SQUARE
]);
70 for (int iter
= 0; iter
< MAX_SB_SIZE
&& !HasFatalFailure(); ++iter
) {
71 const int pre_stride
= iter
;
73 for (int i
= 0; i
< MAX_SB_SQUARE
; ++i
) {
75 wsrc
[i
] = UINT8_MAX
* kMaskMax
* kMaskMax
;
76 mask
[i
] = kMaskMax
* kMaskMax
;
79 const unsigned int ref_res
= params_
.ref_func(pre
, pre_stride
, wsrc
, mask
);
81 API_REGISTER_STATE_CHECK(tst_res
=
82 params_
.tst_func(pre
, pre_stride
, wsrc
, mask
));
84 ASSERT_EQ(ref_res
, tst_res
);
89 const ObmcSadTest::ParamType sse4_functions
[] = {
90 TestFuncs(aom_obmc_sad128x128_c
, aom_obmc_sad128x128_sse4_1
),
91 TestFuncs(aom_obmc_sad128x64_c
, aom_obmc_sad128x64_sse4_1
),
92 TestFuncs(aom_obmc_sad64x128_c
, aom_obmc_sad64x128_sse4_1
),
93 TestFuncs(aom_obmc_sad64x64_c
, aom_obmc_sad64x64_sse4_1
),
94 TestFuncs(aom_obmc_sad64x32_c
, aom_obmc_sad64x32_sse4_1
),
95 TestFuncs(aom_obmc_sad32x64_c
, aom_obmc_sad32x64_sse4_1
),
96 TestFuncs(aom_obmc_sad32x32_c
, aom_obmc_sad32x32_sse4_1
),
97 TestFuncs(aom_obmc_sad32x16_c
, aom_obmc_sad32x16_sse4_1
),
98 TestFuncs(aom_obmc_sad16x32_c
, aom_obmc_sad16x32_sse4_1
),
99 TestFuncs(aom_obmc_sad16x16_c
, aom_obmc_sad16x16_sse4_1
),
100 TestFuncs(aom_obmc_sad16x8_c
, aom_obmc_sad16x8_sse4_1
),
101 TestFuncs(aom_obmc_sad8x16_c
, aom_obmc_sad8x16_sse4_1
),
102 TestFuncs(aom_obmc_sad8x8_c
, aom_obmc_sad8x8_sse4_1
),
103 TestFuncs(aom_obmc_sad8x4_c
, aom_obmc_sad8x4_sse4_1
),
104 TestFuncs(aom_obmc_sad4x8_c
, aom_obmc_sad4x8_sse4_1
),
105 TestFuncs(aom_obmc_sad4x4_c
, aom_obmc_sad4x4_sse4_1
),
107 TestFuncs(aom_obmc_sad64x16_c
, aom_obmc_sad64x16_sse4_1
),
108 TestFuncs(aom_obmc_sad16x64_c
, aom_obmc_sad16x64_sse4_1
),
109 TestFuncs(aom_obmc_sad32x8_c
, aom_obmc_sad32x8_sse4_1
),
110 TestFuncs(aom_obmc_sad8x32_c
, aom_obmc_sad8x32_sse4_1
),
111 TestFuncs(aom_obmc_sad16x4_c
, aom_obmc_sad16x4_sse4_1
),
112 TestFuncs(aom_obmc_sad4x16_c
, aom_obmc_sad4x16_sse4_1
),
115 INSTANTIATE_TEST_SUITE_P(SSE4_1
, ObmcSadTest
,
116 ::testing::ValuesIn(sse4_functions
));
117 #endif // HAVE_SSE4_1
120 const ObmcSadTest::ParamType avx2_functions
[] = {
121 TestFuncs(aom_obmc_sad128x128_c
, aom_obmc_sad128x128_avx2
),
122 TestFuncs(aom_obmc_sad128x64_c
, aom_obmc_sad128x64_avx2
),
123 TestFuncs(aom_obmc_sad64x128_c
, aom_obmc_sad64x128_avx2
),
124 TestFuncs(aom_obmc_sad64x64_c
, aom_obmc_sad64x64_avx2
),
125 TestFuncs(aom_obmc_sad64x32_c
, aom_obmc_sad64x32_avx2
),
126 TestFuncs(aom_obmc_sad32x64_c
, aom_obmc_sad32x64_avx2
),
127 TestFuncs(aom_obmc_sad32x32_c
, aom_obmc_sad32x32_avx2
),
128 TestFuncs(aom_obmc_sad32x16_c
, aom_obmc_sad32x16_avx2
),
129 TestFuncs(aom_obmc_sad16x32_c
, aom_obmc_sad16x32_avx2
),
130 TestFuncs(aom_obmc_sad16x16_c
, aom_obmc_sad16x16_avx2
),
131 TestFuncs(aom_obmc_sad16x8_c
, aom_obmc_sad16x8_avx2
),
132 TestFuncs(aom_obmc_sad8x16_c
, aom_obmc_sad8x16_avx2
),
133 TestFuncs(aom_obmc_sad8x8_c
, aom_obmc_sad8x8_avx2
),
134 TestFuncs(aom_obmc_sad8x4_c
, aom_obmc_sad8x4_avx2
),
135 TestFuncs(aom_obmc_sad4x8_c
, aom_obmc_sad4x8_avx2
),
136 TestFuncs(aom_obmc_sad4x4_c
, aom_obmc_sad4x4_avx2
),
138 TestFuncs(aom_obmc_sad64x16_c
, aom_obmc_sad64x16_avx2
),
139 TestFuncs(aom_obmc_sad16x64_c
, aom_obmc_sad16x64_avx2
),
140 TestFuncs(aom_obmc_sad32x8_c
, aom_obmc_sad32x8_avx2
),
141 TestFuncs(aom_obmc_sad8x32_c
, aom_obmc_sad8x32_avx2
),
142 TestFuncs(aom_obmc_sad16x4_c
, aom_obmc_sad16x4_avx2
),
143 TestFuncs(aom_obmc_sad4x16_c
, aom_obmc_sad4x16_avx2
),
146 INSTANTIATE_TEST_SUITE_P(AVX2
, ObmcSadTest
,
147 ::testing::ValuesIn(avx2_functions
));
151 const ObmcSadTest::ParamType neon_functions
[] = {
152 TestFuncs(aom_obmc_sad128x128_c
, aom_obmc_sad128x128_neon
),
153 TestFuncs(aom_obmc_sad128x64_c
, aom_obmc_sad128x64_neon
),
154 TestFuncs(aom_obmc_sad64x128_c
, aom_obmc_sad64x128_neon
),
155 TestFuncs(aom_obmc_sad64x64_c
, aom_obmc_sad64x64_neon
),
156 TestFuncs(aom_obmc_sad64x32_c
, aom_obmc_sad64x32_neon
),
157 TestFuncs(aom_obmc_sad32x64_c
, aom_obmc_sad32x64_neon
),
158 TestFuncs(aom_obmc_sad32x32_c
, aom_obmc_sad32x32_neon
),
159 TestFuncs(aom_obmc_sad32x16_c
, aom_obmc_sad32x16_neon
),
160 TestFuncs(aom_obmc_sad16x32_c
, aom_obmc_sad16x32_neon
),
161 TestFuncs(aom_obmc_sad16x16_c
, aom_obmc_sad16x16_neon
),
162 TestFuncs(aom_obmc_sad16x8_c
, aom_obmc_sad16x8_neon
),
163 TestFuncs(aom_obmc_sad8x16_c
, aom_obmc_sad8x16_neon
),
164 TestFuncs(aom_obmc_sad8x8_c
, aom_obmc_sad8x8_neon
),
165 TestFuncs(aom_obmc_sad8x4_c
, aom_obmc_sad8x4_neon
),
166 TestFuncs(aom_obmc_sad4x8_c
, aom_obmc_sad4x8_neon
),
167 TestFuncs(aom_obmc_sad4x4_c
, aom_obmc_sad4x4_neon
),
169 TestFuncs(aom_obmc_sad64x16_c
, aom_obmc_sad64x16_neon
),
170 TestFuncs(aom_obmc_sad16x64_c
, aom_obmc_sad16x64_neon
),
171 TestFuncs(aom_obmc_sad32x8_c
, aom_obmc_sad32x8_neon
),
172 TestFuncs(aom_obmc_sad8x32_c
, aom_obmc_sad8x32_neon
),
173 TestFuncs(aom_obmc_sad16x4_c
, aom_obmc_sad16x4_neon
),
174 TestFuncs(aom_obmc_sad4x16_c
, aom_obmc_sad4x16_neon
),
177 INSTANTIATE_TEST_SUITE_P(NEON
, ObmcSadTest
,
178 ::testing::ValuesIn(neon_functions
));
181 #if CONFIG_AV1_HIGHBITDEPTH
182 ////////////////////////////////////////////////////////////////////////////////
184 ////////////////////////////////////////////////////////////////////////////////
186 class ObmcSadHBDTest
: public FunctionEquivalenceTest
<ObmcSadF
> {};
187 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ObmcSadHBDTest
);
189 TEST_P(ObmcSadHBDTest
, RandomValues
) {
190 DECLARE_ALIGNED(32, uint16_t, pre
[MAX_SB_SQUARE
]);
191 DECLARE_ALIGNED(32, int32_t, wsrc
[MAX_SB_SQUARE
]);
192 DECLARE_ALIGNED(32, int32_t, mask
[MAX_SB_SQUARE
]);
194 for (int iter
= 0; iter
< kIterations
&& !HasFatalFailure(); ++iter
) {
195 const int pre_stride
= rng_(MAX_SB_SIZE
+ 1);
197 for (int i
= 0; i
< MAX_SB_SQUARE
; ++i
) {
198 pre
[i
] = rng_(1 << 12);
199 wsrc
[i
] = rng_(1 << 12) * rng_(kMaskMax
* kMaskMax
+ 1);
200 mask
[i
] = rng_(kMaskMax
* kMaskMax
+ 1);
203 const unsigned int ref_res
=
204 params_
.ref_func(CONVERT_TO_BYTEPTR(pre
), pre_stride
, wsrc
, mask
);
205 unsigned int tst_res
;
206 API_REGISTER_STATE_CHECK(
208 params_
.tst_func(CONVERT_TO_BYTEPTR(pre
), pre_stride
, wsrc
, mask
));
210 ASSERT_EQ(ref_res
, tst_res
);
214 TEST_P(ObmcSadHBDTest
, ExtremeValues
) {
215 DECLARE_ALIGNED(32, uint16_t, pre
[MAX_SB_SQUARE
]);
216 DECLARE_ALIGNED(32, int32_t, wsrc
[MAX_SB_SQUARE
]);
217 DECLARE_ALIGNED(32, int32_t, mask
[MAX_SB_SQUARE
]);
219 for (int iter
= 0; iter
< MAX_SB_SIZE
&& !HasFatalFailure(); ++iter
) {
220 const int pre_stride
= iter
;
222 for (int i
= 0; i
< MAX_SB_SQUARE
; ++i
) {
223 pre
[i
] = (1 << 12) - 1;
224 wsrc
[i
] = ((1 << 12) - 1) * kMaskMax
* kMaskMax
;
225 mask
[i
] = kMaskMax
* kMaskMax
;
228 const unsigned int ref_res
=
229 params_
.ref_func(CONVERT_TO_BYTEPTR(pre
), pre_stride
, wsrc
, mask
);
230 unsigned int tst_res
;
231 API_REGISTER_STATE_CHECK(
233 params_
.tst_func(CONVERT_TO_BYTEPTR(pre
), pre_stride
, wsrc
, mask
));
235 ASSERT_EQ(ref_res
, tst_res
);
240 ObmcSadHBDTest::ParamType neon_functions_hbd
[] = {
241 TestFuncs(aom_highbd_obmc_sad128x128_c
, aom_highbd_obmc_sad128x128_neon
),
242 TestFuncs(aom_highbd_obmc_sad128x64_c
, aom_highbd_obmc_sad128x64_neon
),
243 TestFuncs(aom_highbd_obmc_sad64x128_c
, aom_highbd_obmc_sad64x128_neon
),
244 TestFuncs(aom_highbd_obmc_sad64x64_c
, aom_highbd_obmc_sad64x64_neon
),
245 TestFuncs(aom_highbd_obmc_sad64x32_c
, aom_highbd_obmc_sad64x32_neon
),
246 TestFuncs(aom_highbd_obmc_sad32x64_c
, aom_highbd_obmc_sad32x64_neon
),
247 TestFuncs(aom_highbd_obmc_sad32x32_c
, aom_highbd_obmc_sad32x32_neon
),
248 TestFuncs(aom_highbd_obmc_sad32x16_c
, aom_highbd_obmc_sad32x16_neon
),
249 TestFuncs(aom_highbd_obmc_sad16x32_c
, aom_highbd_obmc_sad16x32_neon
),
250 TestFuncs(aom_highbd_obmc_sad16x16_c
, aom_highbd_obmc_sad16x16_neon
),
251 TestFuncs(aom_highbd_obmc_sad16x8_c
, aom_highbd_obmc_sad16x8_neon
),
252 TestFuncs(aom_highbd_obmc_sad8x16_c
, aom_highbd_obmc_sad8x16_neon
),
253 TestFuncs(aom_highbd_obmc_sad8x8_c
, aom_highbd_obmc_sad8x8_neon
),
254 TestFuncs(aom_highbd_obmc_sad8x4_c
, aom_highbd_obmc_sad8x4_neon
),
255 TestFuncs(aom_highbd_obmc_sad4x8_c
, aom_highbd_obmc_sad4x8_neon
),
256 TestFuncs(aom_highbd_obmc_sad4x4_c
, aom_highbd_obmc_sad4x4_neon
),
257 #if !CONFIG_REALTIME_ONLY
258 TestFuncs(aom_highbd_obmc_sad64x16_c
, aom_highbd_obmc_sad64x16_neon
),
259 TestFuncs(aom_highbd_obmc_sad16x64_c
, aom_highbd_obmc_sad16x64_neon
),
260 TestFuncs(aom_highbd_obmc_sad32x8_c
, aom_highbd_obmc_sad32x8_neon
),
261 TestFuncs(aom_highbd_obmc_sad8x32_c
, aom_highbd_obmc_sad8x32_neon
),
262 TestFuncs(aom_highbd_obmc_sad16x4_c
, aom_highbd_obmc_sad16x4_neon
),
263 TestFuncs(aom_highbd_obmc_sad4x16_c
, aom_highbd_obmc_sad4x16_neon
),
264 #endif // !CONFIG_REALTIME_ONLY
267 INSTANTIATE_TEST_SUITE_P(NEON
, ObmcSadHBDTest
,
268 ::testing::ValuesIn(neon_functions_hbd
));
272 ObmcSadHBDTest::ParamType sse4_functions_hbd
[] = {
273 TestFuncs(aom_highbd_obmc_sad128x128_c
, aom_highbd_obmc_sad128x128_sse4_1
),
274 TestFuncs(aom_highbd_obmc_sad128x64_c
, aom_highbd_obmc_sad128x64_sse4_1
),
275 TestFuncs(aom_highbd_obmc_sad64x128_c
, aom_highbd_obmc_sad64x128_sse4_1
),
276 TestFuncs(aom_highbd_obmc_sad64x64_c
, aom_highbd_obmc_sad64x64_sse4_1
),
277 TestFuncs(aom_highbd_obmc_sad64x32_c
, aom_highbd_obmc_sad64x32_sse4_1
),
278 TestFuncs(aom_highbd_obmc_sad32x64_c
, aom_highbd_obmc_sad32x64_sse4_1
),
279 TestFuncs(aom_highbd_obmc_sad32x32_c
, aom_highbd_obmc_sad32x32_sse4_1
),
280 TestFuncs(aom_highbd_obmc_sad32x16_c
, aom_highbd_obmc_sad32x16_sse4_1
),
281 TestFuncs(aom_highbd_obmc_sad16x32_c
, aom_highbd_obmc_sad16x32_sse4_1
),
282 TestFuncs(aom_highbd_obmc_sad16x16_c
, aom_highbd_obmc_sad16x16_sse4_1
),
283 TestFuncs(aom_highbd_obmc_sad16x8_c
, aom_highbd_obmc_sad16x8_sse4_1
),
284 TestFuncs(aom_highbd_obmc_sad8x16_c
, aom_highbd_obmc_sad8x16_sse4_1
),
285 TestFuncs(aom_highbd_obmc_sad8x8_c
, aom_highbd_obmc_sad8x8_sse4_1
),
286 TestFuncs(aom_highbd_obmc_sad8x4_c
, aom_highbd_obmc_sad8x4_sse4_1
),
287 TestFuncs(aom_highbd_obmc_sad4x8_c
, aom_highbd_obmc_sad4x8_sse4_1
),
288 TestFuncs(aom_highbd_obmc_sad4x4_c
, aom_highbd_obmc_sad4x4_sse4_1
),
290 TestFuncs(aom_highbd_obmc_sad64x16_c
, aom_highbd_obmc_sad64x16_sse4_1
),
291 TestFuncs(aom_highbd_obmc_sad16x64_c
, aom_highbd_obmc_sad16x64_sse4_1
),
292 TestFuncs(aom_highbd_obmc_sad32x8_c
, aom_highbd_obmc_sad32x8_sse4_1
),
293 TestFuncs(aom_highbd_obmc_sad8x32_c
, aom_highbd_obmc_sad8x32_sse4_1
),
294 TestFuncs(aom_highbd_obmc_sad16x4_c
, aom_highbd_obmc_sad16x4_sse4_1
),
295 TestFuncs(aom_highbd_obmc_sad4x16_c
, aom_highbd_obmc_sad4x16_sse4_1
),
298 INSTANTIATE_TEST_SUITE_P(SSE4_1
, ObmcSadHBDTest
,
299 ::testing::ValuesIn(sse4_functions_hbd
));
300 #endif // HAVE_SSE4_1
303 ObmcSadHBDTest::ParamType avx2_functions_hbd
[] = {
304 TestFuncs(aom_highbd_obmc_sad128x128_c
, aom_highbd_obmc_sad128x128_avx2
),
305 TestFuncs(aom_highbd_obmc_sad128x64_c
, aom_highbd_obmc_sad128x64_avx2
),
306 TestFuncs(aom_highbd_obmc_sad64x128_c
, aom_highbd_obmc_sad64x128_avx2
),
307 TestFuncs(aom_highbd_obmc_sad64x64_c
, aom_highbd_obmc_sad64x64_avx2
),
308 TestFuncs(aom_highbd_obmc_sad64x32_c
, aom_highbd_obmc_sad64x32_avx2
),
309 TestFuncs(aom_highbd_obmc_sad32x64_c
, aom_highbd_obmc_sad32x64_avx2
),
310 TestFuncs(aom_highbd_obmc_sad32x32_c
, aom_highbd_obmc_sad32x32_avx2
),
311 TestFuncs(aom_highbd_obmc_sad32x16_c
, aom_highbd_obmc_sad32x16_avx2
),
312 TestFuncs(aom_highbd_obmc_sad16x32_c
, aom_highbd_obmc_sad16x32_avx2
),
313 TestFuncs(aom_highbd_obmc_sad16x16_c
, aom_highbd_obmc_sad16x16_avx2
),
314 TestFuncs(aom_highbd_obmc_sad16x8_c
, aom_highbd_obmc_sad16x8_avx2
),
315 TestFuncs(aom_highbd_obmc_sad8x16_c
, aom_highbd_obmc_sad8x16_avx2
),
316 TestFuncs(aom_highbd_obmc_sad8x8_c
, aom_highbd_obmc_sad8x8_avx2
),
317 TestFuncs(aom_highbd_obmc_sad8x4_c
, aom_highbd_obmc_sad8x4_avx2
),
318 TestFuncs(aom_highbd_obmc_sad4x8_c
, aom_highbd_obmc_sad4x8_avx2
),
319 TestFuncs(aom_highbd_obmc_sad4x4_c
, aom_highbd_obmc_sad4x4_avx2
),
321 TestFuncs(aom_highbd_obmc_sad64x16_c
, aom_highbd_obmc_sad64x16_avx2
),
322 TestFuncs(aom_highbd_obmc_sad16x64_c
, aom_highbd_obmc_sad16x64_avx2
),
323 TestFuncs(aom_highbd_obmc_sad32x8_c
, aom_highbd_obmc_sad32x8_avx2
),
324 TestFuncs(aom_highbd_obmc_sad8x32_c
, aom_highbd_obmc_sad8x32_avx2
),
325 TestFuncs(aom_highbd_obmc_sad16x4_c
, aom_highbd_obmc_sad16x4_avx2
),
326 TestFuncs(aom_highbd_obmc_sad4x16_c
, aom_highbd_obmc_sad4x16_avx2
),
329 INSTANTIATE_TEST_SUITE_P(AVX2
, ObmcSadHBDTest
,
330 ::testing::ValuesIn(avx2_functions_hbd
));
332 #endif // CONFIG_AV1_HIGHBITDEPTH