blob: b16f14c8e7ee2cda9f7cbbd0e191c97e754ec8bb [file] [log] [blame]
Deb Mukherjee931ed512014-09-17 16:55:05 -07001/*
2 * Copyright (c) 2014 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 <cmath>
12#include <cstdlib>
13#include <string>
14
15#include "third_party/googletest/src/include/gtest/gtest.h"
Jingning Han097d59c2015-07-29 14:51:36 -070016
17#include "./vpx_config.h"
18#include "./vpx_dsp_rtcd.h"
Deb Mukherjee931ed512014-09-17 16:55:05 -070019#include "test/acm_random.h"
20#include "test/clear_system_state.h"
21#include "test/register_state_check.h"
22#include "test/util.h"
Deb Mukherjee931ed512014-09-17 16:55:05 -070023#include "vp9/common/vp9_entropy.h"
Deb Mukherjee072ed172014-12-03 16:26:48 -080024#include "vp9/common/vp9_loopfilter.h"
Deb Mukherjee931ed512014-09-17 16:55:05 -070025#include "vpx/vpx_integer.h"
26
27using libvpx_test::ACMRandom;
28
29namespace {
30// Horizontally and Vertically need 32x32: 8 Coeffs preceeding filtered section
31// 16 Coefs within filtered section
32// 8 Coeffs following filtered section
33const int kNumCoeffs = 1024;
34
35const int number_of_iterations = 10000;
36
37#if CONFIG_VP9_HIGHBITDEPTH
38typedef void (*loop_op_t)(uint16_t *s, int p, const uint8_t *blimit,
39 const uint8_t *limit, const uint8_t *thresh,
James Zern3ea537c2016-02-13 11:05:24 -080040 int bd);
Deb Mukherjee931ed512014-09-17 16:55:05 -070041typedef void (*dual_loop_op_t)(uint16_t *s, int p, const uint8_t *blimit0,
42 const uint8_t *limit0, const uint8_t *thresh0,
43 const uint8_t *blimit1, const uint8_t *limit1,
44 const uint8_t *thresh1, int bd);
45#else
46typedef void (*loop_op_t)(uint8_t *s, int p, const uint8_t *blimit,
James Zern3ea537c2016-02-13 11:05:24 -080047 const uint8_t *limit, const uint8_t *thresh);
Deb Mukherjee931ed512014-09-17 16:55:05 -070048typedef void (*dual_loop_op_t)(uint8_t *s, int p, const uint8_t *blimit0,
49 const uint8_t *limit0, const uint8_t *thresh0,
50 const uint8_t *blimit1, const uint8_t *limit1,
51 const uint8_t *thresh1);
52#endif // CONFIG_VP9_HIGHBITDEPTH
53
James Zern3ea537c2016-02-13 11:05:24 -080054typedef std::tr1::tuple<loop_op_t, loop_op_t, int> loop8_param_t;
Deb Mukherjee931ed512014-09-17 16:55:05 -070055typedef std::tr1::tuple<dual_loop_op_t, dual_loop_op_t, int> dualloop8_param_t;
56
Deb Mukherjee931ed512014-09-17 16:55:05 -070057class Loop8Test6Param : public ::testing::TestWithParam<loop8_param_t> {
58 public:
59 virtual ~Loop8Test6Param() {}
60 virtual void SetUp() {
61 loopfilter_op_ = GET_PARAM(0);
62 ref_loopfilter_op_ = GET_PARAM(1);
63 bit_depth_ = GET_PARAM(2);
64 mask_ = (1 << bit_depth_) - 1;
65 }
66
67 virtual void TearDown() { libvpx_test::ClearSystemState(); }
68
69 protected:
70 int bit_depth_;
71 int mask_;
72 loop_op_t loopfilter_op_;
73 loop_op_t ref_loopfilter_op_;
74};
75
76class Loop8Test9Param : public ::testing::TestWithParam<dualloop8_param_t> {
77 public:
78 virtual ~Loop8Test9Param() {}
79 virtual void SetUp() {
80 loopfilter_op_ = GET_PARAM(0);
81 ref_loopfilter_op_ = GET_PARAM(1);
82 bit_depth_ = GET_PARAM(2);
83 mask_ = (1 << bit_depth_) - 1;
84 }
85
86 virtual void TearDown() { libvpx_test::ClearSystemState(); }
87
88 protected:
89 int bit_depth_;
90 int mask_;
91 dual_loop_op_t loopfilter_op_;
92 dual_loop_op_t ref_loopfilter_op_;
93};
94
95TEST_P(Loop8Test6Param, OperationCheck) {
96 ACMRandom rnd(ACMRandom::DeterministicSeed());
97 const int count_test_block = number_of_iterations;
98#if CONFIG_VP9_HIGHBITDEPTH
99 int32_t bd = bit_depth_;
James Zernfd3658b2015-05-02 13:24:16 -0700100 DECLARE_ALIGNED(16, uint16_t, s[kNumCoeffs]);
101 DECLARE_ALIGNED(16, uint16_t, ref_s[kNumCoeffs]);
Deb Mukherjee931ed512014-09-17 16:55:05 -0700102#else
James Zernfd3658b2015-05-02 13:24:16 -0700103 DECLARE_ALIGNED(8, uint8_t, s[kNumCoeffs]);
104 DECLARE_ALIGNED(8, uint8_t, ref_s[kNumCoeffs]);
Deb Mukherjee931ed512014-09-17 16:55:05 -0700105#endif // CONFIG_VP9_HIGHBITDEPTH
106 int err_count_total = 0;
107 int first_failure = -1;
108 for (int i = 0; i < count_test_block; ++i) {
109 int err_count = 0;
Deb Mukherjee072ed172014-12-03 16:26:48 -0800110 uint8_t tmp = static_cast<uint8_t>(rnd(3 * MAX_LOOP_FILTER + 4));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700111 DECLARE_ALIGNED(16, const uint8_t, blimit[16]) = {
112 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
113 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
114 };
Deb Mukherjee072ed172014-12-03 16:26:48 -0800115 tmp = static_cast<uint8_t>(rnd(MAX_LOOP_FILTER));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700116 DECLARE_ALIGNED(16, const uint8_t, limit[16]) = {
117 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
118 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
119 };
120 tmp = rnd.Rand8();
121 DECLARE_ALIGNED(16, const uint8_t, thresh[16]) = {
122 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
123 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
124 };
125 int32_t p = kNumCoeffs/32;
Deb Mukherjee931ed512014-09-17 16:55:05 -0700126
127 uint16_t tmp_s[kNumCoeffs];
128 int j = 0;
129 while (j < kNumCoeffs) {
130 uint8_t val = rnd.Rand8();
131 if (val & 0x80) { // 50% chance to choose a new value.
132 tmp_s[j] = rnd.Rand16();
133 j++;
134 } else { // 50% chance to repeat previous value in row X times
135 int k = 0;
136 while (k++ < ((val & 0x1f) + 1) && j < kNumCoeffs) {
137 if (j < 1) {
138 tmp_s[j] = rnd.Rand16();
139 } else if (val & 0x20) { // Increment by an value within the limit
140 tmp_s[j] = (tmp_s[j - 1] + (*limit - 1));
141 } else { // Decrement by an value within the limit
142 tmp_s[j] = (tmp_s[j - 1] - (*limit - 1));
143 }
144 j++;
145 }
146 }
147 }
148 for (j = 0; j < kNumCoeffs; j++) {
149 if (i % 2) {
150 s[j] = tmp_s[j] & mask_;
151 } else {
152 s[j] = tmp_s[p * (j % p) + j / p] & mask_;
153 }
154 ref_s[j] = s[j];
155 }
156#if CONFIG_VP9_HIGHBITDEPTH
James Zern3ea537c2016-02-13 11:05:24 -0800157 ref_loopfilter_op_(ref_s + 8 + p * 8, p, blimit, limit, thresh, bd);
Deb Mukherjee931ed512014-09-17 16:55:05 -0700158 ASM_REGISTER_STATE_CHECK(
James Zern3ea537c2016-02-13 11:05:24 -0800159 loopfilter_op_(s + 8 + p * 8, p, blimit, limit, thresh, bd));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700160#else
James Zern3ea537c2016-02-13 11:05:24 -0800161 ref_loopfilter_op_(ref_s+8+p*8, p, blimit, limit, thresh);
Deb Mukherjee931ed512014-09-17 16:55:05 -0700162 ASM_REGISTER_STATE_CHECK(
James Zern3ea537c2016-02-13 11:05:24 -0800163 loopfilter_op_(s + 8 + p * 8, p, blimit, limit, thresh));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700164#endif // CONFIG_VP9_HIGHBITDEPTH
165
166 for (int j = 0; j < kNumCoeffs; ++j) {
167 err_count += ref_s[j] != s[j];
168 }
169 if (err_count && !err_count_total) {
170 first_failure = i;
171 }
172 err_count_total += err_count;
173 }
174 EXPECT_EQ(0, err_count_total)
175 << "Error: Loop8Test6Param, C output doesn't match SSE2 "
176 "loopfilter output. "
177 << "First failed at test case " << first_failure;
178}
179
180TEST_P(Loop8Test6Param, ValueCheck) {
181 ACMRandom rnd(ACMRandom::DeterministicSeed());
182 const int count_test_block = number_of_iterations;
183#if CONFIG_VP9_HIGHBITDEPTH
184 const int32_t bd = bit_depth_;
James Zernfd3658b2015-05-02 13:24:16 -0700185 DECLARE_ALIGNED(16, uint16_t, s[kNumCoeffs]);
186 DECLARE_ALIGNED(16, uint16_t, ref_s[kNumCoeffs]);
Deb Mukherjee931ed512014-09-17 16:55:05 -0700187#else
James Zernfd3658b2015-05-02 13:24:16 -0700188 DECLARE_ALIGNED(8, uint8_t, s[kNumCoeffs]);
189 DECLARE_ALIGNED(8, uint8_t, ref_s[kNumCoeffs]);
Deb Mukherjee931ed512014-09-17 16:55:05 -0700190#endif // CONFIG_VP9_HIGHBITDEPTH
191 int err_count_total = 0;
192 int first_failure = -1;
Deb Mukherjee072ed172014-12-03 16:26:48 -0800193
194 // NOTE: The code in vp9_loopfilter.c:update_sharpness computes mblim as a
195 // function of sharpness_lvl and the loopfilter lvl as:
196 // block_inside_limit = lvl >> ((sharpness_lvl > 0) + (sharpness_lvl > 4));
197 // ...
James Zernf58011a2015-04-23 20:47:40 -0700198 // memset(lfi->lfthr[lvl].mblim, (2 * (lvl + 2) + block_inside_limit),
199 // SIMD_WIDTH);
Deb Mukherjee072ed172014-12-03 16:26:48 -0800200 // This means that the largest value for mblim will occur when sharpness_lvl
201 // is equal to 0, and lvl is equal to its greatest value (MAX_LOOP_FILTER).
202 // In this case block_inside_limit will be equal to MAX_LOOP_FILTER and
203 // therefore mblim will be equal to (2 * (lvl + 2) + block_inside_limit) =
204 // 2 * (MAX_LOOP_FILTER + 2) + MAX_LOOP_FILTER = 3 * MAX_LOOP_FILTER + 4
205
Deb Mukherjee931ed512014-09-17 16:55:05 -0700206 for (int i = 0; i < count_test_block; ++i) {
207 int err_count = 0;
Deb Mukherjee072ed172014-12-03 16:26:48 -0800208 uint8_t tmp = static_cast<uint8_t>(rnd(3 * MAX_LOOP_FILTER + 4));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700209 DECLARE_ALIGNED(16, const uint8_t, blimit[16]) = {
210 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
211 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
212 };
Deb Mukherjee072ed172014-12-03 16:26:48 -0800213 tmp = static_cast<uint8_t>(rnd(MAX_LOOP_FILTER));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700214 DECLARE_ALIGNED(16, const uint8_t, limit[16]) = {
215 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
216 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
217 };
218 tmp = rnd.Rand8();
219 DECLARE_ALIGNED(16, const uint8_t, thresh[16]) = {
220 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
221 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
222 };
223 int32_t p = kNumCoeffs / 32;
Deb Mukherjee931ed512014-09-17 16:55:05 -0700224 for (int j = 0; j < kNumCoeffs; ++j) {
225 s[j] = rnd.Rand16() & mask_;
226 ref_s[j] = s[j];
227 }
228#if CONFIG_VP9_HIGHBITDEPTH
James Zern3ea537c2016-02-13 11:05:24 -0800229 ref_loopfilter_op_(ref_s + 8 + p * 8, p, blimit, limit, thresh, bd);
Deb Mukherjee931ed512014-09-17 16:55:05 -0700230 ASM_REGISTER_STATE_CHECK(
James Zern3ea537c2016-02-13 11:05:24 -0800231 loopfilter_op_(s + 8 + p * 8, p, blimit, limit, thresh, bd));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700232#else
James Zern3ea537c2016-02-13 11:05:24 -0800233 ref_loopfilter_op_(ref_s+8+p*8, p, blimit, limit, thresh);
Deb Mukherjee931ed512014-09-17 16:55:05 -0700234 ASM_REGISTER_STATE_CHECK(
James Zern3ea537c2016-02-13 11:05:24 -0800235 loopfilter_op_(s + 8 + p * 8, p, blimit, limit, thresh));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700236#endif // CONFIG_VP9_HIGHBITDEPTH
237 for (int j = 0; j < kNumCoeffs; ++j) {
238 err_count += ref_s[j] != s[j];
239 }
240 if (err_count && !err_count_total) {
241 first_failure = i;
242 }
243 err_count_total += err_count;
244 }
245 EXPECT_EQ(0, err_count_total)
246 << "Error: Loop8Test6Param, C output doesn't match SSE2 "
247 "loopfilter output. "
248 << "First failed at test case " << first_failure;
249}
250
251TEST_P(Loop8Test9Param, OperationCheck) {
252 ACMRandom rnd(ACMRandom::DeterministicSeed());
253 const int count_test_block = number_of_iterations;
254#if CONFIG_VP9_HIGHBITDEPTH
255 const int32_t bd = bit_depth_;
James Zernfd3658b2015-05-02 13:24:16 -0700256 DECLARE_ALIGNED(16, uint16_t, s[kNumCoeffs]);
257 DECLARE_ALIGNED(16, uint16_t, ref_s[kNumCoeffs]);
Deb Mukherjee931ed512014-09-17 16:55:05 -0700258#else
James Zernfd3658b2015-05-02 13:24:16 -0700259 DECLARE_ALIGNED(8, uint8_t, s[kNumCoeffs]);
260 DECLARE_ALIGNED(8, uint8_t, ref_s[kNumCoeffs]);
Deb Mukherjee931ed512014-09-17 16:55:05 -0700261#endif // CONFIG_VP9_HIGHBITDEPTH
262 int err_count_total = 0;
263 int first_failure = -1;
264 for (int i = 0; i < count_test_block; ++i) {
265 int err_count = 0;
Deb Mukherjee072ed172014-12-03 16:26:48 -0800266 uint8_t tmp = static_cast<uint8_t>(rnd(3 * MAX_LOOP_FILTER + 4));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700267 DECLARE_ALIGNED(16, const uint8_t, blimit0[16]) = {
268 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
269 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
270 };
Deb Mukherjee072ed172014-12-03 16:26:48 -0800271 tmp = static_cast<uint8_t>(rnd(MAX_LOOP_FILTER));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700272 DECLARE_ALIGNED(16, const uint8_t, limit0[16]) = {
273 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
274 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
275 };
276 tmp = rnd.Rand8();
277 DECLARE_ALIGNED(16, const uint8_t, thresh0[16]) = {
278 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
279 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
280 };
Deb Mukherjee072ed172014-12-03 16:26:48 -0800281 tmp = static_cast<uint8_t>(rnd(3 * MAX_LOOP_FILTER + 4));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700282 DECLARE_ALIGNED(16, const uint8_t, blimit1[16]) = {
283 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
284 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
285 };
Deb Mukherjee072ed172014-12-03 16:26:48 -0800286 tmp = static_cast<uint8_t>(rnd(MAX_LOOP_FILTER));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700287 DECLARE_ALIGNED(16, const uint8_t, limit1[16]) = {
288 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
289 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
290 };
291 tmp = rnd.Rand8();
292 DECLARE_ALIGNED(16, const uint8_t, thresh1[16]) = {
293 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
294 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
295 };
296 int32_t p = kNumCoeffs / 32;
297 uint16_t tmp_s[kNumCoeffs];
298 int j = 0;
299 const uint8_t limit = *limit0 < *limit1 ? *limit0 : *limit1;
300 while (j < kNumCoeffs) {
301 uint8_t val = rnd.Rand8();
302 if (val & 0x80) { // 50% chance to choose a new value.
303 tmp_s[j] = rnd.Rand16();
304 j++;
305 } else { // 50% chance to repeat previous value in row X times.
306 int k = 0;
307 while (k++ < ((val & 0x1f) + 1) && j < kNumCoeffs) {
308 if (j < 1) {
309 tmp_s[j] = rnd.Rand16();
310 } else if (val & 0x20) { // Increment by a value within the limit.
311 tmp_s[j] = (tmp_s[j - 1] + (limit - 1));
312 } else { // Decrement by an value within the limit.
313 tmp_s[j] = (tmp_s[j - 1] - (limit - 1));
314 }
315 j++;
316 }
317 }
318 }
319 for (j = 0; j < kNumCoeffs; j++) {
320 if (i % 2) {
321 s[j] = tmp_s[j] & mask_;
322 } else {
323 s[j] = tmp_s[p * (j % p) + j / p] & mask_;
324 }
325 ref_s[j] = s[j];
326 }
327#if CONFIG_VP9_HIGHBITDEPTH
328 ref_loopfilter_op_(ref_s + 8 + p * 8, p, blimit0, limit0, thresh0,
329 blimit1, limit1, thresh1, bd);
330 ASM_REGISTER_STATE_CHECK(
331 loopfilter_op_(s + 8 + p * 8, p, blimit0, limit0, thresh0,
332 blimit1, limit1, thresh1, bd));
333#else
334 ref_loopfilter_op_(ref_s + 8 + p * 8, p, blimit0, limit0, thresh0,
335 blimit1, limit1, thresh1);
336 ASM_REGISTER_STATE_CHECK(
337 loopfilter_op_(s + 8 + p * 8, p, blimit0, limit0, thresh0,
338 blimit1, limit1, thresh1));
339#endif // CONFIG_VP9_HIGHBITDEPTH
340 for (int j = 0; j < kNumCoeffs; ++j) {
341 err_count += ref_s[j] != s[j];
342 }
343 if (err_count && !err_count_total) {
344 first_failure = i;
345 }
346 err_count_total += err_count;
347 }
348 EXPECT_EQ(0, err_count_total)
349 << "Error: Loop8Test9Param, C output doesn't match SSE2 "
350 "loopfilter output. "
351 << "First failed at test case " << first_failure;
352}
353
354TEST_P(Loop8Test9Param, ValueCheck) {
355 ACMRandom rnd(ACMRandom::DeterministicSeed());
356 const int count_test_block = number_of_iterations;
357#if CONFIG_VP9_HIGHBITDEPTH
James Zernfd3658b2015-05-02 13:24:16 -0700358 DECLARE_ALIGNED(16, uint16_t, s[kNumCoeffs]);
359 DECLARE_ALIGNED(16, uint16_t, ref_s[kNumCoeffs]);
Deb Mukherjee931ed512014-09-17 16:55:05 -0700360#else
James Zernfd3658b2015-05-02 13:24:16 -0700361 DECLARE_ALIGNED(8, uint8_t, s[kNumCoeffs]);
362 DECLARE_ALIGNED(8, uint8_t, ref_s[kNumCoeffs]);
Deb Mukherjee931ed512014-09-17 16:55:05 -0700363#endif // CONFIG_VP9_HIGHBITDEPTH
364 int err_count_total = 0;
365 int first_failure = -1;
366 for (int i = 0; i < count_test_block; ++i) {
367 int err_count = 0;
Deb Mukherjee072ed172014-12-03 16:26:48 -0800368 uint8_t tmp = static_cast<uint8_t>(rnd(3 * MAX_LOOP_FILTER + 4));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700369 DECLARE_ALIGNED(16, const uint8_t, blimit0[16]) = {
370 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
371 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
372 };
Deb Mukherjee072ed172014-12-03 16:26:48 -0800373 tmp = static_cast<uint8_t>(rnd(MAX_LOOP_FILTER));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700374 DECLARE_ALIGNED(16, const uint8_t, limit0[16]) = {
375 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
376 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
377 };
378 tmp = rnd.Rand8();
379 DECLARE_ALIGNED(16, const uint8_t, thresh0[16]) = {
380 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
381 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
382 };
Deb Mukherjee072ed172014-12-03 16:26:48 -0800383 tmp = static_cast<uint8_t>(rnd(3 * MAX_LOOP_FILTER + 4));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700384 DECLARE_ALIGNED(16, const uint8_t, blimit1[16]) = {
385 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
386 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
387 };
Deb Mukherjee072ed172014-12-03 16:26:48 -0800388 tmp = static_cast<uint8_t>(rnd(MAX_LOOP_FILTER));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700389 DECLARE_ALIGNED(16, const uint8_t, limit1[16]) = {
390 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
391 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
392 };
393 tmp = rnd.Rand8();
394 DECLARE_ALIGNED(16, const uint8_t, thresh1[16]) = {
395 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp,
396 tmp, tmp, tmp, tmp, tmp, tmp, tmp, tmp
397 };
398 int32_t p = kNumCoeffs / 32; // TODO(pdlf) can we have non-square here?
399 for (int j = 0; j < kNumCoeffs; ++j) {
400 s[j] = rnd.Rand16() & mask_;
401 ref_s[j] = s[j];
402 }
403#if CONFIG_VP9_HIGHBITDEPTH
404 const int32_t bd = bit_depth_;
405 ref_loopfilter_op_(ref_s + 8 + p * 8, p, blimit0, limit0, thresh0,
406 blimit1, limit1, thresh1, bd);
407 ASM_REGISTER_STATE_CHECK(
408 loopfilter_op_(s + 8 + p * 8, p, blimit0, limit0,
409 thresh0, blimit1, limit1, thresh1, bd));
410#else
411 ref_loopfilter_op_(ref_s + 8 + p * 8, p, blimit0, limit0, thresh0,
412 blimit1, limit1, thresh1);
413 ASM_REGISTER_STATE_CHECK(
414 loopfilter_op_(s + 8 + p * 8, p, blimit0, limit0, thresh0,
415 blimit1, limit1, thresh1));
416#endif // CONFIG_VP9_HIGHBITDEPTH
417 for (int j = 0; j < kNumCoeffs; ++j) {
418 err_count += ref_s[j] != s[j];
419 }
420 if (err_count && !err_count_total) {
421 first_failure = i;
422 }
423 err_count_total += err_count;
424 }
425 EXPECT_EQ(0, err_count_total)
426 << "Error: Loop8Test9Param, C output doesn't match SSE2"
427 "loopfilter output. "
428 << "First failed at test case " << first_failure;
429}
430
431using std::tr1::make_tuple;
432
James Zernc3f2c8a2016-02-12 20:23:41 -0800433#if HAVE_MMX && !CONFIG_VP9_HIGHBITDEPTH
434INSTANTIATE_TEST_CASE_P(
435 MMX, Loop8Test6Param,
436 ::testing::Values(
James Zern3ea537c2016-02-13 11:05:24 -0800437 make_tuple(&vpx_lpf_horizontal_4_mmx,
438 &vpx_lpf_horizontal_4_c, 8),
439 make_tuple(&vpx_lpf_vertical_4_mmx,
440 &vpx_lpf_vertical_4_c, 8)));
James Zernc3f2c8a2016-02-12 20:23:41 -0800441#endif // HAVE_MMX
442
Deb Mukherjee931ed512014-09-17 16:55:05 -0700443#if HAVE_SSE2
444#if CONFIG_VP9_HIGHBITDEPTH
445INSTANTIATE_TEST_CASE_P(
Deb Mukherjee27dce0f2014-11-07 10:19:46 -0800446 SSE2, Loop8Test6Param,
Deb Mukherjee931ed512014-09-17 16:55:05 -0700447 ::testing::Values(
James Zern3ea537c2016-02-13 11:05:24 -0800448 make_tuple(&vpx_highbd_lpf_horizontal_4_sse2,
449 &vpx_highbd_lpf_horizontal_4_c, 8),
450 make_tuple(&vpx_highbd_lpf_vertical_4_sse2,
451 &vpx_highbd_lpf_vertical_4_c, 8),
452 make_tuple(&vpx_highbd_lpf_horizontal_8_sse2,
453 &vpx_highbd_lpf_horizontal_8_c, 8),
454 make_tuple(&vpx_highbd_lpf_horizontal_edge_8_sse2,
455 &vpx_highbd_lpf_horizontal_edge_8_c, 8),
456 make_tuple(&vpx_highbd_lpf_horizontal_edge_16_sse2,
457 &vpx_highbd_lpf_horizontal_edge_16_c, 8),
458 make_tuple(&vpx_highbd_lpf_vertical_8_sse2,
459 &vpx_highbd_lpf_vertical_8_c, 8),
460 make_tuple(&vpx_highbd_lpf_vertical_16_sse2,
461 &vpx_highbd_lpf_vertical_16_c, 8),
462 make_tuple(&vpx_highbd_lpf_horizontal_4_sse2,
463 &vpx_highbd_lpf_horizontal_4_c, 10),
464 make_tuple(&vpx_highbd_lpf_vertical_4_sse2,
465 &vpx_highbd_lpf_vertical_4_c, 10),
466 make_tuple(&vpx_highbd_lpf_horizontal_8_sse2,
467 &vpx_highbd_lpf_horizontal_8_c, 10),
468 make_tuple(&vpx_highbd_lpf_horizontal_edge_8_sse2,
469 &vpx_highbd_lpf_horizontal_edge_8_c, 10),
470 make_tuple(&vpx_highbd_lpf_horizontal_edge_16_sse2,
471 &vpx_highbd_lpf_horizontal_edge_16_c, 10),
472 make_tuple(&vpx_highbd_lpf_vertical_8_sse2,
473 &vpx_highbd_lpf_vertical_8_c, 10),
474 make_tuple(&vpx_highbd_lpf_vertical_16_sse2,
475 &vpx_highbd_lpf_vertical_16_c, 10),
476 make_tuple(&vpx_highbd_lpf_horizontal_4_sse2,
477 &vpx_highbd_lpf_horizontal_4_c, 12),
478 make_tuple(&vpx_highbd_lpf_vertical_4_sse2,
479 &vpx_highbd_lpf_vertical_4_c, 12),
480 make_tuple(&vpx_highbd_lpf_horizontal_8_sse2,
481 &vpx_highbd_lpf_horizontal_8_c, 12),
482 make_tuple(&vpx_highbd_lpf_horizontal_edge_8_sse2,
483 &vpx_highbd_lpf_horizontal_edge_8_c, 12),
484 make_tuple(&vpx_highbd_lpf_horizontal_edge_16_sse2,
485 &vpx_highbd_lpf_horizontal_edge_16_c, 12),
486 make_tuple(&vpx_highbd_lpf_vertical_8_sse2,
487 &vpx_highbd_lpf_vertical_8_c, 12),
488 make_tuple(&vpx_highbd_lpf_vertical_16_sse2,
489 &vpx_highbd_lpf_vertical_16_c, 12),
490 make_tuple(&vpx_highbd_lpf_vertical_16_dual_sse2,
491 &vpx_highbd_lpf_vertical_16_dual_c, 8),
492 make_tuple(&vpx_highbd_lpf_vertical_16_dual_sse2,
493 &vpx_highbd_lpf_vertical_16_dual_c, 10),
494 make_tuple(&vpx_highbd_lpf_vertical_16_dual_sse2,
495 &vpx_highbd_lpf_vertical_16_dual_c, 12)));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700496#else
497INSTANTIATE_TEST_CASE_P(
Deb Mukherjee072ed172014-12-03 16:26:48 -0800498 SSE2, Loop8Test6Param,
Deb Mukherjee931ed512014-09-17 16:55:05 -0700499 ::testing::Values(
James Zern3ea537c2016-02-13 11:05:24 -0800500 make_tuple(&vpx_lpf_horizontal_8_sse2,
501 &vpx_lpf_horizontal_8_c, 8),
502 make_tuple(&vpx_lpf_horizontal_edge_8_sse2,
503 &vpx_lpf_horizontal_edge_8_c, 8),
504 make_tuple(&vpx_lpf_horizontal_edge_16_sse2,
505 &vpx_lpf_horizontal_edge_16_c, 8),
506 make_tuple(&vpx_lpf_vertical_8_sse2,
507 &vpx_lpf_vertical_8_c, 8),
508 make_tuple(&vpx_lpf_vertical_16_sse2,
509 &vpx_lpf_vertical_16_c, 8),
510 make_tuple(&vpx_lpf_vertical_16_dual_sse2,
511 &vpx_lpf_vertical_16_dual_c, 8)));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700512#endif // CONFIG_VP9_HIGHBITDEPTH
Deb Mukherjee27dce0f2014-11-07 10:19:46 -0800513#endif
514
515#if HAVE_AVX2 && (!CONFIG_VP9_HIGHBITDEPTH)
516INSTANTIATE_TEST_CASE_P(
Deb Mukherjee072ed172014-12-03 16:26:48 -0800517 AVX2, Loop8Test6Param,
Deb Mukherjee27dce0f2014-11-07 10:19:46 -0800518 ::testing::Values(
James Zern3ea537c2016-02-13 11:05:24 -0800519 make_tuple(&vpx_lpf_horizontal_edge_8_avx2,
520 &vpx_lpf_horizontal_edge_8_c, 8),
521 make_tuple(&vpx_lpf_horizontal_edge_16_avx2,
522 &vpx_lpf_horizontal_edge_16_c, 8)));
Deb Mukherjee27dce0f2014-11-07 10:19:46 -0800523#endif
Deb Mukherjee931ed512014-09-17 16:55:05 -0700524
525#if HAVE_SSE2
526#if CONFIG_VP9_HIGHBITDEPTH
527INSTANTIATE_TEST_CASE_P(
Deb Mukherjee27dce0f2014-11-07 10:19:46 -0800528 SSE2, Loop8Test9Param,
Deb Mukherjee931ed512014-09-17 16:55:05 -0700529 ::testing::Values(
Jingning Han29927392015-07-17 12:31:53 -0700530 make_tuple(&vpx_highbd_lpf_horizontal_4_dual_sse2,
531 &vpx_highbd_lpf_horizontal_4_dual_c, 8),
532 make_tuple(&vpx_highbd_lpf_horizontal_8_dual_sse2,
533 &vpx_highbd_lpf_horizontal_8_dual_c, 8),
534 make_tuple(&vpx_highbd_lpf_vertical_4_dual_sse2,
535 &vpx_highbd_lpf_vertical_4_dual_c, 8),
536 make_tuple(&vpx_highbd_lpf_vertical_8_dual_sse2,
537 &vpx_highbd_lpf_vertical_8_dual_c, 8),
538 make_tuple(&vpx_highbd_lpf_horizontal_4_dual_sse2,
539 &vpx_highbd_lpf_horizontal_4_dual_c, 10),
540 make_tuple(&vpx_highbd_lpf_horizontal_8_dual_sse2,
541 &vpx_highbd_lpf_horizontal_8_dual_c, 10),
542 make_tuple(&vpx_highbd_lpf_vertical_4_dual_sse2,
543 &vpx_highbd_lpf_vertical_4_dual_c, 10),
544 make_tuple(&vpx_highbd_lpf_vertical_8_dual_sse2,
545 &vpx_highbd_lpf_vertical_8_dual_c, 10),
546 make_tuple(&vpx_highbd_lpf_horizontal_4_dual_sse2,
547 &vpx_highbd_lpf_horizontal_4_dual_c, 12),
548 make_tuple(&vpx_highbd_lpf_horizontal_8_dual_sse2,
549 &vpx_highbd_lpf_horizontal_8_dual_c, 12),
550 make_tuple(&vpx_highbd_lpf_vertical_4_dual_sse2,
551 &vpx_highbd_lpf_vertical_4_dual_c, 12),
552 make_tuple(&vpx_highbd_lpf_vertical_8_dual_sse2,
553 &vpx_highbd_lpf_vertical_8_dual_c, 12)));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700554#else
555INSTANTIATE_TEST_CASE_P(
Deb Mukherjee072ed172014-12-03 16:26:48 -0800556 SSE2, Loop8Test9Param,
Deb Mukherjee931ed512014-09-17 16:55:05 -0700557 ::testing::Values(
Jingning Han29927392015-07-17 12:31:53 -0700558 make_tuple(&vpx_lpf_horizontal_4_dual_sse2,
559 &vpx_lpf_horizontal_4_dual_c, 8),
560 make_tuple(&vpx_lpf_horizontal_8_dual_sse2,
561 &vpx_lpf_horizontal_8_dual_c, 8),
562 make_tuple(&vpx_lpf_vertical_4_dual_sse2,
563 &vpx_lpf_vertical_4_dual_c, 8),
564 make_tuple(&vpx_lpf_vertical_8_dual_sse2,
565 &vpx_lpf_vertical_8_dual_c, 8)));
Deb Mukherjee931ed512014-09-17 16:55:05 -0700566#endif // CONFIG_VP9_HIGHBITDEPTH
567#endif
levytamar8286175a52014-10-16 16:56:37 -0700568
Johannfca00372015-01-06 14:13:41 -0800569#if HAVE_NEON
570#if CONFIG_VP9_HIGHBITDEPTH
571// No neon high bitdepth functions.
572#else
James Yu5b098b12014-01-21 09:43:29 +0800573INSTANTIATE_TEST_CASE_P(
574 NEON, Loop8Test6Param,
575 ::testing::Values(
576#if HAVE_NEON_ASM
Johannfca00372015-01-06 14:13:41 -0800577// Using #if inside the macro is unsupported on MSVS but the tests are not
578// currently built for MSVS with ARM and NEON.
James Zern3ea537c2016-02-13 11:05:24 -0800579 make_tuple(&vpx_lpf_horizontal_edge_8_neon,
580 &vpx_lpf_horizontal_edge_8_c, 8),
581 make_tuple(&vpx_lpf_horizontal_edge_16_neon,
582 &vpx_lpf_horizontal_edge_16_c, 8),
583 make_tuple(&vpx_lpf_vertical_16_neon,
584 &vpx_lpf_vertical_16_c, 8),
585 make_tuple(&vpx_lpf_vertical_16_dual_neon,
586 &vpx_lpf_vertical_16_dual_c, 8),
Jingning Han50adfdf2015-07-15 19:14:54 -0700587#endif // HAVE_NEON_ASM
James Zern3ea537c2016-02-13 11:05:24 -0800588 make_tuple(&vpx_lpf_horizontal_8_neon,
589 &vpx_lpf_horizontal_8_c, 8),
590 make_tuple(&vpx_lpf_vertical_8_neon,
591 &vpx_lpf_vertical_8_c, 8),
592 make_tuple(&vpx_lpf_horizontal_4_neon,
593 &vpx_lpf_horizontal_4_c, 8),
594 make_tuple(&vpx_lpf_vertical_4_neon,
595 &vpx_lpf_vertical_4_c, 8)));
James Yu5b098b12014-01-21 09:43:29 +0800596INSTANTIATE_TEST_CASE_P(
597 NEON, Loop8Test9Param,
598 ::testing::Values(
Johann377b6682014-12-19 15:00:04 -0800599#if HAVE_NEON_ASM
Jingning Han29927392015-07-17 12:31:53 -0700600 make_tuple(&vpx_lpf_horizontal_8_dual_neon,
601 &vpx_lpf_horizontal_8_dual_c, 8),
602 make_tuple(&vpx_lpf_vertical_8_dual_neon,
603 &vpx_lpf_vertical_8_dual_c, 8),
Johann377b6682014-12-19 15:00:04 -0800604#endif // HAVE_NEON_ASM
Jingning Han29927392015-07-17 12:31:53 -0700605 make_tuple(&vpx_lpf_horizontal_4_dual_neon,
606 &vpx_lpf_horizontal_4_dual_c, 8),
607 make_tuple(&vpx_lpf_vertical_4_dual_neon,
608 &vpx_lpf_vertical_4_dual_c, 8)));
Johannfca00372015-01-06 14:13:41 -0800609#endif // CONFIG_VP9_HIGHBITDEPTH
610#endif // HAVE_NEON
James Yu5b098b12014-01-21 09:43:29 +0800611
James Zern47dee372016-02-13 10:24:26 -0800612#if HAVE_DSPR2 && !CONFIG_VP9_HIGHBITDEPTH
613INSTANTIATE_TEST_CASE_P(
614 DSPR2, Loop8Test6Param,
615 ::testing::Values(
James Zern3ea537c2016-02-13 11:05:24 -0800616 make_tuple(&vpx_lpf_horizontal_4_dspr2,
617 &vpx_lpf_horizontal_4_c, 8),
618 make_tuple(&vpx_lpf_horizontal_8_dspr2,
619 &vpx_lpf_horizontal_8_c, 8),
620 make_tuple(&vpx_lpf_horizontal_edge_8,
621 &vpx_lpf_horizontal_edge_8, 8),
622 make_tuple(&vpx_lpf_horizontal_edge_16,
623 &vpx_lpf_horizontal_edge_16, 8),
624 make_tuple(&vpx_lpf_vertical_4_dspr2,
625 &vpx_lpf_vertical_4_c, 8),
626 make_tuple(&vpx_lpf_vertical_8_dspr2,
627 &vpx_lpf_vertical_8_c, 8),
628 make_tuple(&vpx_lpf_vertical_16_dspr2,
629 &vpx_lpf_vertical_16_c, 8),
630 make_tuple(&vpx_lpf_vertical_16_dual_dspr2,
631 &vpx_lpf_vertical_16_dual_c, 8)));
James Zern47dee372016-02-13 10:24:26 -0800632
633INSTANTIATE_TEST_CASE_P(
634 DSPR2, Loop8Test9Param,
635 ::testing::Values(
636 make_tuple(&vpx_lpf_horizontal_4_dual_dspr2,
637 &vpx_lpf_horizontal_4_dual_c, 8),
638 make_tuple(&vpx_lpf_horizontal_8_dual_dspr2,
639 &vpx_lpf_horizontal_8_dual_c, 8),
640 make_tuple(&vpx_lpf_vertical_4_dual_dspr2,
641 &vpx_lpf_vertical_4_dual_c, 8),
642 make_tuple(&vpx_lpf_vertical_8_dual_dspr2,
643 &vpx_lpf_vertical_8_dual_c, 8)));
644#endif // HAVE_DSPR2 && !CONFIG_VP9_HIGHBITDEPTH
645
Parag Salasakar914f8f92015-06-04 11:50:41 +0530646#if HAVE_MSA && (!CONFIG_VP9_HIGHBITDEPTH)
647INSTANTIATE_TEST_CASE_P(
648 MSA, Loop8Test6Param,
649 ::testing::Values(
James Zern3ea537c2016-02-13 11:05:24 -0800650 make_tuple(&vpx_lpf_horizontal_4_msa,
651 &vpx_lpf_horizontal_4_c, 8),
652 make_tuple(&vpx_lpf_horizontal_8_msa,
653 &vpx_lpf_horizontal_8_c, 8),
654 make_tuple(&vpx_lpf_horizontal_edge_8_msa,
655 &vpx_lpf_horizontal_edge_8_c, 8),
656 make_tuple(&vpx_lpf_horizontal_edge_16_msa,
657 &vpx_lpf_horizontal_edge_16_c, 8),
658 make_tuple(&vpx_lpf_vertical_4_msa,
659 &vpx_lpf_vertical_4_c, 8),
660 make_tuple(&vpx_lpf_vertical_8_msa,
661 &vpx_lpf_vertical_8_c, 8),
662 make_tuple(&vpx_lpf_vertical_16_msa,
663 &vpx_lpf_vertical_16_c, 8)));
Parag Salasakard43fd992015-06-05 07:52:40 +0530664
665INSTANTIATE_TEST_CASE_P(
666 MSA, Loop8Test9Param,
667 ::testing::Values(
Jingning Han29927392015-07-17 12:31:53 -0700668 make_tuple(&vpx_lpf_horizontal_4_dual_msa,
669 &vpx_lpf_horizontal_4_dual_c, 8),
670 make_tuple(&vpx_lpf_horizontal_8_dual_msa,
671 &vpx_lpf_horizontal_8_dual_c, 8),
672 make_tuple(&vpx_lpf_vertical_4_dual_msa,
673 &vpx_lpf_vertical_4_dual_c, 8),
674 make_tuple(&vpx_lpf_vertical_8_dual_msa,
675 &vpx_lpf_vertical_8_dual_c, 8)));
Parag Salasakar914f8f92015-06-04 11:50:41 +0530676#endif // HAVE_MSA && (!CONFIG_VP9_HIGHBITDEPTH)
677
Deb Mukherjee931ed512014-09-17 16:55:05 -0700678} // namespace