av1_convolve_ x,y _avx2() -- use 256 bit load/store
[aom.git] / test / obmc_variance_test.cc
blobed6c4c132ac88f1f9ebdb4cc4761a5718977be63
1 /*
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 "./aom_config.h"
19 #include "./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::ACMRandom;
25 using libaom_test::FunctionEquivalenceTest;
27 namespace {
29 static const int kIterations = 1000;
30 static const int kMaskMax = 64;
32 typedef unsigned int (*ObmcVarF)(const uint8_t *pre, int pre_stride,
33 const int32_t *wsrc, const int32_t *mask,
34 unsigned int *sse);
35 typedef libaom_test::FuncParam<ObmcVarF> TestFuncs;
37 ////////////////////////////////////////////////////////////////////////////////
38 // 8 bit
39 ////////////////////////////////////////////////////////////////////////////////
41 class ObmcVarianceTest : public FunctionEquivalenceTest<ObmcVarF> {};
43 TEST_P(ObmcVarianceTest, RandomValues) {
44 DECLARE_ALIGNED(32, uint8_t, pre[MAX_SB_SQUARE]);
45 DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
46 DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
48 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
49 const int pre_stride = this->rng_(MAX_SB_SIZE + 1);
51 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
52 pre[i] = this->rng_.Rand8();
53 wsrc[i] = this->rng_.Rand8() * this->rng_(kMaskMax * kMaskMax + 1);
54 mask[i] = this->rng_(kMaskMax * kMaskMax + 1);
57 unsigned int ref_sse, tst_sse;
58 const unsigned int ref_res =
59 params_.ref_func(pre, pre_stride, wsrc, mask, &ref_sse);
60 unsigned int tst_res;
61 ASM_REGISTER_STATE_CHECK(
62 tst_res = params_.tst_func(pre, pre_stride, wsrc, mask, &tst_sse));
64 ASSERT_EQ(ref_res, tst_res);
65 ASSERT_EQ(ref_sse, tst_sse);
69 TEST_P(ObmcVarianceTest, ExtremeValues) {
70 DECLARE_ALIGNED(32, uint8_t, pre[MAX_SB_SQUARE]);
71 DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
72 DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
74 for (int iter = 0; iter < MAX_SB_SIZE && !HasFatalFailure(); ++iter) {
75 const int pre_stride = iter;
77 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
78 pre[i] = UINT8_MAX;
79 wsrc[i] = UINT8_MAX * kMaskMax * kMaskMax;
80 mask[i] = kMaskMax * kMaskMax;
83 unsigned int ref_sse, tst_sse;
84 const unsigned int ref_res =
85 params_.ref_func(pre, pre_stride, wsrc, mask, &ref_sse);
86 unsigned int tst_res;
87 ASM_REGISTER_STATE_CHECK(
88 tst_res = params_.tst_func(pre, pre_stride, wsrc, mask, &tst_sse));
90 ASSERT_EQ(ref_res, tst_res);
91 ASSERT_EQ(ref_sse, tst_sse);
95 #if HAVE_SSE4_1
96 const ObmcVarianceTest::ParamType sse4_functions[] = {
97 #if CONFIG_EXT_PARTITION
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 #endif // CONFIG_EXT_PARTITION
102 TestFuncs(aom_obmc_variance64x64_c, aom_obmc_variance64x64_sse4_1),
103 TestFuncs(aom_obmc_variance64x32_c, aom_obmc_variance64x32_sse4_1),
104 TestFuncs(aom_obmc_variance32x64_c, aom_obmc_variance32x64_sse4_1),
105 TestFuncs(aom_obmc_variance32x32_c, aom_obmc_variance32x32_sse4_1),
106 TestFuncs(aom_obmc_variance32x16_c, aom_obmc_variance32x16_sse4_1),
107 TestFuncs(aom_obmc_variance16x32_c, aom_obmc_variance16x32_sse4_1),
108 TestFuncs(aom_obmc_variance16x16_c, aom_obmc_variance16x16_sse4_1),
109 TestFuncs(aom_obmc_variance16x8_c, aom_obmc_variance16x8_sse4_1),
110 TestFuncs(aom_obmc_variance8x16_c, aom_obmc_variance8x16_sse4_1),
111 TestFuncs(aom_obmc_variance8x8_c, aom_obmc_variance8x8_sse4_1),
112 TestFuncs(aom_obmc_variance8x4_c, aom_obmc_variance8x4_sse4_1),
113 TestFuncs(aom_obmc_variance4x8_c, aom_obmc_variance4x8_sse4_1),
114 TestFuncs(aom_obmc_variance4x4_c, aom_obmc_variance4x4_sse4_1)
117 INSTANTIATE_TEST_CASE_P(SSE4_1, ObmcVarianceTest,
118 ::testing::ValuesIn(sse4_functions));
119 #endif // HAVE_SSE4_1
121 ////////////////////////////////////////////////////////////////////////////////
122 // High bit-depth
123 ////////////////////////////////////////////////////////////////////////////////
125 class ObmcVarianceHBDTest : public FunctionEquivalenceTest<ObmcVarF> {};
127 TEST_P(ObmcVarianceHBDTest, RandomValues) {
128 DECLARE_ALIGNED(32, uint16_t, pre[MAX_SB_SQUARE]);
129 DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
130 DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
132 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
133 const int pre_stride = this->rng_(MAX_SB_SIZE + 1);
135 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
136 pre[i] = this->rng_(1 << params_.bit_depth);
137 wsrc[i] = this->rng_(1 << params_.bit_depth) *
138 this->rng_(kMaskMax * kMaskMax + 1);
139 mask[i] = this->rng_(kMaskMax * kMaskMax + 1);
142 unsigned int ref_sse, tst_sse;
143 const unsigned int ref_res = params_.ref_func(
144 CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask, &ref_sse);
145 unsigned int tst_res;
146 ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(CONVERT_TO_BYTEPTR(pre),
147 pre_stride, wsrc, mask,
148 &tst_sse));
150 ASSERT_EQ(ref_res, tst_res);
151 ASSERT_EQ(ref_sse, tst_sse);
155 TEST_P(ObmcVarianceHBDTest, ExtremeValues) {
156 DECLARE_ALIGNED(32, uint16_t, pre[MAX_SB_SQUARE]);
157 DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
158 DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
160 for (int iter = 0; iter < MAX_SB_SIZE && !HasFatalFailure(); ++iter) {
161 const int pre_stride = iter;
163 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
164 pre[i] = (1 << params_.bit_depth) - 1;
165 wsrc[i] = ((1 << params_.bit_depth) - 1) * kMaskMax * kMaskMax;
166 mask[i] = kMaskMax * kMaskMax;
169 unsigned int ref_sse, tst_sse;
170 const unsigned int ref_res = params_.ref_func(
171 CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask, &ref_sse);
172 unsigned int tst_res;
173 ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(CONVERT_TO_BYTEPTR(pre),
174 pre_stride, wsrc, mask,
175 &tst_sse));
177 ASSERT_EQ(ref_res, tst_res);
178 ASSERT_EQ(ref_sse, tst_sse);
182 #if HAVE_SSE4_1
183 ObmcVarianceHBDTest::ParamType sse4_functions_hbd[] = {
184 #if CONFIG_EXT_PARTITION
185 TestFuncs(aom_highbd_obmc_variance128x128_c,
186 aom_highbd_obmc_variance128x128_sse4_1, 8),
187 TestFuncs(aom_highbd_obmc_variance128x64_c,
188 aom_highbd_obmc_variance128x64_sse4_1, 8),
189 TestFuncs(aom_highbd_obmc_variance64x128_c,
190 aom_highbd_obmc_variance64x128_sse4_1, 8),
191 #endif // CONFIG_EXT_PARTITION
192 TestFuncs(aom_highbd_obmc_variance64x64_c,
193 aom_highbd_obmc_variance64x64_sse4_1, 8),
194 TestFuncs(aom_highbd_obmc_variance64x32_c,
195 aom_highbd_obmc_variance64x32_sse4_1, 8),
196 TestFuncs(aom_highbd_obmc_variance32x64_c,
197 aom_highbd_obmc_variance32x64_sse4_1, 8),
198 TestFuncs(aom_highbd_obmc_variance32x32_c,
199 aom_highbd_obmc_variance32x32_sse4_1, 8),
200 TestFuncs(aom_highbd_obmc_variance32x16_c,
201 aom_highbd_obmc_variance32x16_sse4_1, 8),
202 TestFuncs(aom_highbd_obmc_variance16x32_c,
203 aom_highbd_obmc_variance16x32_sse4_1, 8),
204 TestFuncs(aom_highbd_obmc_variance16x16_c,
205 aom_highbd_obmc_variance16x16_sse4_1, 8),
206 TestFuncs(aom_highbd_obmc_variance16x8_c, aom_highbd_obmc_variance16x8_sse4_1,
208 TestFuncs(aom_highbd_obmc_variance8x16_c, aom_highbd_obmc_variance8x16_sse4_1,
210 TestFuncs(aom_highbd_obmc_variance8x8_c, aom_highbd_obmc_variance8x8_sse4_1,
212 TestFuncs(aom_highbd_obmc_variance8x4_c, aom_highbd_obmc_variance8x4_sse4_1,
214 TestFuncs(aom_highbd_obmc_variance4x8_c, aom_highbd_obmc_variance4x8_sse4_1,
216 TestFuncs(aom_highbd_obmc_variance4x4_c, aom_highbd_obmc_variance4x4_sse4_1,
218 #if CONFIG_EXT_PARTITION
219 TestFuncs(aom_highbd_10_obmc_variance128x128_c,
220 aom_highbd_10_obmc_variance128x128_sse4_1, 10),
221 TestFuncs(aom_highbd_10_obmc_variance128x64_c,
222 aom_highbd_10_obmc_variance128x64_sse4_1, 10),
223 TestFuncs(aom_highbd_10_obmc_variance64x128_c,
224 aom_highbd_10_obmc_variance64x128_sse4_1, 10),
225 #endif // CONFIG_EXT_PARTITION
226 TestFuncs(aom_highbd_10_obmc_variance64x64_c,
227 aom_highbd_10_obmc_variance64x64_sse4_1, 10),
228 TestFuncs(aom_highbd_10_obmc_variance64x32_c,
229 aom_highbd_10_obmc_variance64x32_sse4_1, 10),
230 TestFuncs(aom_highbd_10_obmc_variance32x64_c,
231 aom_highbd_10_obmc_variance32x64_sse4_1, 10),
232 TestFuncs(aom_highbd_10_obmc_variance32x32_c,
233 aom_highbd_10_obmc_variance32x32_sse4_1, 10),
234 TestFuncs(aom_highbd_10_obmc_variance32x16_c,
235 aom_highbd_10_obmc_variance32x16_sse4_1, 10),
236 TestFuncs(aom_highbd_10_obmc_variance16x32_c,
237 aom_highbd_10_obmc_variance16x32_sse4_1, 10),
238 TestFuncs(aom_highbd_10_obmc_variance16x16_c,
239 aom_highbd_10_obmc_variance16x16_sse4_1, 10),
240 TestFuncs(aom_highbd_10_obmc_variance16x8_c,
241 aom_highbd_10_obmc_variance16x8_sse4_1, 10),
242 TestFuncs(aom_highbd_10_obmc_variance8x16_c,
243 aom_highbd_10_obmc_variance8x16_sse4_1, 10),
244 TestFuncs(aom_highbd_10_obmc_variance8x8_c,
245 aom_highbd_10_obmc_variance8x8_sse4_1, 10),
246 TestFuncs(aom_highbd_10_obmc_variance8x4_c,
247 aom_highbd_10_obmc_variance8x4_sse4_1, 10),
248 TestFuncs(aom_highbd_10_obmc_variance4x8_c,
249 aom_highbd_10_obmc_variance4x8_sse4_1, 10),
250 TestFuncs(aom_highbd_10_obmc_variance4x4_c,
251 aom_highbd_10_obmc_variance4x4_sse4_1, 10),
252 #if CONFIG_EXT_PARTITION
253 TestFuncs(aom_highbd_12_obmc_variance128x128_c,
254 aom_highbd_12_obmc_variance128x128_sse4_1, 12),
255 TestFuncs(aom_highbd_12_obmc_variance128x64_c,
256 aom_highbd_12_obmc_variance128x64_sse4_1, 12),
257 TestFuncs(aom_highbd_12_obmc_variance64x128_c,
258 aom_highbd_12_obmc_variance64x128_sse4_1, 12),
259 #endif // CONFIG_EXT_PARTITION
260 TestFuncs(aom_highbd_12_obmc_variance64x64_c,
261 aom_highbd_12_obmc_variance64x64_sse4_1, 12),
262 TestFuncs(aom_highbd_12_obmc_variance64x32_c,
263 aom_highbd_12_obmc_variance64x32_sse4_1, 12),
264 TestFuncs(aom_highbd_12_obmc_variance32x64_c,
265 aom_highbd_12_obmc_variance32x64_sse4_1, 12),
266 TestFuncs(aom_highbd_12_obmc_variance32x32_c,
267 aom_highbd_12_obmc_variance32x32_sse4_1, 12),
268 TestFuncs(aom_highbd_12_obmc_variance32x16_c,
269 aom_highbd_12_obmc_variance32x16_sse4_1, 12),
270 TestFuncs(aom_highbd_12_obmc_variance16x32_c,
271 aom_highbd_12_obmc_variance16x32_sse4_1, 12),
272 TestFuncs(aom_highbd_12_obmc_variance16x16_c,
273 aom_highbd_12_obmc_variance16x16_sse4_1, 12),
274 TestFuncs(aom_highbd_12_obmc_variance16x8_c,
275 aom_highbd_12_obmc_variance16x8_sse4_1, 12),
276 TestFuncs(aom_highbd_12_obmc_variance8x16_c,
277 aom_highbd_12_obmc_variance8x16_sse4_1, 12),
278 TestFuncs(aom_highbd_12_obmc_variance8x8_c,
279 aom_highbd_12_obmc_variance8x8_sse4_1, 12),
280 TestFuncs(aom_highbd_12_obmc_variance8x4_c,
281 aom_highbd_12_obmc_variance8x4_sse4_1, 12),
282 TestFuncs(aom_highbd_12_obmc_variance4x8_c,
283 aom_highbd_12_obmc_variance4x8_sse4_1, 12),
284 TestFuncs(aom_highbd_12_obmc_variance4x4_c,
285 aom_highbd_12_obmc_variance4x4_sse4_1, 12)
288 INSTANTIATE_TEST_CASE_P(SSE4_1, ObmcVarianceHBDTest,
289 ::testing::ValuesIn(sse4_functions_hbd));
290 #endif // HAVE_SSE4_1
291 } // namespace