blob: 4506a90dbd601a7f96f6fed3fd23c1bbd72bf442 [file] [log] [blame]
David Barkerce110cc2017-02-22 10:38:59 +00001/*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 *
4 * 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.
10 */
11
12#include <ctime>
13
14#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
15
Tom Finegan44702c82018-05-22 13:00:39 -070016#include "config/av1_rtcd.h"
17
David Barkerce110cc2017-02-22 10:38:59 +000018#include "test/acm_random.h"
19#include "test/clear_system_state.h"
20#include "test/register_state_check.h"
21#include "test/util.h"
22
Yaowu Xuabdf6552017-11-29 08:41:52 -080023#include "aom_ports/aom_timer.h"
David Barkerce110cc2017-02-22 10:38:59 +000024#include "av1/common/mv.h"
25#include "av1/common/restoration.h"
26
27namespace {
28
James Zern95612802018-03-30 11:37:54 -070029using ::testing::make_tuple;
30using ::testing::tuple;
David Barkerce110cc2017-02-22 10:38:59 +000031using libaom_test::ACMRandom;
32
Imdad Sardharwallac6acc532018-01-03 15:18:24 +000033typedef void (*SgrFunc)(const uint8_t *dat8, int width, int height, int stride,
34 int eps, const int *xqd, uint8_t *dst8, int dst_stride,
35 int32_t *tmpbuf, int bit_depth, int highbd);
36
37// Test parameter list:
38// <tst_fun_>
39typedef tuple<SgrFunc> FilterTestParam;
David Barkerce110cc2017-02-22 10:38:59 +000040
41class AV1SelfguidedFilterTest
42 : public ::testing::TestWithParam<FilterTestParam> {
43 public:
44 virtual ~AV1SelfguidedFilterTest() {}
45 virtual void SetUp() {}
46
47 virtual void TearDown() { libaom_test::ClearSystemState(); }
48
49 protected:
50 void RunSpeedTest() {
Imdad Sardharwallac6acc532018-01-03 15:18:24 +000051 tst_fun_ = GET_PARAM(0);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -070052 const int pu_width = RESTORATION_PROC_UNIT_SIZE;
53 const int pu_height = RESTORATION_PROC_UNIT_SIZE;
Debargha Mukherjeee168a782017-08-31 12:30:10 -070054 const int width = 256, height = 256, stride = 288, out_stride = 288;
David Barkerce110cc2017-02-22 10:38:59 +000055 const int NUM_ITERS = 2000;
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -070056 int i, j, k;
David Barkerce110cc2017-02-22 10:38:59 +000057
Debargha Mukherjeee168a782017-08-31 12:30:10 -070058 uint8_t *input_ =
Imdad Sardharwallac6acc532018-01-03 15:18:24 +000059 (uint8_t *)aom_memalign(32, stride * (height + 32) * sizeof(uint8_t));
Debargha Mukherjeee168a782017-08-31 12:30:10 -070060 uint8_t *output_ = (uint8_t *)aom_memalign(
Imdad Sardharwallac6acc532018-01-03 15:18:24 +000061 32, out_stride * (height + 32) * sizeof(uint8_t));
62 int32_t *tmpbuf = (int32_t *)aom_memalign(32, RESTORATION_TMPBUF_SIZE);
Debargha Mukherjeee168a782017-08-31 12:30:10 -070063 uint8_t *input = input_ + stride * 16 + 16;
64 uint8_t *output = output_ + out_stride * 16 + 16;
David Barkerce110cc2017-02-22 10:38:59 +000065
66 ACMRandom rnd(ACMRandom::DeterministicSeed());
67
Debargha Mukherjeee168a782017-08-31 12:30:10 -070068 for (i = -16; i < height + 16; ++i)
69 for (j = -16; j < width + 16; ++j)
70 input[i * stride + j] = rnd.Rand16() & 0xFF;
David Barkerce110cc2017-02-22 10:38:59 +000071
Johannf152ff62018-02-08 14:33:07 -080072 int xqd[2] = { SGRPROJ_PRJ_MIN0 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX0 + 1 -
73 SGRPROJ_PRJ_MIN0),
74 SGRPROJ_PRJ_MIN1 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX1 + 1 -
75 SGRPROJ_PRJ_MIN1) };
David Barkerce110cc2017-02-22 10:38:59 +000076 // Fix a parameter set, since the speed depends slightly on r.
77 // Change this to test different combinations of values of r.
David Barker5765fad2017-03-08 11:27:09 +000078 int eps = 15;
David Barkerce110cc2017-02-22 10:38:59 +000079
80 av1_loop_restoration_precal();
81
Imdad Sardharwallad051e562018-02-02 09:42:07 +000082 aom_usec_timer ref_timer;
83 aom_usec_timer_start(&ref_timer);
84 for (i = 0; i < NUM_ITERS; ++i) {
85 for (k = 0; k < height; k += pu_height)
86 for (j = 0; j < width; j += pu_width) {
87 int w = AOMMIN(pu_width, width - j);
88 int h = AOMMIN(pu_height, height - k);
89 uint8_t *input_p = input + k * stride + j;
90 uint8_t *output_p = output + k * out_stride + j;
91 apply_selfguided_restoration_c(input_p, w, h, stride, eps, xqd,
92 output_p, out_stride, tmpbuf, 8, 0);
93 }
94 }
95 aom_usec_timer_mark(&ref_timer);
96 const int64_t ref_time = aom_usec_timer_elapsed(&ref_timer);
97
98 aom_usec_timer tst_timer;
99 aom_usec_timer_start(&tst_timer);
David Barkerce110cc2017-02-22 10:38:59 +0000100 for (i = 0; i < NUM_ITERS; ++i) {
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700101 for (k = 0; k < height; k += pu_height)
102 for (j = 0; j < width; j += pu_width) {
103 int w = AOMMIN(pu_width, width - j);
104 int h = AOMMIN(pu_height, height - k);
105 uint8_t *input_p = input + k * stride + j;
106 uint8_t *output_p = output + k * out_stride + j;
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000107 tst_fun_(input_p, w, h, stride, eps, xqd, output_p, out_stride,
108 tmpbuf, 8, 0);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700109 }
David Barkerce110cc2017-02-22 10:38:59 +0000110 }
Imdad Sardharwallad051e562018-02-02 09:42:07 +0000111 aom_usec_timer_mark(&tst_timer);
112 const int64_t tst_time = aom_usec_timer_elapsed(&tst_timer);
David Barkerce110cc2017-02-22 10:38:59 +0000113
Imdad Sardharwallad051e562018-02-02 09:42:07 +0000114 std::cout << "[ ] C time = " << ref_time / 1000
115 << " ms, SIMD time = " << tst_time / 1000 << " ms\n";
116
117 EXPECT_GT(ref_time, tst_time)
118 << "Error: AV1SelfguidedFilterTest.SpeedTest, SIMD slower than C.\n"
119 << "C time: " << ref_time << " us\n"
120 << "SIMD time: " << tst_time << " us\n";
David Barkerce110cc2017-02-22 10:38:59 +0000121
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700122 aom_free(input_);
123 aom_free(output_);
David Barkerce110cc2017-02-22 10:38:59 +0000124 aom_free(tmpbuf);
David Barkerce110cc2017-02-22 10:38:59 +0000125 }
126
127 void RunCorrectnessTest() {
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000128 tst_fun_ = GET_PARAM(0);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700129 const int pu_width = RESTORATION_PROC_UNIT_SIZE;
130 const int pu_height = RESTORATION_PROC_UNIT_SIZE;
David Barkerbcc55352017-03-10 15:04:52 +0000131 // Set the maximum width/height to test here. We actually test a small
132 // range of sizes *up to* this size, so that we can check, eg.,
133 // the behaviour on tiles which are not a multiple of 4 wide.
134 const int max_w = 260, max_h = 260, stride = 672, out_stride = 672;
David Barker5765fad2017-03-08 11:27:09 +0000135 const int NUM_ITERS = 81;
David Barkerce110cc2017-02-22 10:38:59 +0000136 int i, j, k;
137
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700138 uint8_t *input_ =
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000139 (uint8_t *)aom_memalign(32, stride * (max_h + 32) * sizeof(uint8_t));
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700140 uint8_t *output_ = (uint8_t *)aom_memalign(
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000141 32, out_stride * (max_h + 32) * sizeof(uint8_t));
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700142 uint8_t *output2_ = (uint8_t *)aom_memalign(
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000143 32, out_stride * (max_h + 32) * sizeof(uint8_t));
144 int32_t *tmpbuf = (int32_t *)aom_memalign(32, RESTORATION_TMPBUF_SIZE);
David Barkerce110cc2017-02-22 10:38:59 +0000145
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700146 uint8_t *input = input_ + stride * 16 + 16;
147 uint8_t *output = output_ + out_stride * 16 + 16;
148 uint8_t *output2 = output2_ + out_stride * 16 + 16;
149
David Barkerce110cc2017-02-22 10:38:59 +0000150 ACMRandom rnd(ACMRandom::DeterministicSeed());
151
152 av1_loop_restoration_precal();
153
154 for (i = 0; i < NUM_ITERS; ++i) {
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700155 for (j = -16; j < max_h + 16; ++j)
156 for (k = -16; k < max_w + 16; ++k)
157 input[j * stride + k] = rnd.Rand16() & 0xFF;
David Barkerce110cc2017-02-22 10:38:59 +0000158
Johannf152ff62018-02-08 14:33:07 -0800159 int xqd[2] = { SGRPROJ_PRJ_MIN0 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX0 + 1 -
160 SGRPROJ_PRJ_MIN0),
161 SGRPROJ_PRJ_MIN1 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX1 + 1 -
162 SGRPROJ_PRJ_MIN1) };
David Barkerce110cc2017-02-22 10:38:59 +0000163 int eps = rnd.PseudoUniform(1 << SGRPROJ_PARAMS_BITS);
164
David Barker5765fad2017-03-08 11:27:09 +0000165 // Test various tile sizes around 256x256
David Barkerbcc55352017-03-10 15:04:52 +0000166 int test_w = max_w - (i / 9);
167 int test_h = max_h - (i % 9);
David Barker5765fad2017-03-08 11:27:09 +0000168
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700169 for (k = 0; k < test_h; k += pu_height)
170 for (j = 0; j < test_w; j += pu_width) {
171 int w = AOMMIN(pu_width, test_w - j);
172 int h = AOMMIN(pu_height, test_h - k);
173 uint8_t *input_p = input + k * stride + j;
174 uint8_t *output_p = output + k * out_stride + j;
175 uint8_t *output2_p = output2 + k * out_stride + j;
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000176 tst_fun_(input_p, w, h, stride, eps, xqd, output_p, out_stride,
177 tmpbuf, 8, 0);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700178 apply_selfguided_restoration_c(input_p, w, h, stride, eps, xqd,
Rupert Swarbrick625e50b2017-11-22 11:49:55 +0000179 output2_p, out_stride, tmpbuf, 8, 0);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700180 }
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000181
David Barker5765fad2017-03-08 11:27:09 +0000182 for (j = 0; j < test_h; ++j)
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700183 for (k = 0; k < test_w; ++k) {
David Barkerce110cc2017-02-22 10:38:59 +0000184 ASSERT_EQ(output[j * out_stride + k], output2[j * out_stride + k]);
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700185 }
David Barkerce110cc2017-02-22 10:38:59 +0000186 }
187
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700188 aom_free(input_);
189 aom_free(output_);
190 aom_free(output2_);
David Barkerce110cc2017-02-22 10:38:59 +0000191 aom_free(tmpbuf);
David Barkerce110cc2017-02-22 10:38:59 +0000192 }
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000193
194 private:
195 SgrFunc tst_fun_;
David Barkerce110cc2017-02-22 10:38:59 +0000196};
197
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000198TEST_P(AV1SelfguidedFilterTest, DISABLED_SpeedTest) { RunSpeedTest(); }
David Barkerce110cc2017-02-22 10:38:59 +0000199TEST_P(AV1SelfguidedFilterTest, CorrectnessTest) { RunCorrectnessTest(); }
200
David Barkerce110cc2017-02-22 10:38:59 +0000201#if HAVE_SSE4_1
202INSTANTIATE_TEST_CASE_P(SSE4_1, AV1SelfguidedFilterTest,
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000203 ::testing::Values(apply_selfguided_restoration_sse4_1));
David Barkerce110cc2017-02-22 10:38:59 +0000204#endif
205
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000206#if HAVE_AVX2
207INSTANTIATE_TEST_CASE_P(AVX2, AV1SelfguidedFilterTest,
208 ::testing::Values(apply_selfguided_restoration_avx2));
209#endif
210
211// Test parameter list:
212// <tst_fun_, bit_depth>
213typedef tuple<SgrFunc, int> HighbdFilterTestParam;
David Barker4d2af5d2017-03-09 11:46:50 +0000214
215class AV1HighbdSelfguidedFilterTest
216 : public ::testing::TestWithParam<HighbdFilterTestParam> {
217 public:
218 virtual ~AV1HighbdSelfguidedFilterTest() {}
219 virtual void SetUp() {}
220
221 virtual void TearDown() { libaom_test::ClearSystemState(); }
222
223 protected:
224 void RunSpeedTest() {
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000225 tst_fun_ = GET_PARAM(0);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700226 const int pu_width = RESTORATION_PROC_UNIT_SIZE;
227 const int pu_height = RESTORATION_PROC_UNIT_SIZE;
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700228 const int width = 256, height = 256, stride = 288, out_stride = 288;
David Barker4d2af5d2017-03-09 11:46:50 +0000229 const int NUM_ITERS = 2000;
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700230 int i, j, k;
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000231 int bit_depth = GET_PARAM(1);
David Barker4d2af5d2017-03-09 11:46:50 +0000232 int mask = (1 << bit_depth) - 1;
233
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700234 uint16_t *input_ =
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000235 (uint16_t *)aom_memalign(32, stride * (height + 32) * sizeof(uint16_t));
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700236 uint16_t *output_ = (uint16_t *)aom_memalign(
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000237 32, out_stride * (height + 32) * sizeof(uint16_t));
238 int32_t *tmpbuf = (int32_t *)aom_memalign(32, RESTORATION_TMPBUF_SIZE);
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700239 uint16_t *input = input_ + stride * 16 + 16;
240 uint16_t *output = output_ + out_stride * 16 + 16;
David Barker4d2af5d2017-03-09 11:46:50 +0000241
242 ACMRandom rnd(ACMRandom::DeterministicSeed());
243
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700244 for (i = -16; i < height + 16; ++i)
245 for (j = -16; j < width + 16; ++j)
246 input[i * stride + j] = rnd.Rand16() & mask;
David Barker4d2af5d2017-03-09 11:46:50 +0000247
Johannf152ff62018-02-08 14:33:07 -0800248 int xqd[2] = { SGRPROJ_PRJ_MIN0 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX0 + 1 -
249 SGRPROJ_PRJ_MIN0),
250 SGRPROJ_PRJ_MIN1 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX1 + 1 -
251 SGRPROJ_PRJ_MIN1) };
David Barker4d2af5d2017-03-09 11:46:50 +0000252 // Fix a parameter set, since the speed depends slightly on r.
253 // Change this to test different combinations of values of r.
254 int eps = 15;
255
256 av1_loop_restoration_precal();
257
Imdad Sardharwallad051e562018-02-02 09:42:07 +0000258 aom_usec_timer ref_timer;
259 aom_usec_timer_start(&ref_timer);
260 for (i = 0; i < NUM_ITERS; ++i) {
261 for (k = 0; k < height; k += pu_height)
262 for (j = 0; j < width; j += pu_width) {
263 int w = AOMMIN(pu_width, width - j);
264 int h = AOMMIN(pu_height, height - k);
265 uint16_t *input_p = input + k * stride + j;
266 uint16_t *output_p = output + k * out_stride + j;
267 apply_selfguided_restoration_c(
268 CONVERT_TO_BYTEPTR(input_p), w, h, stride, eps, xqd,
269 CONVERT_TO_BYTEPTR(output_p), out_stride, tmpbuf, bit_depth, 1);
270 }
271 }
272 aom_usec_timer_mark(&ref_timer);
273 const int64_t ref_time = aom_usec_timer_elapsed(&ref_timer);
274
275 aom_usec_timer tst_timer;
276 aom_usec_timer_start(&tst_timer);
David Barker4d2af5d2017-03-09 11:46:50 +0000277 for (i = 0; i < NUM_ITERS; ++i) {
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700278 for (k = 0; k < height; k += pu_height)
279 for (j = 0; j < width; j += pu_width) {
280 int w = AOMMIN(pu_width, width - j);
281 int h = AOMMIN(pu_height, height - k);
282 uint16_t *input_p = input + k * stride + j;
283 uint16_t *output_p = output + k * out_stride + j;
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000284 tst_fun_(CONVERT_TO_BYTEPTR(input_p), w, h, stride, eps, xqd,
285 CONVERT_TO_BYTEPTR(output_p), out_stride, tmpbuf, bit_depth,
286 1);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700287 }
David Barker4d2af5d2017-03-09 11:46:50 +0000288 }
Imdad Sardharwallad051e562018-02-02 09:42:07 +0000289 aom_usec_timer_mark(&tst_timer);
290 const int64_t tst_time = aom_usec_timer_elapsed(&tst_timer);
David Barker4d2af5d2017-03-09 11:46:50 +0000291
Imdad Sardharwallad051e562018-02-02 09:42:07 +0000292 std::cout << "[ ] C time = " << ref_time / 1000
293 << " ms, SIMD time = " << tst_time / 1000 << " ms\n";
294
295 EXPECT_GT(ref_time, tst_time)
296 << "Error: AV1HighbdSelfguidedFilterTest.SpeedTest, SIMD slower than "
297 "C.\n"
298 << "C time: " << ref_time << " us\n"
299 << "SIMD time: " << tst_time << " us\n";
David Barker4d2af5d2017-03-09 11:46:50 +0000300
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700301 aom_free(input_);
302 aom_free(output_);
David Barker4d2af5d2017-03-09 11:46:50 +0000303 aom_free(tmpbuf);
David Barker4d2af5d2017-03-09 11:46:50 +0000304 }
305
306 void RunCorrectnessTest() {
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000307 tst_fun_ = GET_PARAM(0);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700308 const int pu_width = RESTORATION_PROC_UNIT_SIZE;
309 const int pu_height = RESTORATION_PROC_UNIT_SIZE;
David Barkerbcc55352017-03-10 15:04:52 +0000310 // Set the maximum width/height to test here. We actually test a small
311 // range of sizes *up to* this size, so that we can check, eg.,
312 // the behaviour on tiles which are not a multiple of 4 wide.
313 const int max_w = 260, max_h = 260, stride = 672, out_stride = 672;
David Barker4d2af5d2017-03-09 11:46:50 +0000314 const int NUM_ITERS = 81;
315 int i, j, k;
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000316 int bit_depth = GET_PARAM(1);
David Barker4d2af5d2017-03-09 11:46:50 +0000317 int mask = (1 << bit_depth) - 1;
318
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700319 uint16_t *input_ =
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000320 (uint16_t *)aom_memalign(32, stride * (max_h + 32) * sizeof(uint16_t));
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700321 uint16_t *output_ = (uint16_t *)aom_memalign(
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000322 32, out_stride * (max_h + 32) * sizeof(uint16_t));
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700323 uint16_t *output2_ = (uint16_t *)aom_memalign(
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000324 32, out_stride * (max_h + 32) * sizeof(uint16_t));
325 int32_t *tmpbuf = (int32_t *)aom_memalign(32, RESTORATION_TMPBUF_SIZE);
David Barker4d2af5d2017-03-09 11:46:50 +0000326
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700327 uint16_t *input = input_ + stride * 16 + 16;
328 uint16_t *output = output_ + out_stride * 16 + 16;
329 uint16_t *output2 = output2_ + out_stride * 16 + 16;
330
David Barker4d2af5d2017-03-09 11:46:50 +0000331 ACMRandom rnd(ACMRandom::DeterministicSeed());
332
333 av1_loop_restoration_precal();
334
335 for (i = 0; i < NUM_ITERS; ++i) {
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700336 for (j = -16; j < max_h + 16; ++j)
337 for (k = -16; k < max_w + 16; ++k)
338 input[j * stride + k] = rnd.Rand16() & mask;
David Barker4d2af5d2017-03-09 11:46:50 +0000339
Johannf152ff62018-02-08 14:33:07 -0800340 int xqd[2] = { SGRPROJ_PRJ_MIN0 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX0 + 1 -
341 SGRPROJ_PRJ_MIN0),
342 SGRPROJ_PRJ_MIN1 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX1 + 1 -
343 SGRPROJ_PRJ_MIN1) };
David Barker4d2af5d2017-03-09 11:46:50 +0000344 int eps = rnd.PseudoUniform(1 << SGRPROJ_PARAMS_BITS);
345
346 // Test various tile sizes around 256x256
David Barkerbcc55352017-03-10 15:04:52 +0000347 int test_w = max_w - (i / 9);
348 int test_h = max_h - (i % 9);
David Barker4d2af5d2017-03-09 11:46:50 +0000349
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700350 for (k = 0; k < test_h; k += pu_height)
351 for (j = 0; j < test_w; j += pu_width) {
352 int w = AOMMIN(pu_width, test_w - j);
353 int h = AOMMIN(pu_height, test_h - k);
354 uint16_t *input_p = input + k * stride + j;
355 uint16_t *output_p = output + k * out_stride + j;
356 uint16_t *output2_p = output2 + k * out_stride + j;
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000357 tst_fun_(CONVERT_TO_BYTEPTR(input_p), w, h, stride, eps, xqd,
358 CONVERT_TO_BYTEPTR(output_p), out_stride, tmpbuf, bit_depth,
359 1);
Rupert Swarbrick625e50b2017-11-22 11:49:55 +0000360 apply_selfguided_restoration_c(
361 CONVERT_TO_BYTEPTR(input_p), w, h, stride, eps, xqd,
362 CONVERT_TO_BYTEPTR(output2_p), out_stride, tmpbuf, bit_depth, 1);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700363 }
364
David Barker4d2af5d2017-03-09 11:46:50 +0000365 for (j = 0; j < test_h; ++j)
366 for (k = 0; k < test_w; ++k)
367 ASSERT_EQ(output[j * out_stride + k], output2[j * out_stride + k]);
368 }
369
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700370 aom_free(input_);
371 aom_free(output_);
372 aom_free(output2_);
David Barker4d2af5d2017-03-09 11:46:50 +0000373 aom_free(tmpbuf);
David Barker4d2af5d2017-03-09 11:46:50 +0000374 }
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000375
376 private:
377 SgrFunc tst_fun_;
David Barker4d2af5d2017-03-09 11:46:50 +0000378};
379
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000380TEST_P(AV1HighbdSelfguidedFilterTest, DISABLED_SpeedTest) { RunSpeedTest(); }
David Barker4d2af5d2017-03-09 11:46:50 +0000381TEST_P(AV1HighbdSelfguidedFilterTest, CorrectnessTest) { RunCorrectnessTest(); }
382
Tom Finegan9f021302017-09-07 07:49:42 -0700383#if HAVE_SSE4_1
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000384const int highbd_params_sse4_1[] = { 8, 10, 12 };
385INSTANTIATE_TEST_CASE_P(
386 SSE4_1, AV1HighbdSelfguidedFilterTest,
387 ::testing::Combine(::testing::Values(apply_selfguided_restoration_sse4_1),
388 ::testing::ValuesIn(highbd_params_sse4_1)));
389#endif
390
391#if HAVE_AVX2
392const int highbd_params_avx2[] = { 8, 10, 12 };
393INSTANTIATE_TEST_CASE_P(
394 AVX2, AV1HighbdSelfguidedFilterTest,
395 ::testing::Combine(::testing::Values(apply_selfguided_restoration_avx2),
396 ::testing::ValuesIn(highbd_params_avx2)));
David Barker4d2af5d2017-03-09 11:46:50 +0000397#endif
David Barker4d2af5d2017-03-09 11:46:50 +0000398
David Barkerce110cc2017-02-22 10:38:59 +0000399} // namespace