1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2017, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker *
4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker */
11*77c1e3ccSAndroid Build Coastguard Worker
12*77c1e3ccSAndroid Build Coastguard Worker #include <math.h>
13*77c1e3ccSAndroid Build Coastguard Worker #include <stdlib.h>
14*77c1e3ccSAndroid Build Coastguard Worker #include <string.h>
15*77c1e3ccSAndroid Build Coastguard Worker
16*77c1e3ccSAndroid Build Coastguard Worker #include "gtest/gtest.h"
17*77c1e3ccSAndroid Build Coastguard Worker #include "test/register_state_check.h"
18*77c1e3ccSAndroid Build Coastguard Worker #include "test/function_equivalence_test.h"
19*77c1e3ccSAndroid Build Coastguard Worker
20*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_config.h"
21*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_dsp_rtcd.h"
22*77c1e3ccSAndroid Build Coastguard Worker #include "config/av1_rtcd.h"
23*77c1e3ccSAndroid Build Coastguard Worker
24*77c1e3ccSAndroid Build Coastguard Worker #include "aom/aom_integer.h"
25*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/enums.h"
26*77c1e3ccSAndroid Build Coastguard Worker
27*77c1e3ccSAndroid Build Coastguard Worker using libaom_test::FunctionEquivalenceTest;
28*77c1e3ccSAndroid Build Coastguard Worker
29*77c1e3ccSAndroid Build Coastguard Worker namespace {
30*77c1e3ccSAndroid Build Coastguard Worker
31*77c1e3ccSAndroid Build Coastguard Worker template <typename F, typename T>
32*77c1e3ccSAndroid Build Coastguard Worker class UpsampleTest : public FunctionEquivalenceTest<F> {
33*77c1e3ccSAndroid Build Coastguard Worker protected:
34*77c1e3ccSAndroid Build Coastguard Worker static const int kIterations = 1000000;
35*77c1e3ccSAndroid Build Coastguard Worker static const int kMinEdge = 4;
36*77c1e3ccSAndroid Build Coastguard Worker static const int kMaxEdge = 24;
37*77c1e3ccSAndroid Build Coastguard Worker static const int kBufSize = 2 * 64 + 32;
38*77c1e3ccSAndroid Build Coastguard Worker static const int kOffset = 16;
39*77c1e3ccSAndroid Build Coastguard Worker
40*77c1e3ccSAndroid Build Coastguard Worker ~UpsampleTest() override = default;
41*77c1e3ccSAndroid Build Coastguard Worker
42*77c1e3ccSAndroid Build Coastguard Worker virtual void Execute(T *edge_tst) = 0;
43*77c1e3ccSAndroid Build Coastguard Worker
Common()44*77c1e3ccSAndroid Build Coastguard Worker void Common() {
45*77c1e3ccSAndroid Build Coastguard Worker edge_ref_ = &edge_ref_data_[kOffset];
46*77c1e3ccSAndroid Build Coastguard Worker edge_tst_ = &edge_tst_data_[kOffset];
47*77c1e3ccSAndroid Build Coastguard Worker
48*77c1e3ccSAndroid Build Coastguard Worker Execute(edge_tst_);
49*77c1e3ccSAndroid Build Coastguard Worker
50*77c1e3ccSAndroid Build Coastguard Worker const int max_idx = (size_ - 1) * 2;
51*77c1e3ccSAndroid Build Coastguard Worker for (int r = -2; r <= max_idx; ++r) {
52*77c1e3ccSAndroid Build Coastguard Worker ASSERT_EQ(edge_ref_[r], edge_tst_[r]);
53*77c1e3ccSAndroid Build Coastguard Worker }
54*77c1e3ccSAndroid Build Coastguard Worker }
55*77c1e3ccSAndroid Build Coastguard Worker
56*77c1e3ccSAndroid Build Coastguard Worker T edge_ref_data_[kBufSize];
57*77c1e3ccSAndroid Build Coastguard Worker T edge_tst_data_[kBufSize];
58*77c1e3ccSAndroid Build Coastguard Worker
59*77c1e3ccSAndroid Build Coastguard Worker T *edge_ref_;
60*77c1e3ccSAndroid Build Coastguard Worker T *edge_tst_;
61*77c1e3ccSAndroid Build Coastguard Worker
62*77c1e3ccSAndroid Build Coastguard Worker int size_;
63*77c1e3ccSAndroid Build Coastguard Worker };
64*77c1e3ccSAndroid Build Coastguard Worker
65*77c1e3ccSAndroid Build Coastguard Worker typedef void (*UP8B)(uint8_t *p, int size);
66*77c1e3ccSAndroid Build Coastguard Worker typedef libaom_test::FuncParam<UP8B> TestFuncs;
67*77c1e3ccSAndroid Build Coastguard Worker
68*77c1e3ccSAndroid Build Coastguard Worker class UpsampleTest8B : public UpsampleTest<UP8B, uint8_t> {
69*77c1e3ccSAndroid Build Coastguard Worker protected:
Execute(uint8_t * edge_tst)70*77c1e3ccSAndroid Build Coastguard Worker void Execute(uint8_t *edge_tst) override {
71*77c1e3ccSAndroid Build Coastguard Worker params_.ref_func(edge_ref_, size_);
72*77c1e3ccSAndroid Build Coastguard Worker API_REGISTER_STATE_CHECK(params_.tst_func(edge_tst, size_));
73*77c1e3ccSAndroid Build Coastguard Worker }
74*77c1e3ccSAndroid Build Coastguard Worker };
75*77c1e3ccSAndroid Build Coastguard Worker
TEST_P(UpsampleTest8B,RandomValues)76*77c1e3ccSAndroid Build Coastguard Worker TEST_P(UpsampleTest8B, RandomValues) {
77*77c1e3ccSAndroid Build Coastguard Worker for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
78*77c1e3ccSAndroid Build Coastguard Worker size_ = 4 * (this->rng_(4) + 1);
79*77c1e3ccSAndroid Build Coastguard Worker
80*77c1e3ccSAndroid Build Coastguard Worker int i, pix = 0;
81*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < kOffset + size_; ++i) {
82*77c1e3ccSAndroid Build Coastguard Worker pix = rng_.Rand8();
83*77c1e3ccSAndroid Build Coastguard Worker edge_ref_data_[i] = pix;
84*77c1e3ccSAndroid Build Coastguard Worker edge_tst_data_[i] = edge_ref_data_[i];
85*77c1e3ccSAndroid Build Coastguard Worker }
86*77c1e3ccSAndroid Build Coastguard Worker
87*77c1e3ccSAndroid Build Coastguard Worker // Extend final sample
88*77c1e3ccSAndroid Build Coastguard Worker while (i < kBufSize) {
89*77c1e3ccSAndroid Build Coastguard Worker edge_ref_data_[i] = pix;
90*77c1e3ccSAndroid Build Coastguard Worker edge_tst_data_[i] = pix;
91*77c1e3ccSAndroid Build Coastguard Worker i++;
92*77c1e3ccSAndroid Build Coastguard Worker }
93*77c1e3ccSAndroid Build Coastguard Worker
94*77c1e3ccSAndroid Build Coastguard Worker Common();
95*77c1e3ccSAndroid Build Coastguard Worker }
96*77c1e3ccSAndroid Build Coastguard Worker }
97*77c1e3ccSAndroid Build Coastguard Worker
TEST_P(UpsampleTest8B,DISABLED_Speed)98*77c1e3ccSAndroid Build Coastguard Worker TEST_P(UpsampleTest8B, DISABLED_Speed) {
99*77c1e3ccSAndroid Build Coastguard Worker const int test_count = 10000000;
100*77c1e3ccSAndroid Build Coastguard Worker size_ = kMaxEdge;
101*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < kOffset + size_; ++i) {
102*77c1e3ccSAndroid Build Coastguard Worker edge_tst_data_[i] = rng_.Rand8();
103*77c1e3ccSAndroid Build Coastguard Worker }
104*77c1e3ccSAndroid Build Coastguard Worker edge_tst_ = &edge_tst_data_[kOffset];
105*77c1e3ccSAndroid Build Coastguard Worker for (int iter = 0; iter < test_count; ++iter) {
106*77c1e3ccSAndroid Build Coastguard Worker API_REGISTER_STATE_CHECK(params_.tst_func(edge_tst_, size_));
107*77c1e3ccSAndroid Build Coastguard Worker }
108*77c1e3ccSAndroid Build Coastguard Worker }
109*77c1e3ccSAndroid Build Coastguard Worker
110*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE4_1
111*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
112*77c1e3ccSAndroid Build Coastguard Worker SSE4_1, UpsampleTest8B,
113*77c1e3ccSAndroid Build Coastguard Worker ::testing::Values(TestFuncs(av1_upsample_intra_edge_c,
114*77c1e3ccSAndroid Build Coastguard Worker av1_upsample_intra_edge_sse4_1)));
115*77c1e3ccSAndroid Build Coastguard Worker #endif // HAVE_SSE4_1
116*77c1e3ccSAndroid Build Coastguard Worker
117*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
118*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
119*77c1e3ccSAndroid Build Coastguard Worker NEON, UpsampleTest8B,
120*77c1e3ccSAndroid Build Coastguard Worker ::testing::Values(TestFuncs(av1_upsample_intra_edge_c,
121*77c1e3ccSAndroid Build Coastguard Worker av1_upsample_intra_edge_neon)));
122*77c1e3ccSAndroid Build Coastguard Worker #endif // HAVE_NEON
123*77c1e3ccSAndroid Build Coastguard Worker
124*77c1e3ccSAndroid Build Coastguard Worker template <typename F, typename T>
125*77c1e3ccSAndroid Build Coastguard Worker class FilterEdgeTest : public FunctionEquivalenceTest<F> {
126*77c1e3ccSAndroid Build Coastguard Worker protected:
127*77c1e3ccSAndroid Build Coastguard Worker static const int kIterations = 1000000;
128*77c1e3ccSAndroid Build Coastguard Worker static const int kMaxEdge = 2 * 64;
129*77c1e3ccSAndroid Build Coastguard Worker static const int kBufSize = kMaxEdge + 32;
130*77c1e3ccSAndroid Build Coastguard Worker static const int kOffset = 15;
131*77c1e3ccSAndroid Build Coastguard Worker
132*77c1e3ccSAndroid Build Coastguard Worker ~FilterEdgeTest() override = default;
133*77c1e3ccSAndroid Build Coastguard Worker
134*77c1e3ccSAndroid Build Coastguard Worker virtual void Execute(T *edge_tst) = 0;
135*77c1e3ccSAndroid Build Coastguard Worker
Common()136*77c1e3ccSAndroid Build Coastguard Worker void Common() {
137*77c1e3ccSAndroid Build Coastguard Worker edge_ref_ = &edge_ref_data_[kOffset];
138*77c1e3ccSAndroid Build Coastguard Worker edge_tst_ = &edge_tst_data_[kOffset];
139*77c1e3ccSAndroid Build Coastguard Worker
140*77c1e3ccSAndroid Build Coastguard Worker Execute(edge_tst_);
141*77c1e3ccSAndroid Build Coastguard Worker
142*77c1e3ccSAndroid Build Coastguard Worker for (int r = 0; r < size_; ++r) {
143*77c1e3ccSAndroid Build Coastguard Worker ASSERT_EQ(edge_ref_[r], edge_tst_[r]);
144*77c1e3ccSAndroid Build Coastguard Worker }
145*77c1e3ccSAndroid Build Coastguard Worker }
146*77c1e3ccSAndroid Build Coastguard Worker
147*77c1e3ccSAndroid Build Coastguard Worker T edge_ref_data_[kBufSize];
148*77c1e3ccSAndroid Build Coastguard Worker T edge_tst_data_[kBufSize];
149*77c1e3ccSAndroid Build Coastguard Worker
150*77c1e3ccSAndroid Build Coastguard Worker T *edge_ref_;
151*77c1e3ccSAndroid Build Coastguard Worker T *edge_tst_;
152*77c1e3ccSAndroid Build Coastguard Worker
153*77c1e3ccSAndroid Build Coastguard Worker int size_;
154*77c1e3ccSAndroid Build Coastguard Worker int strength_;
155*77c1e3ccSAndroid Build Coastguard Worker };
156*77c1e3ccSAndroid Build Coastguard Worker
157*77c1e3ccSAndroid Build Coastguard Worker typedef void (*FE8B)(uint8_t *p, int size, int strength);
158*77c1e3ccSAndroid Build Coastguard Worker typedef libaom_test::FuncParam<FE8B> FilterEdgeTestFuncs;
159*77c1e3ccSAndroid Build Coastguard Worker
160*77c1e3ccSAndroid Build Coastguard Worker class FilterEdgeTest8B : public FilterEdgeTest<FE8B, uint8_t> {
161*77c1e3ccSAndroid Build Coastguard Worker protected:
Execute(uint8_t * edge_tst)162*77c1e3ccSAndroid Build Coastguard Worker void Execute(uint8_t *edge_tst) override {
163*77c1e3ccSAndroid Build Coastguard Worker params_.ref_func(edge_ref_, size_, strength_);
164*77c1e3ccSAndroid Build Coastguard Worker API_REGISTER_STATE_CHECK(params_.tst_func(edge_tst, size_, strength_));
165*77c1e3ccSAndroid Build Coastguard Worker }
166*77c1e3ccSAndroid Build Coastguard Worker };
167*77c1e3ccSAndroid Build Coastguard Worker
TEST_P(FilterEdgeTest8B,RandomValues)168*77c1e3ccSAndroid Build Coastguard Worker TEST_P(FilterEdgeTest8B, RandomValues) {
169*77c1e3ccSAndroid Build Coastguard Worker for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
170*77c1e3ccSAndroid Build Coastguard Worker strength_ = this->rng_(4);
171*77c1e3ccSAndroid Build Coastguard Worker size_ = 4 * (this->rng_(128 / 4) + 1) + 1;
172*77c1e3ccSAndroid Build Coastguard Worker
173*77c1e3ccSAndroid Build Coastguard Worker int i, pix = 0;
174*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < kOffset + size_; ++i) {
175*77c1e3ccSAndroid Build Coastguard Worker pix = rng_.Rand8();
176*77c1e3ccSAndroid Build Coastguard Worker edge_ref_data_[i] = pix;
177*77c1e3ccSAndroid Build Coastguard Worker edge_tst_data_[i] = pix;
178*77c1e3ccSAndroid Build Coastguard Worker }
179*77c1e3ccSAndroid Build Coastguard Worker
180*77c1e3ccSAndroid Build Coastguard Worker Common();
181*77c1e3ccSAndroid Build Coastguard Worker }
182*77c1e3ccSAndroid Build Coastguard Worker }
183*77c1e3ccSAndroid Build Coastguard Worker
TEST_P(FilterEdgeTest8B,DISABLED_Speed)184*77c1e3ccSAndroid Build Coastguard Worker TEST_P(FilterEdgeTest8B, DISABLED_Speed) {
185*77c1e3ccSAndroid Build Coastguard Worker const int test_count = 10000000;
186*77c1e3ccSAndroid Build Coastguard Worker size_ = kMaxEdge;
187*77c1e3ccSAndroid Build Coastguard Worker strength_ = 1;
188*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < kOffset + size_; ++i) {
189*77c1e3ccSAndroid Build Coastguard Worker edge_tst_data_[i] = rng_.Rand8();
190*77c1e3ccSAndroid Build Coastguard Worker }
191*77c1e3ccSAndroid Build Coastguard Worker edge_tst_ = &edge_tst_data_[kOffset];
192*77c1e3ccSAndroid Build Coastguard Worker for (int iter = 0; iter < test_count; ++iter) {
193*77c1e3ccSAndroid Build Coastguard Worker API_REGISTER_STATE_CHECK(params_.tst_func(edge_tst_, size_, strength_));
194*77c1e3ccSAndroid Build Coastguard Worker // iterate over filter strengths (1,2,3)
195*77c1e3ccSAndroid Build Coastguard Worker strength_ = strength_ == 3 ? 1 : strength_ + 1;
196*77c1e3ccSAndroid Build Coastguard Worker }
197*77c1e3ccSAndroid Build Coastguard Worker }
198*77c1e3ccSAndroid Build Coastguard Worker
199*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE4_1
200*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
201*77c1e3ccSAndroid Build Coastguard Worker SSE4_1, FilterEdgeTest8B,
202*77c1e3ccSAndroid Build Coastguard Worker ::testing::Values(FilterEdgeTestFuncs(av1_filter_intra_edge_c,
203*77c1e3ccSAndroid Build Coastguard Worker av1_filter_intra_edge_sse4_1)));
204*77c1e3ccSAndroid Build Coastguard Worker #endif // HAVE_SSE4_1
205*77c1e3ccSAndroid Build Coastguard Worker
206*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
207*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
208*77c1e3ccSAndroid Build Coastguard Worker NEON, FilterEdgeTest8B,
209*77c1e3ccSAndroid Build Coastguard Worker ::testing::Values(FilterEdgeTestFuncs(av1_filter_intra_edge_c,
210*77c1e3ccSAndroid Build Coastguard Worker av1_filter_intra_edge_neon)));
211*77c1e3ccSAndroid Build Coastguard Worker #endif // HAVE_NEON
212*77c1e3ccSAndroid Build Coastguard Worker
213*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
214*77c1e3ccSAndroid Build Coastguard Worker
215*77c1e3ccSAndroid Build Coastguard Worker typedef void (*UPHB)(uint16_t *p, int size, int bd);
216*77c1e3ccSAndroid Build Coastguard Worker typedef libaom_test::FuncParam<UPHB> TestFuncsHBD;
217*77c1e3ccSAndroid Build Coastguard Worker
218*77c1e3ccSAndroid Build Coastguard Worker class UpsampleTestHB : public UpsampleTest<UPHB, uint16_t> {
219*77c1e3ccSAndroid Build Coastguard Worker protected:
Execute(uint16_t * edge_tst)220*77c1e3ccSAndroid Build Coastguard Worker void Execute(uint16_t *edge_tst) override {
221*77c1e3ccSAndroid Build Coastguard Worker params_.ref_func(edge_ref_, size_, bit_depth_);
222*77c1e3ccSAndroid Build Coastguard Worker API_REGISTER_STATE_CHECK(params_.tst_func(edge_tst, size_, bit_depth_));
223*77c1e3ccSAndroid Build Coastguard Worker }
224*77c1e3ccSAndroid Build Coastguard Worker int bit_depth_;
225*77c1e3ccSAndroid Build Coastguard Worker };
226*77c1e3ccSAndroid Build Coastguard Worker
TEST_P(UpsampleTestHB,RandomValues)227*77c1e3ccSAndroid Build Coastguard Worker TEST_P(UpsampleTestHB, RandomValues) {
228*77c1e3ccSAndroid Build Coastguard Worker for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
229*77c1e3ccSAndroid Build Coastguard Worker switch (rng_(3)) {
230*77c1e3ccSAndroid Build Coastguard Worker case 0: bit_depth_ = 8; break;
231*77c1e3ccSAndroid Build Coastguard Worker case 1: bit_depth_ = 10; break;
232*77c1e3ccSAndroid Build Coastguard Worker default: bit_depth_ = 12; break;
233*77c1e3ccSAndroid Build Coastguard Worker }
234*77c1e3ccSAndroid Build Coastguard Worker const int hi = 1 << bit_depth_;
235*77c1e3ccSAndroid Build Coastguard Worker
236*77c1e3ccSAndroid Build Coastguard Worker size_ = 4 * (this->rng_(4) + 1);
237*77c1e3ccSAndroid Build Coastguard Worker
238*77c1e3ccSAndroid Build Coastguard Worker int i, pix = 0;
239*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < kOffset + size_; ++i) {
240*77c1e3ccSAndroid Build Coastguard Worker pix = rng_(hi);
241*77c1e3ccSAndroid Build Coastguard Worker edge_ref_data_[i] = pix;
242*77c1e3ccSAndroid Build Coastguard Worker edge_tst_data_[i] = pix;
243*77c1e3ccSAndroid Build Coastguard Worker }
244*77c1e3ccSAndroid Build Coastguard Worker
245*77c1e3ccSAndroid Build Coastguard Worker // Extend final sample
246*77c1e3ccSAndroid Build Coastguard Worker while (i < kBufSize) {
247*77c1e3ccSAndroid Build Coastguard Worker edge_ref_data_[i] = pix;
248*77c1e3ccSAndroid Build Coastguard Worker edge_tst_data_[i] = pix;
249*77c1e3ccSAndroid Build Coastguard Worker i++;
250*77c1e3ccSAndroid Build Coastguard Worker }
251*77c1e3ccSAndroid Build Coastguard Worker
252*77c1e3ccSAndroid Build Coastguard Worker Common();
253*77c1e3ccSAndroid Build Coastguard Worker }
254*77c1e3ccSAndroid Build Coastguard Worker }
255*77c1e3ccSAndroid Build Coastguard Worker
TEST_P(UpsampleTestHB,DISABLED_Speed)256*77c1e3ccSAndroid Build Coastguard Worker TEST_P(UpsampleTestHB, DISABLED_Speed) {
257*77c1e3ccSAndroid Build Coastguard Worker const int test_count = 10000000;
258*77c1e3ccSAndroid Build Coastguard Worker size_ = kMaxEdge;
259*77c1e3ccSAndroid Build Coastguard Worker bit_depth_ = 12;
260*77c1e3ccSAndroid Build Coastguard Worker const int hi = 1 << bit_depth_;
261*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < kOffset + size_; ++i) {
262*77c1e3ccSAndroid Build Coastguard Worker edge_tst_data_[i] = rng_(hi);
263*77c1e3ccSAndroid Build Coastguard Worker }
264*77c1e3ccSAndroid Build Coastguard Worker edge_tst_ = &edge_tst_data_[kOffset];
265*77c1e3ccSAndroid Build Coastguard Worker for (int iter = 0; iter < test_count; ++iter) {
266*77c1e3ccSAndroid Build Coastguard Worker API_REGISTER_STATE_CHECK(params_.tst_func(edge_tst_, size_, bit_depth_));
267*77c1e3ccSAndroid Build Coastguard Worker }
268*77c1e3ccSAndroid Build Coastguard Worker }
269*77c1e3ccSAndroid Build Coastguard Worker
270*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE4_1
271*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
272*77c1e3ccSAndroid Build Coastguard Worker SSE4_1, UpsampleTestHB,
273*77c1e3ccSAndroid Build Coastguard Worker ::testing::Values(TestFuncsHBD(av1_highbd_upsample_intra_edge_c,
274*77c1e3ccSAndroid Build Coastguard Worker av1_highbd_upsample_intra_edge_sse4_1)));
275*77c1e3ccSAndroid Build Coastguard Worker #endif // HAVE_SSE4_1
276*77c1e3ccSAndroid Build Coastguard Worker
277*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
278*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
279*77c1e3ccSAndroid Build Coastguard Worker NEON, UpsampleTestHB,
280*77c1e3ccSAndroid Build Coastguard Worker ::testing::Values(TestFuncsHBD(av1_highbd_upsample_intra_edge_c,
281*77c1e3ccSAndroid Build Coastguard Worker av1_highbd_upsample_intra_edge_neon)));
282*77c1e3ccSAndroid Build Coastguard Worker #endif // HAVE_NEON
283*77c1e3ccSAndroid Build Coastguard Worker
284*77c1e3ccSAndroid Build Coastguard Worker typedef void (*FEHB)(uint16_t *p, int size, int strength);
285*77c1e3ccSAndroid Build Coastguard Worker typedef libaom_test::FuncParam<FEHB> FilterEdgeTestFuncsHBD;
286*77c1e3ccSAndroid Build Coastguard Worker
287*77c1e3ccSAndroid Build Coastguard Worker class FilterEdgeTestHB : public FilterEdgeTest<FEHB, uint16_t> {
288*77c1e3ccSAndroid Build Coastguard Worker protected:
Execute(uint16_t * edge_tst)289*77c1e3ccSAndroid Build Coastguard Worker void Execute(uint16_t *edge_tst) override {
290*77c1e3ccSAndroid Build Coastguard Worker params_.ref_func(edge_ref_, size_, strength_);
291*77c1e3ccSAndroid Build Coastguard Worker API_REGISTER_STATE_CHECK(params_.tst_func(edge_tst, size_, strength_));
292*77c1e3ccSAndroid Build Coastguard Worker }
293*77c1e3ccSAndroid Build Coastguard Worker int bit_depth_;
294*77c1e3ccSAndroid Build Coastguard Worker };
295*77c1e3ccSAndroid Build Coastguard Worker
TEST_P(FilterEdgeTestHB,RandomValues)296*77c1e3ccSAndroid Build Coastguard Worker TEST_P(FilterEdgeTestHB, RandomValues) {
297*77c1e3ccSAndroid Build Coastguard Worker for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
298*77c1e3ccSAndroid Build Coastguard Worker switch (rng_(3)) {
299*77c1e3ccSAndroid Build Coastguard Worker case 0: bit_depth_ = 8; break;
300*77c1e3ccSAndroid Build Coastguard Worker case 1: bit_depth_ = 10; break;
301*77c1e3ccSAndroid Build Coastguard Worker default: bit_depth_ = 12; break;
302*77c1e3ccSAndroid Build Coastguard Worker }
303*77c1e3ccSAndroid Build Coastguard Worker const int hi = 1 << bit_depth_;
304*77c1e3ccSAndroid Build Coastguard Worker strength_ = this->rng_(4);
305*77c1e3ccSAndroid Build Coastguard Worker size_ = 4 * (this->rng_(128 / 4) + 1) + 1;
306*77c1e3ccSAndroid Build Coastguard Worker
307*77c1e3ccSAndroid Build Coastguard Worker int i, pix = 0;
308*77c1e3ccSAndroid Build Coastguard Worker for (i = 0; i < kOffset + size_; ++i) {
309*77c1e3ccSAndroid Build Coastguard Worker pix = rng_(hi);
310*77c1e3ccSAndroid Build Coastguard Worker edge_ref_data_[i] = pix;
311*77c1e3ccSAndroid Build Coastguard Worker edge_tst_data_[i] = pix;
312*77c1e3ccSAndroid Build Coastguard Worker }
313*77c1e3ccSAndroid Build Coastguard Worker
314*77c1e3ccSAndroid Build Coastguard Worker Common();
315*77c1e3ccSAndroid Build Coastguard Worker }
316*77c1e3ccSAndroid Build Coastguard Worker }
317*77c1e3ccSAndroid Build Coastguard Worker
TEST_P(FilterEdgeTestHB,DISABLED_Speed)318*77c1e3ccSAndroid Build Coastguard Worker TEST_P(FilterEdgeTestHB, DISABLED_Speed) {
319*77c1e3ccSAndroid Build Coastguard Worker const int test_count = 10000000;
320*77c1e3ccSAndroid Build Coastguard Worker size_ = kMaxEdge;
321*77c1e3ccSAndroid Build Coastguard Worker strength_ = 1;
322*77c1e3ccSAndroid Build Coastguard Worker bit_depth_ = 12;
323*77c1e3ccSAndroid Build Coastguard Worker const int hi = 1 << bit_depth_;
324*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < kOffset + size_; ++i) {
325*77c1e3ccSAndroid Build Coastguard Worker edge_tst_data_[i] = rng_(hi);
326*77c1e3ccSAndroid Build Coastguard Worker }
327*77c1e3ccSAndroid Build Coastguard Worker edge_tst_ = &edge_tst_data_[kOffset];
328*77c1e3ccSAndroid Build Coastguard Worker for (int iter = 0; iter < test_count; ++iter) {
329*77c1e3ccSAndroid Build Coastguard Worker API_REGISTER_STATE_CHECK(params_.tst_func(edge_tst_, size_, strength_));
330*77c1e3ccSAndroid Build Coastguard Worker // iterate over filter strengths (1,2,3)
331*77c1e3ccSAndroid Build Coastguard Worker strength_ = strength_ == 3 ? 1 : strength_ + 1;
332*77c1e3ccSAndroid Build Coastguard Worker }
333*77c1e3ccSAndroid Build Coastguard Worker }
334*77c1e3ccSAndroid Build Coastguard Worker
335*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE4_1
336*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE4_1, FilterEdgeTestHB,
337*77c1e3ccSAndroid Build Coastguard Worker ::testing::Values(FilterEdgeTestFuncsHBD(
338*77c1e3ccSAndroid Build Coastguard Worker av1_highbd_filter_intra_edge_c,
339*77c1e3ccSAndroid Build Coastguard Worker av1_highbd_filter_intra_edge_sse4_1)));
340*77c1e3ccSAndroid Build Coastguard Worker #endif // HAVE_SSE4_1
341*77c1e3ccSAndroid Build Coastguard Worker
342*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
343*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, FilterEdgeTestHB,
344*77c1e3ccSAndroid Build Coastguard Worker ::testing::Values(FilterEdgeTestFuncsHBD(
345*77c1e3ccSAndroid Build Coastguard Worker av1_highbd_filter_intra_edge_c,
346*77c1e3ccSAndroid Build Coastguard Worker av1_highbd_filter_intra_edge_neon)));
347*77c1e3ccSAndroid Build Coastguard Worker #endif // HAVE_NEON
348*77c1e3ccSAndroid Build Coastguard Worker
349*77c1e3ccSAndroid Build Coastguard Worker #endif // CONFIG_AV1_HIGHBITDEPTH
350*77c1e3ccSAndroid Build Coastguard Worker
351*77c1e3ccSAndroid Build Coastguard Worker } // namespace
352