blob: 52b9fc0b8d8b8aac086a90c0750334964e0e329a [file] [log] [blame]
Geza Lore2791d9d2016-06-21 20:29:21 +01001/*
Yaowu Xubde4ac82016-11-28 15:26:06 -08002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Geza Lore2791d9d2016-06-21 20:29:21 +01003 *
Yaowu Xubde4ac82016-11-28 15:26:06 -08004 * 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 Lore2791d9d2016-06-21 20:29:21 +010010 */
11
12#include "third_party/googletest/src/include/gtest/gtest.h"
13
Yaowu Xuf883b422016-08-30 14:01:10 -070014#include "./aom_config.h"
Geza Lore2791d9d2016-06-21 20:29:21 +010015
Yaowu Xuf883b422016-08-30 14:01:10 -070016#include "./aom_dsp_rtcd.h"
17#include "./av1_rtcd.h"
Geza Lore2791d9d2016-06-21 20:29:21 +010018
Yaowu Xuf883b422016-08-30 14:01:10 -070019#include "aom_dsp/aom_dsp_common.h"
Geza Lore2791d9d2016-06-21 20:29:21 +010020
Yaowu Xuc27fc142016-08-22 16:08:15 -070021#include "av1/common/enums.h"
Geza Lore2791d9d2016-06-21 20:29:21 +010022
23#include "test/acm_random.h"
24#include "test/function_equivalence_test.h"
Geza Lorea3f7ddc2016-07-12 15:26:36 +010025#include "test/register_state_check.h"
Geza Lore2791d9d2016-06-21 20:29:21 +010026
27#define WEDGE_WEIGHT_BITS 6
clang-format3a826f12016-08-11 17:46:05 -070028#define MAX_MASK_VALUE (1 << (WEDGE_WEIGHT_BITS))
Geza Lore2791d9d2016-06-21 20:29:21 +010029
Yaowu Xuc27fc142016-08-22 16:08:15 -070030using libaom_test::ACMRandom;
31using libaom_test::FunctionEquivalenceTest;
Geza Lore2791d9d2016-06-21 20:29:21 +010032
33namespace {
34
35static const int16_t kInt13Max = (1 << 12) - 1;
36
37//////////////////////////////////////////////////////////////////////////////
Yaowu Xuf883b422016-08-30 14:01:10 -070038// av1_wedge_sse_from_residuals - functionality
Geza Lore2791d9d2016-06-21 20:29:21 +010039//////////////////////////////////////////////////////////////////////////////
40
41class WedgeUtilsSSEFuncTest : public testing::Test {
42 protected:
43 WedgeUtilsSSEFuncTest() : rng_(ACMRandom::DeterministicSeed()) {}
44
45 static const int kIterations = 1000;
46
47 ACMRandom rng_;
48};
49
clang-format3a826f12016-08-11 17:46:05 -070050static void equiv_blend_residuals(int16_t *r, const int16_t *r0,
51 const int16_t *r1, const uint8_t *m, int N) {
52 for (int i = 0; i < N; i++) {
Geza Lore2791d9d2016-06-21 20:29:21 +010053 const int32_t m0 = m[i];
54 const int32_t m1 = MAX_MASK_VALUE - m0;
55 const int16_t R = m0 * r0[i] + m1 * r1[i];
56 // Note that this rounding is designed to match the result
57 // you would get when actually blending the 2 predictors and computing
58 // the residuals.
59 r[i] = ROUND_POWER_OF_TWO(R - 1, WEDGE_WEIGHT_BITS);
60 }
61}
62
clang-format3a826f12016-08-11 17:46:05 -070063static uint64_t equiv_sse_from_residuals(const int16_t *r0, const int16_t *r1,
64 const uint8_t *m, int N) {
Geza Lore2791d9d2016-06-21 20:29:21 +010065 uint64_t acc = 0;
clang-format3a826f12016-08-11 17:46:05 -070066 for (int i = 0; i < N; i++) {
Geza Lore2791d9d2016-06-21 20:29:21 +010067 const int32_t m0 = m[i];
68 const int32_t m1 = MAX_MASK_VALUE - m0;
69 const int16_t R = m0 * r0[i] + m1 * r1[i];
70 const int32_t r = ROUND_POWER_OF_TWO(R - 1, WEDGE_WEIGHT_BITS);
71 acc += r * r;
72 }
73 return acc;
74}
75
76TEST_F(WedgeUtilsSSEFuncTest, ResidualBlendingEquiv) {
77 DECLARE_ALIGNED(32, uint8_t, s[MAX_SB_SQUARE]);
78 DECLARE_ALIGNED(32, uint8_t, p0[MAX_SB_SQUARE]);
79 DECLARE_ALIGNED(32, uint8_t, p1[MAX_SB_SQUARE]);
80 DECLARE_ALIGNED(32, uint8_t, p[MAX_SB_SQUARE]);
81
82 DECLARE_ALIGNED(32, int16_t, r0[MAX_SB_SQUARE]);
83 DECLARE_ALIGNED(32, int16_t, r1[MAX_SB_SQUARE]);
84 DECLARE_ALIGNED(32, int16_t, r_ref[MAX_SB_SQUARE]);
85 DECLARE_ALIGNED(32, int16_t, r_tst[MAX_SB_SQUARE]);
86 DECLARE_ALIGNED(32, uint8_t, m[MAX_SB_SQUARE]);
87
clang-format3a826f12016-08-11 17:46:05 -070088 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
89 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Geza Lore2791d9d2016-06-21 20:29:21 +010090 s[i] = rng_.Rand8();
91 m[i] = rng_(MAX_MASK_VALUE + 1);
92 }
93
94 const int w = 1 << (rng_(MAX_SB_SIZE_LOG2 + 1 - 3) + 3);
95 const int h = 1 << (rng_(MAX_SB_SIZE_LOG2 + 1 - 3) + 3);
96 const int N = w * h;
97
clang-format3a826f12016-08-11 17:46:05 -070098 for (int j = 0; j < N; j++) {
Geza Lore2791d9d2016-06-21 20:29:21 +010099 p0[j] = clamp(s[j] + rng_(33) - 16, 0, UINT8_MAX);
100 p1[j] = clamp(s[j] + rng_(33) - 16, 0, UINT8_MAX);
101 }
102
Yaowu Xuf883b422016-08-30 14:01:10 -0700103 aom_blend_a64_mask(p, w, p0, w, p1, w, m, w, h, w, 0, 0);
Geza Lore2791d9d2016-06-21 20:29:21 +0100104
Yaowu Xuf883b422016-08-30 14:01:10 -0700105 aom_subtract_block(h, w, r0, w, s, w, p0, w);
106 aom_subtract_block(h, w, r1, w, s, w, p1, w);
Geza Lore2791d9d2016-06-21 20:29:21 +0100107
Yaowu Xuf883b422016-08-30 14:01:10 -0700108 aom_subtract_block(h, w, r_ref, w, s, w, p, w);
Geza Lore2791d9d2016-06-21 20:29:21 +0100109 equiv_blend_residuals(r_tst, r0, r1, m, N);
110
clang-format3a826f12016-08-11 17:46:05 -0700111 for (int i = 0; i < N; ++i) ASSERT_EQ(r_ref[i], r_tst[i]);
Geza Lore2791d9d2016-06-21 20:29:21 +0100112
Yaowu Xuf883b422016-08-30 14:01:10 -0700113 uint64_t ref_sse = aom_sum_squares_i16(r_ref, N);
Geza Lore2791d9d2016-06-21 20:29:21 +0100114 uint64_t tst_sse = equiv_sse_from_residuals(r0, r1, m, N);
115
116 ASSERT_EQ(ref_sse, tst_sse);
117 }
118}
119
clang-format3a826f12016-08-11 17:46:05 -0700120static uint64_t sse_from_residuals(const int16_t *r0, const int16_t *r1,
121 const uint8_t *m, int N) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100122 uint64_t acc = 0;
clang-format3a826f12016-08-11 17:46:05 -0700123 for (int i = 0; i < N; i++) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100124 const int32_t m0 = m[i];
125 const int32_t m1 = MAX_MASK_VALUE - m0;
126 const int32_t r = m0 * r0[i] + m1 * r1[i];
127 acc += r * r;
128 }
129 return ROUND_POWER_OF_TWO(acc, 2 * WEDGE_WEIGHT_BITS);
130}
131
132TEST_F(WedgeUtilsSSEFuncTest, ResidualBlendingMethod) {
133 DECLARE_ALIGNED(32, int16_t, r0[MAX_SB_SQUARE]);
134 DECLARE_ALIGNED(32, int16_t, r1[MAX_SB_SQUARE]);
135 DECLARE_ALIGNED(32, int16_t, d[MAX_SB_SQUARE]);
136 DECLARE_ALIGNED(32, uint8_t, m[MAX_SB_SQUARE]);
137
clang-format3a826f12016-08-11 17:46:05 -0700138 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
139 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100140 r1[i] = rng_(2 * INT8_MAX - 2 * INT8_MIN + 1) + 2 * INT8_MIN;
141 d[i] = rng_(2 * INT8_MAX - 2 * INT8_MIN + 1) + 2 * INT8_MIN;
142 m[i] = rng_(MAX_MASK_VALUE + 1);
143 }
144
clang-format3a826f12016-08-11 17:46:05 -0700145 const int N = 64 * (rng_(MAX_SB_SQUARE / 64) + 1);
Geza Lore2791d9d2016-06-21 20:29:21 +0100146
clang-format3a826f12016-08-11 17:46:05 -0700147 for (int i = 0; i < N; i++) r0[i] = r1[i] + d[i];
Geza Lore2791d9d2016-06-21 20:29:21 +0100148
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100149 const uint64_t ref_res = sse_from_residuals(r0, r1, m, N);
Yaowu Xuf883b422016-08-30 14:01:10 -0700150 const uint64_t tst_res = av1_wedge_sse_from_residuals(r1, d, m, N);
Geza Lore2791d9d2016-06-21 20:29:21 +0100151
152 ASSERT_EQ(ref_res, tst_res);
153 }
154}
155
156//////////////////////////////////////////////////////////////////////////////
Yaowu Xuf883b422016-08-30 14:01:10 -0700157// av1_wedge_sse_from_residuals - optimizations
Geza Lore2791d9d2016-06-21 20:29:21 +0100158//////////////////////////////////////////////////////////////////////////////
159
clang-format3a826f12016-08-11 17:46:05 -0700160typedef uint64_t (*FSSE)(const int16_t *r1, const int16_t *d, const uint8_t *m,
Geza Lore2791d9d2016-06-21 20:29:21 +0100161 int N);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700162typedef libaom_test::FuncParam<FSSE> TestFuncsFSSE;
Geza Lore2791d9d2016-06-21 20:29:21 +0100163
164class WedgeUtilsSSEOptTest : public FunctionEquivalenceTest<FSSE> {
165 protected:
Geza Lore2791d9d2016-06-21 20:29:21 +0100166 static const int kIterations = 10000;
Geza Lore2791d9d2016-06-21 20:29:21 +0100167};
168
169TEST_P(WedgeUtilsSSEOptTest, RandomValues) {
170 DECLARE_ALIGNED(32, int16_t, r1[MAX_SB_SQUARE]);
171 DECLARE_ALIGNED(32, int16_t, d[MAX_SB_SQUARE]);
172 DECLARE_ALIGNED(32, uint8_t, m[MAX_SB_SQUARE]);
173
clang-format3a826f12016-08-11 17:46:05 -0700174 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
175 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100176 r1[i] = rng_(2 * kInt13Max + 1) - kInt13Max;
177 d[i] = rng_(2 * kInt13Max + 1) - kInt13Max;
178 m[i] = rng_(MAX_MASK_VALUE + 1);
179 }
180
clang-format3a826f12016-08-11 17:46:05 -0700181 const int N = 64 * (rng_(MAX_SB_SQUARE / 64) + 1);
Geza Lore2791d9d2016-06-21 20:29:21 +0100182
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100183 const uint64_t ref_res = params_.ref_func(r1, d, m, N);
184 uint64_t tst_res;
185 ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(r1, d, m, N));
Geza Lore2791d9d2016-06-21 20:29:21 +0100186
187 ASSERT_EQ(ref_res, tst_res);
188 }
189}
190
191TEST_P(WedgeUtilsSSEOptTest, ExtremeValues) {
192 DECLARE_ALIGNED(32, int16_t, r1[MAX_SB_SQUARE]);
193 DECLARE_ALIGNED(32, int16_t, d[MAX_SB_SQUARE]);
194 DECLARE_ALIGNED(32, uint8_t, m[MAX_SB_SQUARE]);
195
clang-format3a826f12016-08-11 17:46:05 -0700196 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100197 if (rng_(2)) {
clang-format3a826f12016-08-11 17:46:05 -0700198 for (int i = 0; i < MAX_SB_SQUARE; ++i) r1[i] = kInt13Max;
Geza Lore2791d9d2016-06-21 20:29:21 +0100199 } else {
clang-format3a826f12016-08-11 17:46:05 -0700200 for (int i = 0; i < MAX_SB_SQUARE; ++i) r1[i] = -kInt13Max;
Geza Lore2791d9d2016-06-21 20:29:21 +0100201 }
202
203 if (rng_(2)) {
clang-format3a826f12016-08-11 17:46:05 -0700204 for (int i = 0; i < MAX_SB_SQUARE; ++i) d[i] = kInt13Max;
Geza Lore2791d9d2016-06-21 20:29:21 +0100205 } else {
clang-format3a826f12016-08-11 17:46:05 -0700206 for (int i = 0; i < MAX_SB_SQUARE; ++i) d[i] = -kInt13Max;
Geza Lore2791d9d2016-06-21 20:29:21 +0100207 }
208
clang-format3a826f12016-08-11 17:46:05 -0700209 for (int i = 0; i < MAX_SB_SQUARE; ++i) m[i] = MAX_MASK_VALUE;
Geza Lore2791d9d2016-06-21 20:29:21 +0100210
clang-format3a826f12016-08-11 17:46:05 -0700211 const int N = 64 * (rng_(MAX_SB_SQUARE / 64) + 1);
Geza Lore2791d9d2016-06-21 20:29:21 +0100212
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100213 const uint64_t ref_res = params_.ref_func(r1, d, m, N);
214 uint64_t tst_res;
215 ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(r1, d, m, N));
Geza Lore2791d9d2016-06-21 20:29:21 +0100216
217 ASSERT_EQ(ref_res, tst_res);
218 }
219}
220
221#if HAVE_SSE2
222INSTANTIATE_TEST_CASE_P(
223 SSE2, WedgeUtilsSSEOptTest,
Yaowu Xuf883b422016-08-30 14:01:10 -0700224 ::testing::Values(TestFuncsFSSE(av1_wedge_sse_from_residuals_c,
225 av1_wedge_sse_from_residuals_sse2)));
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100226
Geza Lore2791d9d2016-06-21 20:29:21 +0100227#endif // HAVE_SSE2
228
229//////////////////////////////////////////////////////////////////////////////
Yaowu Xuf883b422016-08-30 14:01:10 -0700230// av1_wedge_sign_from_residuals
Geza Lore2791d9d2016-06-21 20:29:21 +0100231//////////////////////////////////////////////////////////////////////////////
232
clang-format3a826f12016-08-11 17:46:05 -0700233typedef int (*FSign)(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700234typedef libaom_test::FuncParam<FSign> TestFuncsFSign;
Geza Lore2791d9d2016-06-21 20:29:21 +0100235
236class WedgeUtilsSignOptTest : public FunctionEquivalenceTest<FSign> {
237 protected:
Geza Lore2791d9d2016-06-21 20:29:21 +0100238 static const int kIterations = 10000;
239 static const int kMaxSize = 8196; // Size limited by SIMD implementation.
Geza Lore2791d9d2016-06-21 20:29:21 +0100240};
241
242TEST_P(WedgeUtilsSignOptTest, RandomValues) {
243 DECLARE_ALIGNED(32, int16_t, r0[MAX_SB_SQUARE]);
244 DECLARE_ALIGNED(32, int16_t, r1[MAX_SB_SQUARE]);
245 DECLARE_ALIGNED(32, int16_t, ds[MAX_SB_SQUARE]);
246 DECLARE_ALIGNED(32, uint8_t, m[MAX_SB_SQUARE]);
247
clang-format3a826f12016-08-11 17:46:05 -0700248 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
249 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100250 r0[i] = rng_(2 * kInt13Max + 1) - kInt13Max;
251 r1[i] = rng_(2 * kInt13Max + 1) - kInt13Max;
252 m[i] = rng_(MAX_MASK_VALUE + 1);
253 }
254
Yaowu Xuf883b422016-08-30 14:01:10 -0700255 const int maxN = AOMMIN(kMaxSize, MAX_SB_SQUARE);
clang-format3a826f12016-08-11 17:46:05 -0700256 const int N = 64 * (rng_(maxN / 64 - 1) + 1);
Geza Lore2791d9d2016-06-21 20:29:21 +0100257
258 int64_t limit;
Yaowu Xuf883b422016-08-30 14:01:10 -0700259 limit = (int64_t)aom_sum_squares_i16(r0, N);
260 limit -= (int64_t)aom_sum_squares_i16(r1, N);
Geza Lore2791d9d2016-06-21 20:29:21 +0100261 limit *= (1 << WEDGE_WEIGHT_BITS) / 2;
262
clang-format3a826f12016-08-11 17:46:05 -0700263 for (int i = 0; i < N; i++)
264 ds[i] = clamp(r0[i] * r0[i] - r1[i] * r1[i], INT16_MIN, INT16_MAX);
Geza Lore2791d9d2016-06-21 20:29:21 +0100265
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100266 const int ref_res = params_.ref_func(ds, m, N, limit);
267 int tst_res;
268 ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(ds, m, N, limit));
Geza Lore2791d9d2016-06-21 20:29:21 +0100269
270 ASSERT_EQ(ref_res, tst_res);
271 }
272}
273
274TEST_P(WedgeUtilsSignOptTest, ExtremeValues) {
275 DECLARE_ALIGNED(32, int16_t, r0[MAX_SB_SQUARE]);
276 DECLARE_ALIGNED(32, int16_t, r1[MAX_SB_SQUARE]);
277 DECLARE_ALIGNED(32, int16_t, ds[MAX_SB_SQUARE]);
278 DECLARE_ALIGNED(32, uint8_t, m[MAX_SB_SQUARE]);
279
clang-format3a826f12016-08-11 17:46:05 -0700280 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100281 switch (rng_(4)) {
clang-format3a826f12016-08-11 17:46:05 -0700282 case 0:
283 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
284 r0[i] = 0;
285 r1[i] = kInt13Max;
286 }
287 break;
288 case 1:
289 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
290 r0[i] = kInt13Max;
291 r1[i] = 0;
292 }
293 break;
294 case 2:
295 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
296 r0[i] = 0;
297 r1[i] = -kInt13Max;
298 }
299 break;
300 default:
301 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
302 r0[i] = -kInt13Max;
303 r1[i] = 0;
304 }
305 break;
Geza Lore2791d9d2016-06-21 20:29:21 +0100306 }
307
clang-format3a826f12016-08-11 17:46:05 -0700308 for (int i = 0; i < MAX_SB_SQUARE; ++i) m[i] = MAX_MASK_VALUE;
Geza Lore2791d9d2016-06-21 20:29:21 +0100309
Yaowu Xuf883b422016-08-30 14:01:10 -0700310 const int maxN = AOMMIN(kMaxSize, MAX_SB_SQUARE);
clang-format3a826f12016-08-11 17:46:05 -0700311 const int N = 64 * (rng_(maxN / 64 - 1) + 1);
Geza Lore2791d9d2016-06-21 20:29:21 +0100312
313 int64_t limit;
Yaowu Xuf883b422016-08-30 14:01:10 -0700314 limit = (int64_t)aom_sum_squares_i16(r0, N);
315 limit -= (int64_t)aom_sum_squares_i16(r1, N);
Geza Lore2791d9d2016-06-21 20:29:21 +0100316 limit *= (1 << WEDGE_WEIGHT_BITS) / 2;
317
clang-format3a826f12016-08-11 17:46:05 -0700318 for (int i = 0; i < N; i++)
319 ds[i] = clamp(r0[i] * r0[i] - r1[i] * r1[i], INT16_MIN, INT16_MAX);
Geza Lore2791d9d2016-06-21 20:29:21 +0100320
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100321 const int ref_res = params_.ref_func(ds, m, N, limit);
322 int tst_res;
323 ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(ds, m, N, limit));
Geza Lore2791d9d2016-06-21 20:29:21 +0100324
325 ASSERT_EQ(ref_res, tst_res);
326 }
327}
328
329#if HAVE_SSE2
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100330
Geza Lore2791d9d2016-06-21 20:29:21 +0100331INSTANTIATE_TEST_CASE_P(
332 SSE2, WedgeUtilsSignOptTest,
Yaowu Xuf883b422016-08-30 14:01:10 -0700333 ::testing::Values(TestFuncsFSign(av1_wedge_sign_from_residuals_c,
334 av1_wedge_sign_from_residuals_sse2)));
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100335
Geza Lore2791d9d2016-06-21 20:29:21 +0100336#endif // HAVE_SSE2
337
338//////////////////////////////////////////////////////////////////////////////
Yaowu Xuf883b422016-08-30 14:01:10 -0700339// av1_wedge_compute_delta_squares
Geza Lore2791d9d2016-06-21 20:29:21 +0100340//////////////////////////////////////////////////////////////////////////////
341
clang-format3a826f12016-08-11 17:46:05 -0700342typedef void (*FDS)(int16_t *d, const int16_t *a, const int16_t *b, int N);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700343typedef libaom_test::FuncParam<FDS> TestFuncsFDS;
Geza Lore2791d9d2016-06-21 20:29:21 +0100344
345class WedgeUtilsDeltaSquaresOptTest : public FunctionEquivalenceTest<FDS> {
346 protected:
Geza Lore2791d9d2016-06-21 20:29:21 +0100347 static const int kIterations = 10000;
Geza Lore2791d9d2016-06-21 20:29:21 +0100348};
349
350TEST_P(WedgeUtilsDeltaSquaresOptTest, RandomValues) {
351 DECLARE_ALIGNED(32, int16_t, a[MAX_SB_SQUARE]);
352 DECLARE_ALIGNED(32, int16_t, b[MAX_SB_SQUARE]);
353 DECLARE_ALIGNED(32, int16_t, d_ref[MAX_SB_SQUARE]);
354 DECLARE_ALIGNED(32, int16_t, d_tst[MAX_SB_SQUARE]);
355
clang-format3a826f12016-08-11 17:46:05 -0700356 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
357 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100358 a[i] = rng_.Rand16();
359 b[i] = rng_(2 * INT16_MAX + 1) - INT16_MAX;
360 }
361
clang-format3a826f12016-08-11 17:46:05 -0700362 const int N = 64 * (rng_(MAX_SB_SQUARE / 64) + 1);
Geza Lore2791d9d2016-06-21 20:29:21 +0100363
364 memset(&d_ref, INT16_MAX, sizeof(d_ref));
365 memset(&d_tst, INT16_MAX, sizeof(d_tst));
366
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100367 params_.ref_func(d_ref, a, b, N);
368 ASM_REGISTER_STATE_CHECK(params_.tst_func(d_tst, a, b, N));
Geza Lore2791d9d2016-06-21 20:29:21 +0100369
clang-format3a826f12016-08-11 17:46:05 -0700370 for (int i = 0; i < MAX_SB_SQUARE; ++i) ASSERT_EQ(d_ref[i], d_tst[i]);
Geza Lore2791d9d2016-06-21 20:29:21 +0100371 }
372}
373
374#if HAVE_SSE2
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100375
Geza Lore2791d9d2016-06-21 20:29:21 +0100376INSTANTIATE_TEST_CASE_P(
377 SSE2, WedgeUtilsDeltaSquaresOptTest,
Yaowu Xuf883b422016-08-30 14:01:10 -0700378 ::testing::Values(TestFuncsFDS(av1_wedge_compute_delta_squares_c,
379 av1_wedge_compute_delta_squares_sse2)));
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100380
Geza Lore2791d9d2016-06-21 20:29:21 +0100381#endif // HAVE_SSE2
382
383} // namespace