blob: 9dcb50ab530901da7e6dfa3e1e6bc98121171208 [file] [log] [blame]
Geza Loreebc2d342016-07-12 11:41:54 +01001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Geza Loreebc2d342016-07-12 11:41:54 +01003 *
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07004 * 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.
Geza Loreebc2d342016-07-12 11:41:54 +010010 */
11
12#include "third_party/googletest/src/include/gtest/gtest.h"
13#include "test/acm_random.h"
14
15#include "test/function_equivalence_test.h"
16#include "test/register_state_check.h"
17
Yaowu Xuf883b422016-08-30 14:01:10 -070018#include "./aom_config.h"
19#include "./aom_dsp_rtcd.h"
20#include "aom/aom_integer.h"
Geza Loreebc2d342016-07-12 11:41:54 +010021
22#define MAX_SB_SQUARE (MAX_SB_SIZE * MAX_SB_SIZE)
23
Yaowu Xuc27fc142016-08-22 16:08:15 -070024using libaom_test::ACMRandom;
25using libaom_test::FunctionEquivalenceTest;
Geza Loreebc2d342016-07-12 11:41:54 +010026
27namespace {
28
29static const int kIterations = 1000;
30static const int kMaskMax = 64;
31
32typedef unsigned int (*ObmcVarF)(const uint8_t *pre, int pre_stride,
33 const int32_t *wsrc, const int32_t *mask,
34 unsigned int *sse);
Yaowu Xuc27fc142016-08-22 16:08:15 -070035typedef libaom_test::FuncParam<ObmcVarF> TestFuncs;
Geza Loreebc2d342016-07-12 11:41:54 +010036
37////////////////////////////////////////////////////////////////////////////////
38// 8 bit
39////////////////////////////////////////////////////////////////////////////////
40
41class ObmcVarianceTest : public FunctionEquivalenceTest<ObmcVarF> {};
42
43TEST_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]);
47
clang-format3a826f12016-08-11 17:46:05 -070048 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
Geza Loreebc2d342016-07-12 11:41:54 +010049 const int pre_stride = this->rng_(MAX_SB_SIZE + 1);
50
clang-format3a826f12016-08-11 17:46:05 -070051 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Geza Loreebc2d342016-07-12 11:41:54 +010052 pre[i] = this->rng_.Rand8();
53 wsrc[i] = this->rng_.Rand8() * this->rng_(kMaskMax * kMaskMax + 1);
54 mask[i] = this->rng_(kMaskMax * kMaskMax + 1);
55 }
56
57 unsigned int ref_sse, tst_sse;
clang-format3a826f12016-08-11 17:46:05 -070058 const unsigned int ref_res =
59 params_.ref_func(pre, pre_stride, wsrc, mask, &ref_sse);
Geza Loreebc2d342016-07-12 11:41:54 +010060 unsigned int tst_res;
61 ASM_REGISTER_STATE_CHECK(
62 tst_res = params_.tst_func(pre, pre_stride, wsrc, mask, &tst_sse));
63
64 ASSERT_EQ(ref_res, tst_res);
65 ASSERT_EQ(ref_sse, tst_sse);
66 }
67}
68
69TEST_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]);
73
clang-format3a826f12016-08-11 17:46:05 -070074 for (int iter = 0; iter < MAX_SB_SIZE && !HasFatalFailure(); ++iter) {
Geza Loreebc2d342016-07-12 11:41:54 +010075 const int pre_stride = iter;
76
clang-format3a826f12016-08-11 17:46:05 -070077 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Geza Loreebc2d342016-07-12 11:41:54 +010078 pre[i] = UINT8_MAX;
79 wsrc[i] = UINT8_MAX * kMaskMax * kMaskMax;
80 mask[i] = kMaskMax * kMaskMax;
81 }
82
83 unsigned int ref_sse, tst_sse;
clang-format3a826f12016-08-11 17:46:05 -070084 const unsigned int ref_res =
85 params_.ref_func(pre, pre_stride, wsrc, mask, &ref_sse);
Geza Loreebc2d342016-07-12 11:41:54 +010086 unsigned int tst_res;
87 ASM_REGISTER_STATE_CHECK(
88 tst_res = params_.tst_func(pre, pre_stride, wsrc, mask, &tst_sse));
89
90 ASSERT_EQ(ref_res, tst_res);
91 ASSERT_EQ(ref_sse, tst_sse);
92 }
93}
94
95#if HAVE_SSE4_1
96const ObmcVarianceTest::ParamType sse4_functions[] = {
97#if CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -070098 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),
Geza Loreebc2d342016-07-12 11:41:54 +0100101#endif // CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700102 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)
Geza Loreebc2d342016-07-12 11:41:54 +0100115};
116
117INSTANTIATE_TEST_CASE_P(SSE4_1_C_COMPARE, ObmcVarianceTest,
118 ::testing::ValuesIn(sse4_functions));
119#endif // HAVE_SSE4_1
120
121////////////////////////////////////////////////////////////////////////////////
122// High bit-depth
123////////////////////////////////////////////////////////////////////////////////
124
Yaowu Xuf883b422016-08-30 14:01:10 -0700125#if CONFIG_AOM_HIGHBITDEPTH
Jingning Hana387b192016-07-14 10:11:32 -0700126class ObmcVarianceHBDTest : public FunctionEquivalenceTest<ObmcVarF> {};
Geza Loreebc2d342016-07-12 11:41:54 +0100127
128TEST_P(ObmcVarianceHBDTest, RandomValues) {
129 DECLARE_ALIGNED(32, uint16_t, pre[MAX_SB_SQUARE]);
130 DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
131 DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
132
clang-format3a826f12016-08-11 17:46:05 -0700133 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
Geza Loreebc2d342016-07-12 11:41:54 +0100134 const int pre_stride = this->rng_(MAX_SB_SIZE + 1);
135
clang-format3a826f12016-08-11 17:46:05 -0700136 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Jingning Hana387b192016-07-14 10:11:32 -0700137 pre[i] = this->rng_(1 << params_.bit_depth);
138 wsrc[i] = this->rng_(1 << params_.bit_depth) *
Geza Loreebc2d342016-07-12 11:41:54 +0100139 this->rng_(kMaskMax * kMaskMax + 1);
140 mask[i] = this->rng_(kMaskMax * kMaskMax + 1);
141 }
142
143 unsigned int ref_sse, tst_sse;
clang-format3a826f12016-08-11 17:46:05 -0700144 const unsigned int ref_res = params_.ref_func(
145 CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask, &ref_sse);
Geza Loreebc2d342016-07-12 11:41:54 +0100146 unsigned int tst_res;
clang-format3a826f12016-08-11 17:46:05 -0700147 ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(CONVERT_TO_BYTEPTR(pre),
148 pre_stride, wsrc, mask,
149 &tst_sse));
Geza Loreebc2d342016-07-12 11:41:54 +0100150
151 ASSERT_EQ(ref_res, tst_res);
152 ASSERT_EQ(ref_sse, tst_sse);
153 }
154}
155
156TEST_P(ObmcVarianceHBDTest, ExtremeValues) {
157 DECLARE_ALIGNED(32, uint16_t, pre[MAX_SB_SQUARE]);
158 DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
159 DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
160
clang-format3a826f12016-08-11 17:46:05 -0700161 for (int iter = 0; iter < MAX_SB_SIZE && !HasFatalFailure(); ++iter) {
Geza Loreebc2d342016-07-12 11:41:54 +0100162 const int pre_stride = iter;
163
clang-format3a826f12016-08-11 17:46:05 -0700164 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Jingning Hana387b192016-07-14 10:11:32 -0700165 pre[i] = (1 << params_.bit_depth) - 1;
166 wsrc[i] = ((1 << params_.bit_depth) - 1) * kMaskMax * kMaskMax;
Geza Loreebc2d342016-07-12 11:41:54 +0100167 mask[i] = kMaskMax * kMaskMax;
168 }
169
170 unsigned int ref_sse, tst_sse;
clang-format3a826f12016-08-11 17:46:05 -0700171 const unsigned int ref_res = params_.ref_func(
172 CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask, &ref_sse);
Geza Loreebc2d342016-07-12 11:41:54 +0100173 unsigned int tst_res;
clang-format3a826f12016-08-11 17:46:05 -0700174 ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(CONVERT_TO_BYTEPTR(pre),
175 pre_stride, wsrc, mask,
176 &tst_sse));
Geza Loreebc2d342016-07-12 11:41:54 +0100177
178 ASSERT_EQ(ref_res, tst_res);
179 ASSERT_EQ(ref_sse, tst_sse);
180 }
181}
182
183#if HAVE_SSE4_1
184ObmcVarianceHBDTest::ParamType sse4_functions_hbd[] = {
185#if CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700186 TestFuncs(aom_highbd_obmc_variance128x128_c,
187 aom_highbd_obmc_variance128x128_sse4_1, 8),
188 TestFuncs(aom_highbd_obmc_variance128x64_c,
189 aom_highbd_obmc_variance128x64_sse4_1, 8),
190 TestFuncs(aom_highbd_obmc_variance64x128_c,
191 aom_highbd_obmc_variance64x128_sse4_1, 8),
Geza Loreebc2d342016-07-12 11:41:54 +0100192#endif // CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700193 TestFuncs(aom_highbd_obmc_variance64x64_c,
194 aom_highbd_obmc_variance64x64_sse4_1, 8),
195 TestFuncs(aom_highbd_obmc_variance64x32_c,
196 aom_highbd_obmc_variance64x32_sse4_1, 8),
197 TestFuncs(aom_highbd_obmc_variance32x64_c,
198 aom_highbd_obmc_variance32x64_sse4_1, 8),
199 TestFuncs(aom_highbd_obmc_variance32x32_c,
200 aom_highbd_obmc_variance32x32_sse4_1, 8),
201 TestFuncs(aom_highbd_obmc_variance32x16_c,
202 aom_highbd_obmc_variance32x16_sse4_1, 8),
203 TestFuncs(aom_highbd_obmc_variance16x32_c,
204 aom_highbd_obmc_variance16x32_sse4_1, 8),
205 TestFuncs(aom_highbd_obmc_variance16x16_c,
206 aom_highbd_obmc_variance16x16_sse4_1, 8),
207 TestFuncs(aom_highbd_obmc_variance16x8_c, aom_highbd_obmc_variance16x8_sse4_1,
clang-format3a826f12016-08-11 17:46:05 -0700208 8),
Yaowu Xuf883b422016-08-30 14:01:10 -0700209 TestFuncs(aom_highbd_obmc_variance8x16_c, aom_highbd_obmc_variance8x16_sse4_1,
clang-format3a826f12016-08-11 17:46:05 -0700210 8),
Yaowu Xuf883b422016-08-30 14:01:10 -0700211 TestFuncs(aom_highbd_obmc_variance8x8_c, aom_highbd_obmc_variance8x8_sse4_1,
clang-format3a826f12016-08-11 17:46:05 -0700212 8),
Yaowu Xuf883b422016-08-30 14:01:10 -0700213 TestFuncs(aom_highbd_obmc_variance8x4_c, aom_highbd_obmc_variance8x4_sse4_1,
clang-format3a826f12016-08-11 17:46:05 -0700214 8),
Yaowu Xuf883b422016-08-30 14:01:10 -0700215 TestFuncs(aom_highbd_obmc_variance4x8_c, aom_highbd_obmc_variance4x8_sse4_1,
clang-format3a826f12016-08-11 17:46:05 -0700216 8),
Yaowu Xuf883b422016-08-30 14:01:10 -0700217 TestFuncs(aom_highbd_obmc_variance4x4_c, aom_highbd_obmc_variance4x4_sse4_1,
clang-format3a826f12016-08-11 17:46:05 -0700218 8),
Geza Loreebc2d342016-07-12 11:41:54 +0100219#if CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700220 TestFuncs(aom_highbd_10_obmc_variance128x128_c,
221 aom_highbd_10_obmc_variance128x128_sse4_1, 10),
222 TestFuncs(aom_highbd_10_obmc_variance128x64_c,
223 aom_highbd_10_obmc_variance128x64_sse4_1, 10),
224 TestFuncs(aom_highbd_10_obmc_variance64x128_c,
225 aom_highbd_10_obmc_variance64x128_sse4_1, 10),
Geza Loreebc2d342016-07-12 11:41:54 +0100226#endif // CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700227 TestFuncs(aom_highbd_10_obmc_variance64x64_c,
228 aom_highbd_10_obmc_variance64x64_sse4_1, 10),
229 TestFuncs(aom_highbd_10_obmc_variance64x32_c,
230 aom_highbd_10_obmc_variance64x32_sse4_1, 10),
231 TestFuncs(aom_highbd_10_obmc_variance32x64_c,
232 aom_highbd_10_obmc_variance32x64_sse4_1, 10),
233 TestFuncs(aom_highbd_10_obmc_variance32x32_c,
234 aom_highbd_10_obmc_variance32x32_sse4_1, 10),
235 TestFuncs(aom_highbd_10_obmc_variance32x16_c,
236 aom_highbd_10_obmc_variance32x16_sse4_1, 10),
237 TestFuncs(aom_highbd_10_obmc_variance16x32_c,
238 aom_highbd_10_obmc_variance16x32_sse4_1, 10),
239 TestFuncs(aom_highbd_10_obmc_variance16x16_c,
240 aom_highbd_10_obmc_variance16x16_sse4_1, 10),
241 TestFuncs(aom_highbd_10_obmc_variance16x8_c,
242 aom_highbd_10_obmc_variance16x8_sse4_1, 10),
243 TestFuncs(aom_highbd_10_obmc_variance8x16_c,
244 aom_highbd_10_obmc_variance8x16_sse4_1, 10),
245 TestFuncs(aom_highbd_10_obmc_variance8x8_c,
246 aom_highbd_10_obmc_variance8x8_sse4_1, 10),
247 TestFuncs(aom_highbd_10_obmc_variance8x4_c,
248 aom_highbd_10_obmc_variance8x4_sse4_1, 10),
249 TestFuncs(aom_highbd_10_obmc_variance4x8_c,
250 aom_highbd_10_obmc_variance4x8_sse4_1, 10),
251 TestFuncs(aom_highbd_10_obmc_variance4x4_c,
252 aom_highbd_10_obmc_variance4x4_sse4_1, 10),
Geza Loreebc2d342016-07-12 11:41:54 +0100253#if CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700254 TestFuncs(aom_highbd_12_obmc_variance128x128_c,
255 aom_highbd_12_obmc_variance128x128_sse4_1, 12),
256 TestFuncs(aom_highbd_12_obmc_variance128x64_c,
257 aom_highbd_12_obmc_variance128x64_sse4_1, 12),
258 TestFuncs(aom_highbd_12_obmc_variance64x128_c,
259 aom_highbd_12_obmc_variance64x128_sse4_1, 12),
Geza Loreebc2d342016-07-12 11:41:54 +0100260#endif // CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700261 TestFuncs(aom_highbd_12_obmc_variance64x64_c,
262 aom_highbd_12_obmc_variance64x64_sse4_1, 12),
263 TestFuncs(aom_highbd_12_obmc_variance64x32_c,
264 aom_highbd_12_obmc_variance64x32_sse4_1, 12),
265 TestFuncs(aom_highbd_12_obmc_variance32x64_c,
266 aom_highbd_12_obmc_variance32x64_sse4_1, 12),
267 TestFuncs(aom_highbd_12_obmc_variance32x32_c,
268 aom_highbd_12_obmc_variance32x32_sse4_1, 12),
269 TestFuncs(aom_highbd_12_obmc_variance32x16_c,
270 aom_highbd_12_obmc_variance32x16_sse4_1, 12),
271 TestFuncs(aom_highbd_12_obmc_variance16x32_c,
272 aom_highbd_12_obmc_variance16x32_sse4_1, 12),
273 TestFuncs(aom_highbd_12_obmc_variance16x16_c,
274 aom_highbd_12_obmc_variance16x16_sse4_1, 12),
275 TestFuncs(aom_highbd_12_obmc_variance16x8_c,
276 aom_highbd_12_obmc_variance16x8_sse4_1, 12),
277 TestFuncs(aom_highbd_12_obmc_variance8x16_c,
278 aom_highbd_12_obmc_variance8x16_sse4_1, 12),
279 TestFuncs(aom_highbd_12_obmc_variance8x8_c,
280 aom_highbd_12_obmc_variance8x8_sse4_1, 12),
281 TestFuncs(aom_highbd_12_obmc_variance8x4_c,
282 aom_highbd_12_obmc_variance8x4_sse4_1, 12),
283 TestFuncs(aom_highbd_12_obmc_variance4x8_c,
284 aom_highbd_12_obmc_variance4x8_sse4_1, 12),
285 TestFuncs(aom_highbd_12_obmc_variance4x4_c,
286 aom_highbd_12_obmc_variance4x4_sse4_1, 12)
Geza Loreebc2d342016-07-12 11:41:54 +0100287};
288
289INSTANTIATE_TEST_CASE_P(SSE4_1_C_COMPARE, ObmcVarianceHBDTest,
290 ::testing::ValuesIn(sse4_functions_hbd));
291#endif // HAVE_SSE4_1
Yaowu Xuf883b422016-08-30 14:01:10 -0700292#endif // CONFIG_AOM_HIGHBITDEPTH
Geza Loreebc2d342016-07-12 11:41:54 +0100293} // namespace