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