blob: 1b30645a52222133ffd1569e8fb1edac27bc5c29 [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
Tom Finegan7a07ece2017-02-07 17:14:05 -080012#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
Geza Loreebc2d342016-07-12 11:41:54 +010013#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
Tom Finegan29ba6752017-01-31 16:30:55 -080096#if CONFIG_MOTION_VAR
Geza Loreebc2d342016-07-12 11:41:54 +010097const ObmcVarianceTest::ParamType sse4_functions[] = {
98#if CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -070099 TestFuncs(aom_obmc_variance128x128_c, aom_obmc_variance128x128_sse4_1),
100 TestFuncs(aom_obmc_variance128x64_c, aom_obmc_variance128x64_sse4_1),
101 TestFuncs(aom_obmc_variance64x128_c, aom_obmc_variance64x128_sse4_1),
Geza Loreebc2d342016-07-12 11:41:54 +0100102#endif // CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700103 TestFuncs(aom_obmc_variance64x64_c, aom_obmc_variance64x64_sse4_1),
104 TestFuncs(aom_obmc_variance64x32_c, aom_obmc_variance64x32_sse4_1),
105 TestFuncs(aom_obmc_variance32x64_c, aom_obmc_variance32x64_sse4_1),
106 TestFuncs(aom_obmc_variance32x32_c, aom_obmc_variance32x32_sse4_1),
107 TestFuncs(aom_obmc_variance32x16_c, aom_obmc_variance32x16_sse4_1),
108 TestFuncs(aom_obmc_variance16x32_c, aom_obmc_variance16x32_sse4_1),
109 TestFuncs(aom_obmc_variance16x16_c, aom_obmc_variance16x16_sse4_1),
110 TestFuncs(aom_obmc_variance16x8_c, aom_obmc_variance16x8_sse4_1),
111 TestFuncs(aom_obmc_variance8x16_c, aom_obmc_variance8x16_sse4_1),
112 TestFuncs(aom_obmc_variance8x8_c, aom_obmc_variance8x8_sse4_1),
113 TestFuncs(aom_obmc_variance8x4_c, aom_obmc_variance8x4_sse4_1),
114 TestFuncs(aom_obmc_variance4x8_c, aom_obmc_variance4x8_sse4_1),
115 TestFuncs(aom_obmc_variance4x4_c, aom_obmc_variance4x4_sse4_1)
Geza Loreebc2d342016-07-12 11:41:54 +0100116};
117
Yaowu Xu685039d2016-12-07 10:56:39 -0800118INSTANTIATE_TEST_CASE_P(SSE4_1, ObmcVarianceTest,
Geza Loreebc2d342016-07-12 11:41:54 +0100119 ::testing::ValuesIn(sse4_functions));
Tom Finegan29ba6752017-01-31 16:30:55 -0800120#endif // CONFIG_MOTION_VAR
Geza Loreebc2d342016-07-12 11:41:54 +0100121#endif // HAVE_SSE4_1
122
123////////////////////////////////////////////////////////////////////////////////
124// High bit-depth
125////////////////////////////////////////////////////////////////////////////////
126
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200127#if CONFIG_HIGHBITDEPTH
Jingning Hana387b192016-07-14 10:11:32 -0700128class ObmcVarianceHBDTest : public FunctionEquivalenceTest<ObmcVarF> {};
Geza Loreebc2d342016-07-12 11:41:54 +0100129
130TEST_P(ObmcVarianceHBDTest, RandomValues) {
131 DECLARE_ALIGNED(32, uint16_t, pre[MAX_SB_SQUARE]);
132 DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
133 DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
134
clang-format3a826f12016-08-11 17:46:05 -0700135 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
Geza Loreebc2d342016-07-12 11:41:54 +0100136 const int pre_stride = this->rng_(MAX_SB_SIZE + 1);
137
clang-format3a826f12016-08-11 17:46:05 -0700138 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Jingning Hana387b192016-07-14 10:11:32 -0700139 pre[i] = this->rng_(1 << params_.bit_depth);
140 wsrc[i] = this->rng_(1 << params_.bit_depth) *
Geza Loreebc2d342016-07-12 11:41:54 +0100141 this->rng_(kMaskMax * kMaskMax + 1);
142 mask[i] = this->rng_(kMaskMax * kMaskMax + 1);
143 }
144
145 unsigned int ref_sse, tst_sse;
clang-format3a826f12016-08-11 17:46:05 -0700146 const unsigned int ref_res = params_.ref_func(
147 CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask, &ref_sse);
Geza Loreebc2d342016-07-12 11:41:54 +0100148 unsigned int tst_res;
clang-format3a826f12016-08-11 17:46:05 -0700149 ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(CONVERT_TO_BYTEPTR(pre),
150 pre_stride, wsrc, mask,
151 &tst_sse));
Geza Loreebc2d342016-07-12 11:41:54 +0100152
153 ASSERT_EQ(ref_res, tst_res);
154 ASSERT_EQ(ref_sse, tst_sse);
155 }
156}
157
158TEST_P(ObmcVarianceHBDTest, ExtremeValues) {
159 DECLARE_ALIGNED(32, uint16_t, pre[MAX_SB_SQUARE]);
160 DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
161 DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
162
clang-format3a826f12016-08-11 17:46:05 -0700163 for (int iter = 0; iter < MAX_SB_SIZE && !HasFatalFailure(); ++iter) {
Geza Loreebc2d342016-07-12 11:41:54 +0100164 const int pre_stride = iter;
165
clang-format3a826f12016-08-11 17:46:05 -0700166 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Jingning Hana387b192016-07-14 10:11:32 -0700167 pre[i] = (1 << params_.bit_depth) - 1;
168 wsrc[i] = ((1 << params_.bit_depth) - 1) * kMaskMax * kMaskMax;
Geza Loreebc2d342016-07-12 11:41:54 +0100169 mask[i] = kMaskMax * kMaskMax;
170 }
171
172 unsigned int ref_sse, tst_sse;
clang-format3a826f12016-08-11 17:46:05 -0700173 const unsigned int ref_res = params_.ref_func(
174 CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask, &ref_sse);
Geza Loreebc2d342016-07-12 11:41:54 +0100175 unsigned int tst_res;
clang-format3a826f12016-08-11 17:46:05 -0700176 ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(CONVERT_TO_BYTEPTR(pre),
177 pre_stride, wsrc, mask,
178 &tst_sse));
Geza Loreebc2d342016-07-12 11:41:54 +0100179
180 ASSERT_EQ(ref_res, tst_res);
181 ASSERT_EQ(ref_sse, tst_sse);
182 }
183}
184
185#if HAVE_SSE4_1
Tom Finegance4bceb2017-02-03 11:02:53 -0800186#if CONFIG_MOTION_VAR
Geza Loreebc2d342016-07-12 11:41:54 +0100187ObmcVarianceHBDTest::ParamType sse4_functions_hbd[] = {
188#if CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700189 TestFuncs(aom_highbd_obmc_variance128x128_c,
190 aom_highbd_obmc_variance128x128_sse4_1, 8),
191 TestFuncs(aom_highbd_obmc_variance128x64_c,
192 aom_highbd_obmc_variance128x64_sse4_1, 8),
193 TestFuncs(aom_highbd_obmc_variance64x128_c,
194 aom_highbd_obmc_variance64x128_sse4_1, 8),
Geza Loreebc2d342016-07-12 11:41:54 +0100195#endif // CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700196 TestFuncs(aom_highbd_obmc_variance64x64_c,
197 aom_highbd_obmc_variance64x64_sse4_1, 8),
198 TestFuncs(aom_highbd_obmc_variance64x32_c,
199 aom_highbd_obmc_variance64x32_sse4_1, 8),
200 TestFuncs(aom_highbd_obmc_variance32x64_c,
201 aom_highbd_obmc_variance32x64_sse4_1, 8),
202 TestFuncs(aom_highbd_obmc_variance32x32_c,
203 aom_highbd_obmc_variance32x32_sse4_1, 8),
204 TestFuncs(aom_highbd_obmc_variance32x16_c,
205 aom_highbd_obmc_variance32x16_sse4_1, 8),
206 TestFuncs(aom_highbd_obmc_variance16x32_c,
207 aom_highbd_obmc_variance16x32_sse4_1, 8),
208 TestFuncs(aom_highbd_obmc_variance16x16_c,
209 aom_highbd_obmc_variance16x16_sse4_1, 8),
210 TestFuncs(aom_highbd_obmc_variance16x8_c, aom_highbd_obmc_variance16x8_sse4_1,
clang-format3a826f12016-08-11 17:46:05 -0700211 8),
Yaowu Xuf883b422016-08-30 14:01:10 -0700212 TestFuncs(aom_highbd_obmc_variance8x16_c, aom_highbd_obmc_variance8x16_sse4_1,
clang-format3a826f12016-08-11 17:46:05 -0700213 8),
Yaowu Xuf883b422016-08-30 14:01:10 -0700214 TestFuncs(aom_highbd_obmc_variance8x8_c, aom_highbd_obmc_variance8x8_sse4_1,
clang-format3a826f12016-08-11 17:46:05 -0700215 8),
Yaowu Xuf883b422016-08-30 14:01:10 -0700216 TestFuncs(aom_highbd_obmc_variance8x4_c, aom_highbd_obmc_variance8x4_sse4_1,
clang-format3a826f12016-08-11 17:46:05 -0700217 8),
Yaowu Xuf883b422016-08-30 14:01:10 -0700218 TestFuncs(aom_highbd_obmc_variance4x8_c, aom_highbd_obmc_variance4x8_sse4_1,
clang-format3a826f12016-08-11 17:46:05 -0700219 8),
Yaowu Xuf883b422016-08-30 14:01:10 -0700220 TestFuncs(aom_highbd_obmc_variance4x4_c, aom_highbd_obmc_variance4x4_sse4_1,
clang-format3a826f12016-08-11 17:46:05 -0700221 8),
Geza Loreebc2d342016-07-12 11:41:54 +0100222#if CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700223 TestFuncs(aom_highbd_10_obmc_variance128x128_c,
224 aom_highbd_10_obmc_variance128x128_sse4_1, 10),
225 TestFuncs(aom_highbd_10_obmc_variance128x64_c,
226 aom_highbd_10_obmc_variance128x64_sse4_1, 10),
227 TestFuncs(aom_highbd_10_obmc_variance64x128_c,
228 aom_highbd_10_obmc_variance64x128_sse4_1, 10),
Geza Loreebc2d342016-07-12 11:41:54 +0100229#endif // CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700230 TestFuncs(aom_highbd_10_obmc_variance64x64_c,
231 aom_highbd_10_obmc_variance64x64_sse4_1, 10),
232 TestFuncs(aom_highbd_10_obmc_variance64x32_c,
233 aom_highbd_10_obmc_variance64x32_sse4_1, 10),
234 TestFuncs(aom_highbd_10_obmc_variance32x64_c,
235 aom_highbd_10_obmc_variance32x64_sse4_1, 10),
236 TestFuncs(aom_highbd_10_obmc_variance32x32_c,
237 aom_highbd_10_obmc_variance32x32_sse4_1, 10),
238 TestFuncs(aom_highbd_10_obmc_variance32x16_c,
239 aom_highbd_10_obmc_variance32x16_sse4_1, 10),
240 TestFuncs(aom_highbd_10_obmc_variance16x32_c,
241 aom_highbd_10_obmc_variance16x32_sse4_1, 10),
242 TestFuncs(aom_highbd_10_obmc_variance16x16_c,
243 aom_highbd_10_obmc_variance16x16_sse4_1, 10),
244 TestFuncs(aom_highbd_10_obmc_variance16x8_c,
245 aom_highbd_10_obmc_variance16x8_sse4_1, 10),
246 TestFuncs(aom_highbd_10_obmc_variance8x16_c,
247 aom_highbd_10_obmc_variance8x16_sse4_1, 10),
248 TestFuncs(aom_highbd_10_obmc_variance8x8_c,
249 aom_highbd_10_obmc_variance8x8_sse4_1, 10),
250 TestFuncs(aom_highbd_10_obmc_variance8x4_c,
251 aom_highbd_10_obmc_variance8x4_sse4_1, 10),
252 TestFuncs(aom_highbd_10_obmc_variance4x8_c,
253 aom_highbd_10_obmc_variance4x8_sse4_1, 10),
254 TestFuncs(aom_highbd_10_obmc_variance4x4_c,
255 aom_highbd_10_obmc_variance4x4_sse4_1, 10),
Geza Loreebc2d342016-07-12 11:41:54 +0100256#if CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700257 TestFuncs(aom_highbd_12_obmc_variance128x128_c,
258 aom_highbd_12_obmc_variance128x128_sse4_1, 12),
259 TestFuncs(aom_highbd_12_obmc_variance128x64_c,
260 aom_highbd_12_obmc_variance128x64_sse4_1, 12),
261 TestFuncs(aom_highbd_12_obmc_variance64x128_c,
262 aom_highbd_12_obmc_variance64x128_sse4_1, 12),
Geza Loreebc2d342016-07-12 11:41:54 +0100263#endif // CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -0700264 TestFuncs(aom_highbd_12_obmc_variance64x64_c,
265 aom_highbd_12_obmc_variance64x64_sse4_1, 12),
266 TestFuncs(aom_highbd_12_obmc_variance64x32_c,
267 aom_highbd_12_obmc_variance64x32_sse4_1, 12),
268 TestFuncs(aom_highbd_12_obmc_variance32x64_c,
269 aom_highbd_12_obmc_variance32x64_sse4_1, 12),
270 TestFuncs(aom_highbd_12_obmc_variance32x32_c,
271 aom_highbd_12_obmc_variance32x32_sse4_1, 12),
272 TestFuncs(aom_highbd_12_obmc_variance32x16_c,
273 aom_highbd_12_obmc_variance32x16_sse4_1, 12),
274 TestFuncs(aom_highbd_12_obmc_variance16x32_c,
275 aom_highbd_12_obmc_variance16x32_sse4_1, 12),
276 TestFuncs(aom_highbd_12_obmc_variance16x16_c,
277 aom_highbd_12_obmc_variance16x16_sse4_1, 12),
278 TestFuncs(aom_highbd_12_obmc_variance16x8_c,
279 aom_highbd_12_obmc_variance16x8_sse4_1, 12),
280 TestFuncs(aom_highbd_12_obmc_variance8x16_c,
281 aom_highbd_12_obmc_variance8x16_sse4_1, 12),
282 TestFuncs(aom_highbd_12_obmc_variance8x8_c,
283 aom_highbd_12_obmc_variance8x8_sse4_1, 12),
284 TestFuncs(aom_highbd_12_obmc_variance8x4_c,
285 aom_highbd_12_obmc_variance8x4_sse4_1, 12),
286 TestFuncs(aom_highbd_12_obmc_variance4x8_c,
287 aom_highbd_12_obmc_variance4x8_sse4_1, 12),
288 TestFuncs(aom_highbd_12_obmc_variance4x4_c,
289 aom_highbd_12_obmc_variance4x4_sse4_1, 12)
Geza Loreebc2d342016-07-12 11:41:54 +0100290};
291
Yaowu Xu685039d2016-12-07 10:56:39 -0800292INSTANTIATE_TEST_CASE_P(SSE4_1, ObmcVarianceHBDTest,
Geza Loreebc2d342016-07-12 11:41:54 +0100293 ::testing::ValuesIn(sse4_functions_hbd));
Tom Finegance4bceb2017-02-03 11:02:53 -0800294#endif // CONFIG_MOTION_VAR
Geza Loreebc2d342016-07-12 11:41:54 +0100295#endif // HAVE_SSE4_1
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200296#endif // CONFIG_HIGHBITDEPTH
Geza Loreebc2d342016-07-12 11:41:54 +0100297} // namespace