blob: 539e9ef98254a62121f59d7a570fff9f48ccab19 [file] [log] [blame]
Geza Lore2791d9d2016-06-21 20:29:21 +01001/*
2 * Copyright (c) 2016 The WebM project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "third_party/googletest/src/include/gtest/gtest.h"
12
Yaowu Xuf883b422016-08-30 14:01:10 -070013#include "./aom_config.h"
Geza Lore2791d9d2016-06-21 20:29:21 +010014
Yaowu Xuf883b422016-08-30 14:01:10 -070015#include "./aom_dsp_rtcd.h"
16#include "./av1_rtcd.h"
Geza Lore2791d9d2016-06-21 20:29:21 +010017
Yaowu Xuf883b422016-08-30 14:01:10 -070018#include "aom_dsp/aom_dsp_common.h"
Geza Lore2791d9d2016-06-21 20:29:21 +010019
Yaowu Xuc27fc142016-08-22 16:08:15 -070020#include "av1/common/enums.h"
Geza Lore2791d9d2016-06-21 20:29:21 +010021
22#include "test/acm_random.h"
23#include "test/function_equivalence_test.h"
Geza Lorea3f7ddc2016-07-12 15:26:36 +010024#include "test/register_state_check.h"
Geza Lore2791d9d2016-06-21 20:29:21 +010025
26#define WEDGE_WEIGHT_BITS 6
clang-format3a826f12016-08-11 17:46:05 -070027#define MAX_MASK_VALUE (1 << (WEDGE_WEIGHT_BITS))
Geza Lore2791d9d2016-06-21 20:29:21 +010028
Yaowu Xuc27fc142016-08-22 16:08:15 -070029using libaom_test::ACMRandom;
30using libaom_test::FunctionEquivalenceTest;
Geza Lore2791d9d2016-06-21 20:29:21 +010031
32namespace {
33
34static const int16_t kInt13Max = (1 << 12) - 1;
35
36//////////////////////////////////////////////////////////////////////////////
Yaowu Xuf883b422016-08-30 14:01:10 -070037// av1_wedge_sse_from_residuals - functionality
Geza Lore2791d9d2016-06-21 20:29:21 +010038//////////////////////////////////////////////////////////////////////////////
39
40class WedgeUtilsSSEFuncTest : public testing::Test {
41 protected:
42 WedgeUtilsSSEFuncTest() : rng_(ACMRandom::DeterministicSeed()) {}
43
44 static const int kIterations = 1000;
45
46 ACMRandom rng_;
47};
48
clang-format3a826f12016-08-11 17:46:05 -070049static void equiv_blend_residuals(int16_t *r, const int16_t *r0,
50 const int16_t *r1, const uint8_t *m, int N) {
51 for (int i = 0; i < N; i++) {
Geza Lore2791d9d2016-06-21 20:29:21 +010052 const int32_t m0 = m[i];
53 const int32_t m1 = MAX_MASK_VALUE - m0;
54 const int16_t R = m0 * r0[i] + m1 * r1[i];
55 // Note that this rounding is designed to match the result
56 // you would get when actually blending the 2 predictors and computing
57 // the residuals.
58 r[i] = ROUND_POWER_OF_TWO(R - 1, WEDGE_WEIGHT_BITS);
59 }
60}
61
clang-format3a826f12016-08-11 17:46:05 -070062static uint64_t equiv_sse_from_residuals(const int16_t *r0, const int16_t *r1,
63 const uint8_t *m, int N) {
Geza Lore2791d9d2016-06-21 20:29:21 +010064 uint64_t acc = 0;
clang-format3a826f12016-08-11 17:46:05 -070065 for (int i = 0; i < N; i++) {
Geza Lore2791d9d2016-06-21 20:29:21 +010066 const int32_t m0 = m[i];
67 const int32_t m1 = MAX_MASK_VALUE - m0;
68 const int16_t R = m0 * r0[i] + m1 * r1[i];
69 const int32_t r = ROUND_POWER_OF_TWO(R - 1, WEDGE_WEIGHT_BITS);
70 acc += r * r;
71 }
72 return acc;
73}
74
75TEST_F(WedgeUtilsSSEFuncTest, ResidualBlendingEquiv) {
76 DECLARE_ALIGNED(32, uint8_t, s[MAX_SB_SQUARE]);
77 DECLARE_ALIGNED(32, uint8_t, p0[MAX_SB_SQUARE]);
78 DECLARE_ALIGNED(32, uint8_t, p1[MAX_SB_SQUARE]);
79 DECLARE_ALIGNED(32, uint8_t, p[MAX_SB_SQUARE]);
80
81 DECLARE_ALIGNED(32, int16_t, r0[MAX_SB_SQUARE]);
82 DECLARE_ALIGNED(32, int16_t, r1[MAX_SB_SQUARE]);
83 DECLARE_ALIGNED(32, int16_t, r_ref[MAX_SB_SQUARE]);
84 DECLARE_ALIGNED(32, int16_t, r_tst[MAX_SB_SQUARE]);
85 DECLARE_ALIGNED(32, uint8_t, m[MAX_SB_SQUARE]);
86
clang-format3a826f12016-08-11 17:46:05 -070087 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
88 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Geza Lore2791d9d2016-06-21 20:29:21 +010089 s[i] = rng_.Rand8();
90 m[i] = rng_(MAX_MASK_VALUE + 1);
91 }
92
93 const int w = 1 << (rng_(MAX_SB_SIZE_LOG2 + 1 - 3) + 3);
94 const int h = 1 << (rng_(MAX_SB_SIZE_LOG2 + 1 - 3) + 3);
95 const int N = w * h;
96
clang-format3a826f12016-08-11 17:46:05 -070097 for (int j = 0; j < N; j++) {
Geza Lore2791d9d2016-06-21 20:29:21 +010098 p0[j] = clamp(s[j] + rng_(33) - 16, 0, UINT8_MAX);
99 p1[j] = clamp(s[j] + rng_(33) - 16, 0, UINT8_MAX);
100 }
101
Yaowu Xuf883b422016-08-30 14:01:10 -0700102 aom_blend_a64_mask(p, w, p0, w, p1, w, m, w, h, w, 0, 0);
Geza Lore2791d9d2016-06-21 20:29:21 +0100103
Yaowu Xuf883b422016-08-30 14:01:10 -0700104 aom_subtract_block(h, w, r0, w, s, w, p0, w);
105 aom_subtract_block(h, w, r1, w, s, w, p1, w);
Geza Lore2791d9d2016-06-21 20:29:21 +0100106
Yaowu Xuf883b422016-08-30 14:01:10 -0700107 aom_subtract_block(h, w, r_ref, w, s, w, p, w);
Geza Lore2791d9d2016-06-21 20:29:21 +0100108 equiv_blend_residuals(r_tst, r0, r1, m, N);
109
clang-format3a826f12016-08-11 17:46:05 -0700110 for (int i = 0; i < N; ++i) ASSERT_EQ(r_ref[i], r_tst[i]);
Geza Lore2791d9d2016-06-21 20:29:21 +0100111
Yaowu Xuf883b422016-08-30 14:01:10 -0700112 uint64_t ref_sse = aom_sum_squares_i16(r_ref, N);
Geza Lore2791d9d2016-06-21 20:29:21 +0100113 uint64_t tst_sse = equiv_sse_from_residuals(r0, r1, m, N);
114
115 ASSERT_EQ(ref_sse, tst_sse);
116 }
117}
118
clang-format3a826f12016-08-11 17:46:05 -0700119static uint64_t sse_from_residuals(const int16_t *r0, const int16_t *r1,
120 const uint8_t *m, int N) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100121 uint64_t acc = 0;
clang-format3a826f12016-08-11 17:46:05 -0700122 for (int i = 0; i < N; i++) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100123 const int32_t m0 = m[i];
124 const int32_t m1 = MAX_MASK_VALUE - m0;
125 const int32_t r = m0 * r0[i] + m1 * r1[i];
126 acc += r * r;
127 }
128 return ROUND_POWER_OF_TWO(acc, 2 * WEDGE_WEIGHT_BITS);
129}
130
131TEST_F(WedgeUtilsSSEFuncTest, ResidualBlendingMethod) {
132 DECLARE_ALIGNED(32, int16_t, r0[MAX_SB_SQUARE]);
133 DECLARE_ALIGNED(32, int16_t, r1[MAX_SB_SQUARE]);
134 DECLARE_ALIGNED(32, int16_t, d[MAX_SB_SQUARE]);
135 DECLARE_ALIGNED(32, uint8_t, m[MAX_SB_SQUARE]);
136
clang-format3a826f12016-08-11 17:46:05 -0700137 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
138 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100139 r1[i] = rng_(2 * INT8_MAX - 2 * INT8_MIN + 1) + 2 * INT8_MIN;
140 d[i] = rng_(2 * INT8_MAX - 2 * INT8_MIN + 1) + 2 * INT8_MIN;
141 m[i] = rng_(MAX_MASK_VALUE + 1);
142 }
143
clang-format3a826f12016-08-11 17:46:05 -0700144 const int N = 64 * (rng_(MAX_SB_SQUARE / 64) + 1);
Geza Lore2791d9d2016-06-21 20:29:21 +0100145
clang-format3a826f12016-08-11 17:46:05 -0700146 for (int i = 0; i < N; i++) r0[i] = r1[i] + d[i];
Geza Lore2791d9d2016-06-21 20:29:21 +0100147
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100148 const uint64_t ref_res = sse_from_residuals(r0, r1, m, N);
Yaowu Xuf883b422016-08-30 14:01:10 -0700149 const uint64_t tst_res = av1_wedge_sse_from_residuals(r1, d, m, N);
Geza Lore2791d9d2016-06-21 20:29:21 +0100150
151 ASSERT_EQ(ref_res, tst_res);
152 }
153}
154
155//////////////////////////////////////////////////////////////////////////////
Yaowu Xuf883b422016-08-30 14:01:10 -0700156// av1_wedge_sse_from_residuals - optimizations
Geza Lore2791d9d2016-06-21 20:29:21 +0100157//////////////////////////////////////////////////////////////////////////////
158
clang-format3a826f12016-08-11 17:46:05 -0700159typedef uint64_t (*FSSE)(const int16_t *r1, const int16_t *d, const uint8_t *m,
Geza Lore2791d9d2016-06-21 20:29:21 +0100160 int N);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700161typedef libaom_test::FuncParam<FSSE> TestFuncsFSSE;
Geza Lore2791d9d2016-06-21 20:29:21 +0100162
163class WedgeUtilsSSEOptTest : public FunctionEquivalenceTest<FSSE> {
164 protected:
Geza Lore2791d9d2016-06-21 20:29:21 +0100165 static const int kIterations = 10000;
Geza Lore2791d9d2016-06-21 20:29:21 +0100166};
167
168TEST_P(WedgeUtilsSSEOptTest, RandomValues) {
169 DECLARE_ALIGNED(32, int16_t, r1[MAX_SB_SQUARE]);
170 DECLARE_ALIGNED(32, int16_t, d[MAX_SB_SQUARE]);
171 DECLARE_ALIGNED(32, uint8_t, m[MAX_SB_SQUARE]);
172
clang-format3a826f12016-08-11 17:46:05 -0700173 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
174 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100175 r1[i] = rng_(2 * kInt13Max + 1) - kInt13Max;
176 d[i] = rng_(2 * kInt13Max + 1) - kInt13Max;
177 m[i] = rng_(MAX_MASK_VALUE + 1);
178 }
179
clang-format3a826f12016-08-11 17:46:05 -0700180 const int N = 64 * (rng_(MAX_SB_SQUARE / 64) + 1);
Geza Lore2791d9d2016-06-21 20:29:21 +0100181
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100182 const uint64_t ref_res = params_.ref_func(r1, d, m, N);
183 uint64_t tst_res;
184 ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(r1, d, m, N));
Geza Lore2791d9d2016-06-21 20:29:21 +0100185
186 ASSERT_EQ(ref_res, tst_res);
187 }
188}
189
190TEST_P(WedgeUtilsSSEOptTest, ExtremeValues) {
191 DECLARE_ALIGNED(32, int16_t, r1[MAX_SB_SQUARE]);
192 DECLARE_ALIGNED(32, int16_t, d[MAX_SB_SQUARE]);
193 DECLARE_ALIGNED(32, uint8_t, m[MAX_SB_SQUARE]);
194
clang-format3a826f12016-08-11 17:46:05 -0700195 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100196 if (rng_(2)) {
clang-format3a826f12016-08-11 17:46:05 -0700197 for (int i = 0; i < MAX_SB_SQUARE; ++i) r1[i] = kInt13Max;
Geza Lore2791d9d2016-06-21 20:29:21 +0100198 } else {
clang-format3a826f12016-08-11 17:46:05 -0700199 for (int i = 0; i < MAX_SB_SQUARE; ++i) r1[i] = -kInt13Max;
Geza Lore2791d9d2016-06-21 20:29:21 +0100200 }
201
202 if (rng_(2)) {
clang-format3a826f12016-08-11 17:46:05 -0700203 for (int i = 0; i < MAX_SB_SQUARE; ++i) d[i] = kInt13Max;
Geza Lore2791d9d2016-06-21 20:29:21 +0100204 } else {
clang-format3a826f12016-08-11 17:46:05 -0700205 for (int i = 0; i < MAX_SB_SQUARE; ++i) d[i] = -kInt13Max;
Geza Lore2791d9d2016-06-21 20:29:21 +0100206 }
207
clang-format3a826f12016-08-11 17:46:05 -0700208 for (int i = 0; i < MAX_SB_SQUARE; ++i) m[i] = MAX_MASK_VALUE;
Geza Lore2791d9d2016-06-21 20:29:21 +0100209
clang-format3a826f12016-08-11 17:46:05 -0700210 const int N = 64 * (rng_(MAX_SB_SQUARE / 64) + 1);
Geza Lore2791d9d2016-06-21 20:29:21 +0100211
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100212 const uint64_t ref_res = params_.ref_func(r1, d, m, N);
213 uint64_t tst_res;
214 ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(r1, d, m, N));
Geza Lore2791d9d2016-06-21 20:29:21 +0100215
216 ASSERT_EQ(ref_res, tst_res);
217 }
218}
219
220#if HAVE_SSE2
221INSTANTIATE_TEST_CASE_P(
222 SSE2, WedgeUtilsSSEOptTest,
Yaowu Xuf883b422016-08-30 14:01:10 -0700223 ::testing::Values(TestFuncsFSSE(av1_wedge_sse_from_residuals_c,
224 av1_wedge_sse_from_residuals_sse2)));
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100225
Geza Lore2791d9d2016-06-21 20:29:21 +0100226#endif // HAVE_SSE2
227
228//////////////////////////////////////////////////////////////////////////////
Yaowu Xuf883b422016-08-30 14:01:10 -0700229// av1_wedge_sign_from_residuals
Geza Lore2791d9d2016-06-21 20:29:21 +0100230//////////////////////////////////////////////////////////////////////////////
231
clang-format3a826f12016-08-11 17:46:05 -0700232typedef int (*FSign)(const int16_t *ds, const uint8_t *m, int N, int64_t limit);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700233typedef libaom_test::FuncParam<FSign> TestFuncsFSign;
Geza Lore2791d9d2016-06-21 20:29:21 +0100234
235class WedgeUtilsSignOptTest : public FunctionEquivalenceTest<FSign> {
236 protected:
Geza Lore2791d9d2016-06-21 20:29:21 +0100237 static const int kIterations = 10000;
238 static const int kMaxSize = 8196; // Size limited by SIMD implementation.
Geza Lore2791d9d2016-06-21 20:29:21 +0100239};
240
241TEST_P(WedgeUtilsSignOptTest, RandomValues) {
242 DECLARE_ALIGNED(32, int16_t, r0[MAX_SB_SQUARE]);
243 DECLARE_ALIGNED(32, int16_t, r1[MAX_SB_SQUARE]);
244 DECLARE_ALIGNED(32, int16_t, ds[MAX_SB_SQUARE]);
245 DECLARE_ALIGNED(32, uint8_t, m[MAX_SB_SQUARE]);
246
clang-format3a826f12016-08-11 17:46:05 -0700247 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
248 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100249 r0[i] = rng_(2 * kInt13Max + 1) - kInt13Max;
250 r1[i] = rng_(2 * kInt13Max + 1) - kInt13Max;
251 m[i] = rng_(MAX_MASK_VALUE + 1);
252 }
253
Yaowu Xuf883b422016-08-30 14:01:10 -0700254 const int maxN = AOMMIN(kMaxSize, MAX_SB_SQUARE);
clang-format3a826f12016-08-11 17:46:05 -0700255 const int N = 64 * (rng_(maxN / 64 - 1) + 1);
Geza Lore2791d9d2016-06-21 20:29:21 +0100256
257 int64_t limit;
Yaowu Xuf883b422016-08-30 14:01:10 -0700258 limit = (int64_t)aom_sum_squares_i16(r0, N);
259 limit -= (int64_t)aom_sum_squares_i16(r1, N);
Geza Lore2791d9d2016-06-21 20:29:21 +0100260 limit *= (1 << WEDGE_WEIGHT_BITS) / 2;
261
clang-format3a826f12016-08-11 17:46:05 -0700262 for (int i = 0; i < N; i++)
263 ds[i] = clamp(r0[i] * r0[i] - r1[i] * r1[i], INT16_MIN, INT16_MAX);
Geza Lore2791d9d2016-06-21 20:29:21 +0100264
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100265 const int ref_res = params_.ref_func(ds, m, N, limit);
266 int tst_res;
267 ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(ds, m, N, limit));
Geza Lore2791d9d2016-06-21 20:29:21 +0100268
269 ASSERT_EQ(ref_res, tst_res);
270 }
271}
272
273TEST_P(WedgeUtilsSignOptTest, ExtremeValues) {
274 DECLARE_ALIGNED(32, int16_t, r0[MAX_SB_SQUARE]);
275 DECLARE_ALIGNED(32, int16_t, r1[MAX_SB_SQUARE]);
276 DECLARE_ALIGNED(32, int16_t, ds[MAX_SB_SQUARE]);
277 DECLARE_ALIGNED(32, uint8_t, m[MAX_SB_SQUARE]);
278
clang-format3a826f12016-08-11 17:46:05 -0700279 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100280 switch (rng_(4)) {
clang-format3a826f12016-08-11 17:46:05 -0700281 case 0:
282 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
283 r0[i] = 0;
284 r1[i] = kInt13Max;
285 }
286 break;
287 case 1:
288 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
289 r0[i] = kInt13Max;
290 r1[i] = 0;
291 }
292 break;
293 case 2:
294 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
295 r0[i] = 0;
296 r1[i] = -kInt13Max;
297 }
298 break;
299 default:
300 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
301 r0[i] = -kInt13Max;
302 r1[i] = 0;
303 }
304 break;
Geza Lore2791d9d2016-06-21 20:29:21 +0100305 }
306
clang-format3a826f12016-08-11 17:46:05 -0700307 for (int i = 0; i < MAX_SB_SQUARE; ++i) m[i] = MAX_MASK_VALUE;
Geza Lore2791d9d2016-06-21 20:29:21 +0100308
Yaowu Xuf883b422016-08-30 14:01:10 -0700309 const int maxN = AOMMIN(kMaxSize, MAX_SB_SQUARE);
clang-format3a826f12016-08-11 17:46:05 -0700310 const int N = 64 * (rng_(maxN / 64 - 1) + 1);
Geza Lore2791d9d2016-06-21 20:29:21 +0100311
312 int64_t limit;
Yaowu Xuf883b422016-08-30 14:01:10 -0700313 limit = (int64_t)aom_sum_squares_i16(r0, N);
314 limit -= (int64_t)aom_sum_squares_i16(r1, N);
Geza Lore2791d9d2016-06-21 20:29:21 +0100315 limit *= (1 << WEDGE_WEIGHT_BITS) / 2;
316
clang-format3a826f12016-08-11 17:46:05 -0700317 for (int i = 0; i < N; i++)
318 ds[i] = clamp(r0[i] * r0[i] - r1[i] * r1[i], INT16_MIN, INT16_MAX);
Geza Lore2791d9d2016-06-21 20:29:21 +0100319
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100320 const int ref_res = params_.ref_func(ds, m, N, limit);
321 int tst_res;
322 ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(ds, m, N, limit));
Geza Lore2791d9d2016-06-21 20:29:21 +0100323
324 ASSERT_EQ(ref_res, tst_res);
325 }
326}
327
328#if HAVE_SSE2
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100329
Geza Lore2791d9d2016-06-21 20:29:21 +0100330INSTANTIATE_TEST_CASE_P(
331 SSE2, WedgeUtilsSignOptTest,
Yaowu Xuf883b422016-08-30 14:01:10 -0700332 ::testing::Values(TestFuncsFSign(av1_wedge_sign_from_residuals_c,
333 av1_wedge_sign_from_residuals_sse2)));
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100334
Geza Lore2791d9d2016-06-21 20:29:21 +0100335#endif // HAVE_SSE2
336
337//////////////////////////////////////////////////////////////////////////////
Yaowu Xuf883b422016-08-30 14:01:10 -0700338// av1_wedge_compute_delta_squares
Geza Lore2791d9d2016-06-21 20:29:21 +0100339//////////////////////////////////////////////////////////////////////////////
340
clang-format3a826f12016-08-11 17:46:05 -0700341typedef void (*FDS)(int16_t *d, const int16_t *a, const int16_t *b, int N);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700342typedef libaom_test::FuncParam<FDS> TestFuncsFDS;
Geza Lore2791d9d2016-06-21 20:29:21 +0100343
344class WedgeUtilsDeltaSquaresOptTest : public FunctionEquivalenceTest<FDS> {
345 protected:
Geza Lore2791d9d2016-06-21 20:29:21 +0100346 static const int kIterations = 10000;
Geza Lore2791d9d2016-06-21 20:29:21 +0100347};
348
349TEST_P(WedgeUtilsDeltaSquaresOptTest, RandomValues) {
350 DECLARE_ALIGNED(32, int16_t, a[MAX_SB_SQUARE]);
351 DECLARE_ALIGNED(32, int16_t, b[MAX_SB_SQUARE]);
352 DECLARE_ALIGNED(32, int16_t, d_ref[MAX_SB_SQUARE]);
353 DECLARE_ALIGNED(32, int16_t, d_tst[MAX_SB_SQUARE]);
354
clang-format3a826f12016-08-11 17:46:05 -0700355 for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
356 for (int i = 0; i < MAX_SB_SQUARE; ++i) {
Geza Lore2791d9d2016-06-21 20:29:21 +0100357 a[i] = rng_.Rand16();
358 b[i] = rng_(2 * INT16_MAX + 1) - INT16_MAX;
359 }
360
clang-format3a826f12016-08-11 17:46:05 -0700361 const int N = 64 * (rng_(MAX_SB_SQUARE / 64) + 1);
Geza Lore2791d9d2016-06-21 20:29:21 +0100362
363 memset(&d_ref, INT16_MAX, sizeof(d_ref));
364 memset(&d_tst, INT16_MAX, sizeof(d_tst));
365
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100366 params_.ref_func(d_ref, a, b, N);
367 ASM_REGISTER_STATE_CHECK(params_.tst_func(d_tst, a, b, N));
Geza Lore2791d9d2016-06-21 20:29:21 +0100368
clang-format3a826f12016-08-11 17:46:05 -0700369 for (int i = 0; i < MAX_SB_SQUARE; ++i) ASSERT_EQ(d_ref[i], d_tst[i]);
Geza Lore2791d9d2016-06-21 20:29:21 +0100370 }
371}
372
373#if HAVE_SSE2
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100374
Geza Lore2791d9d2016-06-21 20:29:21 +0100375INSTANTIATE_TEST_CASE_P(
376 SSE2, WedgeUtilsDeltaSquaresOptTest,
Yaowu Xuf883b422016-08-30 14:01:10 -0700377 ::testing::Values(TestFuncsFDS(av1_wedge_compute_delta_squares_c,
378 av1_wedge_compute_delta_squares_sse2)));
Geza Lorea3f7ddc2016-07-12 15:26:36 +0100379
Geza Lore2791d9d2016-06-21 20:29:21 +0100380#endif // HAVE_SSE2
381
382} // namespace