blob: 5e2969c2f3df2cce1d1eb73a7d452e42126ef55f [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
16#include "./av1_rtcd.h"
17#include "test/acm_random.h"
18#include "test/clear_system_state.h"
19#include "test/register_state_check.h"
20#include "test/util.h"
21
Yaowu Xuabdf6552017-11-29 08:41:52 -080022#include "aom_ports/aom_timer.h"
David Barkerce110cc2017-02-22 10:38:59 +000023#include "av1/common/mv.h"
24#include "av1/common/restoration.h"
25
26namespace {
27
David Barkerce110cc2017-02-22 10:38:59 +000028using libaom_test::ACMRandom;
Johann123e8a62017-12-28 14:40:49 -080029using std::tr1::make_tuple;
30using std::tr1::tuple;
David Barkerce110cc2017-02-22 10:38:59 +000031
Imdad Sardharwallac6acc532018-01-03 15:18:24 +000032typedef void (*SgrFunc)(const uint8_t *dat8, int width, int height, int stride,
33 int eps, const int *xqd, uint8_t *dst8, int dst_stride,
34 int32_t *tmpbuf, int bit_depth, int highbd);
35
36// Test parameter list:
37// <tst_fun_>
38typedef tuple<SgrFunc> FilterTestParam;
David Barkerce110cc2017-02-22 10:38:59 +000039
40class AV1SelfguidedFilterTest
41 : public ::testing::TestWithParam<FilterTestParam> {
42 public:
43 virtual ~AV1SelfguidedFilterTest() {}
44 virtual void SetUp() {}
45
46 virtual void TearDown() { libaom_test::ClearSystemState(); }
47
48 protected:
49 void RunSpeedTest() {
Imdad Sardharwallac6acc532018-01-03 15:18:24 +000050 tst_fun_ = GET_PARAM(0);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -070051 const int pu_width = RESTORATION_PROC_UNIT_SIZE;
52 const int pu_height = RESTORATION_PROC_UNIT_SIZE;
Debargha Mukherjeee168a782017-08-31 12:30:10 -070053 const int width = 256, height = 256, stride = 288, out_stride = 288;
David Barkerce110cc2017-02-22 10:38:59 +000054 const int NUM_ITERS = 2000;
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -070055 int i, j, k;
David Barkerce110cc2017-02-22 10:38:59 +000056
Debargha Mukherjeee168a782017-08-31 12:30:10 -070057 uint8_t *input_ =
Imdad Sardharwallac6acc532018-01-03 15:18:24 +000058 (uint8_t *)aom_memalign(32, stride * (height + 32) * sizeof(uint8_t));
Debargha Mukherjeee168a782017-08-31 12:30:10 -070059 uint8_t *output_ = (uint8_t *)aom_memalign(
Imdad Sardharwallac6acc532018-01-03 15:18:24 +000060 32, out_stride * (height + 32) * sizeof(uint8_t));
61 int32_t *tmpbuf = (int32_t *)aom_memalign(32, RESTORATION_TMPBUF_SIZE);
Debargha Mukherjeee168a782017-08-31 12:30:10 -070062 uint8_t *input = input_ + stride * 16 + 16;
63 uint8_t *output = output_ + out_stride * 16 + 16;
David Barkerce110cc2017-02-22 10:38:59 +000064
65 ACMRandom rnd(ACMRandom::DeterministicSeed());
66
Debargha Mukherjeee168a782017-08-31 12:30:10 -070067 for (i = -16; i < height + 16; ++i)
68 for (j = -16; j < width + 16; ++j)
69 input[i * stride + j] = rnd.Rand16() & 0xFF;
David Barkerce110cc2017-02-22 10:38:59 +000070
Johannf152ff62018-02-08 14:33:07 -080071 int xqd[2] = { SGRPROJ_PRJ_MIN0 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX0 + 1 -
72 SGRPROJ_PRJ_MIN0),
73 SGRPROJ_PRJ_MIN1 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX1 + 1 -
74 SGRPROJ_PRJ_MIN1) };
David Barkerce110cc2017-02-22 10:38:59 +000075 // Fix a parameter set, since the speed depends slightly on r.
76 // Change this to test different combinations of values of r.
David Barker5765fad2017-03-08 11:27:09 +000077 int eps = 15;
David Barkerce110cc2017-02-22 10:38:59 +000078
79 av1_loop_restoration_precal();
80
Imdad Sardharwallad051e562018-02-02 09:42:07 +000081 aom_usec_timer ref_timer;
82 aom_usec_timer_start(&ref_timer);
83 for (i = 0; i < NUM_ITERS; ++i) {
84 for (k = 0; k < height; k += pu_height)
85 for (j = 0; j < width; j += pu_width) {
86 int w = AOMMIN(pu_width, width - j);
87 int h = AOMMIN(pu_height, height - k);
88 uint8_t *input_p = input + k * stride + j;
89 uint8_t *output_p = output + k * out_stride + j;
90 apply_selfguided_restoration_c(input_p, w, h, stride, eps, xqd,
91 output_p, out_stride, tmpbuf, 8, 0);
92 }
93 }
94 aom_usec_timer_mark(&ref_timer);
95 const int64_t ref_time = aom_usec_timer_elapsed(&ref_timer);
96
97 aom_usec_timer tst_timer;
98 aom_usec_timer_start(&tst_timer);
David Barkerce110cc2017-02-22 10:38:59 +000099 for (i = 0; i < NUM_ITERS; ++i) {
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700100 for (k = 0; k < height; k += pu_height)
101 for (j = 0; j < width; j += pu_width) {
102 int w = AOMMIN(pu_width, width - j);
103 int h = AOMMIN(pu_height, height - k);
104 uint8_t *input_p = input + k * stride + j;
105 uint8_t *output_p = output + k * out_stride + j;
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000106 tst_fun_(input_p, w, h, stride, eps, xqd, output_p, out_stride,
107 tmpbuf, 8, 0);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700108 }
David Barkerce110cc2017-02-22 10:38:59 +0000109 }
Imdad Sardharwallad051e562018-02-02 09:42:07 +0000110 aom_usec_timer_mark(&tst_timer);
111 const int64_t tst_time = aom_usec_timer_elapsed(&tst_timer);
David Barkerce110cc2017-02-22 10:38:59 +0000112
Imdad Sardharwallad051e562018-02-02 09:42:07 +0000113 std::cout << "[ ] C time = " << ref_time / 1000
114 << " ms, SIMD time = " << tst_time / 1000 << " ms\n";
115
116 EXPECT_GT(ref_time, tst_time)
117 << "Error: AV1SelfguidedFilterTest.SpeedTest, SIMD slower than C.\n"
118 << "C time: " << ref_time << " us\n"
119 << "SIMD time: " << tst_time << " us\n";
David Barkerce110cc2017-02-22 10:38:59 +0000120
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700121 aom_free(input_);
122 aom_free(output_);
David Barkerce110cc2017-02-22 10:38:59 +0000123 aom_free(tmpbuf);
David Barkerce110cc2017-02-22 10:38:59 +0000124 }
125
126 void RunCorrectnessTest() {
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000127 tst_fun_ = GET_PARAM(0);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700128 const int pu_width = RESTORATION_PROC_UNIT_SIZE;
129 const int pu_height = RESTORATION_PROC_UNIT_SIZE;
David Barkerbcc55352017-03-10 15:04:52 +0000130 // Set the maximum width/height to test here. We actually test a small
131 // range of sizes *up to* this size, so that we can check, eg.,
132 // the behaviour on tiles which are not a multiple of 4 wide.
133 const int max_w = 260, max_h = 260, stride = 672, out_stride = 672;
David Barker5765fad2017-03-08 11:27:09 +0000134 const int NUM_ITERS = 81;
David Barkerce110cc2017-02-22 10:38:59 +0000135 int i, j, k;
136
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700137 uint8_t *input_ =
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000138 (uint8_t *)aom_memalign(32, stride * (max_h + 32) * sizeof(uint8_t));
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700139 uint8_t *output_ = (uint8_t *)aom_memalign(
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000140 32, out_stride * (max_h + 32) * sizeof(uint8_t));
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700141 uint8_t *output2_ = (uint8_t *)aom_memalign(
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000142 32, out_stride * (max_h + 32) * sizeof(uint8_t));
143 int32_t *tmpbuf = (int32_t *)aom_memalign(32, RESTORATION_TMPBUF_SIZE);
David Barkerce110cc2017-02-22 10:38:59 +0000144
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700145 uint8_t *input = input_ + stride * 16 + 16;
146 uint8_t *output = output_ + out_stride * 16 + 16;
147 uint8_t *output2 = output2_ + out_stride * 16 + 16;
148
David Barkerce110cc2017-02-22 10:38:59 +0000149 ACMRandom rnd(ACMRandom::DeterministicSeed());
150
151 av1_loop_restoration_precal();
152
153 for (i = 0; i < NUM_ITERS; ++i) {
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700154 for (j = -16; j < max_h + 16; ++j)
155 for (k = -16; k < max_w + 16; ++k)
156 input[j * stride + k] = rnd.Rand16() & 0xFF;
David Barkerce110cc2017-02-22 10:38:59 +0000157
Johannf152ff62018-02-08 14:33:07 -0800158 int xqd[2] = { SGRPROJ_PRJ_MIN0 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX0 + 1 -
159 SGRPROJ_PRJ_MIN0),
160 SGRPROJ_PRJ_MIN1 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX1 + 1 -
161 SGRPROJ_PRJ_MIN1) };
David Barkerce110cc2017-02-22 10:38:59 +0000162 int eps = rnd.PseudoUniform(1 << SGRPROJ_PARAMS_BITS);
163
David Barker5765fad2017-03-08 11:27:09 +0000164 // Test various tile sizes around 256x256
David Barkerbcc55352017-03-10 15:04:52 +0000165 int test_w = max_w - (i / 9);
166 int test_h = max_h - (i % 9);
David Barker5765fad2017-03-08 11:27:09 +0000167
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700168 for (k = 0; k < test_h; k += pu_height)
169 for (j = 0; j < test_w; j += pu_width) {
170 int w = AOMMIN(pu_width, test_w - j);
171 int h = AOMMIN(pu_height, test_h - k);
172 uint8_t *input_p = input + k * stride + j;
173 uint8_t *output_p = output + k * out_stride + j;
174 uint8_t *output2_p = output2 + k * out_stride + j;
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000175 tst_fun_(input_p, w, h, stride, eps, xqd, output_p, out_stride,
176 tmpbuf, 8, 0);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700177 apply_selfguided_restoration_c(input_p, w, h, stride, eps, xqd,
Rupert Swarbrick625e50b2017-11-22 11:49:55 +0000178 output2_p, out_stride, tmpbuf, 8, 0);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700179 }
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000180
David Barker5765fad2017-03-08 11:27:09 +0000181 for (j = 0; j < test_h; ++j)
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700182 for (k = 0; k < test_w; ++k) {
David Barkerce110cc2017-02-22 10:38:59 +0000183 ASSERT_EQ(output[j * out_stride + k], output2[j * out_stride + k]);
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700184 }
David Barkerce110cc2017-02-22 10:38:59 +0000185 }
186
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700187 aom_free(input_);
188 aom_free(output_);
189 aom_free(output2_);
David Barkerce110cc2017-02-22 10:38:59 +0000190 aom_free(tmpbuf);
David Barkerce110cc2017-02-22 10:38:59 +0000191 }
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000192
193 private:
194 SgrFunc tst_fun_;
David Barkerce110cc2017-02-22 10:38:59 +0000195};
196
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000197TEST_P(AV1SelfguidedFilterTest, DISABLED_SpeedTest) { RunSpeedTest(); }
David Barkerce110cc2017-02-22 10:38:59 +0000198TEST_P(AV1SelfguidedFilterTest, CorrectnessTest) { RunCorrectnessTest(); }
199
David Barkerce110cc2017-02-22 10:38:59 +0000200#if HAVE_SSE4_1
201INSTANTIATE_TEST_CASE_P(SSE4_1, AV1SelfguidedFilterTest,
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000202 ::testing::Values(apply_selfguided_restoration_sse4_1));
David Barkerce110cc2017-02-22 10:38:59 +0000203#endif
204
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000205#if HAVE_AVX2
206INSTANTIATE_TEST_CASE_P(AVX2, AV1SelfguidedFilterTest,
207 ::testing::Values(apply_selfguided_restoration_avx2));
208#endif
209
210// Test parameter list:
211// <tst_fun_, bit_depth>
212typedef tuple<SgrFunc, int> HighbdFilterTestParam;
David Barker4d2af5d2017-03-09 11:46:50 +0000213
214class AV1HighbdSelfguidedFilterTest
215 : public ::testing::TestWithParam<HighbdFilterTestParam> {
216 public:
217 virtual ~AV1HighbdSelfguidedFilterTest() {}
218 virtual void SetUp() {}
219
220 virtual void TearDown() { libaom_test::ClearSystemState(); }
221
222 protected:
223 void RunSpeedTest() {
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000224 tst_fun_ = GET_PARAM(0);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700225 const int pu_width = RESTORATION_PROC_UNIT_SIZE;
226 const int pu_height = RESTORATION_PROC_UNIT_SIZE;
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700227 const int width = 256, height = 256, stride = 288, out_stride = 288;
David Barker4d2af5d2017-03-09 11:46:50 +0000228 const int NUM_ITERS = 2000;
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700229 int i, j, k;
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000230 int bit_depth = GET_PARAM(1);
David Barker4d2af5d2017-03-09 11:46:50 +0000231 int mask = (1 << bit_depth) - 1;
232
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700233 uint16_t *input_ =
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000234 (uint16_t *)aom_memalign(32, stride * (height + 32) * sizeof(uint16_t));
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700235 uint16_t *output_ = (uint16_t *)aom_memalign(
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000236 32, out_stride * (height + 32) * sizeof(uint16_t));
237 int32_t *tmpbuf = (int32_t *)aom_memalign(32, RESTORATION_TMPBUF_SIZE);
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700238 uint16_t *input = input_ + stride * 16 + 16;
239 uint16_t *output = output_ + out_stride * 16 + 16;
David Barker4d2af5d2017-03-09 11:46:50 +0000240
241 ACMRandom rnd(ACMRandom::DeterministicSeed());
242
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700243 for (i = -16; i < height + 16; ++i)
244 for (j = -16; j < width + 16; ++j)
245 input[i * stride + j] = rnd.Rand16() & mask;
David Barker4d2af5d2017-03-09 11:46:50 +0000246
Johannf152ff62018-02-08 14:33:07 -0800247 int xqd[2] = { SGRPROJ_PRJ_MIN0 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX0 + 1 -
248 SGRPROJ_PRJ_MIN0),
249 SGRPROJ_PRJ_MIN1 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX1 + 1 -
250 SGRPROJ_PRJ_MIN1) };
David Barker4d2af5d2017-03-09 11:46:50 +0000251 // Fix a parameter set, since the speed depends slightly on r.
252 // Change this to test different combinations of values of r.
253 int eps = 15;
254
255 av1_loop_restoration_precal();
256
Imdad Sardharwallad051e562018-02-02 09:42:07 +0000257 aom_usec_timer ref_timer;
258 aom_usec_timer_start(&ref_timer);
259 for (i = 0; i < NUM_ITERS; ++i) {
260 for (k = 0; k < height; k += pu_height)
261 for (j = 0; j < width; j += pu_width) {
262 int w = AOMMIN(pu_width, width - j);
263 int h = AOMMIN(pu_height, height - k);
264 uint16_t *input_p = input + k * stride + j;
265 uint16_t *output_p = output + k * out_stride + j;
266 apply_selfguided_restoration_c(
267 CONVERT_TO_BYTEPTR(input_p), w, h, stride, eps, xqd,
268 CONVERT_TO_BYTEPTR(output_p), out_stride, tmpbuf, bit_depth, 1);
269 }
270 }
271 aom_usec_timer_mark(&ref_timer);
272 const int64_t ref_time = aom_usec_timer_elapsed(&ref_timer);
273
274 aom_usec_timer tst_timer;
275 aom_usec_timer_start(&tst_timer);
David Barker4d2af5d2017-03-09 11:46:50 +0000276 for (i = 0; i < NUM_ITERS; ++i) {
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700277 for (k = 0; k < height; k += pu_height)
278 for (j = 0; j < width; j += pu_width) {
279 int w = AOMMIN(pu_width, width - j);
280 int h = AOMMIN(pu_height, height - k);
281 uint16_t *input_p = input + k * stride + j;
282 uint16_t *output_p = output + k * out_stride + j;
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000283 tst_fun_(CONVERT_TO_BYTEPTR(input_p), w, h, stride, eps, xqd,
284 CONVERT_TO_BYTEPTR(output_p), out_stride, tmpbuf, bit_depth,
285 1);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700286 }
David Barker4d2af5d2017-03-09 11:46:50 +0000287 }
Imdad Sardharwallad051e562018-02-02 09:42:07 +0000288 aom_usec_timer_mark(&tst_timer);
289 const int64_t tst_time = aom_usec_timer_elapsed(&tst_timer);
David Barker4d2af5d2017-03-09 11:46:50 +0000290
Imdad Sardharwallad051e562018-02-02 09:42:07 +0000291 std::cout << "[ ] C time = " << ref_time / 1000
292 << " ms, SIMD time = " << tst_time / 1000 << " ms\n";
293
294 EXPECT_GT(ref_time, tst_time)
295 << "Error: AV1HighbdSelfguidedFilterTest.SpeedTest, SIMD slower than "
296 "C.\n"
297 << "C time: " << ref_time << " us\n"
298 << "SIMD time: " << tst_time << " us\n";
David Barker4d2af5d2017-03-09 11:46:50 +0000299
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700300 aom_free(input_);
301 aom_free(output_);
David Barker4d2af5d2017-03-09 11:46:50 +0000302 aom_free(tmpbuf);
David Barker4d2af5d2017-03-09 11:46:50 +0000303 }
304
305 void RunCorrectnessTest() {
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000306 tst_fun_ = GET_PARAM(0);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700307 const int pu_width = RESTORATION_PROC_UNIT_SIZE;
308 const int pu_height = RESTORATION_PROC_UNIT_SIZE;
David Barkerbcc55352017-03-10 15:04:52 +0000309 // Set the maximum width/height to test here. We actually test a small
310 // range of sizes *up to* this size, so that we can check, eg.,
311 // the behaviour on tiles which are not a multiple of 4 wide.
312 const int max_w = 260, max_h = 260, stride = 672, out_stride = 672;
David Barker4d2af5d2017-03-09 11:46:50 +0000313 const int NUM_ITERS = 81;
314 int i, j, k;
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000315 int bit_depth = GET_PARAM(1);
David Barker4d2af5d2017-03-09 11:46:50 +0000316 int mask = (1 << bit_depth) - 1;
317
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700318 uint16_t *input_ =
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000319 (uint16_t *)aom_memalign(32, stride * (max_h + 32) * sizeof(uint16_t));
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700320 uint16_t *output_ = (uint16_t *)aom_memalign(
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000321 32, out_stride * (max_h + 32) * sizeof(uint16_t));
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700322 uint16_t *output2_ = (uint16_t *)aom_memalign(
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000323 32, out_stride * (max_h + 32) * sizeof(uint16_t));
324 int32_t *tmpbuf = (int32_t *)aom_memalign(32, RESTORATION_TMPBUF_SIZE);
David Barker4d2af5d2017-03-09 11:46:50 +0000325
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700326 uint16_t *input = input_ + stride * 16 + 16;
327 uint16_t *output = output_ + out_stride * 16 + 16;
328 uint16_t *output2 = output2_ + out_stride * 16 + 16;
329
David Barker4d2af5d2017-03-09 11:46:50 +0000330 ACMRandom rnd(ACMRandom::DeterministicSeed());
331
332 av1_loop_restoration_precal();
333
334 for (i = 0; i < NUM_ITERS; ++i) {
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700335 for (j = -16; j < max_h + 16; ++j)
336 for (k = -16; k < max_w + 16; ++k)
337 input[j * stride + k] = rnd.Rand16() & mask;
David Barker4d2af5d2017-03-09 11:46:50 +0000338
Johannf152ff62018-02-08 14:33:07 -0800339 int xqd[2] = { SGRPROJ_PRJ_MIN0 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX0 + 1 -
340 SGRPROJ_PRJ_MIN0),
341 SGRPROJ_PRJ_MIN1 + rnd.PseudoUniform(SGRPROJ_PRJ_MAX1 + 1 -
342 SGRPROJ_PRJ_MIN1) };
David Barker4d2af5d2017-03-09 11:46:50 +0000343 int eps = rnd.PseudoUniform(1 << SGRPROJ_PARAMS_BITS);
344
345 // Test various tile sizes around 256x256
David Barkerbcc55352017-03-10 15:04:52 +0000346 int test_w = max_w - (i / 9);
347 int test_h = max_h - (i % 9);
David Barker4d2af5d2017-03-09 11:46:50 +0000348
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700349 for (k = 0; k < test_h; k += pu_height)
350 for (j = 0; j < test_w; j += pu_width) {
351 int w = AOMMIN(pu_width, test_w - j);
352 int h = AOMMIN(pu_height, test_h - k);
353 uint16_t *input_p = input + k * stride + j;
354 uint16_t *output_p = output + k * out_stride + j;
355 uint16_t *output2_p = output2 + k * out_stride + j;
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000356 tst_fun_(CONVERT_TO_BYTEPTR(input_p), w, h, stride, eps, xqd,
357 CONVERT_TO_BYTEPTR(output_p), out_stride, tmpbuf, bit_depth,
358 1);
Rupert Swarbrick625e50b2017-11-22 11:49:55 +0000359 apply_selfguided_restoration_c(
360 CONVERT_TO_BYTEPTR(input_p), w, h, stride, eps, xqd,
361 CONVERT_TO_BYTEPTR(output2_p), out_stride, tmpbuf, bit_depth, 1);
Debargha Mukherjee1330dfd2017-09-03 22:22:27 -0700362 }
363
David Barker4d2af5d2017-03-09 11:46:50 +0000364 for (j = 0; j < test_h; ++j)
365 for (k = 0; k < test_w; ++k)
366 ASSERT_EQ(output[j * out_stride + k], output2[j * out_stride + k]);
367 }
368
Debargha Mukherjeee168a782017-08-31 12:30:10 -0700369 aom_free(input_);
370 aom_free(output_);
371 aom_free(output2_);
David Barker4d2af5d2017-03-09 11:46:50 +0000372 aom_free(tmpbuf);
David Barker4d2af5d2017-03-09 11:46:50 +0000373 }
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000374
375 private:
376 SgrFunc tst_fun_;
David Barker4d2af5d2017-03-09 11:46:50 +0000377};
378
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000379TEST_P(AV1HighbdSelfguidedFilterTest, DISABLED_SpeedTest) { RunSpeedTest(); }
David Barker4d2af5d2017-03-09 11:46:50 +0000380TEST_P(AV1HighbdSelfguidedFilterTest, CorrectnessTest) { RunCorrectnessTest(); }
381
Tom Finegan9f021302017-09-07 07:49:42 -0700382#if HAVE_SSE4_1
Imdad Sardharwallac6acc532018-01-03 15:18:24 +0000383const int highbd_params_sse4_1[] = { 8, 10, 12 };
384INSTANTIATE_TEST_CASE_P(
385 SSE4_1, AV1HighbdSelfguidedFilterTest,
386 ::testing::Combine(::testing::Values(apply_selfguided_restoration_sse4_1),
387 ::testing::ValuesIn(highbd_params_sse4_1)));
388#endif
389
390#if HAVE_AVX2
391const int highbd_params_avx2[] = { 8, 10, 12 };
392INSTANTIATE_TEST_CASE_P(
393 AVX2, AV1HighbdSelfguidedFilterTest,
394 ::testing::Combine(::testing::Values(apply_selfguided_restoration_avx2),
395 ::testing::ValuesIn(highbd_params_avx2)));
David Barker4d2af5d2017-03-09 11:46:50 +0000396#endif
David Barker4d2af5d2017-03-09 11:46:50 +0000397
David Barkerce110cc2017-02-22 10:38:59 +0000398} // namespace