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"
13 #include "test/acm_random.h"
15 #include "test/function_equivalence_test.h"
16 #include "test/register_state_check.h"
18 #include "config/aom_config.h"
19 #include "config/aom_dsp_rtcd.h"
21 #include "aom/aom_integer.h"
23 #define MAX_SB_SQUARE (MAX_SB_SIZE * MAX_SB_SIZE)
25 using libaom_test::ACMRandom
;
26 using libaom_test::FunctionEquivalenceTest
;
30 static const int kIterations
= 1000;
31 static const int kMaskMax
= 64;
33 typedef unsigned int (*ObmcVarF
)(const uint8_t *pre
, int pre_stride
,
34 const int32_t *wsrc
, const int32_t *mask
,
36 typedef libaom_test::FuncParam
<ObmcVarF
> TestFuncs
;
38 ////////////////////////////////////////////////////////////////////////////////
40 ////////////////////////////////////////////////////////////////////////////////
42 class ObmcVarianceTest
: public FunctionEquivalenceTest
<ObmcVarF
> {};
44 TEST_P(ObmcVarianceTest
, RandomValues
) {
45 DECLARE_ALIGNED(32, uint8_t, pre
[MAX_SB_SQUARE
]);
46 DECLARE_ALIGNED(32, int32_t, wsrc
[MAX_SB_SQUARE
]);
47 DECLARE_ALIGNED(32, int32_t, mask
[MAX_SB_SQUARE
]);
49 for (int iter
= 0; iter
< kIterations
&& !HasFatalFailure(); ++iter
) {
50 const int pre_stride
= this->rng_(MAX_SB_SIZE
+ 1);
52 for (int i
= 0; i
< MAX_SB_SQUARE
; ++i
) {
53 pre
[i
] = this->rng_
.Rand8();
54 wsrc
[i
] = this->rng_
.Rand8() * this->rng_(kMaskMax
* kMaskMax
+ 1);
55 mask
[i
] = this->rng_(kMaskMax
* kMaskMax
+ 1);
58 unsigned int ref_sse
, tst_sse
;
59 const unsigned int ref_res
=
60 params_
.ref_func(pre
, pre_stride
, wsrc
, mask
, &ref_sse
);
62 ASM_REGISTER_STATE_CHECK(
63 tst_res
= params_
.tst_func(pre
, pre_stride
, wsrc
, mask
, &tst_sse
));
65 ASSERT_EQ(ref_res
, tst_res
);
66 ASSERT_EQ(ref_sse
, tst_sse
);
70 TEST_P(ObmcVarianceTest
, ExtremeValues
) {
71 DECLARE_ALIGNED(32, uint8_t, pre
[MAX_SB_SQUARE
]);
72 DECLARE_ALIGNED(32, int32_t, wsrc
[MAX_SB_SQUARE
]);
73 DECLARE_ALIGNED(32, int32_t, mask
[MAX_SB_SQUARE
]);
75 for (int iter
= 0; iter
< MAX_SB_SIZE
&& !HasFatalFailure(); ++iter
) {
76 const int pre_stride
= iter
;
78 for (int i
= 0; i
< MAX_SB_SQUARE
; ++i
) {
80 wsrc
[i
] = UINT8_MAX
* kMaskMax
* kMaskMax
;
81 mask
[i
] = kMaskMax
* kMaskMax
;
84 unsigned int ref_sse
, tst_sse
;
85 const unsigned int ref_res
=
86 params_
.ref_func(pre
, pre_stride
, wsrc
, mask
, &ref_sse
);
88 ASM_REGISTER_STATE_CHECK(
89 tst_res
= params_
.tst_func(pre
, pre_stride
, wsrc
, mask
, &tst_sse
));
91 ASSERT_EQ(ref_res
, tst_res
);
92 ASSERT_EQ(ref_sse
, tst_sse
);
97 const ObmcVarianceTest::ParamType sse4_functions
[] = {
98 TestFuncs(aom_obmc_variance128x128_c
, aom_obmc_variance128x128_sse4_1
),
99 TestFuncs(aom_obmc_variance128x64_c
, aom_obmc_variance128x64_sse4_1
),
100 TestFuncs(aom_obmc_variance64x128_c
, aom_obmc_variance64x128_sse4_1
),
101 TestFuncs(aom_obmc_variance64x64_c
, aom_obmc_variance64x64_sse4_1
),
102 TestFuncs(aom_obmc_variance64x32_c
, aom_obmc_variance64x32_sse4_1
),
103 TestFuncs(aom_obmc_variance32x64_c
, aom_obmc_variance32x64_sse4_1
),
104 TestFuncs(aom_obmc_variance32x32_c
, aom_obmc_variance32x32_sse4_1
),
105 TestFuncs(aom_obmc_variance32x16_c
, aom_obmc_variance32x16_sse4_1
),
106 TestFuncs(aom_obmc_variance16x32_c
, aom_obmc_variance16x32_sse4_1
),
107 TestFuncs(aom_obmc_variance16x16_c
, aom_obmc_variance16x16_sse4_1
),
108 TestFuncs(aom_obmc_variance16x8_c
, aom_obmc_variance16x8_sse4_1
),
109 TestFuncs(aom_obmc_variance8x16_c
, aom_obmc_variance8x16_sse4_1
),
110 TestFuncs(aom_obmc_variance8x8_c
, aom_obmc_variance8x8_sse4_1
),
111 TestFuncs(aom_obmc_variance8x4_c
, aom_obmc_variance8x4_sse4_1
),
112 TestFuncs(aom_obmc_variance4x8_c
, aom_obmc_variance4x8_sse4_1
),
113 TestFuncs(aom_obmc_variance4x4_c
, aom_obmc_variance4x4_sse4_1
)
116 INSTANTIATE_TEST_CASE_P(SSE4_1
, ObmcVarianceTest
,
117 ::testing::ValuesIn(sse4_functions
));
118 #endif // HAVE_SSE4_1
120 ////////////////////////////////////////////////////////////////////////////////
122 ////////////////////////////////////////////////////////////////////////////////
124 class ObmcVarianceHBDTest
: public FunctionEquivalenceTest
<ObmcVarF
> {};
126 TEST_P(ObmcVarianceHBDTest
, RandomValues
) {
127 DECLARE_ALIGNED(32, uint16_t, pre
[MAX_SB_SQUARE
]);
128 DECLARE_ALIGNED(32, int32_t, wsrc
[MAX_SB_SQUARE
]);
129 DECLARE_ALIGNED(32, int32_t, mask
[MAX_SB_SQUARE
]);
131 for (int iter
= 0; iter
< kIterations
&& !HasFatalFailure(); ++iter
) {
132 const int pre_stride
= this->rng_(MAX_SB_SIZE
+ 1);
134 for (int i
= 0; i
< MAX_SB_SQUARE
; ++i
) {
135 pre
[i
] = this->rng_(1 << params_
.bit_depth
);
136 wsrc
[i
] = this->rng_(1 << params_
.bit_depth
) *
137 this->rng_(kMaskMax
* kMaskMax
+ 1);
138 mask
[i
] = this->rng_(kMaskMax
* kMaskMax
+ 1);
141 unsigned int ref_sse
, tst_sse
;
142 const unsigned int ref_res
= params_
.ref_func(
143 CONVERT_TO_BYTEPTR(pre
), pre_stride
, wsrc
, mask
, &ref_sse
);
144 unsigned int tst_res
;
145 ASM_REGISTER_STATE_CHECK(tst_res
= params_
.tst_func(CONVERT_TO_BYTEPTR(pre
),
146 pre_stride
, wsrc
, mask
,
149 ASSERT_EQ(ref_res
, tst_res
);
150 ASSERT_EQ(ref_sse
, tst_sse
);
154 TEST_P(ObmcVarianceHBDTest
, ExtremeValues
) {
155 DECLARE_ALIGNED(32, uint16_t, pre
[MAX_SB_SQUARE
]);
156 DECLARE_ALIGNED(32, int32_t, wsrc
[MAX_SB_SQUARE
]);
157 DECLARE_ALIGNED(32, int32_t, mask
[MAX_SB_SQUARE
]);
159 for (int iter
= 0; iter
< MAX_SB_SIZE
&& !HasFatalFailure(); ++iter
) {
160 const int pre_stride
= iter
;
162 for (int i
= 0; i
< MAX_SB_SQUARE
; ++i
) {
163 pre
[i
] = (1 << params_
.bit_depth
) - 1;
164 wsrc
[i
] = ((1 << params_
.bit_depth
) - 1) * kMaskMax
* kMaskMax
;
165 mask
[i
] = kMaskMax
* kMaskMax
;
168 unsigned int ref_sse
, tst_sse
;
169 const unsigned int ref_res
= params_
.ref_func(
170 CONVERT_TO_BYTEPTR(pre
), pre_stride
, wsrc
, mask
, &ref_sse
);
171 unsigned int tst_res
;
172 ASM_REGISTER_STATE_CHECK(tst_res
= params_
.tst_func(CONVERT_TO_BYTEPTR(pre
),
173 pre_stride
, wsrc
, mask
,
176 ASSERT_EQ(ref_res
, tst_res
);
177 ASSERT_EQ(ref_sse
, tst_sse
);
182 ObmcVarianceHBDTest::ParamType sse4_functions_hbd
[] = {
183 TestFuncs(aom_highbd_obmc_variance128x128_c
,
184 aom_highbd_obmc_variance128x128_sse4_1
, 8),
185 TestFuncs(aom_highbd_obmc_variance128x64_c
,
186 aom_highbd_obmc_variance128x64_sse4_1
, 8),
187 TestFuncs(aom_highbd_obmc_variance64x128_c
,
188 aom_highbd_obmc_variance64x128_sse4_1
, 8),
189 TestFuncs(aom_highbd_obmc_variance64x64_c
,
190 aom_highbd_obmc_variance64x64_sse4_1
, 8),
191 TestFuncs(aom_highbd_obmc_variance64x32_c
,
192 aom_highbd_obmc_variance64x32_sse4_1
, 8),
193 TestFuncs(aom_highbd_obmc_variance32x64_c
,
194 aom_highbd_obmc_variance32x64_sse4_1
, 8),
195 TestFuncs(aom_highbd_obmc_variance32x32_c
,
196 aom_highbd_obmc_variance32x32_sse4_1
, 8),
197 TestFuncs(aom_highbd_obmc_variance32x16_c
,
198 aom_highbd_obmc_variance32x16_sse4_1
, 8),
199 TestFuncs(aom_highbd_obmc_variance16x32_c
,
200 aom_highbd_obmc_variance16x32_sse4_1
, 8),
201 TestFuncs(aom_highbd_obmc_variance16x16_c
,
202 aom_highbd_obmc_variance16x16_sse4_1
, 8),
203 TestFuncs(aom_highbd_obmc_variance16x8_c
, aom_highbd_obmc_variance16x8_sse4_1
,
205 TestFuncs(aom_highbd_obmc_variance8x16_c
, aom_highbd_obmc_variance8x16_sse4_1
,
207 TestFuncs(aom_highbd_obmc_variance8x8_c
, aom_highbd_obmc_variance8x8_sse4_1
,
209 TestFuncs(aom_highbd_obmc_variance8x4_c
, aom_highbd_obmc_variance8x4_sse4_1
,
211 TestFuncs(aom_highbd_obmc_variance4x8_c
, aom_highbd_obmc_variance4x8_sse4_1
,
213 TestFuncs(aom_highbd_obmc_variance4x4_c
, aom_highbd_obmc_variance4x4_sse4_1
,
215 TestFuncs(aom_highbd_10_obmc_variance128x128_c
,
216 aom_highbd_10_obmc_variance128x128_sse4_1
, 10),
217 TestFuncs(aom_highbd_10_obmc_variance128x64_c
,
218 aom_highbd_10_obmc_variance128x64_sse4_1
, 10),
219 TestFuncs(aom_highbd_10_obmc_variance64x128_c
,
220 aom_highbd_10_obmc_variance64x128_sse4_1
, 10),
221 TestFuncs(aom_highbd_10_obmc_variance64x64_c
,
222 aom_highbd_10_obmc_variance64x64_sse4_1
, 10),
223 TestFuncs(aom_highbd_10_obmc_variance64x32_c
,
224 aom_highbd_10_obmc_variance64x32_sse4_1
, 10),
225 TestFuncs(aom_highbd_10_obmc_variance32x64_c
,
226 aom_highbd_10_obmc_variance32x64_sse4_1
, 10),
227 TestFuncs(aom_highbd_10_obmc_variance32x32_c
,
228 aom_highbd_10_obmc_variance32x32_sse4_1
, 10),
229 TestFuncs(aom_highbd_10_obmc_variance32x16_c
,
230 aom_highbd_10_obmc_variance32x16_sse4_1
, 10),
231 TestFuncs(aom_highbd_10_obmc_variance16x32_c
,
232 aom_highbd_10_obmc_variance16x32_sse4_1
, 10),
233 TestFuncs(aom_highbd_10_obmc_variance16x16_c
,
234 aom_highbd_10_obmc_variance16x16_sse4_1
, 10),
235 TestFuncs(aom_highbd_10_obmc_variance16x8_c
,
236 aom_highbd_10_obmc_variance16x8_sse4_1
, 10),
237 TestFuncs(aom_highbd_10_obmc_variance8x16_c
,
238 aom_highbd_10_obmc_variance8x16_sse4_1
, 10),
239 TestFuncs(aom_highbd_10_obmc_variance8x8_c
,
240 aom_highbd_10_obmc_variance8x8_sse4_1
, 10),
241 TestFuncs(aom_highbd_10_obmc_variance8x4_c
,
242 aom_highbd_10_obmc_variance8x4_sse4_1
, 10),
243 TestFuncs(aom_highbd_10_obmc_variance4x8_c
,
244 aom_highbd_10_obmc_variance4x8_sse4_1
, 10),
245 TestFuncs(aom_highbd_10_obmc_variance4x4_c
,
246 aom_highbd_10_obmc_variance4x4_sse4_1
, 10),
247 TestFuncs(aom_highbd_12_obmc_variance128x128_c
,
248 aom_highbd_12_obmc_variance128x128_sse4_1
, 12),
249 TestFuncs(aom_highbd_12_obmc_variance128x64_c
,
250 aom_highbd_12_obmc_variance128x64_sse4_1
, 12),
251 TestFuncs(aom_highbd_12_obmc_variance64x128_c
,
252 aom_highbd_12_obmc_variance64x128_sse4_1
, 12),
253 TestFuncs(aom_highbd_12_obmc_variance64x64_c
,
254 aom_highbd_12_obmc_variance64x64_sse4_1
, 12),
255 TestFuncs(aom_highbd_12_obmc_variance64x32_c
,
256 aom_highbd_12_obmc_variance64x32_sse4_1
, 12),
257 TestFuncs(aom_highbd_12_obmc_variance32x64_c
,
258 aom_highbd_12_obmc_variance32x64_sse4_1
, 12),
259 TestFuncs(aom_highbd_12_obmc_variance32x32_c
,
260 aom_highbd_12_obmc_variance32x32_sse4_1
, 12),
261 TestFuncs(aom_highbd_12_obmc_variance32x16_c
,
262 aom_highbd_12_obmc_variance32x16_sse4_1
, 12),
263 TestFuncs(aom_highbd_12_obmc_variance16x32_c
,
264 aom_highbd_12_obmc_variance16x32_sse4_1
, 12),
265 TestFuncs(aom_highbd_12_obmc_variance16x16_c
,
266 aom_highbd_12_obmc_variance16x16_sse4_1
, 12),
267 TestFuncs(aom_highbd_12_obmc_variance16x8_c
,
268 aom_highbd_12_obmc_variance16x8_sse4_1
, 12),
269 TestFuncs(aom_highbd_12_obmc_variance8x16_c
,
270 aom_highbd_12_obmc_variance8x16_sse4_1
, 12),
271 TestFuncs(aom_highbd_12_obmc_variance8x8_c
,
272 aom_highbd_12_obmc_variance8x8_sse4_1
, 12),
273 TestFuncs(aom_highbd_12_obmc_variance8x4_c
,
274 aom_highbd_12_obmc_variance8x4_sse4_1
, 12),
275 TestFuncs(aom_highbd_12_obmc_variance4x8_c
,
276 aom_highbd_12_obmc_variance4x8_sse4_1
, 12),
277 TestFuncs(aom_highbd_12_obmc_variance4x4_c
,
278 aom_highbd_12_obmc_variance4x4_sse4_1
, 12)
281 INSTANTIATE_TEST_CASE_P(SSE4_1
, ObmcVarianceHBDTest
,
282 ::testing::ValuesIn(sse4_functions_hbd
));
283 #endif // HAVE_SSE4_1