xref: /aosp_15_r20/external/libaom/test/av1_convolve_test.cc (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker  * Copyright (c) 2020, 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 <cstddef>
13*77c1e3ccSAndroid Build Coastguard Worker #include <cstdint>
14*77c1e3ccSAndroid Build Coastguard Worker #include <ostream>
15*77c1e3ccSAndroid Build Coastguard Worker #include <set>
16*77c1e3ccSAndroid Build Coastguard Worker #include <vector>
17*77c1e3ccSAndroid Build Coastguard Worker #include "config/av1_rtcd.h"
18*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_dsp_rtcd.h"
19*77c1e3ccSAndroid Build Coastguard Worker #include "aom_ports/aom_timer.h"
20*77c1e3ccSAndroid Build Coastguard Worker #include "gtest/gtest.h"
21*77c1e3ccSAndroid Build Coastguard Worker #include "test/acm_random.h"
22*77c1e3ccSAndroid Build Coastguard Worker 
23*77c1e3ccSAndroid Build Coastguard Worker namespace {
24*77c1e3ccSAndroid Build Coastguard Worker 
25*77c1e3ccSAndroid Build Coastguard Worker // TODO(any): Remove following INTERP_FILTERS_ALL define, so that 12-tap filter
26*77c1e3ccSAndroid Build Coastguard Worker // is tested once 12-tap filter SIMD is done.
27*77c1e3ccSAndroid Build Coastguard Worker #undef INTERP_FILTERS_ALL
28*77c1e3ccSAndroid Build Coastguard Worker #define INTERP_FILTERS_ALL 4
29*77c1e3ccSAndroid Build Coastguard Worker 
30*77c1e3ccSAndroid Build Coastguard Worker // All single reference convolve tests are parameterized on block size,
31*77c1e3ccSAndroid Build Coastguard Worker // bit-depth, and function to test.
32*77c1e3ccSAndroid Build Coastguard Worker //
33*77c1e3ccSAndroid Build Coastguard Worker // Note that parameterizing on these variables (and not other parameters) is
34*77c1e3ccSAndroid Build Coastguard Worker // a conscious decision - Jenkins needs some degree of parallelization to run
35*77c1e3ccSAndroid Build Coastguard Worker // the tests within the time limit, but if the number of parameters increases
36*77c1e3ccSAndroid Build Coastguard Worker // too much, the gtest framework does not handle it well (increased overhead per
37*77c1e3ccSAndroid Build Coastguard Worker // test, huge amount of output to stdout, etc.).
38*77c1e3ccSAndroid Build Coastguard Worker //
39*77c1e3ccSAndroid Build Coastguard Worker // Also note that the test suites must be named with the architecture, e.g.,
40*77c1e3ccSAndroid Build Coastguard Worker // C, C_X, AVX2_X, ... The test suite that runs on Jenkins sometimes runs tests
41*77c1e3ccSAndroid Build Coastguard Worker // that cannot deal with intrinsics (e.g., the Valgrind tests on 32-bit x86
42*77c1e3ccSAndroid Build Coastguard Worker // binaries) and will disable tests using a filter like
43*77c1e3ccSAndroid Build Coastguard Worker // --gtest_filter=-:SSE4_1.*. If the test suites are not named this way, the
44*77c1e3ccSAndroid Build Coastguard Worker // testing infrastructure will not selectively filter them properly.
45*77c1e3ccSAndroid Build Coastguard Worker class BlockSize {
46*77c1e3ccSAndroid Build Coastguard Worker  public:
BlockSize(int w,int h)47*77c1e3ccSAndroid Build Coastguard Worker   BlockSize(int w, int h) : width_(w), height_(h) {}
48*77c1e3ccSAndroid Build Coastguard Worker 
Width() const49*77c1e3ccSAndroid Build Coastguard Worker   int Width() const { return width_; }
Height() const50*77c1e3ccSAndroid Build Coastguard Worker   int Height() const { return height_; }
51*77c1e3ccSAndroid Build Coastguard Worker 
operator <(const BlockSize & other) const52*77c1e3ccSAndroid Build Coastguard Worker   bool operator<(const BlockSize &other) const {
53*77c1e3ccSAndroid Build Coastguard Worker     if (Width() == other.Width()) {
54*77c1e3ccSAndroid Build Coastguard Worker       return Height() < other.Height();
55*77c1e3ccSAndroid Build Coastguard Worker     }
56*77c1e3ccSAndroid Build Coastguard Worker     return Width() < other.Width();
57*77c1e3ccSAndroid Build Coastguard Worker   }
58*77c1e3ccSAndroid Build Coastguard Worker 
operator ==(const BlockSize & other) const59*77c1e3ccSAndroid Build Coastguard Worker   bool operator==(const BlockSize &other) const {
60*77c1e3ccSAndroid Build Coastguard Worker     return Width() == other.Width() && Height() == other.Height();
61*77c1e3ccSAndroid Build Coastguard Worker   }
62*77c1e3ccSAndroid Build Coastguard Worker 
63*77c1e3ccSAndroid Build Coastguard Worker  private:
64*77c1e3ccSAndroid Build Coastguard Worker   int width_;
65*77c1e3ccSAndroid Build Coastguard Worker   int height_;
66*77c1e3ccSAndroid Build Coastguard Worker };
67*77c1e3ccSAndroid Build Coastguard Worker 
68*77c1e3ccSAndroid Build Coastguard Worker // Block size / bit depth / test function used to parameterize the tests.
69*77c1e3ccSAndroid Build Coastguard Worker template <typename T>
70*77c1e3ccSAndroid Build Coastguard Worker class TestParam {
71*77c1e3ccSAndroid Build Coastguard Worker  public:
TestParam(const BlockSize & block,int bd,T test_func)72*77c1e3ccSAndroid Build Coastguard Worker   TestParam(const BlockSize &block, int bd, T test_func)
73*77c1e3ccSAndroid Build Coastguard Worker       : block_(block), bd_(bd), test_func_(test_func) {}
74*77c1e3ccSAndroid Build Coastguard Worker 
Block() const75*77c1e3ccSAndroid Build Coastguard Worker   const BlockSize &Block() const { return block_; }
BitDepth() const76*77c1e3ccSAndroid Build Coastguard Worker   int BitDepth() const { return bd_; }
TestFunction() const77*77c1e3ccSAndroid Build Coastguard Worker   T TestFunction() const { return test_func_; }
78*77c1e3ccSAndroid Build Coastguard Worker 
operator ==(const TestParam & other) const79*77c1e3ccSAndroid Build Coastguard Worker   bool operator==(const TestParam &other) const {
80*77c1e3ccSAndroid Build Coastguard Worker     return Block() == other.Block() && BitDepth() == other.BitDepth() &&
81*77c1e3ccSAndroid Build Coastguard Worker            TestFunction() == other.TestFunction();
82*77c1e3ccSAndroid Build Coastguard Worker   }
83*77c1e3ccSAndroid Build Coastguard Worker 
84*77c1e3ccSAndroid Build Coastguard Worker  private:
85*77c1e3ccSAndroid Build Coastguard Worker   BlockSize block_;
86*77c1e3ccSAndroid Build Coastguard Worker   int bd_;
87*77c1e3ccSAndroid Build Coastguard Worker   T test_func_;
88*77c1e3ccSAndroid Build Coastguard Worker };
89*77c1e3ccSAndroid Build Coastguard Worker 
90*77c1e3ccSAndroid Build Coastguard Worker template <typename T>
operator <<(std::ostream & os,const TestParam<T> & test_arg)91*77c1e3ccSAndroid Build Coastguard Worker std::ostream &operator<<(std::ostream &os, const TestParam<T> &test_arg) {
92*77c1e3ccSAndroid Build Coastguard Worker   return os << "TestParam { width:" << test_arg.Block().Width()
93*77c1e3ccSAndroid Build Coastguard Worker             << " height:" << test_arg.Block().Height()
94*77c1e3ccSAndroid Build Coastguard Worker             << " bd:" << test_arg.BitDepth() << " }";
95*77c1e3ccSAndroid Build Coastguard Worker }
96*77c1e3ccSAndroid Build Coastguard Worker 
97*77c1e3ccSAndroid Build Coastguard Worker // Generate the list of all block widths / heights that need to be tested,
98*77c1e3ccSAndroid Build Coastguard Worker // includes chroma and luma sizes, for the given bit-depths. The test
99*77c1e3ccSAndroid Build Coastguard Worker // function is the same for all generated parameters.
100*77c1e3ccSAndroid Build Coastguard Worker template <typename T>
GetTestParams(std::initializer_list<int> bit_depths,T test_func)101*77c1e3ccSAndroid Build Coastguard Worker std::vector<TestParam<T>> GetTestParams(std::initializer_list<int> bit_depths,
102*77c1e3ccSAndroid Build Coastguard Worker                                         T test_func) {
103*77c1e3ccSAndroid Build Coastguard Worker   std::set<BlockSize> sizes;
104*77c1e3ccSAndroid Build Coastguard Worker   for (int b = BLOCK_4X4; b < BLOCK_SIZES_ALL; ++b) {
105*77c1e3ccSAndroid Build Coastguard Worker     const int w = block_size_wide[b];
106*77c1e3ccSAndroid Build Coastguard Worker     const int h = block_size_high[b];
107*77c1e3ccSAndroid Build Coastguard Worker     sizes.insert(BlockSize(w, h));
108*77c1e3ccSAndroid Build Coastguard Worker     // Add in smaller chroma sizes as well.
109*77c1e3ccSAndroid Build Coastguard Worker     if (w == 4 || h == 4) {
110*77c1e3ccSAndroid Build Coastguard Worker       sizes.insert(BlockSize(w / 2, h / 2));
111*77c1e3ccSAndroid Build Coastguard Worker     }
112*77c1e3ccSAndroid Build Coastguard Worker   }
113*77c1e3ccSAndroid Build Coastguard Worker   std::vector<TestParam<T>> result;
114*77c1e3ccSAndroid Build Coastguard Worker   for (const BlockSize &block : sizes) {
115*77c1e3ccSAndroid Build Coastguard Worker     for (int bd : bit_depths) {
116*77c1e3ccSAndroid Build Coastguard Worker       result.push_back(TestParam<T>(block, bd, test_func));
117*77c1e3ccSAndroid Build Coastguard Worker     }
118*77c1e3ccSAndroid Build Coastguard Worker   }
119*77c1e3ccSAndroid Build Coastguard Worker   return result;
120*77c1e3ccSAndroid Build Coastguard Worker }
121*77c1e3ccSAndroid Build Coastguard Worker 
122*77c1e3ccSAndroid Build Coastguard Worker template <typename T>
GetLowbdTestParams(T test_func)123*77c1e3ccSAndroid Build Coastguard Worker std::vector<TestParam<T>> GetLowbdTestParams(T test_func) {
124*77c1e3ccSAndroid Build Coastguard Worker   return GetTestParams({ 8 }, test_func);
125*77c1e3ccSAndroid Build Coastguard Worker }
126*77c1e3ccSAndroid Build Coastguard Worker 
127*77c1e3ccSAndroid Build Coastguard Worker template <typename T>
BuildLowbdParams(T test_func)128*77c1e3ccSAndroid Build Coastguard Worker ::testing::internal::ParamGenerator<TestParam<T>> BuildLowbdParams(
129*77c1e3ccSAndroid Build Coastguard Worker     T test_func) {
130*77c1e3ccSAndroid Build Coastguard Worker   return ::testing::ValuesIn(GetLowbdTestParams(test_func));
131*77c1e3ccSAndroid Build Coastguard Worker }
132*77c1e3ccSAndroid Build Coastguard Worker 
133*77c1e3ccSAndroid Build Coastguard Worker // Test the test-parameters generators work as expected.
134*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveParametersTest : public ::testing::Test {};
135*77c1e3ccSAndroid Build Coastguard Worker 
TEST_F(AV1ConvolveParametersTest,GetLowbdTestParams)136*77c1e3ccSAndroid Build Coastguard Worker TEST_F(AV1ConvolveParametersTest, GetLowbdTestParams) {
137*77c1e3ccSAndroid Build Coastguard Worker   auto v = GetLowbdTestParams(av1_convolve_x_sr_c);
138*77c1e3ccSAndroid Build Coastguard Worker   ASSERT_EQ(27U, v.size());
139*77c1e3ccSAndroid Build Coastguard Worker   for (const auto &p : v) {
140*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_EQ(8, p.BitDepth());
141*77c1e3ccSAndroid Build Coastguard Worker     // Needed (instead of ASSERT_EQ(...) since gtest does not
142*77c1e3ccSAndroid Build Coastguard Worker     // have built in printing for arbitrary functions, which
143*77c1e3ccSAndroid Build Coastguard Worker     // causes a compilation error.
144*77c1e3ccSAndroid Build Coastguard Worker     bool same_fn = av1_convolve_x_sr_c == p.TestFunction();
145*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_TRUE(same_fn);
146*77c1e3ccSAndroid Build Coastguard Worker   }
147*77c1e3ccSAndroid Build Coastguard Worker }
148*77c1e3ccSAndroid Build Coastguard Worker 
149*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
150*77c1e3ccSAndroid Build Coastguard Worker template <typename T>
GetHighbdTestParams(T test_func)151*77c1e3ccSAndroid Build Coastguard Worker std::vector<TestParam<T>> GetHighbdTestParams(T test_func) {
152*77c1e3ccSAndroid Build Coastguard Worker   return GetTestParams({ 10, 12 }, test_func);
153*77c1e3ccSAndroid Build Coastguard Worker }
154*77c1e3ccSAndroid Build Coastguard Worker 
155*77c1e3ccSAndroid Build Coastguard Worker template <typename T>
BuildHighbdParams(T test_func)156*77c1e3ccSAndroid Build Coastguard Worker ::testing::internal::ParamGenerator<TestParam<T>> BuildHighbdParams(
157*77c1e3ccSAndroid Build Coastguard Worker     T test_func) {
158*77c1e3ccSAndroid Build Coastguard Worker   return ::testing::ValuesIn(GetHighbdTestParams(test_func));
159*77c1e3ccSAndroid Build Coastguard Worker }
160*77c1e3ccSAndroid Build Coastguard Worker 
TEST_F(AV1ConvolveParametersTest,GetHighbdTestParams)161*77c1e3ccSAndroid Build Coastguard Worker TEST_F(AV1ConvolveParametersTest, GetHighbdTestParams) {
162*77c1e3ccSAndroid Build Coastguard Worker   auto v = GetHighbdTestParams(av1_highbd_convolve_x_sr_c);
163*77c1e3ccSAndroid Build Coastguard Worker   ASSERT_EQ(54U, v.size());
164*77c1e3ccSAndroid Build Coastguard Worker   int num_10 = 0;
165*77c1e3ccSAndroid Build Coastguard Worker   int num_12 = 0;
166*77c1e3ccSAndroid Build Coastguard Worker   for (const auto &p : v) {
167*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_TRUE(p.BitDepth() == 10 || p.BitDepth() == 12);
168*77c1e3ccSAndroid Build Coastguard Worker     bool same_fn = av1_highbd_convolve_x_sr_c == p.TestFunction();
169*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_TRUE(same_fn);
170*77c1e3ccSAndroid Build Coastguard Worker     if (p.BitDepth() == 10) {
171*77c1e3ccSAndroid Build Coastguard Worker       ++num_10;
172*77c1e3ccSAndroid Build Coastguard Worker     } else {
173*77c1e3ccSAndroid Build Coastguard Worker       ++num_12;
174*77c1e3ccSAndroid Build Coastguard Worker     }
175*77c1e3ccSAndroid Build Coastguard Worker   }
176*77c1e3ccSAndroid Build Coastguard Worker   ASSERT_EQ(num_10, num_12);
177*77c1e3ccSAndroid Build Coastguard Worker }
178*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
179*77c1e3ccSAndroid Build Coastguard Worker 
180*77c1e3ccSAndroid Build Coastguard Worker // AV1ConvolveTest is the base class that all convolve tests should derive from.
181*77c1e3ccSAndroid Build Coastguard Worker // It provides storage/methods for generating randomized buffers for both
182*77c1e3ccSAndroid Build Coastguard Worker // low bit-depth and high bit-depth, and setup/teardown methods for clearing
183*77c1e3ccSAndroid Build Coastguard Worker // system state. Implementors can get the bit-depth / block-size /
184*77c1e3ccSAndroid Build Coastguard Worker // test function by calling GetParam().
185*77c1e3ccSAndroid Build Coastguard Worker template <typename T>
186*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveTest : public ::testing::TestWithParam<TestParam<T>> {
187*77c1e3ccSAndroid Build Coastguard Worker  public:
188*77c1e3ccSAndroid Build Coastguard Worker   ~AV1ConvolveTest() override = default;
189*77c1e3ccSAndroid Build Coastguard Worker 
SetUp()190*77c1e3ccSAndroid Build Coastguard Worker   void SetUp() override {
191*77c1e3ccSAndroid Build Coastguard Worker     rnd_.Reset(libaom_test::ACMRandom::DeterministicSeed());
192*77c1e3ccSAndroid Build Coastguard Worker   }
193*77c1e3ccSAndroid Build Coastguard Worker 
194*77c1e3ccSAndroid Build Coastguard Worker   // Randomizes the 8-bit input buffer and returns a pointer to it. Note that
195*77c1e3ccSAndroid Build Coastguard Worker   // the pointer is safe to use with an 8-tap filter. The stride can range
196*77c1e3ccSAndroid Build Coastguard Worker   // from width to (width + kPadding). Also note that the pointer is to the
197*77c1e3ccSAndroid Build Coastguard Worker   // same memory location.
198*77c1e3ccSAndroid Build Coastguard Worker   static constexpr int kInputPadding = 12;
199*77c1e3ccSAndroid Build Coastguard Worker 
200*77c1e3ccSAndroid Build Coastguard Worker   // Get a pointer to a buffer with stride == width. Note that we must have
201*77c1e3ccSAndroid Build Coastguard Worker   // the test param passed in explicitly -- the gtest framework does not
202*77c1e3ccSAndroid Build Coastguard Worker   // support calling GetParam() within a templatized class.
203*77c1e3ccSAndroid Build Coastguard Worker   // Note that FirstRandomInput8 always returns the same pointer -- if two
204*77c1e3ccSAndroid Build Coastguard Worker   // inputs are needed, also use SecondRandomInput8.
FirstRandomInput8(const TestParam<T> & param)205*77c1e3ccSAndroid Build Coastguard Worker   const uint8_t *FirstRandomInput8(const TestParam<T> &param) {
206*77c1e3ccSAndroid Build Coastguard Worker     // Note we can't call GetParam() directly -- gtest does not support
207*77c1e3ccSAndroid Build Coastguard Worker     // this for parameterized types.
208*77c1e3ccSAndroid Build Coastguard Worker     return RandomInput8(input8_1_, param);
209*77c1e3ccSAndroid Build Coastguard Worker   }
210*77c1e3ccSAndroid Build Coastguard Worker 
SecondRandomInput8(const TestParam<T> & param)211*77c1e3ccSAndroid Build Coastguard Worker   const uint8_t *SecondRandomInput8(const TestParam<T> &param) {
212*77c1e3ccSAndroid Build Coastguard Worker     return RandomInput8(input8_2_, param);
213*77c1e3ccSAndroid Build Coastguard Worker   }
214*77c1e3ccSAndroid Build Coastguard Worker 
215*77c1e3ccSAndroid Build Coastguard Worker   // Some of the intrinsics perform writes in 32 byte chunks. Moreover, some
216*77c1e3ccSAndroid Build Coastguard Worker   // of the instrinsics assume that the stride is also a multiple of 32.
217*77c1e3ccSAndroid Build Coastguard Worker   // To satisfy these constraints and also remain simple, output buffer strides
218*77c1e3ccSAndroid Build Coastguard Worker   // are assumed MAX_SB_SIZE.
219*77c1e3ccSAndroid Build Coastguard Worker   static constexpr int kOutputStride = MAX_SB_SIZE;
220*77c1e3ccSAndroid Build Coastguard Worker 
221*77c1e3ccSAndroid Build Coastguard Worker   // Check that two 8-bit output buffers are identical.
AssertOutputBufferEq(const uint8_t * p1,const uint8_t * p2,int width,int height)222*77c1e3ccSAndroid Build Coastguard Worker   void AssertOutputBufferEq(const uint8_t *p1, const uint8_t *p2, int width,
223*77c1e3ccSAndroid Build Coastguard Worker                             int height) {
224*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_TRUE(p1 != p2) << "Buffers must be at different memory locations";
225*77c1e3ccSAndroid Build Coastguard Worker     for (int j = 0; j < height; ++j) {
226*77c1e3ccSAndroid Build Coastguard Worker       if (memcmp(p1, p2, sizeof(*p1) * width) == 0) {
227*77c1e3ccSAndroid Build Coastguard Worker         p1 += kOutputStride;
228*77c1e3ccSAndroid Build Coastguard Worker         p2 += kOutputStride;
229*77c1e3ccSAndroid Build Coastguard Worker         continue;
230*77c1e3ccSAndroid Build Coastguard Worker       }
231*77c1e3ccSAndroid Build Coastguard Worker       for (int i = 0; i < width; ++i) {
232*77c1e3ccSAndroid Build Coastguard Worker         ASSERT_EQ(p1[i], p2[i])
233*77c1e3ccSAndroid Build Coastguard Worker             << width << "x" << height << " Pixel mismatch at (" << i << ", "
234*77c1e3ccSAndroid Build Coastguard Worker             << j << ")";
235*77c1e3ccSAndroid Build Coastguard Worker       }
236*77c1e3ccSAndroid Build Coastguard Worker     }
237*77c1e3ccSAndroid Build Coastguard Worker   }
238*77c1e3ccSAndroid Build Coastguard Worker 
239*77c1e3ccSAndroid Build Coastguard Worker   // Check that two 16-bit output buffers are identical.
AssertOutputBufferEq(const uint16_t * p1,const uint16_t * p2,int width,int height)240*77c1e3ccSAndroid Build Coastguard Worker   void AssertOutputBufferEq(const uint16_t *p1, const uint16_t *p2, int width,
241*77c1e3ccSAndroid Build Coastguard Worker                             int height) {
242*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_TRUE(p1 != p2) << "Buffers must be in different memory locations";
243*77c1e3ccSAndroid Build Coastguard Worker     for (int j = 0; j < height; ++j) {
244*77c1e3ccSAndroid Build Coastguard Worker       if (memcmp(p1, p2, sizeof(*p1) * width) == 0) {
245*77c1e3ccSAndroid Build Coastguard Worker         p1 += kOutputStride;
246*77c1e3ccSAndroid Build Coastguard Worker         p2 += kOutputStride;
247*77c1e3ccSAndroid Build Coastguard Worker         continue;
248*77c1e3ccSAndroid Build Coastguard Worker       }
249*77c1e3ccSAndroid Build Coastguard Worker       for (int i = 0; i < width; ++i) {
250*77c1e3ccSAndroid Build Coastguard Worker         ASSERT_EQ(p1[i], p2[i])
251*77c1e3ccSAndroid Build Coastguard Worker             << width << "x" << height << " Pixel mismatch at (" << i << ", "
252*77c1e3ccSAndroid Build Coastguard Worker             << j << ")";
253*77c1e3ccSAndroid Build Coastguard Worker       }
254*77c1e3ccSAndroid Build Coastguard Worker     }
255*77c1e3ccSAndroid Build Coastguard Worker   }
256*77c1e3ccSAndroid Build Coastguard Worker 
257*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
258*77c1e3ccSAndroid Build Coastguard Worker   // Note that the randomized values are capped by bit-depth.
FirstRandomInput16(const TestParam<T> & param)259*77c1e3ccSAndroid Build Coastguard Worker   const uint16_t *FirstRandomInput16(const TestParam<T> &param) {
260*77c1e3ccSAndroid Build Coastguard Worker     return RandomInput16(input16_1_, param);
261*77c1e3ccSAndroid Build Coastguard Worker   }
262*77c1e3ccSAndroid Build Coastguard Worker 
SecondRandomInput16(const TestParam<T> & param)263*77c1e3ccSAndroid Build Coastguard Worker   const uint16_t *SecondRandomInput16(const TestParam<T> &param) {
264*77c1e3ccSAndroid Build Coastguard Worker     return RandomInput16(input16_2_, param);
265*77c1e3ccSAndroid Build Coastguard Worker   }
266*77c1e3ccSAndroid Build Coastguard Worker #endif
267*77c1e3ccSAndroid Build Coastguard Worker 
268*77c1e3ccSAndroid Build Coastguard Worker  private:
RandomInput8(uint8_t * p,const TestParam<T> & param)269*77c1e3ccSAndroid Build Coastguard Worker   const uint8_t *RandomInput8(uint8_t *p, const TestParam<T> &param) {
270*77c1e3ccSAndroid Build Coastguard Worker     EXPECT_EQ(8, param.BitDepth());
271*77c1e3ccSAndroid Build Coastguard Worker     EXPECT_GE(MAX_SB_SIZE, param.Block().Width());
272*77c1e3ccSAndroid Build Coastguard Worker     EXPECT_GE(MAX_SB_SIZE, param.Block().Height());
273*77c1e3ccSAndroid Build Coastguard Worker     const int padded_width = param.Block().Width() + kInputPadding;
274*77c1e3ccSAndroid Build Coastguard Worker     const int padded_height = param.Block().Height() + kInputPadding;
275*77c1e3ccSAndroid Build Coastguard Worker     Randomize(p, padded_width * padded_height);
276*77c1e3ccSAndroid Build Coastguard Worker     return p + (kInputPadding / 2) * padded_width + kInputPadding / 2;
277*77c1e3ccSAndroid Build Coastguard Worker   }
278*77c1e3ccSAndroid Build Coastguard Worker 
Randomize(uint8_t * p,int size)279*77c1e3ccSAndroid Build Coastguard Worker   void Randomize(uint8_t *p, int size) {
280*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < size; ++i) {
281*77c1e3ccSAndroid Build Coastguard Worker       p[i] = rnd_.Rand8();
282*77c1e3ccSAndroid Build Coastguard Worker     }
283*77c1e3ccSAndroid Build Coastguard Worker   }
284*77c1e3ccSAndroid Build Coastguard Worker 
285*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
RandomInput16(uint16_t * p,const TestParam<T> & param)286*77c1e3ccSAndroid Build Coastguard Worker   const uint16_t *RandomInput16(uint16_t *p, const TestParam<T> &param) {
287*77c1e3ccSAndroid Build Coastguard Worker     // Check that this is only called with high bit-depths.
288*77c1e3ccSAndroid Build Coastguard Worker     EXPECT_TRUE(param.BitDepth() == 10 || param.BitDepth() == 12);
289*77c1e3ccSAndroid Build Coastguard Worker     EXPECT_GE(MAX_SB_SIZE, param.Block().Width());
290*77c1e3ccSAndroid Build Coastguard Worker     EXPECT_GE(MAX_SB_SIZE, param.Block().Height());
291*77c1e3ccSAndroid Build Coastguard Worker     const int padded_width = param.Block().Width() + kInputPadding;
292*77c1e3ccSAndroid Build Coastguard Worker     const int padded_height = param.Block().Height() + kInputPadding;
293*77c1e3ccSAndroid Build Coastguard Worker     Randomize(p, padded_width * padded_height, param.BitDepth());
294*77c1e3ccSAndroid Build Coastguard Worker     return p + (kInputPadding / 2) * padded_width + kInputPadding / 2;
295*77c1e3ccSAndroid Build Coastguard Worker   }
296*77c1e3ccSAndroid Build Coastguard Worker 
Randomize(uint16_t * p,int size,int bit_depth)297*77c1e3ccSAndroid Build Coastguard Worker   void Randomize(uint16_t *p, int size, int bit_depth) {
298*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < size; ++i) {
299*77c1e3ccSAndroid Build Coastguard Worker       p[i] = rnd_.Rand16() & ((1 << bit_depth) - 1);
300*77c1e3ccSAndroid Build Coastguard Worker     }
301*77c1e3ccSAndroid Build Coastguard Worker   }
302*77c1e3ccSAndroid Build Coastguard Worker #endif
303*77c1e3ccSAndroid Build Coastguard Worker 
304*77c1e3ccSAndroid Build Coastguard Worker   static constexpr int kInputStride = MAX_SB_SIZE + kInputPadding;
305*77c1e3ccSAndroid Build Coastguard Worker 
306*77c1e3ccSAndroid Build Coastguard Worker   libaom_test::ACMRandom rnd_;
307*77c1e3ccSAndroid Build Coastguard Worker   // Statically allocate all the memory that is needed for the tests. Note
308*77c1e3ccSAndroid Build Coastguard Worker   // that we cannot allocate output memory here. It must use DECLARE_ALIGNED,
309*77c1e3ccSAndroid Build Coastguard Worker   // which is a C99 feature and interacts badly with C++ member variables.
310*77c1e3ccSAndroid Build Coastguard Worker   uint8_t input8_1_[kInputStride * kInputStride];
311*77c1e3ccSAndroid Build Coastguard Worker   uint8_t input8_2_[kInputStride * kInputStride];
312*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
313*77c1e3ccSAndroid Build Coastguard Worker   uint16_t input16_1_[kInputStride * kInputStride];
314*77c1e3ccSAndroid Build Coastguard Worker   uint16_t input16_2_[kInputStride * kInputStride];
315*77c1e3ccSAndroid Build Coastguard Worker #endif
316*77c1e3ccSAndroid Build Coastguard Worker };
317*77c1e3ccSAndroid Build Coastguard Worker 
318*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////////////
319*77c1e3ccSAndroid Build Coastguard Worker // Single reference convolve-x functions (low bit-depth)
320*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////////////
321*77c1e3ccSAndroid Build Coastguard Worker typedef void (*convolve_x_func)(const uint8_t *src, int src_stride,
322*77c1e3ccSAndroid Build Coastguard Worker                                 uint8_t *dst, int dst_stride, int w, int h,
323*77c1e3ccSAndroid Build Coastguard Worker                                 const InterpFilterParams *filter_params_x,
324*77c1e3ccSAndroid Build Coastguard Worker                                 const int subpel_x_qn,
325*77c1e3ccSAndroid Build Coastguard Worker                                 ConvolveParams *conv_params);
326*77c1e3ccSAndroid Build Coastguard Worker 
327*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveXTest : public AV1ConvolveTest<convolve_x_func> {
328*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()329*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
330*77c1e3ccSAndroid Build Coastguard Worker     // Do not test the no-op filter.
331*77c1e3ccSAndroid Build Coastguard Worker     for (int sub_x = 1; sub_x < 16; ++sub_x) {
332*77c1e3ccSAndroid Build Coastguard Worker       for (int filter = EIGHTTAP_REGULAR; filter <= INTERP_FILTERS_ALL;
333*77c1e3ccSAndroid Build Coastguard Worker            ++filter) {
334*77c1e3ccSAndroid Build Coastguard Worker         InterpFilter f = static_cast<InterpFilter>(filter);
335*77c1e3ccSAndroid Build Coastguard Worker         TestConvolve(sub_x, f);
336*77c1e3ccSAndroid Build Coastguard Worker       }
337*77c1e3ccSAndroid Build Coastguard Worker     }
338*77c1e3ccSAndroid Build Coastguard Worker   }
339*77c1e3ccSAndroid Build Coastguard Worker 
340*77c1e3ccSAndroid Build Coastguard Worker  public:
SpeedTest()341*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTest() {
342*77c1e3ccSAndroid Build Coastguard Worker     for (int filter = EIGHTTAP_REGULAR; filter <= INTERP_FILTERS_ALL;
343*77c1e3ccSAndroid Build Coastguard Worker          ++filter) {
344*77c1e3ccSAndroid Build Coastguard Worker       InterpFilter f = static_cast<InterpFilter>(filter);
345*77c1e3ccSAndroid Build Coastguard Worker       TestConvolveSpeed(f, 10000);
346*77c1e3ccSAndroid Build Coastguard Worker     }
347*77c1e3ccSAndroid Build Coastguard Worker   }
348*77c1e3ccSAndroid Build Coastguard Worker 
349*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolve(const int sub_x,const InterpFilter filter)350*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolve(const int sub_x, const InterpFilter filter) {
351*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
352*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
353*77c1e3ccSAndroid Build Coastguard Worker 
354*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x =
355*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(filter, width);
356*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
357*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
358*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input = FirstRandomInput8(GetParam());
359*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
360*77c1e3ccSAndroid Build Coastguard Worker     av1_convolve_x_sr_c(input, width, reference, kOutputStride, width, height,
361*77c1e3ccSAndroid Build Coastguard Worker                         filter_params_x, sub_x, &conv_params1);
362*77c1e3ccSAndroid Build Coastguard Worker 
363*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
364*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
365*77c1e3ccSAndroid Build Coastguard Worker     convolve_x_func test_func = GetParam().TestFunction();
366*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
367*77c1e3ccSAndroid Build Coastguard Worker     test_func(input, width, test, kOutputStride, width, height, filter_params_x,
368*77c1e3ccSAndroid Build Coastguard Worker               sub_x, &conv_params2);
369*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
370*77c1e3ccSAndroid Build Coastguard Worker   }
371*77c1e3ccSAndroid Build Coastguard Worker 
372*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolveSpeed(const InterpFilter filter,const int num_iters)373*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolveSpeed(const InterpFilter filter, const int num_iters) {
374*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
375*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
376*77c1e3ccSAndroid Build Coastguard Worker 
377*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x =
378*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(filter, width);
379*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
380*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
381*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input = FirstRandomInput8(GetParam());
382*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
383*77c1e3ccSAndroid Build Coastguard Worker 
384*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
385*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
386*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_iters; ++i) {
387*77c1e3ccSAndroid Build Coastguard Worker       av1_convolve_x_sr_c(input, width, reference, kOutputStride, width, height,
388*77c1e3ccSAndroid Build Coastguard Worker                           filter_params_x, 0, &conv_params1);
389*77c1e3ccSAndroid Build Coastguard Worker     }
390*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
391*77c1e3ccSAndroid Build Coastguard Worker     const double time1 = static_cast<double>(aom_usec_timer_elapsed(&timer));
392*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
393*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
394*77c1e3ccSAndroid Build Coastguard Worker     convolve_x_func test_func = GetParam().TestFunction();
395*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
396*77c1e3ccSAndroid Build Coastguard Worker 
397*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
398*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_iters; ++i) {
399*77c1e3ccSAndroid Build Coastguard Worker       test_func(input, width, test, kOutputStride, width, height,
400*77c1e3ccSAndroid Build Coastguard Worker                 filter_params_x, 0, &conv_params2);
401*77c1e3ccSAndroid Build Coastguard Worker     }
402*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
403*77c1e3ccSAndroid Build Coastguard Worker     const double time2 = static_cast<double>(aom_usec_timer_elapsed(&timer));
404*77c1e3ccSAndroid Build Coastguard Worker     printf("%d %3dx%-3d:%7.2f/%7.2fns (%3.2f)\n", filter, width, height, time1,
405*77c1e3ccSAndroid Build Coastguard Worker            time2, time1 / time2);
406*77c1e3ccSAndroid Build Coastguard Worker   }
407*77c1e3ccSAndroid Build Coastguard Worker };
408*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveXTest,RunTest)409*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveXTest, RunTest) { RunTest(); }
410*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveXTest,DISABLED_SpeedTest)411*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveXTest, DISABLED_SpeedTest) { SpeedTest(); }
412*77c1e3ccSAndroid Build Coastguard Worker 
413*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1ConvolveXTest,
414*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_x_sr_c));
415*77c1e3ccSAndroid Build Coastguard Worker 
416*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE2
417*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE2, AV1ConvolveXTest,
418*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_x_sr_sse2));
419*77c1e3ccSAndroid Build Coastguard Worker #endif
420*77c1e3ccSAndroid Build Coastguard Worker 
421*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
422*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, AV1ConvolveXTest,
423*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_x_sr_avx2));
424*77c1e3ccSAndroid Build Coastguard Worker #endif
425*77c1e3ccSAndroid Build Coastguard Worker 
426*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
427*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1ConvolveXTest,
428*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_x_sr_neon));
429*77c1e3ccSAndroid Build Coastguard Worker #endif
430*77c1e3ccSAndroid Build Coastguard Worker 
431*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON_DOTPROD
432*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON_DOTPROD, AV1ConvolveXTest,
433*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_x_sr_neon_dotprod));
434*77c1e3ccSAndroid Build Coastguard Worker #endif
435*77c1e3ccSAndroid Build Coastguard Worker 
436*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON_I8MM
437*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON_I8MM, AV1ConvolveXTest,
438*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_x_sr_neon_i8mm));
439*77c1e3ccSAndroid Build Coastguard Worker #endif
440*77c1e3ccSAndroid Build Coastguard Worker 
441*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////////////////////
442*77c1e3ccSAndroid Build Coastguard Worker // Single reference convolve-x IntraBC functions (low bit-depth)
443*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////////////////////
444*77c1e3ccSAndroid Build Coastguard Worker 
445*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveXIntraBCTest : public AV1ConvolveTest<convolve_x_func> {
446*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()447*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
448*77c1e3ccSAndroid Build Coastguard Worker     // IntraBC functions only operate for subpel_x_qn = 8.
449*77c1e3ccSAndroid Build Coastguard Worker     constexpr int kSubX = 8;
450*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
451*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
452*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x = &av1_intrabc_filter_params;
453*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input = FirstRandomInput8(GetParam());
454*77c1e3ccSAndroid Build Coastguard Worker 
455*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
456*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
457*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
458*77c1e3ccSAndroid Build Coastguard Worker     // Use a stride different from width to avoid potential storing errors that
459*77c1e3ccSAndroid Build Coastguard Worker     // would go undetected. The input buffer is filled using a padding of 12, so
460*77c1e3ccSAndroid Build Coastguard Worker     // the stride can be anywhere between width and width + 12.
461*77c1e3ccSAndroid Build Coastguard Worker     av1_convolve_x_sr_intrabc_c(input, width + 2, reference, kOutputStride,
462*77c1e3ccSAndroid Build Coastguard Worker                                 width, height, filter_params_x, kSubX,
463*77c1e3ccSAndroid Build Coastguard Worker                                 &conv_params1);
464*77c1e3ccSAndroid Build Coastguard Worker 
465*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
466*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
467*77c1e3ccSAndroid Build Coastguard Worker     convolve_x_func test_func = GetParam().TestFunction();
468*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
469*77c1e3ccSAndroid Build Coastguard Worker     test_func(input, width + 2, test, kOutputStride, width, height,
470*77c1e3ccSAndroid Build Coastguard Worker               filter_params_x, kSubX, &conv_params2);
471*77c1e3ccSAndroid Build Coastguard Worker 
472*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
473*77c1e3ccSAndroid Build Coastguard Worker   }
474*77c1e3ccSAndroid Build Coastguard Worker 
SpeedTest()475*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTest() {
476*77c1e3ccSAndroid Build Coastguard Worker     constexpr int kNumIters = 10000;
477*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilter filter = static_cast<InterpFilter>(BILINEAR);
478*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
479*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
480*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x = &av1_intrabc_filter_params;
481*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input = FirstRandomInput8(GetParam());
482*77c1e3ccSAndroid Build Coastguard Worker 
483*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
484*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
485*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
486*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
487*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
488*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < kNumIters; ++i) {
489*77c1e3ccSAndroid Build Coastguard Worker       av1_convolve_x_sr_intrabc_c(input, width, reference, kOutputStride, width,
490*77c1e3ccSAndroid Build Coastguard Worker                                   height, filter_params_x, 0, &conv_params1);
491*77c1e3ccSAndroid Build Coastguard Worker     }
492*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
493*77c1e3ccSAndroid Build Coastguard Worker     const double time1 = static_cast<double>(aom_usec_timer_elapsed(&timer));
494*77c1e3ccSAndroid Build Coastguard Worker 
495*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
496*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
497*77c1e3ccSAndroid Build Coastguard Worker     convolve_x_func test_func = GetParam().TestFunction();
498*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
499*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
500*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < kNumIters; ++i) {
501*77c1e3ccSAndroid Build Coastguard Worker       test_func(input, width, test, kOutputStride, width, height,
502*77c1e3ccSAndroid Build Coastguard Worker                 filter_params_x, 0, &conv_params2);
503*77c1e3ccSAndroid Build Coastguard Worker     }
504*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
505*77c1e3ccSAndroid Build Coastguard Worker     const double time2 = static_cast<double>(aom_usec_timer_elapsed(&timer));
506*77c1e3ccSAndroid Build Coastguard Worker 
507*77c1e3ccSAndroid Build Coastguard Worker     printf("%d %3dx%-3d:%7.2f/%7.2fns (%3.2f)\n", filter, width, height, time1,
508*77c1e3ccSAndroid Build Coastguard Worker            time2, time1 / time2);
509*77c1e3ccSAndroid Build Coastguard Worker   }
510*77c1e3ccSAndroid Build Coastguard Worker };
511*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveXIntraBCTest,RunTest)512*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveXIntraBCTest, RunTest) { RunTest(); }
513*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveXIntraBCTest,DISABLED_SpeedTest)514*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveXIntraBCTest, DISABLED_SpeedTest) { SpeedTest(); }
515*77c1e3ccSAndroid Build Coastguard Worker 
516*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1ConvolveXIntraBCTest,
517*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_x_sr_intrabc_c));
518*77c1e3ccSAndroid Build Coastguard Worker 
519*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
520*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1ConvolveXIntraBCTest,
521*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_x_sr_intrabc_neon));
522*77c1e3ccSAndroid Build Coastguard Worker #endif
523*77c1e3ccSAndroid Build Coastguard Worker 
524*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
525*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////////////
526*77c1e3ccSAndroid Build Coastguard Worker // Single reference convolve-x functions (high bit-depth)
527*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////////////
528*77c1e3ccSAndroid Build Coastguard Worker typedef void (*highbd_convolve_x_func)(
529*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w,
530*77c1e3ccSAndroid Build Coastguard Worker     int h, const InterpFilterParams *filter_params_x, const int subpel_x_qn,
531*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams *conv_params, int bd);
532*77c1e3ccSAndroid Build Coastguard Worker 
533*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveXHighbdTest : public AV1ConvolveTest<highbd_convolve_x_func> {
534*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()535*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
536*77c1e3ccSAndroid Build Coastguard Worker     // Do not test the no-op filter.
537*77c1e3ccSAndroid Build Coastguard Worker     for (int sub_x = 1; sub_x < 16; ++sub_x) {
538*77c1e3ccSAndroid Build Coastguard Worker       for (int filter = EIGHTTAP_REGULAR; filter <= INTERP_FILTERS_ALL;
539*77c1e3ccSAndroid Build Coastguard Worker            ++filter) {
540*77c1e3ccSAndroid Build Coastguard Worker         InterpFilter f = static_cast<InterpFilter>(filter);
541*77c1e3ccSAndroid Build Coastguard Worker         TestConvolve(sub_x, f);
542*77c1e3ccSAndroid Build Coastguard Worker       }
543*77c1e3ccSAndroid Build Coastguard Worker     }
544*77c1e3ccSAndroid Build Coastguard Worker   }
545*77c1e3ccSAndroid Build Coastguard Worker 
546*77c1e3ccSAndroid Build Coastguard Worker  public:
SpeedTest()547*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTest() {
548*77c1e3ccSAndroid Build Coastguard Worker     for (int filter = EIGHTTAP_REGULAR; filter <= INTERP_FILTERS_ALL;
549*77c1e3ccSAndroid Build Coastguard Worker          ++filter) {
550*77c1e3ccSAndroid Build Coastguard Worker       InterpFilter f = static_cast<InterpFilter>(filter);
551*77c1e3ccSAndroid Build Coastguard Worker       TestConvolveSpeed(f, 10000);
552*77c1e3ccSAndroid Build Coastguard Worker     }
553*77c1e3ccSAndroid Build Coastguard Worker   }
554*77c1e3ccSAndroid Build Coastguard Worker 
555*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolve(const int sub_x,const InterpFilter filter)556*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolve(const int sub_x, const InterpFilter filter) {
557*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
558*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
559*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
560*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x =
561*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(filter, width);
562*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
563*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, bit_depth);
564*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input = FirstRandomInput16(GetParam());
565*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
566*77c1e3ccSAndroid Build Coastguard Worker     av1_highbd_convolve_x_sr_c(input, width, reference, kOutputStride, width,
567*77c1e3ccSAndroid Build Coastguard Worker                                height, filter_params_x, sub_x, &conv_params1,
568*77c1e3ccSAndroid Build Coastguard Worker                                bit_depth);
569*77c1e3ccSAndroid Build Coastguard Worker 
570*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
571*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, bit_depth);
572*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
573*77c1e3ccSAndroid Build Coastguard Worker     GetParam().TestFunction()(input, width, test, kOutputStride, width, height,
574*77c1e3ccSAndroid Build Coastguard Worker                               filter_params_x, sub_x, &conv_params2, bit_depth);
575*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
576*77c1e3ccSAndroid Build Coastguard Worker   }
577*77c1e3ccSAndroid Build Coastguard Worker 
578*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolveSpeed(const InterpFilter filter,const int num_iters)579*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolveSpeed(const InterpFilter filter, const int num_iters) {
580*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
581*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
582*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
583*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x =
584*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(filter, width);
585*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
586*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
587*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input = FirstRandomInput16(GetParam());
588*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
589*77c1e3ccSAndroid Build Coastguard Worker 
590*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
591*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
592*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_iters; ++i) {
593*77c1e3ccSAndroid Build Coastguard Worker       av1_highbd_convolve_x_sr_c(input, width, reference, kOutputStride, width,
594*77c1e3ccSAndroid Build Coastguard Worker                                  height, filter_params_x, 0, &conv_params1,
595*77c1e3ccSAndroid Build Coastguard Worker                                  bit_depth);
596*77c1e3ccSAndroid Build Coastguard Worker     }
597*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
598*77c1e3ccSAndroid Build Coastguard Worker     const double time1 = static_cast<double>(aom_usec_timer_elapsed(&timer));
599*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
600*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
601*77c1e3ccSAndroid Build Coastguard Worker     highbd_convolve_x_func test_func = GetParam().TestFunction();
602*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
603*77c1e3ccSAndroid Build Coastguard Worker 
604*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
605*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_iters; ++i) {
606*77c1e3ccSAndroid Build Coastguard Worker       test_func(input, width, test, kOutputStride, width, height,
607*77c1e3ccSAndroid Build Coastguard Worker                 filter_params_x, 0, &conv_params2, bit_depth);
608*77c1e3ccSAndroid Build Coastguard Worker     }
609*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
610*77c1e3ccSAndroid Build Coastguard Worker     const double time2 = static_cast<double>(aom_usec_timer_elapsed(&timer));
611*77c1e3ccSAndroid Build Coastguard Worker     printf("%d %3dx%-3d:%7.2f/%7.2fns (%3.2f)\n", filter, width, height, time1,
612*77c1e3ccSAndroid Build Coastguard Worker            time2, time1 / time2);
613*77c1e3ccSAndroid Build Coastguard Worker   }
614*77c1e3ccSAndroid Build Coastguard Worker };
615*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveXHighbdTest,RunTest)616*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveXHighbdTest, RunTest) { RunTest(); }
617*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveXHighbdTest,DISABLED_SpeedTest)618*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveXHighbdTest, DISABLED_SpeedTest) { SpeedTest(); }
619*77c1e3ccSAndroid Build Coastguard Worker 
620*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1ConvolveXHighbdTest,
621*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_x_sr_c));
622*77c1e3ccSAndroid Build Coastguard Worker 
623*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSSE3
624*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSSE3, AV1ConvolveXHighbdTest,
625*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_x_sr_ssse3));
626*77c1e3ccSAndroid Build Coastguard Worker #endif
627*77c1e3ccSAndroid Build Coastguard Worker 
628*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
629*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, AV1ConvolveXHighbdTest,
630*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_x_sr_avx2));
631*77c1e3ccSAndroid Build Coastguard Worker #endif
632*77c1e3ccSAndroid Build Coastguard Worker 
633*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
634*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1ConvolveXHighbdTest,
635*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_x_sr_neon));
636*77c1e3ccSAndroid Build Coastguard Worker #endif
637*77c1e3ccSAndroid Build Coastguard Worker 
638*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SVE2
639*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SVE2, AV1ConvolveXHighbdTest,
640*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_x_sr_sve2));
641*77c1e3ccSAndroid Build Coastguard Worker #endif
642*77c1e3ccSAndroid Build Coastguard Worker 
643*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////////////////////
644*77c1e3ccSAndroid Build Coastguard Worker // Single reference convolve-x IntraBC functions (high bit-depth)
645*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////////////////////
646*77c1e3ccSAndroid Build Coastguard Worker 
647*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveXHighbdIntraBCTest
648*77c1e3ccSAndroid Build Coastguard Worker     : public AV1ConvolveTest<highbd_convolve_x_func> {
649*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()650*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
651*77c1e3ccSAndroid Build Coastguard Worker     // IntraBC functions only operate for subpel_x_qn = 8.
652*77c1e3ccSAndroid Build Coastguard Worker     constexpr int kSubX = 8;
653*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
654*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
655*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
656*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x = &av1_intrabc_filter_params;
657*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input = FirstRandomInput16(GetParam());
658*77c1e3ccSAndroid Build Coastguard Worker 
659*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
660*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, bit_depth);
661*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
662*77c1e3ccSAndroid Build Coastguard Worker     // Use a stride different from width to avoid potential storing errors that
663*77c1e3ccSAndroid Build Coastguard Worker     // would go undetected. The input buffer is filled using a padding of 12, so
664*77c1e3ccSAndroid Build Coastguard Worker     // the stride can be anywhere between width and width + 12.
665*77c1e3ccSAndroid Build Coastguard Worker     av1_highbd_convolve_x_sr_intrabc_c(
666*77c1e3ccSAndroid Build Coastguard Worker         input, width + 2, reference, kOutputStride, width, height,
667*77c1e3ccSAndroid Build Coastguard Worker         filter_params_x, kSubX, &conv_params1, bit_depth);
668*77c1e3ccSAndroid Build Coastguard Worker 
669*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
670*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, bit_depth);
671*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
672*77c1e3ccSAndroid Build Coastguard Worker     GetParam().TestFunction()(input, width + 2, test, kOutputStride, width,
673*77c1e3ccSAndroid Build Coastguard Worker                               height, filter_params_x, kSubX, &conv_params2,
674*77c1e3ccSAndroid Build Coastguard Worker                               bit_depth);
675*77c1e3ccSAndroid Build Coastguard Worker 
676*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
677*77c1e3ccSAndroid Build Coastguard Worker   }
678*77c1e3ccSAndroid Build Coastguard Worker 
SpeedTest()679*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTest() {
680*77c1e3ccSAndroid Build Coastguard Worker     constexpr int kNumIters = 10000;
681*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilter filter = static_cast<InterpFilter>(BILINEAR);
682*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
683*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
684*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
685*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x = &av1_intrabc_filter_params;
686*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input = FirstRandomInput16(GetParam());
687*77c1e3ccSAndroid Build Coastguard Worker 
688*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
689*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
690*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
691*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
692*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
693*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < kNumIters; ++i) {
694*77c1e3ccSAndroid Build Coastguard Worker       av1_highbd_convolve_x_sr_intrabc_c(input, width, reference, kOutputStride,
695*77c1e3ccSAndroid Build Coastguard Worker                                          width, height, filter_params_x, 0,
696*77c1e3ccSAndroid Build Coastguard Worker                                          &conv_params1, bit_depth);
697*77c1e3ccSAndroid Build Coastguard Worker     }
698*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
699*77c1e3ccSAndroid Build Coastguard Worker     const double time1 = static_cast<double>(aom_usec_timer_elapsed(&timer));
700*77c1e3ccSAndroid Build Coastguard Worker 
701*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
702*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
703*77c1e3ccSAndroid Build Coastguard Worker     highbd_convolve_x_func test_func = GetParam().TestFunction();
704*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
705*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
706*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < kNumIters; ++i) {
707*77c1e3ccSAndroid Build Coastguard Worker       test_func(input, width, test, kOutputStride, width, height,
708*77c1e3ccSAndroid Build Coastguard Worker                 filter_params_x, 0, &conv_params2, bit_depth);
709*77c1e3ccSAndroid Build Coastguard Worker     }
710*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
711*77c1e3ccSAndroid Build Coastguard Worker     const double time2 = static_cast<double>(aom_usec_timer_elapsed(&timer));
712*77c1e3ccSAndroid Build Coastguard Worker 
713*77c1e3ccSAndroid Build Coastguard Worker     printf("%d %3dx%-3d:%7.2f/%7.2fns (%3.2f)\n", filter, width, height, time1,
714*77c1e3ccSAndroid Build Coastguard Worker            time2, time1 / time2);
715*77c1e3ccSAndroid Build Coastguard Worker   }
716*77c1e3ccSAndroid Build Coastguard Worker };
717*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveXHighbdIntraBCTest,RunTest)718*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveXHighbdIntraBCTest, RunTest) { RunTest(); }
719*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveXHighbdIntraBCTest,DISABLED_SpeedTest)720*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveXHighbdIntraBCTest, DISABLED_SpeedTest) { SpeedTest(); }
721*77c1e3ccSAndroid Build Coastguard Worker 
722*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1ConvolveXHighbdIntraBCTest,
723*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_x_sr_intrabc_c));
724*77c1e3ccSAndroid Build Coastguard Worker 
725*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
726*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
727*77c1e3ccSAndroid Build Coastguard Worker     NEON, AV1ConvolveXHighbdIntraBCTest,
728*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdParams(av1_highbd_convolve_x_sr_intrabc_neon));
729*77c1e3ccSAndroid Build Coastguard Worker #endif
730*77c1e3ccSAndroid Build Coastguard Worker 
731*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
732*77c1e3ccSAndroid Build Coastguard Worker 
733*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////////////
734*77c1e3ccSAndroid Build Coastguard Worker // Single reference convolve-y functions (low bit-depth)
735*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////////////
736*77c1e3ccSAndroid Build Coastguard Worker typedef void (*convolve_y_func)(const uint8_t *src, int src_stride,
737*77c1e3ccSAndroid Build Coastguard Worker                                 uint8_t *dst, int dst_stride, int w, int h,
738*77c1e3ccSAndroid Build Coastguard Worker                                 const InterpFilterParams *filter_params_y,
739*77c1e3ccSAndroid Build Coastguard Worker                                 const int subpel_y_qn);
740*77c1e3ccSAndroid Build Coastguard Worker 
741*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveYTest : public AV1ConvolveTest<convolve_y_func> {
742*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()743*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
744*77c1e3ccSAndroid Build Coastguard Worker     // Do not test the no-op filter.
745*77c1e3ccSAndroid Build Coastguard Worker     for (int sub_y = 1; sub_y < 16; ++sub_y) {
746*77c1e3ccSAndroid Build Coastguard Worker       for (int filter = EIGHTTAP_REGULAR; filter <= INTERP_FILTERS_ALL;
747*77c1e3ccSAndroid Build Coastguard Worker            ++filter) {
748*77c1e3ccSAndroid Build Coastguard Worker         InterpFilter f = static_cast<InterpFilter>(filter);
749*77c1e3ccSAndroid Build Coastguard Worker         TestConvolve(sub_y, f);
750*77c1e3ccSAndroid Build Coastguard Worker       }
751*77c1e3ccSAndroid Build Coastguard Worker     }
752*77c1e3ccSAndroid Build Coastguard Worker   }
753*77c1e3ccSAndroid Build Coastguard Worker 
754*77c1e3ccSAndroid Build Coastguard Worker  public:
SpeedTest()755*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTest() {
756*77c1e3ccSAndroid Build Coastguard Worker     for (int filter = EIGHTTAP_REGULAR; filter <= INTERP_FILTERS_ALL;
757*77c1e3ccSAndroid Build Coastguard Worker          ++filter) {
758*77c1e3ccSAndroid Build Coastguard Worker       InterpFilter f = static_cast<InterpFilter>(filter);
759*77c1e3ccSAndroid Build Coastguard Worker       TestConvolveSpeed(f, 10000);
760*77c1e3ccSAndroid Build Coastguard Worker     }
761*77c1e3ccSAndroid Build Coastguard Worker   }
762*77c1e3ccSAndroid Build Coastguard Worker 
763*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolve(const int sub_y,const InterpFilter filter)764*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolve(const int sub_y, const InterpFilter filter) {
765*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
766*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
767*77c1e3ccSAndroid Build Coastguard Worker 
768*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y =
769*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(filter, height);
770*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input = FirstRandomInput8(GetParam());
771*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
772*77c1e3ccSAndroid Build Coastguard Worker     av1_convolve_y_sr_c(input, width, reference, kOutputStride, width, height,
773*77c1e3ccSAndroid Build Coastguard Worker                         filter_params_y, sub_y);
774*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
775*77c1e3ccSAndroid Build Coastguard Worker     GetParam().TestFunction()(input, width, test, kOutputStride, width, height,
776*77c1e3ccSAndroid Build Coastguard Worker                               filter_params_y, sub_y);
777*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
778*77c1e3ccSAndroid Build Coastguard Worker   }
779*77c1e3ccSAndroid Build Coastguard Worker 
780*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolveSpeed(const InterpFilter filter,const int num_iters)781*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolveSpeed(const InterpFilter filter, const int num_iters) {
782*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
783*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
784*77c1e3ccSAndroid Build Coastguard Worker 
785*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y =
786*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(filter, height);
787*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input = FirstRandomInput8(GetParam());
788*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
789*77c1e3ccSAndroid Build Coastguard Worker 
790*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
791*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
792*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_iters; ++i) {
793*77c1e3ccSAndroid Build Coastguard Worker       av1_convolve_y_sr_c(input, width, reference, kOutputStride, width, height,
794*77c1e3ccSAndroid Build Coastguard Worker                           filter_params_y, 0);
795*77c1e3ccSAndroid Build Coastguard Worker     }
796*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
797*77c1e3ccSAndroid Build Coastguard Worker     const double time1 = static_cast<double>(aom_usec_timer_elapsed(&timer));
798*77c1e3ccSAndroid Build Coastguard Worker 
799*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
800*77c1e3ccSAndroid Build Coastguard Worker 
801*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
802*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_iters; ++i) {
803*77c1e3ccSAndroid Build Coastguard Worker       GetParam().TestFunction()(input, width, test, kOutputStride, width,
804*77c1e3ccSAndroid Build Coastguard Worker                                 height, filter_params_y, 0);
805*77c1e3ccSAndroid Build Coastguard Worker     }
806*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
807*77c1e3ccSAndroid Build Coastguard Worker     const double time2 = static_cast<double>(aom_usec_timer_elapsed(&timer));
808*77c1e3ccSAndroid Build Coastguard Worker     printf("%d %3dx%-3d:%7.2f/%7.2fns (%3.2f)\n", filter, width, height, time1,
809*77c1e3ccSAndroid Build Coastguard Worker            time2, time1 / time2);
810*77c1e3ccSAndroid Build Coastguard Worker   }
811*77c1e3ccSAndroid Build Coastguard Worker };
812*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveYTest,RunTest)813*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveYTest, RunTest) { RunTest(); }
814*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveYTest,DISABLED_SpeedTest)815*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveYTest, DISABLED_SpeedTest) { SpeedTest(); }
816*77c1e3ccSAndroid Build Coastguard Worker 
817*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1ConvolveYTest,
818*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_y_sr_c));
819*77c1e3ccSAndroid Build Coastguard Worker 
820*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE2
821*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE2, AV1ConvolveYTest,
822*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_y_sr_sse2));
823*77c1e3ccSAndroid Build Coastguard Worker #endif
824*77c1e3ccSAndroid Build Coastguard Worker 
825*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
826*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, AV1ConvolveYTest,
827*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_y_sr_avx2));
828*77c1e3ccSAndroid Build Coastguard Worker #endif
829*77c1e3ccSAndroid Build Coastguard Worker 
830*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
831*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1ConvolveYTest,
832*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_y_sr_neon));
833*77c1e3ccSAndroid Build Coastguard Worker #endif
834*77c1e3ccSAndroid Build Coastguard Worker 
835*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON_DOTPROD
836*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON_DOTPROD, AV1ConvolveYTest,
837*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_y_sr_neon_dotprod));
838*77c1e3ccSAndroid Build Coastguard Worker #endif
839*77c1e3ccSAndroid Build Coastguard Worker 
840*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON_I8MM
841*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON_I8MM, AV1ConvolveYTest,
842*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_y_sr_neon_i8mm));
843*77c1e3ccSAndroid Build Coastguard Worker #endif
844*77c1e3ccSAndroid Build Coastguard Worker 
845*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////////////////////
846*77c1e3ccSAndroid Build Coastguard Worker // Single reference convolve-y IntraBC functions (low bit-depth)
847*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////////////////////
848*77c1e3ccSAndroid Build Coastguard Worker 
849*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveYIntraBCTest : public AV1ConvolveTest<convolve_y_func> {
850*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()851*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
852*77c1e3ccSAndroid Build Coastguard Worker     // IntraBC functions only operate for subpel_y_qn = 8.
853*77c1e3ccSAndroid Build Coastguard Worker     constexpr int kSubY = 8;
854*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
855*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
856*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y = &av1_intrabc_filter_params;
857*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input = FirstRandomInput8(GetParam());
858*77c1e3ccSAndroid Build Coastguard Worker 
859*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
860*77c1e3ccSAndroid Build Coastguard Worker     // Use a stride different from width to avoid potential storing errors that
861*77c1e3ccSAndroid Build Coastguard Worker     // would go undetected. The input buffer is filled using a padding of 12, so
862*77c1e3ccSAndroid Build Coastguard Worker     // the stride can be anywhere between width and width + 12.
863*77c1e3ccSAndroid Build Coastguard Worker     av1_convolve_y_sr_intrabc_c(input, width + 2, reference, kOutputStride,
864*77c1e3ccSAndroid Build Coastguard Worker                                 width, height, filter_params_y, kSubY);
865*77c1e3ccSAndroid Build Coastguard Worker 
866*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
867*77c1e3ccSAndroid Build Coastguard Worker     GetParam().TestFunction()(input, width + 2, test, kOutputStride, width,
868*77c1e3ccSAndroid Build Coastguard Worker                               height, filter_params_y, kSubY);
869*77c1e3ccSAndroid Build Coastguard Worker 
870*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
871*77c1e3ccSAndroid Build Coastguard Worker   }
872*77c1e3ccSAndroid Build Coastguard Worker 
SpeedTest()873*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTest() {
874*77c1e3ccSAndroid Build Coastguard Worker     constexpr int kNumIters = 10000;
875*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilter filter = static_cast<InterpFilter>(BILINEAR);
876*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
877*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
878*77c1e3ccSAndroid Build Coastguard Worker 
879*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y = &av1_intrabc_filter_params;
880*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input = FirstRandomInput8(GetParam());
881*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
882*77c1e3ccSAndroid Build Coastguard Worker 
883*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
884*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
885*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < kNumIters; ++i) {
886*77c1e3ccSAndroid Build Coastguard Worker       av1_convolve_y_sr_intrabc_c(input, width, reference, kOutputStride, width,
887*77c1e3ccSAndroid Build Coastguard Worker                                   height, filter_params_y, 0);
888*77c1e3ccSAndroid Build Coastguard Worker     }
889*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
890*77c1e3ccSAndroid Build Coastguard Worker     const double time1 = static_cast<double>(aom_usec_timer_elapsed(&timer));
891*77c1e3ccSAndroid Build Coastguard Worker 
892*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
893*77c1e3ccSAndroid Build Coastguard Worker     convolve_y_func test_func = GetParam().TestFunction();
894*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
895*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < kNumIters; ++i) {
896*77c1e3ccSAndroid Build Coastguard Worker       test_func(input, width, test, kOutputStride, width, height,
897*77c1e3ccSAndroid Build Coastguard Worker                 filter_params_y, 0);
898*77c1e3ccSAndroid Build Coastguard Worker     }
899*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
900*77c1e3ccSAndroid Build Coastguard Worker     const double time2 = static_cast<double>(aom_usec_timer_elapsed(&timer));
901*77c1e3ccSAndroid Build Coastguard Worker 
902*77c1e3ccSAndroid Build Coastguard Worker     printf("%d %3dx%-3d:%7.2f/%7.2fns (%3.2f)\n", filter, width, height, time1,
903*77c1e3ccSAndroid Build Coastguard Worker            time2, time1 / time2);
904*77c1e3ccSAndroid Build Coastguard Worker   }
905*77c1e3ccSAndroid Build Coastguard Worker };
906*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveYIntraBCTest,RunTest)907*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveYIntraBCTest, RunTest) { RunTest(); }
908*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveYIntraBCTest,DISABLED_SpeedTest)909*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveYIntraBCTest, DISABLED_SpeedTest) { SpeedTest(); }
910*77c1e3ccSAndroid Build Coastguard Worker 
911*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1ConvolveYIntraBCTest,
912*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_y_sr_intrabc_c));
913*77c1e3ccSAndroid Build Coastguard Worker 
914*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
915*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1ConvolveYIntraBCTest,
916*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_y_sr_intrabc_neon));
917*77c1e3ccSAndroid Build Coastguard Worker #endif
918*77c1e3ccSAndroid Build Coastguard Worker 
919*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
920*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////////////
921*77c1e3ccSAndroid Build Coastguard Worker // Single reference convolve-y functions (high bit-depth)
922*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////////////
923*77c1e3ccSAndroid Build Coastguard Worker typedef void (*highbd_convolve_y_func)(
924*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w,
925*77c1e3ccSAndroid Build Coastguard Worker     int h, const InterpFilterParams *filter_params_y, const int subpel_y_qn,
926*77c1e3ccSAndroid Build Coastguard Worker     int bd);
927*77c1e3ccSAndroid Build Coastguard Worker 
928*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveYHighbdTest : public AV1ConvolveTest<highbd_convolve_y_func> {
929*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()930*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
931*77c1e3ccSAndroid Build Coastguard Worker     // Do not test the no-op filter.
932*77c1e3ccSAndroid Build Coastguard Worker     for (int sub_y = 1; sub_y < 16; ++sub_y) {
933*77c1e3ccSAndroid Build Coastguard Worker       for (int filter = EIGHTTAP_REGULAR; filter <= INTERP_FILTERS_ALL;
934*77c1e3ccSAndroid Build Coastguard Worker            ++filter) {
935*77c1e3ccSAndroid Build Coastguard Worker         InterpFilter f = static_cast<InterpFilter>(filter);
936*77c1e3ccSAndroid Build Coastguard Worker         TestConvolve(sub_y, f);
937*77c1e3ccSAndroid Build Coastguard Worker       }
938*77c1e3ccSAndroid Build Coastguard Worker     }
939*77c1e3ccSAndroid Build Coastguard Worker   }
940*77c1e3ccSAndroid Build Coastguard Worker 
941*77c1e3ccSAndroid Build Coastguard Worker  public:
SpeedTest()942*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTest() {
943*77c1e3ccSAndroid Build Coastguard Worker     for (int filter = EIGHTTAP_REGULAR; filter <= INTERP_FILTERS_ALL;
944*77c1e3ccSAndroid Build Coastguard Worker          ++filter) {
945*77c1e3ccSAndroid Build Coastguard Worker       InterpFilter f = static_cast<InterpFilter>(filter);
946*77c1e3ccSAndroid Build Coastguard Worker       TestConvolveSpeed(f, 10000);
947*77c1e3ccSAndroid Build Coastguard Worker     }
948*77c1e3ccSAndroid Build Coastguard Worker   }
949*77c1e3ccSAndroid Build Coastguard Worker 
950*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolve(const int sub_y,const InterpFilter filter)951*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolve(const int sub_y, const InterpFilter filter) {
952*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
953*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
954*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
955*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y =
956*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(filter, height);
957*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input = FirstRandomInput16(GetParam());
958*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
959*77c1e3ccSAndroid Build Coastguard Worker     av1_highbd_convolve_y_sr_c(input, width, reference, kOutputStride, width,
960*77c1e3ccSAndroid Build Coastguard Worker                                height, filter_params_y, sub_y, bit_depth);
961*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
962*77c1e3ccSAndroid Build Coastguard Worker     GetParam().TestFunction()(input, width, test, kOutputStride, width, height,
963*77c1e3ccSAndroid Build Coastguard Worker                               filter_params_y, sub_y, bit_depth);
964*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
965*77c1e3ccSAndroid Build Coastguard Worker   }
966*77c1e3ccSAndroid Build Coastguard Worker 
967*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolveSpeed(const InterpFilter filter,const int num_iters)968*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolveSpeed(const InterpFilter filter, const int num_iters) {
969*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
970*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
971*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
972*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y =
973*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(filter, width);
974*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input = FirstRandomInput16(GetParam());
975*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
976*77c1e3ccSAndroid Build Coastguard Worker 
977*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
978*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
979*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_iters; ++i) {
980*77c1e3ccSAndroid Build Coastguard Worker       av1_highbd_convolve_y_sr_c(input, width, reference, kOutputStride, width,
981*77c1e3ccSAndroid Build Coastguard Worker                                  height, filter_params_y, 0, bit_depth);
982*77c1e3ccSAndroid Build Coastguard Worker     }
983*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
984*77c1e3ccSAndroid Build Coastguard Worker     const double time1 = static_cast<double>(aom_usec_timer_elapsed(&timer));
985*77c1e3ccSAndroid Build Coastguard Worker     highbd_convolve_y_func test_func = GetParam().TestFunction();
986*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
987*77c1e3ccSAndroid Build Coastguard Worker 
988*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
989*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_iters; ++i) {
990*77c1e3ccSAndroid Build Coastguard Worker       test_func(input, width, test, kOutputStride, width, height,
991*77c1e3ccSAndroid Build Coastguard Worker                 filter_params_y, 0, bit_depth);
992*77c1e3ccSAndroid Build Coastguard Worker     }
993*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
994*77c1e3ccSAndroid Build Coastguard Worker     const double time2 = static_cast<double>(aom_usec_timer_elapsed(&timer));
995*77c1e3ccSAndroid Build Coastguard Worker     printf("%d %3dx%-3d:%7.2f/%7.2fns (%3.2f)\n", filter, width, height, time1,
996*77c1e3ccSAndroid Build Coastguard Worker            time2, time1 / time2);
997*77c1e3ccSAndroid Build Coastguard Worker   }
998*77c1e3ccSAndroid Build Coastguard Worker };
999*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveYHighbdTest,RunTest)1000*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveYHighbdTest, RunTest) { RunTest(); }
1001*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveYHighbdTest,DISABLED_SpeedTest)1002*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveYHighbdTest, DISABLED_SpeedTest) { SpeedTest(); }
1003*77c1e3ccSAndroid Build Coastguard Worker 
1004*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1ConvolveYHighbdTest,
1005*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_y_sr_c));
1006*77c1e3ccSAndroid Build Coastguard Worker 
1007*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSSE3
1008*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSSE3, AV1ConvolveYHighbdTest,
1009*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_y_sr_ssse3));
1010*77c1e3ccSAndroid Build Coastguard Worker #endif
1011*77c1e3ccSAndroid Build Coastguard Worker 
1012*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
1013*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, AV1ConvolveYHighbdTest,
1014*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_y_sr_avx2));
1015*77c1e3ccSAndroid Build Coastguard Worker #endif
1016*77c1e3ccSAndroid Build Coastguard Worker 
1017*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
1018*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1ConvolveYHighbdTest,
1019*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_y_sr_neon));
1020*77c1e3ccSAndroid Build Coastguard Worker #endif
1021*77c1e3ccSAndroid Build Coastguard Worker 
1022*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SVE2
1023*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SVE2, AV1ConvolveYHighbdTest,
1024*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_y_sr_sve2));
1025*77c1e3ccSAndroid Build Coastguard Worker #endif
1026*77c1e3ccSAndroid Build Coastguard Worker 
1027*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////////////////////
1028*77c1e3ccSAndroid Build Coastguard Worker // Single reference convolve-y IntraBC functions (high bit-depth)
1029*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////////////////////
1030*77c1e3ccSAndroid Build Coastguard Worker 
1031*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveYHighbdIntraBCTest
1032*77c1e3ccSAndroid Build Coastguard Worker     : public AV1ConvolveTest<highbd_convolve_y_func> {
1033*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()1034*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
1035*77c1e3ccSAndroid Build Coastguard Worker     // IntraBC functions only operate for subpel_y_qn = 8.
1036*77c1e3ccSAndroid Build Coastguard Worker     constexpr int kSubY = 8;
1037*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1038*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1039*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
1040*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y = &av1_intrabc_filter_params;
1041*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input = FirstRandomInput16(GetParam());
1042*77c1e3ccSAndroid Build Coastguard Worker 
1043*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
1044*77c1e3ccSAndroid Build Coastguard Worker     // Use a stride different from width to avoid potential storing errors that
1045*77c1e3ccSAndroid Build Coastguard Worker     // would go undetected. The input buffer is filled using a padding of 12, so
1046*77c1e3ccSAndroid Build Coastguard Worker     // the stride can be anywhere between width and width + 12.
1047*77c1e3ccSAndroid Build Coastguard Worker     av1_highbd_convolve_y_sr_intrabc_c(input, width + 2, reference,
1048*77c1e3ccSAndroid Build Coastguard Worker                                        kOutputStride, width, height,
1049*77c1e3ccSAndroid Build Coastguard Worker                                        filter_params_y, kSubY, bit_depth);
1050*77c1e3ccSAndroid Build Coastguard Worker 
1051*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
1052*77c1e3ccSAndroid Build Coastguard Worker     GetParam().TestFunction()(input, width + 2, test, kOutputStride, width,
1053*77c1e3ccSAndroid Build Coastguard Worker                               height, filter_params_y, kSubY, bit_depth);
1054*77c1e3ccSAndroid Build Coastguard Worker 
1055*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
1056*77c1e3ccSAndroid Build Coastguard Worker   }
1057*77c1e3ccSAndroid Build Coastguard Worker 
SpeedTest()1058*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTest() {
1059*77c1e3ccSAndroid Build Coastguard Worker     constexpr int kNumIters = 10000;
1060*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilter filter = static_cast<InterpFilter>(BILINEAR);
1061*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1062*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1063*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
1064*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y =
1065*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(filter, width);
1066*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input = FirstRandomInput16(GetParam());
1067*77c1e3ccSAndroid Build Coastguard Worker 
1068*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
1069*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
1070*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
1071*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < kNumIters; ++i) {
1072*77c1e3ccSAndroid Build Coastguard Worker       av1_highbd_convolve_y_sr_intrabc_c(input, width, reference, kOutputStride,
1073*77c1e3ccSAndroid Build Coastguard Worker                                          width, height, filter_params_y, 0,
1074*77c1e3ccSAndroid Build Coastguard Worker                                          bit_depth);
1075*77c1e3ccSAndroid Build Coastguard Worker     }
1076*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
1077*77c1e3ccSAndroid Build Coastguard Worker     const double time1 = static_cast<double>(aom_usec_timer_elapsed(&timer));
1078*77c1e3ccSAndroid Build Coastguard Worker 
1079*77c1e3ccSAndroid Build Coastguard Worker     highbd_convolve_y_func test_func = GetParam().TestFunction();
1080*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
1081*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
1082*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < kNumIters; ++i) {
1083*77c1e3ccSAndroid Build Coastguard Worker       test_func(input, width, test, kOutputStride, width, height,
1084*77c1e3ccSAndroid Build Coastguard Worker                 filter_params_y, 0, bit_depth);
1085*77c1e3ccSAndroid Build Coastguard Worker     }
1086*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
1087*77c1e3ccSAndroid Build Coastguard Worker     const double time2 = static_cast<double>(aom_usec_timer_elapsed(&timer));
1088*77c1e3ccSAndroid Build Coastguard Worker 
1089*77c1e3ccSAndroid Build Coastguard Worker     printf("%d %3dx%-3d:%7.2f/%7.2fns (%3.2f)\n", filter, width, height, time1,
1090*77c1e3ccSAndroid Build Coastguard Worker            time2, time1 / time2);
1091*77c1e3ccSAndroid Build Coastguard Worker   }
1092*77c1e3ccSAndroid Build Coastguard Worker };
1093*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveYHighbdIntraBCTest,RunTest)1094*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveYHighbdIntraBCTest, RunTest) { RunTest(); }
1095*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveYHighbdIntraBCTest,DISABLED_SpeedTest)1096*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveYHighbdIntraBCTest, DISABLED_SpeedTest) { SpeedTest(); }
1097*77c1e3ccSAndroid Build Coastguard Worker 
1098*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1ConvolveYHighbdIntraBCTest,
1099*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_y_sr_intrabc_c));
1100*77c1e3ccSAndroid Build Coastguard Worker 
1101*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
1102*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
1103*77c1e3ccSAndroid Build Coastguard Worker     NEON, AV1ConvolveYHighbdIntraBCTest,
1104*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdParams(av1_highbd_convolve_y_sr_intrabc_neon));
1105*77c1e3ccSAndroid Build Coastguard Worker #endif
1106*77c1e3ccSAndroid Build Coastguard Worker 
1107*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
1108*77c1e3ccSAndroid Build Coastguard Worker 
1109*77c1e3ccSAndroid Build Coastguard Worker //////////////////////////////////////////////////////////////
1110*77c1e3ccSAndroid Build Coastguard Worker // Single reference convolve-copy functions (low bit-depth)
1111*77c1e3ccSAndroid Build Coastguard Worker //////////////////////////////////////////////////////////////
1112*77c1e3ccSAndroid Build Coastguard Worker typedef void (*convolve_copy_func)(const uint8_t *src, ptrdiff_t src_stride,
1113*77c1e3ccSAndroid Build Coastguard Worker                                    uint8_t *dst, ptrdiff_t dst_stride, int w,
1114*77c1e3ccSAndroid Build Coastguard Worker                                    int h);
1115*77c1e3ccSAndroid Build Coastguard Worker 
1116*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveCopyTest : public AV1ConvolveTest<convolve_copy_func> {
1117*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()1118*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
1119*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1120*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1121*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input = FirstRandomInput8(GetParam());
1122*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
1123*77c1e3ccSAndroid Build Coastguard Worker     aom_convolve_copy_c(input, width, reference, kOutputStride, width, height);
1124*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
1125*77c1e3ccSAndroid Build Coastguard Worker     GetParam().TestFunction()(input, width, test, kOutputStride, width, height);
1126*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
1127*77c1e3ccSAndroid Build Coastguard Worker   }
1128*77c1e3ccSAndroid Build Coastguard Worker };
1129*77c1e3ccSAndroid Build Coastguard Worker 
1130*77c1e3ccSAndroid Build Coastguard Worker // Note that even though these are AOM convolve functions, we are using the
1131*77c1e3ccSAndroid Build Coastguard Worker // newer AV1 test framework.
TEST_P(AV1ConvolveCopyTest,RunTest)1132*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveCopyTest, RunTest) { RunTest(); }
1133*77c1e3ccSAndroid Build Coastguard Worker 
1134*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1ConvolveCopyTest,
1135*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(aom_convolve_copy_c));
1136*77c1e3ccSAndroid Build Coastguard Worker 
1137*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE2
1138*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE2, AV1ConvolveCopyTest,
1139*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(aom_convolve_copy_sse2));
1140*77c1e3ccSAndroid Build Coastguard Worker #endif
1141*77c1e3ccSAndroid Build Coastguard Worker 
1142*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
1143*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, AV1ConvolveCopyTest,
1144*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(aom_convolve_copy_avx2));
1145*77c1e3ccSAndroid Build Coastguard Worker #endif
1146*77c1e3ccSAndroid Build Coastguard Worker 
1147*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
1148*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1ConvolveCopyTest,
1149*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(aom_convolve_copy_neon));
1150*77c1e3ccSAndroid Build Coastguard Worker #endif
1151*77c1e3ccSAndroid Build Coastguard Worker 
1152*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
1153*77c1e3ccSAndroid Build Coastguard Worker ///////////////////////////////////////////////////////////////
1154*77c1e3ccSAndroid Build Coastguard Worker // Single reference convolve-copy functions (high bit-depth)
1155*77c1e3ccSAndroid Build Coastguard Worker ///////////////////////////////////////////////////////////////
1156*77c1e3ccSAndroid Build Coastguard Worker typedef void (*highbd_convolve_copy_func)(const uint16_t *src,
1157*77c1e3ccSAndroid Build Coastguard Worker                                           ptrdiff_t src_stride, uint16_t *dst,
1158*77c1e3ccSAndroid Build Coastguard Worker                                           ptrdiff_t dst_stride, int w, int h);
1159*77c1e3ccSAndroid Build Coastguard Worker 
1160*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveCopyHighbdTest
1161*77c1e3ccSAndroid Build Coastguard Worker     : public AV1ConvolveTest<highbd_convolve_copy_func> {
1162*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()1163*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
1164*77c1e3ccSAndroid Build Coastguard Worker     const BlockSize &block = GetParam().Block();
1165*77c1e3ccSAndroid Build Coastguard Worker     const int width = block.Width();
1166*77c1e3ccSAndroid Build Coastguard Worker     const int height = block.Height();
1167*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input = FirstRandomInput16(GetParam());
1168*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
1169*77c1e3ccSAndroid Build Coastguard Worker     aom_highbd_convolve_copy_c(input, width, reference, kOutputStride, width,
1170*77c1e3ccSAndroid Build Coastguard Worker                                height);
1171*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
1172*77c1e3ccSAndroid Build Coastguard Worker     GetParam().TestFunction()(input, width, test, kOutputStride, width, height);
1173*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
1174*77c1e3ccSAndroid Build Coastguard Worker   }
1175*77c1e3ccSAndroid Build Coastguard Worker };
1176*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveCopyHighbdTest,RunTest)1177*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveCopyHighbdTest, RunTest) { RunTest(); }
1178*77c1e3ccSAndroid Build Coastguard Worker 
1179*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1ConvolveCopyHighbdTest,
1180*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(aom_highbd_convolve_copy_c));
1181*77c1e3ccSAndroid Build Coastguard Worker 
1182*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE2
1183*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE2, AV1ConvolveCopyHighbdTest,
1184*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(aom_highbd_convolve_copy_sse2));
1185*77c1e3ccSAndroid Build Coastguard Worker #endif
1186*77c1e3ccSAndroid Build Coastguard Worker 
1187*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
1188*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, AV1ConvolveCopyHighbdTest,
1189*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(aom_highbd_convolve_copy_avx2));
1190*77c1e3ccSAndroid Build Coastguard Worker #endif
1191*77c1e3ccSAndroid Build Coastguard Worker 
1192*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
1193*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1ConvolveCopyHighbdTest,
1194*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(aom_highbd_convolve_copy_neon));
1195*77c1e3ccSAndroid Build Coastguard Worker #endif
1196*77c1e3ccSAndroid Build Coastguard Worker 
1197*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
1198*77c1e3ccSAndroid Build Coastguard Worker 
1199*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////////////
1200*77c1e3ccSAndroid Build Coastguard Worker // Single reference convolve-2D functions (low bit-depth)
1201*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////////////
1202*77c1e3ccSAndroid Build Coastguard Worker typedef void (*convolve_2d_func)(const uint8_t *src, int src_stride,
1203*77c1e3ccSAndroid Build Coastguard Worker                                  uint8_t *dst, int dst_stride, int w, int h,
1204*77c1e3ccSAndroid Build Coastguard Worker                                  const InterpFilterParams *filter_params_x,
1205*77c1e3ccSAndroid Build Coastguard Worker                                  const InterpFilterParams *filter_params_y,
1206*77c1e3ccSAndroid Build Coastguard Worker                                  const int subpel_x_qn, const int subpel_y_qn,
1207*77c1e3ccSAndroid Build Coastguard Worker                                  ConvolveParams *conv_params);
1208*77c1e3ccSAndroid Build Coastguard Worker 
1209*77c1e3ccSAndroid Build Coastguard Worker class AV1Convolve2DTest : public AV1ConvolveTest<convolve_2d_func> {
1210*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()1211*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
1212*77c1e3ccSAndroid Build Coastguard Worker     // Do not test the no-op filter.
1213*77c1e3ccSAndroid Build Coastguard Worker     for (int sub_x = 1; sub_x < 16; ++sub_x) {
1214*77c1e3ccSAndroid Build Coastguard Worker       for (int sub_y = 1; sub_y < 16; ++sub_y) {
1215*77c1e3ccSAndroid Build Coastguard Worker         for (int h_f = EIGHTTAP_REGULAR; h_f <= INTERP_FILTERS_ALL; ++h_f) {
1216*77c1e3ccSAndroid Build Coastguard Worker           for (int v_f = EIGHTTAP_REGULAR; v_f <= INTERP_FILTERS_ALL; ++v_f) {
1217*77c1e3ccSAndroid Build Coastguard Worker             if (((h_f == MULTITAP_SHARP2) && (v_f < MULTITAP_SHARP2)) ||
1218*77c1e3ccSAndroid Build Coastguard Worker                 ((h_f < MULTITAP_SHARP2) && (v_f == MULTITAP_SHARP2)))
1219*77c1e3ccSAndroid Build Coastguard Worker               continue;
1220*77c1e3ccSAndroid Build Coastguard Worker             TestConvolve(static_cast<InterpFilter>(h_f),
1221*77c1e3ccSAndroid Build Coastguard Worker                          static_cast<InterpFilter>(v_f), sub_x, sub_y);
1222*77c1e3ccSAndroid Build Coastguard Worker           }
1223*77c1e3ccSAndroid Build Coastguard Worker         }
1224*77c1e3ccSAndroid Build Coastguard Worker       }
1225*77c1e3ccSAndroid Build Coastguard Worker     }
1226*77c1e3ccSAndroid Build Coastguard Worker   }
1227*77c1e3ccSAndroid Build Coastguard Worker 
1228*77c1e3ccSAndroid Build Coastguard Worker  public:
SpeedTest()1229*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTest() {
1230*77c1e3ccSAndroid Build Coastguard Worker     for (int h_f = EIGHTTAP_REGULAR; h_f <= INTERP_FILTERS_ALL; ++h_f) {
1231*77c1e3ccSAndroid Build Coastguard Worker       for (int v_f = EIGHTTAP_REGULAR; v_f <= INTERP_FILTERS_ALL; ++v_f) {
1232*77c1e3ccSAndroid Build Coastguard Worker         if (((h_f == MULTITAP_SHARP2) && (v_f < MULTITAP_SHARP2)) ||
1233*77c1e3ccSAndroid Build Coastguard Worker             ((h_f < MULTITAP_SHARP2) && (v_f == MULTITAP_SHARP2)))
1234*77c1e3ccSAndroid Build Coastguard Worker           continue;
1235*77c1e3ccSAndroid Build Coastguard Worker         TestConvolveSpeed(static_cast<InterpFilter>(h_f),
1236*77c1e3ccSAndroid Build Coastguard Worker                           static_cast<InterpFilter>(v_f), 10000);
1237*77c1e3ccSAndroid Build Coastguard Worker       }
1238*77c1e3ccSAndroid Build Coastguard Worker     }
1239*77c1e3ccSAndroid Build Coastguard Worker   }
1240*77c1e3ccSAndroid Build Coastguard Worker 
1241*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolve(const InterpFilter h_f,const InterpFilter v_f,const int sub_x,const int sub_y)1242*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolve(const InterpFilter h_f, const InterpFilter v_f,
1243*77c1e3ccSAndroid Build Coastguard Worker                     const int sub_x, const int sub_y) {
1244*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1245*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1246*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x =
1247*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(h_f, width);
1248*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y =
1249*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(v_f, height);
1250*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input = FirstRandomInput8(GetParam());
1251*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
1252*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
1253*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
1254*77c1e3ccSAndroid Build Coastguard Worker     av1_convolve_2d_sr_c(input, width, reference, kOutputStride, width, height,
1255*77c1e3ccSAndroid Build Coastguard Worker                          filter_params_x, filter_params_y, sub_x, sub_y,
1256*77c1e3ccSAndroid Build Coastguard Worker                          &conv_params1);
1257*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
1258*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
1259*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
1260*77c1e3ccSAndroid Build Coastguard Worker     GetParam().TestFunction()(input, width, test, kOutputStride, width, height,
1261*77c1e3ccSAndroid Build Coastguard Worker                               filter_params_x, filter_params_y, sub_x, sub_y,
1262*77c1e3ccSAndroid Build Coastguard Worker                               &conv_params2);
1263*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
1264*77c1e3ccSAndroid Build Coastguard Worker   }
1265*77c1e3ccSAndroid Build Coastguard Worker 
1266*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolveSpeed(const InterpFilter h_f,const InterpFilter v_f,int num_iters)1267*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolveSpeed(const InterpFilter h_f, const InterpFilter v_f,
1268*77c1e3ccSAndroid Build Coastguard Worker                          int num_iters) {
1269*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1270*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1271*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x =
1272*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(h_f, width);
1273*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y =
1274*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(v_f, height);
1275*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input = FirstRandomInput8(GetParam());
1276*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
1277*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
1278*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
1279*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
1280*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
1281*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_iters; ++i) {
1282*77c1e3ccSAndroid Build Coastguard Worker       av1_convolve_2d_sr_c(input, width, reference, kOutputStride, width,
1283*77c1e3ccSAndroid Build Coastguard Worker                            height, filter_params_x, filter_params_y, 0, 0,
1284*77c1e3ccSAndroid Build Coastguard Worker                            &conv_params1);
1285*77c1e3ccSAndroid Build Coastguard Worker     }
1286*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
1287*77c1e3ccSAndroid Build Coastguard Worker     const double time1 = static_cast<double>(aom_usec_timer_elapsed(&timer));
1288*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
1289*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
1290*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
1291*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
1292*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_iters; ++i) {
1293*77c1e3ccSAndroid Build Coastguard Worker       GetParam().TestFunction()(input, width, test, kOutputStride, width,
1294*77c1e3ccSAndroid Build Coastguard Worker                                 height, filter_params_x, filter_params_y, 0, 0,
1295*77c1e3ccSAndroid Build Coastguard Worker                                 &conv_params2);
1296*77c1e3ccSAndroid Build Coastguard Worker     }
1297*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
1298*77c1e3ccSAndroid Build Coastguard Worker     const double time2 = static_cast<double>(aom_usec_timer_elapsed(&timer));
1299*77c1e3ccSAndroid Build Coastguard Worker     printf("%d - %d %3dx%-3d:%7.2f/%7.2fns (%3.2f)\n", h_f, v_f, width, height,
1300*77c1e3ccSAndroid Build Coastguard Worker            time1, time2, time1 / time2);
1301*77c1e3ccSAndroid Build Coastguard Worker   }
1302*77c1e3ccSAndroid Build Coastguard Worker };
1303*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1Convolve2DTest,RunTest)1304*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1Convolve2DTest, RunTest) { RunTest(); }
1305*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1Convolve2DTest,DISABLED_SpeedTest)1306*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1Convolve2DTest, DISABLED_SpeedTest) { SpeedTest(); }
1307*77c1e3ccSAndroid Build Coastguard Worker 
1308*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1Convolve2DTest,
1309*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_2d_sr_c));
1310*77c1e3ccSAndroid Build Coastguard Worker 
1311*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE2
1312*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE2, AV1Convolve2DTest,
1313*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_2d_sr_sse2));
1314*77c1e3ccSAndroid Build Coastguard Worker #endif
1315*77c1e3ccSAndroid Build Coastguard Worker 
1316*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
1317*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, AV1Convolve2DTest,
1318*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_2d_sr_avx2));
1319*77c1e3ccSAndroid Build Coastguard Worker #endif
1320*77c1e3ccSAndroid Build Coastguard Worker 
1321*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
1322*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1Convolve2DTest,
1323*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_2d_sr_neon));
1324*77c1e3ccSAndroid Build Coastguard Worker #endif
1325*77c1e3ccSAndroid Build Coastguard Worker 
1326*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON_DOTPROD
1327*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON_DOTPROD, AV1Convolve2DTest,
1328*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_2d_sr_neon_dotprod));
1329*77c1e3ccSAndroid Build Coastguard Worker #endif
1330*77c1e3ccSAndroid Build Coastguard Worker 
1331*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON_I8MM
1332*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON_I8MM, AV1Convolve2DTest,
1333*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_2d_sr_neon_i8mm));
1334*77c1e3ccSAndroid Build Coastguard Worker #endif
1335*77c1e3ccSAndroid Build Coastguard Worker 
1336*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SVE2
1337*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SVE2, AV1Convolve2DTest,
1338*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_2d_sr_sve2));
1339*77c1e3ccSAndroid Build Coastguard Worker #endif
1340*77c1e3ccSAndroid Build Coastguard Worker 
1341*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////////////////////
1342*77c1e3ccSAndroid Build Coastguard Worker // Single reference convolve-2D IntraBC functions (low bit-depth)
1343*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////////////////////
1344*77c1e3ccSAndroid Build Coastguard Worker 
1345*77c1e3ccSAndroid Build Coastguard Worker class AV1Convolve2DIntraBCTest : public AV1ConvolveTest<convolve_2d_func> {
1346*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()1347*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
1348*77c1e3ccSAndroid Build Coastguard Worker     // IntraBC functions only operate for subpel_x_qn = 8 and subpel_y_qn = 8.
1349*77c1e3ccSAndroid Build Coastguard Worker     constexpr int kSubX = 8;
1350*77c1e3ccSAndroid Build Coastguard Worker     constexpr int kSubY = 8;
1351*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1352*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1353*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x = &av1_intrabc_filter_params;
1354*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y = &av1_intrabc_filter_params;
1355*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input = FirstRandomInput8(GetParam());
1356*77c1e3ccSAndroid Build Coastguard Worker 
1357*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
1358*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
1359*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
1360*77c1e3ccSAndroid Build Coastguard Worker     // Use a stride different from width to avoid potential storing errors that
1361*77c1e3ccSAndroid Build Coastguard Worker     // would go undetected. The input buffer is filled using a padding of 12, so
1362*77c1e3ccSAndroid Build Coastguard Worker     // the stride can be anywhere between width and width + 12.
1363*77c1e3ccSAndroid Build Coastguard Worker     av1_convolve_2d_sr_intrabc_c(input, width + 2, reference, kOutputStride,
1364*77c1e3ccSAndroid Build Coastguard Worker                                  width, height, filter_params_x,
1365*77c1e3ccSAndroid Build Coastguard Worker                                  filter_params_y, kSubX, kSubY, &conv_params1);
1366*77c1e3ccSAndroid Build Coastguard Worker 
1367*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
1368*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
1369*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
1370*77c1e3ccSAndroid Build Coastguard Worker     GetParam().TestFunction()(input, width + 2, test, kOutputStride, width,
1371*77c1e3ccSAndroid Build Coastguard Worker                               height, filter_params_x, filter_params_y, kSubX,
1372*77c1e3ccSAndroid Build Coastguard Worker                               kSubY, &conv_params2);
1373*77c1e3ccSAndroid Build Coastguard Worker 
1374*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
1375*77c1e3ccSAndroid Build Coastguard Worker   }
1376*77c1e3ccSAndroid Build Coastguard Worker 
SpeedTest()1377*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTest() {
1378*77c1e3ccSAndroid Build Coastguard Worker     constexpr int kNumIters = 10000;
1379*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilter h_f = static_cast<InterpFilter>(BILINEAR);
1380*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilter v_f = static_cast<InterpFilter>(BILINEAR);
1381*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1382*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1383*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x = &av1_intrabc_filter_params;
1384*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y = &av1_intrabc_filter_params;
1385*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input = FirstRandomInput8(GetParam());
1386*77c1e3ccSAndroid Build Coastguard Worker 
1387*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
1388*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
1389*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
1390*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
1391*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
1392*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < kNumIters; ++i) {
1393*77c1e3ccSAndroid Build Coastguard Worker       av1_convolve_2d_sr_intrabc_c(input, width, reference, kOutputStride,
1394*77c1e3ccSAndroid Build Coastguard Worker                                    width, height, filter_params_x,
1395*77c1e3ccSAndroid Build Coastguard Worker                                    filter_params_y, 8, 8, &conv_params1);
1396*77c1e3ccSAndroid Build Coastguard Worker     }
1397*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
1398*77c1e3ccSAndroid Build Coastguard Worker     const double time1 = static_cast<double>(aom_usec_timer_elapsed(&timer));
1399*77c1e3ccSAndroid Build Coastguard Worker 
1400*77c1e3ccSAndroid Build Coastguard Worker     convolve_2d_func test_func = GetParam().TestFunction();
1401*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
1402*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
1403*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
1404*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
1405*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < kNumIters; ++i) {
1406*77c1e3ccSAndroid Build Coastguard Worker       test_func(input, width, test, kOutputStride, width, height,
1407*77c1e3ccSAndroid Build Coastguard Worker                 filter_params_x, filter_params_y, 8, 8, &conv_params2);
1408*77c1e3ccSAndroid Build Coastguard Worker     }
1409*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
1410*77c1e3ccSAndroid Build Coastguard Worker     const double time2 = static_cast<double>(aom_usec_timer_elapsed(&timer));
1411*77c1e3ccSAndroid Build Coastguard Worker 
1412*77c1e3ccSAndroid Build Coastguard Worker     printf("%d - %d %3dx%-3d:%7.2f/%7.2fns (%3.2f)\n", h_f, v_f, width, height,
1413*77c1e3ccSAndroid Build Coastguard Worker            time1, time2, time1 / time2);
1414*77c1e3ccSAndroid Build Coastguard Worker   }
1415*77c1e3ccSAndroid Build Coastguard Worker };
1416*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1Convolve2DIntraBCTest,RunTest)1417*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1Convolve2DIntraBCTest, RunTest) { RunTest(); }
1418*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1Convolve2DIntraBCTest,DISABLED_SpeedTest)1419*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1Convolve2DIntraBCTest, DISABLED_SpeedTest) { SpeedTest(); }
1420*77c1e3ccSAndroid Build Coastguard Worker 
1421*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1Convolve2DIntraBCTest,
1422*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_2d_sr_intrabc_c));
1423*77c1e3ccSAndroid Build Coastguard Worker 
1424*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
1425*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1Convolve2DIntraBCTest,
1426*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdParams(av1_convolve_2d_sr_intrabc_neon));
1427*77c1e3ccSAndroid Build Coastguard Worker #endif
1428*77c1e3ccSAndroid Build Coastguard Worker 
1429*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
1430*77c1e3ccSAndroid Build Coastguard Worker //////////////////////////////////////////////////////////
1431*77c1e3ccSAndroid Build Coastguard Worker // Single reference convolve-2d functions (high bit-depth)
1432*77c1e3ccSAndroid Build Coastguard Worker //////////////////////////////////////////////////////////
1433*77c1e3ccSAndroid Build Coastguard Worker 
1434*77c1e3ccSAndroid Build Coastguard Worker typedef void (*highbd_convolve_2d_func)(
1435*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *src, int src_stride, uint16_t *dst, int dst_stride, int w,
1436*77c1e3ccSAndroid Build Coastguard Worker     int h, const InterpFilterParams *filter_params_x,
1437*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y, const int subpel_x_qn,
1438*77c1e3ccSAndroid Build Coastguard Worker     const int subpel_y_qn, ConvolveParams *conv_params, int bd);
1439*77c1e3ccSAndroid Build Coastguard Worker 
1440*77c1e3ccSAndroid Build Coastguard Worker class AV1Convolve2DHighbdTest
1441*77c1e3ccSAndroid Build Coastguard Worker     : public AV1ConvolveTest<highbd_convolve_2d_func> {
1442*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()1443*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
1444*77c1e3ccSAndroid Build Coastguard Worker     // Do not test the no-op filter.
1445*77c1e3ccSAndroid Build Coastguard Worker     for (int sub_x = 1; sub_x < 16; ++sub_x) {
1446*77c1e3ccSAndroid Build Coastguard Worker       for (int sub_y = 1; sub_y < 16; ++sub_y) {
1447*77c1e3ccSAndroid Build Coastguard Worker         for (int h_f = EIGHTTAP_REGULAR; h_f <= INTERP_FILTERS_ALL; ++h_f) {
1448*77c1e3ccSAndroid Build Coastguard Worker           for (int v_f = EIGHTTAP_REGULAR; v_f <= INTERP_FILTERS_ALL; ++v_f) {
1449*77c1e3ccSAndroid Build Coastguard Worker             if (((h_f == MULTITAP_SHARP2) && (v_f < MULTITAP_SHARP2)) ||
1450*77c1e3ccSAndroid Build Coastguard Worker                 ((h_f < MULTITAP_SHARP2) && (v_f == MULTITAP_SHARP2)))
1451*77c1e3ccSAndroid Build Coastguard Worker               continue;
1452*77c1e3ccSAndroid Build Coastguard Worker             TestConvolve(static_cast<InterpFilter>(h_f),
1453*77c1e3ccSAndroid Build Coastguard Worker                          static_cast<InterpFilter>(v_f), sub_x, sub_y);
1454*77c1e3ccSAndroid Build Coastguard Worker           }
1455*77c1e3ccSAndroid Build Coastguard Worker         }
1456*77c1e3ccSAndroid Build Coastguard Worker       }
1457*77c1e3ccSAndroid Build Coastguard Worker     }
1458*77c1e3ccSAndroid Build Coastguard Worker   }
1459*77c1e3ccSAndroid Build Coastguard Worker 
1460*77c1e3ccSAndroid Build Coastguard Worker  public:
SpeedTest()1461*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTest() {
1462*77c1e3ccSAndroid Build Coastguard Worker     for (int h_f = EIGHTTAP_REGULAR; h_f <= INTERP_FILTERS_ALL; ++h_f) {
1463*77c1e3ccSAndroid Build Coastguard Worker       for (int v_f = EIGHTTAP_REGULAR; v_f <= INTERP_FILTERS_ALL; ++v_f) {
1464*77c1e3ccSAndroid Build Coastguard Worker         if (((h_f == MULTITAP_SHARP2) && (v_f < MULTITAP_SHARP2)) ||
1465*77c1e3ccSAndroid Build Coastguard Worker             ((h_f < MULTITAP_SHARP2) && (v_f == MULTITAP_SHARP2)))
1466*77c1e3ccSAndroid Build Coastguard Worker           continue;
1467*77c1e3ccSAndroid Build Coastguard Worker         TestConvolveSpeed(static_cast<InterpFilter>(h_f),
1468*77c1e3ccSAndroid Build Coastguard Worker                           static_cast<InterpFilter>(v_f), 10000);
1469*77c1e3ccSAndroid Build Coastguard Worker       }
1470*77c1e3ccSAndroid Build Coastguard Worker     }
1471*77c1e3ccSAndroid Build Coastguard Worker   }
1472*77c1e3ccSAndroid Build Coastguard Worker 
1473*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolve(const InterpFilter h_f,const InterpFilter v_f,const int sub_x,const int sub_y)1474*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolve(const InterpFilter h_f, const InterpFilter v_f,
1475*77c1e3ccSAndroid Build Coastguard Worker                     const int sub_x, const int sub_y) {
1476*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1477*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1478*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
1479*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x =
1480*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(h_f, width);
1481*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y =
1482*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(v_f, height);
1483*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input = FirstRandomInput16(GetParam());
1484*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
1485*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
1486*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, bit_depth);
1487*77c1e3ccSAndroid Build Coastguard Worker     av1_highbd_convolve_2d_sr_c(input, width, reference, kOutputStride, width,
1488*77c1e3ccSAndroid Build Coastguard Worker                                 height, filter_params_x, filter_params_y, sub_x,
1489*77c1e3ccSAndroid Build Coastguard Worker                                 sub_y, &conv_params1, bit_depth);
1490*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
1491*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
1492*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, bit_depth);
1493*77c1e3ccSAndroid Build Coastguard Worker     GetParam().TestFunction()(input, width, test, kOutputStride, width, height,
1494*77c1e3ccSAndroid Build Coastguard Worker                               filter_params_x, filter_params_y, sub_x, sub_y,
1495*77c1e3ccSAndroid Build Coastguard Worker                               &conv_params2, bit_depth);
1496*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
1497*77c1e3ccSAndroid Build Coastguard Worker   }
1498*77c1e3ccSAndroid Build Coastguard Worker 
TestConvolveSpeed(const InterpFilter h_f,const InterpFilter v_f,int num_iters)1499*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolveSpeed(const InterpFilter h_f, const InterpFilter v_f,
1500*77c1e3ccSAndroid Build Coastguard Worker                          int num_iters) {
1501*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1502*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1503*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
1504*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x =
1505*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(h_f, width);
1506*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y =
1507*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(v_f, height);
1508*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input = FirstRandomInput16(GetParam());
1509*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
1510*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
1511*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
1512*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
1513*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
1514*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_iters; ++i) {
1515*77c1e3ccSAndroid Build Coastguard Worker       av1_highbd_convolve_2d_sr_c(input, width, reference, kOutputStride, width,
1516*77c1e3ccSAndroid Build Coastguard Worker                                   height, filter_params_x, filter_params_y, 0,
1517*77c1e3ccSAndroid Build Coastguard Worker                                   0, &conv_params1, bit_depth);
1518*77c1e3ccSAndroid Build Coastguard Worker     }
1519*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
1520*77c1e3ccSAndroid Build Coastguard Worker     const double time1 = static_cast<double>(aom_usec_timer_elapsed(&timer));
1521*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
1522*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
1523*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
1524*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
1525*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_iters; ++i) {
1526*77c1e3ccSAndroid Build Coastguard Worker       GetParam().TestFunction()(input, width, test, kOutputStride, width,
1527*77c1e3ccSAndroid Build Coastguard Worker                                 height, filter_params_x, filter_params_y, 0, 0,
1528*77c1e3ccSAndroid Build Coastguard Worker                                 &conv_params2, bit_depth);
1529*77c1e3ccSAndroid Build Coastguard Worker     }
1530*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
1531*77c1e3ccSAndroid Build Coastguard Worker     const double time2 = static_cast<double>(aom_usec_timer_elapsed(&timer));
1532*77c1e3ccSAndroid Build Coastguard Worker     printf("%d - %d %3dx%-3d:%7.2f/%7.2fns (%3.2f)\n", h_f, v_f, width, height,
1533*77c1e3ccSAndroid Build Coastguard Worker            time1, time2, time1 / time2);
1534*77c1e3ccSAndroid Build Coastguard Worker   }
1535*77c1e3ccSAndroid Build Coastguard Worker };
1536*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1Convolve2DHighbdTest,RunTest)1537*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1Convolve2DHighbdTest, RunTest) { RunTest(); }
1538*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1Convolve2DHighbdTest,DISABLED_SpeedTest)1539*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1Convolve2DHighbdTest, DISABLED_SpeedTest) { SpeedTest(); }
1540*77c1e3ccSAndroid Build Coastguard Worker 
1541*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1Convolve2DHighbdTest,
1542*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_2d_sr_c));
1543*77c1e3ccSAndroid Build Coastguard Worker 
1544*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSSE3
1545*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSSE3, AV1Convolve2DHighbdTest,
1546*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_2d_sr_ssse3));
1547*77c1e3ccSAndroid Build Coastguard Worker #endif
1548*77c1e3ccSAndroid Build Coastguard Worker 
1549*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
1550*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, AV1Convolve2DHighbdTest,
1551*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_2d_sr_avx2));
1552*77c1e3ccSAndroid Build Coastguard Worker #endif
1553*77c1e3ccSAndroid Build Coastguard Worker 
1554*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
1555*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1Convolve2DHighbdTest,
1556*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_2d_sr_neon));
1557*77c1e3ccSAndroid Build Coastguard Worker #endif
1558*77c1e3ccSAndroid Build Coastguard Worker 
1559*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SVE2
1560*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SVE2, AV1Convolve2DHighbdTest,
1561*77c1e3ccSAndroid Build Coastguard Worker                          BuildHighbdParams(av1_highbd_convolve_2d_sr_sve2));
1562*77c1e3ccSAndroid Build Coastguard Worker #endif
1563*77c1e3ccSAndroid Build Coastguard Worker 
1564*77c1e3ccSAndroid Build Coastguard Worker //////////////////////////////////////////////////////////////////
1565*77c1e3ccSAndroid Build Coastguard Worker // Single reference convolve-2d IntraBC functions (high bit-depth)
1566*77c1e3ccSAndroid Build Coastguard Worker //////////////////////////////////////////////////////////////////
1567*77c1e3ccSAndroid Build Coastguard Worker 
1568*77c1e3ccSAndroid Build Coastguard Worker class AV1Convolve2DHighbdIntraBCTest
1569*77c1e3ccSAndroid Build Coastguard Worker     : public AV1ConvolveTest<highbd_convolve_2d_func> {
1570*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()1571*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
1572*77c1e3ccSAndroid Build Coastguard Worker     // IntraBC functions only operate for subpel_x_qn = 8 and subpel_y_qn = 8.
1573*77c1e3ccSAndroid Build Coastguard Worker     constexpr int kSubX = 8;
1574*77c1e3ccSAndroid Build Coastguard Worker     constexpr int kSubY = 8;
1575*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1576*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1577*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
1578*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x = &av1_intrabc_filter_params;
1579*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y = &av1_intrabc_filter_params;
1580*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input = FirstRandomInput16(GetParam());
1581*77c1e3ccSAndroid Build Coastguard Worker 
1582*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
1583*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
1584*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, bit_depth);
1585*77c1e3ccSAndroid Build Coastguard Worker     // Use a stride different from width to avoid potential storing errors that
1586*77c1e3ccSAndroid Build Coastguard Worker     // would go undetected. The input buffer is filled using a padding of 12, so
1587*77c1e3ccSAndroid Build Coastguard Worker     // the stride can be anywhere between width and width + 12.
1588*77c1e3ccSAndroid Build Coastguard Worker     av1_highbd_convolve_2d_sr_intrabc_c(input, width + 2, reference,
1589*77c1e3ccSAndroid Build Coastguard Worker                                         kOutputStride, width, height,
1590*77c1e3ccSAndroid Build Coastguard Worker                                         filter_params_x, filter_params_y, kSubX,
1591*77c1e3ccSAndroid Build Coastguard Worker                                         kSubY, &conv_params1, bit_depth);
1592*77c1e3ccSAndroid Build Coastguard Worker 
1593*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
1594*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
1595*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, bit_depth);
1596*77c1e3ccSAndroid Build Coastguard Worker     GetParam().TestFunction()(input, width + 2, test, kOutputStride, width,
1597*77c1e3ccSAndroid Build Coastguard Worker                               height, filter_params_x, filter_params_y, kSubX,
1598*77c1e3ccSAndroid Build Coastguard Worker                               kSubY, &conv_params2, bit_depth);
1599*77c1e3ccSAndroid Build Coastguard Worker 
1600*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
1601*77c1e3ccSAndroid Build Coastguard Worker   }
1602*77c1e3ccSAndroid Build Coastguard Worker 
SpeedTest()1603*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTest() {
1604*77c1e3ccSAndroid Build Coastguard Worker     constexpr int kNumIters = 10000;
1605*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilter h_f = static_cast<InterpFilter>(BILINEAR);
1606*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilter v_f = static_cast<InterpFilter>(BILINEAR);
1607*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1608*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1609*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
1610*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x =
1611*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(h_f, width);
1612*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y =
1613*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(v_f, height);
1614*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input = FirstRandomInput16(GetParam());
1615*77c1e3ccSAndroid Build Coastguard Worker 
1616*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
1617*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params1 =
1618*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
1619*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
1620*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
1621*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < kNumIters; ++i) {
1622*77c1e3ccSAndroid Build Coastguard Worker       av1_highbd_convolve_2d_sr_intrabc_c(
1623*77c1e3ccSAndroid Build Coastguard Worker           input, width, reference, kOutputStride, width, height,
1624*77c1e3ccSAndroid Build Coastguard Worker           filter_params_x, filter_params_y, 0, 0, &conv_params1, bit_depth);
1625*77c1e3ccSAndroid Build Coastguard Worker     }
1626*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
1627*77c1e3ccSAndroid Build Coastguard Worker     const double time1 = static_cast<double>(aom_usec_timer_elapsed(&timer));
1628*77c1e3ccSAndroid Build Coastguard Worker 
1629*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
1630*77c1e3ccSAndroid Build Coastguard Worker     highbd_convolve_2d_func test_func = GetParam().TestFunction();
1631*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params2 =
1632*77c1e3ccSAndroid Build Coastguard Worker         get_conv_params_no_round(0, 0, nullptr, 0, 0, 8);
1633*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
1634*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < kNumIters; ++i) {
1635*77c1e3ccSAndroid Build Coastguard Worker       test_func(input, width, test, kOutputStride, width, height,
1636*77c1e3ccSAndroid Build Coastguard Worker                 filter_params_x, filter_params_y, 0, 0, &conv_params2,
1637*77c1e3ccSAndroid Build Coastguard Worker                 bit_depth);
1638*77c1e3ccSAndroid Build Coastguard Worker     }
1639*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
1640*77c1e3ccSAndroid Build Coastguard Worker     const double time2 = static_cast<double>(aom_usec_timer_elapsed(&timer));
1641*77c1e3ccSAndroid Build Coastguard Worker 
1642*77c1e3ccSAndroid Build Coastguard Worker     printf("%d - %d %3dx%-3d:%7.2f/%7.2fns (%3.2f)\n", h_f, v_f, width, height,
1643*77c1e3ccSAndroid Build Coastguard Worker            time1, time2, time1 / time2);
1644*77c1e3ccSAndroid Build Coastguard Worker   }
1645*77c1e3ccSAndroid Build Coastguard Worker };
1646*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1Convolve2DHighbdIntraBCTest,RunTest)1647*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1Convolve2DHighbdIntraBCTest, RunTest) { RunTest(); }
1648*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1Convolve2DHighbdIntraBCTest,DISABLED_SpeedTest)1649*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1Convolve2DHighbdIntraBCTest, DISABLED_SpeedTest) { SpeedTest(); }
1650*77c1e3ccSAndroid Build Coastguard Worker 
1651*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
1652*77c1e3ccSAndroid Build Coastguard Worker     C, AV1Convolve2DHighbdIntraBCTest,
1653*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdParams(av1_highbd_convolve_2d_sr_intrabc_c));
1654*77c1e3ccSAndroid Build Coastguard Worker 
1655*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
1656*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
1657*77c1e3ccSAndroid Build Coastguard Worker     NEON, AV1Convolve2DHighbdIntraBCTest,
1658*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdParams(av1_highbd_convolve_2d_sr_intrabc_neon));
1659*77c1e3ccSAndroid Build Coastguard Worker #endif
1660*77c1e3ccSAndroid Build Coastguard Worker 
1661*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
1662*77c1e3ccSAndroid Build Coastguard Worker 
1663*77c1e3ccSAndroid Build Coastguard Worker //////////////////////////
1664*77c1e3ccSAndroid Build Coastguard Worker // Compound Convolve Tests
1665*77c1e3ccSAndroid Build Coastguard Worker //////////////////////////
1666*77c1e3ccSAndroid Build Coastguard Worker 
1667*77c1e3ccSAndroid Build Coastguard Worker // The compound functions do not work for chroma block sizes. Provide
1668*77c1e3ccSAndroid Build Coastguard Worker // a function to generate test parameters for just luma block sizes.
1669*77c1e3ccSAndroid Build Coastguard Worker template <typename T>
GetLumaTestParams(std::initializer_list<int> bit_depths,T test_func)1670*77c1e3ccSAndroid Build Coastguard Worker std::vector<TestParam<T>> GetLumaTestParams(
1671*77c1e3ccSAndroid Build Coastguard Worker     std::initializer_list<int> bit_depths, T test_func) {
1672*77c1e3ccSAndroid Build Coastguard Worker   std::set<BlockSize> sizes;
1673*77c1e3ccSAndroid Build Coastguard Worker   for (int b = BLOCK_4X4; b < BLOCK_SIZES_ALL; ++b) {
1674*77c1e3ccSAndroid Build Coastguard Worker     const int w = block_size_wide[b];
1675*77c1e3ccSAndroid Build Coastguard Worker     const int h = block_size_high[b];
1676*77c1e3ccSAndroid Build Coastguard Worker     sizes.insert(BlockSize(w, h));
1677*77c1e3ccSAndroid Build Coastguard Worker   }
1678*77c1e3ccSAndroid Build Coastguard Worker   std::vector<TestParam<T>> result;
1679*77c1e3ccSAndroid Build Coastguard Worker   for (int bit_depth : bit_depths) {
1680*77c1e3ccSAndroid Build Coastguard Worker     for (const auto &block : sizes) {
1681*77c1e3ccSAndroid Build Coastguard Worker       result.push_back(TestParam<T>(block, bit_depth, test_func));
1682*77c1e3ccSAndroid Build Coastguard Worker     }
1683*77c1e3ccSAndroid Build Coastguard Worker   }
1684*77c1e3ccSAndroid Build Coastguard Worker   return result;
1685*77c1e3ccSAndroid Build Coastguard Worker }
1686*77c1e3ccSAndroid Build Coastguard Worker 
1687*77c1e3ccSAndroid Build Coastguard Worker template <typename T>
GetLowbdLumaTestParams(T test_func)1688*77c1e3ccSAndroid Build Coastguard Worker std::vector<TestParam<T>> GetLowbdLumaTestParams(T test_func) {
1689*77c1e3ccSAndroid Build Coastguard Worker   return GetLumaTestParams({ 8 }, test_func);
1690*77c1e3ccSAndroid Build Coastguard Worker }
1691*77c1e3ccSAndroid Build Coastguard Worker 
1692*77c1e3ccSAndroid Build Coastguard Worker template <typename T>
BuildLowbdLumaParams(T test_func)1693*77c1e3ccSAndroid Build Coastguard Worker ::testing::internal::ParamGenerator<TestParam<T>> BuildLowbdLumaParams(
1694*77c1e3ccSAndroid Build Coastguard Worker     T test_func) {
1695*77c1e3ccSAndroid Build Coastguard Worker   return ::testing::ValuesIn(GetLowbdLumaTestParams(test_func));
1696*77c1e3ccSAndroid Build Coastguard Worker }
1697*77c1e3ccSAndroid Build Coastguard Worker 
TEST_F(AV1ConvolveParametersTest,GetLowbdLumaTestParams)1698*77c1e3ccSAndroid Build Coastguard Worker TEST_F(AV1ConvolveParametersTest, GetLowbdLumaTestParams) {
1699*77c1e3ccSAndroid Build Coastguard Worker   auto v = GetLowbdLumaTestParams(av1_dist_wtd_convolve_x_c);
1700*77c1e3ccSAndroid Build Coastguard Worker   ASSERT_EQ(22U, v.size());
1701*77c1e3ccSAndroid Build Coastguard Worker   for (const auto &e : v) {
1702*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_EQ(8, e.BitDepth());
1703*77c1e3ccSAndroid Build Coastguard Worker     bool same_fn = av1_dist_wtd_convolve_x_c == e.TestFunction();
1704*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_TRUE(same_fn);
1705*77c1e3ccSAndroid Build Coastguard Worker   }
1706*77c1e3ccSAndroid Build Coastguard Worker }
1707*77c1e3ccSAndroid Build Coastguard Worker 
1708*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
1709*77c1e3ccSAndroid Build Coastguard Worker template <typename T>
GetHighbdLumaTestParams(T test_func)1710*77c1e3ccSAndroid Build Coastguard Worker std::vector<TestParam<T>> GetHighbdLumaTestParams(T test_func) {
1711*77c1e3ccSAndroid Build Coastguard Worker   return GetLumaTestParams({ 10, 12 }, test_func);
1712*77c1e3ccSAndroid Build Coastguard Worker }
1713*77c1e3ccSAndroid Build Coastguard Worker 
TEST_F(AV1ConvolveParametersTest,GetHighbdLumaTestParams)1714*77c1e3ccSAndroid Build Coastguard Worker TEST_F(AV1ConvolveParametersTest, GetHighbdLumaTestParams) {
1715*77c1e3ccSAndroid Build Coastguard Worker   auto v = GetHighbdLumaTestParams(av1_highbd_dist_wtd_convolve_x_c);
1716*77c1e3ccSAndroid Build Coastguard Worker   ASSERT_EQ(44U, v.size());
1717*77c1e3ccSAndroid Build Coastguard Worker   int num_10 = 0;
1718*77c1e3ccSAndroid Build Coastguard Worker   int num_12 = 0;
1719*77c1e3ccSAndroid Build Coastguard Worker   for (const auto &e : v) {
1720*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_TRUE(10 == e.BitDepth() || 12 == e.BitDepth());
1721*77c1e3ccSAndroid Build Coastguard Worker     bool same_fn = av1_highbd_dist_wtd_convolve_x_c == e.TestFunction();
1722*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_TRUE(same_fn);
1723*77c1e3ccSAndroid Build Coastguard Worker     if (e.BitDepth() == 10) {
1724*77c1e3ccSAndroid Build Coastguard Worker       ++num_10;
1725*77c1e3ccSAndroid Build Coastguard Worker     } else {
1726*77c1e3ccSAndroid Build Coastguard Worker       ++num_12;
1727*77c1e3ccSAndroid Build Coastguard Worker     }
1728*77c1e3ccSAndroid Build Coastguard Worker   }
1729*77c1e3ccSAndroid Build Coastguard Worker   ASSERT_EQ(num_10, num_12);
1730*77c1e3ccSAndroid Build Coastguard Worker }
1731*77c1e3ccSAndroid Build Coastguard Worker 
1732*77c1e3ccSAndroid Build Coastguard Worker template <typename T>
BuildHighbdLumaParams(T test_func)1733*77c1e3ccSAndroid Build Coastguard Worker ::testing::internal::ParamGenerator<TestParam<T>> BuildHighbdLumaParams(
1734*77c1e3ccSAndroid Build Coastguard Worker     T test_func) {
1735*77c1e3ccSAndroid Build Coastguard Worker   return ::testing::ValuesIn(GetHighbdLumaTestParams(test_func));
1736*77c1e3ccSAndroid Build Coastguard Worker }
1737*77c1e3ccSAndroid Build Coastguard Worker 
1738*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
1739*77c1e3ccSAndroid Build Coastguard Worker 
1740*77c1e3ccSAndroid Build Coastguard Worker // Compound cases also need to test different frame offsets and weightings.
1741*77c1e3ccSAndroid Build Coastguard Worker class CompoundParam {
1742*77c1e3ccSAndroid Build Coastguard Worker  public:
CompoundParam(bool use_dist_wtd_comp_avg,int fwd_offset,int bck_offset)1743*77c1e3ccSAndroid Build Coastguard Worker   CompoundParam(bool use_dist_wtd_comp_avg, int fwd_offset, int bck_offset)
1744*77c1e3ccSAndroid Build Coastguard Worker       : use_dist_wtd_comp_avg_(use_dist_wtd_comp_avg), fwd_offset_(fwd_offset),
1745*77c1e3ccSAndroid Build Coastguard Worker         bck_offset_(bck_offset) {}
1746*77c1e3ccSAndroid Build Coastguard Worker 
UseDistWtdCompAvg() const1747*77c1e3ccSAndroid Build Coastguard Worker   bool UseDistWtdCompAvg() const { return use_dist_wtd_comp_avg_; }
FwdOffset() const1748*77c1e3ccSAndroid Build Coastguard Worker   int FwdOffset() const { return fwd_offset_; }
BckOffset() const1749*77c1e3ccSAndroid Build Coastguard Worker   int BckOffset() const { return bck_offset_; }
1750*77c1e3ccSAndroid Build Coastguard Worker 
1751*77c1e3ccSAndroid Build Coastguard Worker  private:
1752*77c1e3ccSAndroid Build Coastguard Worker   bool use_dist_wtd_comp_avg_;
1753*77c1e3ccSAndroid Build Coastguard Worker   int fwd_offset_;
1754*77c1e3ccSAndroid Build Coastguard Worker   int bck_offset_;
1755*77c1e3ccSAndroid Build Coastguard Worker };
1756*77c1e3ccSAndroid Build Coastguard Worker 
GetCompoundParams()1757*77c1e3ccSAndroid Build Coastguard Worker std::vector<CompoundParam> GetCompoundParams() {
1758*77c1e3ccSAndroid Build Coastguard Worker   std::vector<CompoundParam> result;
1759*77c1e3ccSAndroid Build Coastguard Worker   result.push_back(CompoundParam(false, 0, 0));
1760*77c1e3ccSAndroid Build Coastguard Worker   for (int k = 0; k < 2; ++k) {
1761*77c1e3ccSAndroid Build Coastguard Worker     for (int l = 0; l < 4; ++l) {
1762*77c1e3ccSAndroid Build Coastguard Worker       result.push_back(CompoundParam(true, quant_dist_lookup_table[l][k],
1763*77c1e3ccSAndroid Build Coastguard Worker                                      quant_dist_lookup_table[l][1 - k]));
1764*77c1e3ccSAndroid Build Coastguard Worker     }
1765*77c1e3ccSAndroid Build Coastguard Worker   }
1766*77c1e3ccSAndroid Build Coastguard Worker   return result;
1767*77c1e3ccSAndroid Build Coastguard Worker }
1768*77c1e3ccSAndroid Build Coastguard Worker 
TEST_F(AV1ConvolveParametersTest,GetCompoundParams)1769*77c1e3ccSAndroid Build Coastguard Worker TEST_F(AV1ConvolveParametersTest, GetCompoundParams) {
1770*77c1e3ccSAndroid Build Coastguard Worker   auto v = GetCompoundParams();
1771*77c1e3ccSAndroid Build Coastguard Worker   ASSERT_EQ(9U, v.size());
1772*77c1e3ccSAndroid Build Coastguard Worker   ASSERT_FALSE(v[0].UseDistWtdCompAvg());
1773*77c1e3ccSAndroid Build Coastguard Worker   for (size_t i = 1; i < v.size(); ++i) {
1774*77c1e3ccSAndroid Build Coastguard Worker     ASSERT_TRUE(v[i].UseDistWtdCompAvg());
1775*77c1e3ccSAndroid Build Coastguard Worker   }
1776*77c1e3ccSAndroid Build Coastguard Worker }
1777*77c1e3ccSAndroid Build Coastguard Worker 
1778*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////
1779*77c1e3ccSAndroid Build Coastguard Worker // Compound convolve-x functions (low bit-depth)
1780*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////
1781*77c1e3ccSAndroid Build Coastguard Worker 
GetConvolveParams(int do_average,CONV_BUF_TYPE * conv_buf,int width,int bit_depth,const CompoundParam & compound)1782*77c1e3ccSAndroid Build Coastguard Worker ConvolveParams GetConvolveParams(int do_average, CONV_BUF_TYPE *conv_buf,
1783*77c1e3ccSAndroid Build Coastguard Worker                                  int width, int bit_depth,
1784*77c1e3ccSAndroid Build Coastguard Worker                                  const CompoundParam &compound) {
1785*77c1e3ccSAndroid Build Coastguard Worker   ConvolveParams conv_params =
1786*77c1e3ccSAndroid Build Coastguard Worker       get_conv_params_no_round(do_average, 0, conv_buf, width, 1, bit_depth);
1787*77c1e3ccSAndroid Build Coastguard Worker   conv_params.use_dist_wtd_comp_avg = compound.UseDistWtdCompAvg();
1788*77c1e3ccSAndroid Build Coastguard Worker   conv_params.fwd_offset = compound.FwdOffset();
1789*77c1e3ccSAndroid Build Coastguard Worker   conv_params.bck_offset = compound.BckOffset();
1790*77c1e3ccSAndroid Build Coastguard Worker   return conv_params;
1791*77c1e3ccSAndroid Build Coastguard Worker }
1792*77c1e3ccSAndroid Build Coastguard Worker 
1793*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveXCompoundTest : public AV1ConvolveTest<convolve_x_func> {
1794*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()1795*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
1796*77c1e3ccSAndroid Build Coastguard Worker     auto compound_params = GetCompoundParams();
1797*77c1e3ccSAndroid Build Coastguard Worker     // Do not test the no-op filter.
1798*77c1e3ccSAndroid Build Coastguard Worker     for (int sub_pix = 1; sub_pix < 16; ++sub_pix) {
1799*77c1e3ccSAndroid Build Coastguard Worker       for (int f = EIGHTTAP_REGULAR; f < INTERP_FILTERS_ALL; ++f) {
1800*77c1e3ccSAndroid Build Coastguard Worker         for (const auto &c : compound_params) {
1801*77c1e3ccSAndroid Build Coastguard Worker           TestConvolve(sub_pix, static_cast<InterpFilter>(f), c);
1802*77c1e3ccSAndroid Build Coastguard Worker         }
1803*77c1e3ccSAndroid Build Coastguard Worker       }
1804*77c1e3ccSAndroid Build Coastguard Worker     }
1805*77c1e3ccSAndroid Build Coastguard Worker   }
1806*77c1e3ccSAndroid Build Coastguard Worker 
1807*77c1e3ccSAndroid Build Coastguard Worker  protected:
FilterParams(InterpFilter f,const BlockSize & block) const1808*77c1e3ccSAndroid Build Coastguard Worker   virtual const InterpFilterParams *FilterParams(InterpFilter f,
1809*77c1e3ccSAndroid Build Coastguard Worker                                                  const BlockSize &block) const {
1810*77c1e3ccSAndroid Build Coastguard Worker     return av1_get_interp_filter_params_with_block_size(f, block.Width());
1811*77c1e3ccSAndroid Build Coastguard Worker   }
1812*77c1e3ccSAndroid Build Coastguard Worker 
ReferenceFunc() const1813*77c1e3ccSAndroid Build Coastguard Worker   virtual convolve_x_func ReferenceFunc() const {
1814*77c1e3ccSAndroid Build Coastguard Worker     return av1_dist_wtd_convolve_x_c;
1815*77c1e3ccSAndroid Build Coastguard Worker   }
1816*77c1e3ccSAndroid Build Coastguard Worker 
1817*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolve(const int sub_pix,const InterpFilter filter,const CompoundParam & compound)1818*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolve(const int sub_pix, const InterpFilter filter,
1819*77c1e3ccSAndroid Build Coastguard Worker                     const CompoundParam &compound) {
1820*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1821*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1822*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input1 = FirstRandomInput8(GetParam());
1823*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input2 = SecondRandomInput8(GetParam());
1824*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
1825*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, CONV_BUF_TYPE, reference_conv_buf[MAX_SB_SQUARE]);
1826*77c1e3ccSAndroid Build Coastguard Worker     Convolve(ReferenceFunc(), input1, input2, reference, reference_conv_buf,
1827*77c1e3ccSAndroid Build Coastguard Worker              compound, sub_pix, filter);
1828*77c1e3ccSAndroid Build Coastguard Worker 
1829*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
1830*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, CONV_BUF_TYPE, test_conv_buf[MAX_SB_SQUARE]);
1831*77c1e3ccSAndroid Build Coastguard Worker     Convolve(GetParam().TestFunction(), input1, input2, test, test_conv_buf,
1832*77c1e3ccSAndroid Build Coastguard Worker              compound, sub_pix, filter);
1833*77c1e3ccSAndroid Build Coastguard Worker 
1834*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference_conv_buf, test_conv_buf, width, height);
1835*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
1836*77c1e3ccSAndroid Build Coastguard Worker   }
1837*77c1e3ccSAndroid Build Coastguard Worker 
1838*77c1e3ccSAndroid Build Coastguard Worker  private:
Convolve(convolve_x_func test_func,const uint8_t * src1,const uint8_t * src2,uint8_t * dst,CONV_BUF_TYPE * conv_buf,const CompoundParam & compound,const int sub_pix,const InterpFilter filter)1839*77c1e3ccSAndroid Build Coastguard Worker   void Convolve(convolve_x_func test_func, const uint8_t *src1,
1840*77c1e3ccSAndroid Build Coastguard Worker                 const uint8_t *src2, uint8_t *dst, CONV_BUF_TYPE *conv_buf,
1841*77c1e3ccSAndroid Build Coastguard Worker                 const CompoundParam &compound, const int sub_pix,
1842*77c1e3ccSAndroid Build Coastguard Worker                 const InterpFilter filter) {
1843*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1844*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1845*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params =
1846*77c1e3ccSAndroid Build Coastguard Worker         FilterParams(filter, GetParam().Block());
1847*77c1e3ccSAndroid Build Coastguard Worker 
1848*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params =
1849*77c1e3ccSAndroid Build Coastguard Worker         GetConvolveParams(0, conv_buf, kOutputStride, 8, compound);
1850*77c1e3ccSAndroid Build Coastguard Worker     test_func(src1, width, dst, kOutputStride, width, height, filter_params,
1851*77c1e3ccSAndroid Build Coastguard Worker               sub_pix, &conv_params);
1852*77c1e3ccSAndroid Build Coastguard Worker 
1853*77c1e3ccSAndroid Build Coastguard Worker     conv_params = GetConvolveParams(1, conv_buf, kOutputStride, 8, compound);
1854*77c1e3ccSAndroid Build Coastguard Worker     test_func(src2, width, dst, kOutputStride, width, height, filter_params,
1855*77c1e3ccSAndroid Build Coastguard Worker               sub_pix, &conv_params);
1856*77c1e3ccSAndroid Build Coastguard Worker   }
1857*77c1e3ccSAndroid Build Coastguard Worker };
1858*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveXCompoundTest,RunTest)1859*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveXCompoundTest, RunTest) { RunTest(); }
1860*77c1e3ccSAndroid Build Coastguard Worker 
1861*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1ConvolveXCompoundTest,
1862*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdLumaParams(av1_dist_wtd_convolve_x_c));
1863*77c1e3ccSAndroid Build Coastguard Worker 
1864*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE2
1865*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE2, AV1ConvolveXCompoundTest,
1866*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdLumaParams(av1_dist_wtd_convolve_x_sse2));
1867*77c1e3ccSAndroid Build Coastguard Worker #endif
1868*77c1e3ccSAndroid Build Coastguard Worker 
1869*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
1870*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, AV1ConvolveXCompoundTest,
1871*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdLumaParams(av1_dist_wtd_convolve_x_avx2));
1872*77c1e3ccSAndroid Build Coastguard Worker #endif
1873*77c1e3ccSAndroid Build Coastguard Worker 
1874*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
1875*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1ConvolveXCompoundTest,
1876*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdLumaParams(av1_dist_wtd_convolve_x_neon));
1877*77c1e3ccSAndroid Build Coastguard Worker #endif
1878*77c1e3ccSAndroid Build Coastguard Worker 
1879*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON_DOTPROD
1880*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
1881*77c1e3ccSAndroid Build Coastguard Worker     NEON_DOTPROD, AV1ConvolveXCompoundTest,
1882*77c1e3ccSAndroid Build Coastguard Worker     BuildLowbdLumaParams(av1_dist_wtd_convolve_x_neon_dotprod));
1883*77c1e3ccSAndroid Build Coastguard Worker #endif
1884*77c1e3ccSAndroid Build Coastguard Worker 
1885*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON_I8MM
1886*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
1887*77c1e3ccSAndroid Build Coastguard Worker     NEON_I8MM, AV1ConvolveXCompoundTest,
1888*77c1e3ccSAndroid Build Coastguard Worker     BuildLowbdLumaParams(av1_dist_wtd_convolve_x_neon_i8mm));
1889*77c1e3ccSAndroid Build Coastguard Worker #endif
1890*77c1e3ccSAndroid Build Coastguard Worker 
1891*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
1892*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////
1893*77c1e3ccSAndroid Build Coastguard Worker // Compound convolve-x functions (high bit-depth)
1894*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////
1895*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveXHighbdCompoundTest
1896*77c1e3ccSAndroid Build Coastguard Worker     : public AV1ConvolveTest<highbd_convolve_x_func> {
1897*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()1898*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
1899*77c1e3ccSAndroid Build Coastguard Worker     auto compound_params = GetCompoundParams();
1900*77c1e3ccSAndroid Build Coastguard Worker     // Do not test the no-op filter.
1901*77c1e3ccSAndroid Build Coastguard Worker     for (int sub_pix = 1; sub_pix < 16; ++sub_pix) {
1902*77c1e3ccSAndroid Build Coastguard Worker       for (int f = EIGHTTAP_REGULAR; f < INTERP_FILTERS_ALL; ++f) {
1903*77c1e3ccSAndroid Build Coastguard Worker         for (const auto &c : compound_params) {
1904*77c1e3ccSAndroid Build Coastguard Worker           TestConvolve(sub_pix, static_cast<InterpFilter>(f), c);
1905*77c1e3ccSAndroid Build Coastguard Worker         }
1906*77c1e3ccSAndroid Build Coastguard Worker       }
1907*77c1e3ccSAndroid Build Coastguard Worker     }
1908*77c1e3ccSAndroid Build Coastguard Worker   }
1909*77c1e3ccSAndroid Build Coastguard Worker 
1910*77c1e3ccSAndroid Build Coastguard Worker  protected:
FilterParams(InterpFilter f,const BlockSize & block) const1911*77c1e3ccSAndroid Build Coastguard Worker   virtual const InterpFilterParams *FilterParams(InterpFilter f,
1912*77c1e3ccSAndroid Build Coastguard Worker                                                  const BlockSize &block) const {
1913*77c1e3ccSAndroid Build Coastguard Worker     return av1_get_interp_filter_params_with_block_size(f, block.Width());
1914*77c1e3ccSAndroid Build Coastguard Worker   }
1915*77c1e3ccSAndroid Build Coastguard Worker 
ReferenceFunc() const1916*77c1e3ccSAndroid Build Coastguard Worker   virtual highbd_convolve_x_func ReferenceFunc() const {
1917*77c1e3ccSAndroid Build Coastguard Worker     return av1_highbd_dist_wtd_convolve_x_c;
1918*77c1e3ccSAndroid Build Coastguard Worker   }
1919*77c1e3ccSAndroid Build Coastguard Worker 
1920*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolve(const int sub_pix,const InterpFilter filter,const CompoundParam & compound)1921*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolve(const int sub_pix, const InterpFilter filter,
1922*77c1e3ccSAndroid Build Coastguard Worker                     const CompoundParam &compound) {
1923*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1924*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1925*77c1e3ccSAndroid Build Coastguard Worker 
1926*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input1 = FirstRandomInput16(GetParam());
1927*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input2 = SecondRandomInput16(GetParam());
1928*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
1929*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, CONV_BUF_TYPE, reference_conv_buf[MAX_SB_SQUARE]);
1930*77c1e3ccSAndroid Build Coastguard Worker     Convolve(ReferenceFunc(), input1, input2, reference, reference_conv_buf,
1931*77c1e3ccSAndroid Build Coastguard Worker              compound, sub_pix, filter);
1932*77c1e3ccSAndroid Build Coastguard Worker 
1933*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
1934*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, CONV_BUF_TYPE, test_conv_buf[MAX_SB_SQUARE]);
1935*77c1e3ccSAndroid Build Coastguard Worker     Convolve(GetParam().TestFunction(), input1, input2, test, test_conv_buf,
1936*77c1e3ccSAndroid Build Coastguard Worker              compound, sub_pix, filter);
1937*77c1e3ccSAndroid Build Coastguard Worker 
1938*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference_conv_buf, test_conv_buf, width, height);
1939*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
1940*77c1e3ccSAndroid Build Coastguard Worker   }
1941*77c1e3ccSAndroid Build Coastguard Worker 
Convolve(highbd_convolve_x_func test_func,const uint16_t * src1,const uint16_t * src2,uint16_t * dst,CONV_BUF_TYPE * conv_buf,const CompoundParam & compound,const int sub_pix,const InterpFilter filter)1942*77c1e3ccSAndroid Build Coastguard Worker   void Convolve(highbd_convolve_x_func test_func, const uint16_t *src1,
1943*77c1e3ccSAndroid Build Coastguard Worker                 const uint16_t *src2, uint16_t *dst, CONV_BUF_TYPE *conv_buf,
1944*77c1e3ccSAndroid Build Coastguard Worker                 const CompoundParam &compound, const int sub_pix,
1945*77c1e3ccSAndroid Build Coastguard Worker                 const InterpFilter filter) {
1946*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
1947*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
1948*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
1949*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params =
1950*77c1e3ccSAndroid Build Coastguard Worker         FilterParams(filter, GetParam().Block());
1951*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params =
1952*77c1e3ccSAndroid Build Coastguard Worker         GetConvolveParams(0, conv_buf, kOutputStride, bit_depth, compound);
1953*77c1e3ccSAndroid Build Coastguard Worker     test_func(src1, width, dst, kOutputStride, width, height, filter_params,
1954*77c1e3ccSAndroid Build Coastguard Worker               sub_pix, &conv_params, bit_depth);
1955*77c1e3ccSAndroid Build Coastguard Worker     conv_params =
1956*77c1e3ccSAndroid Build Coastguard Worker         GetConvolveParams(1, conv_buf, kOutputStride, bit_depth, compound);
1957*77c1e3ccSAndroid Build Coastguard Worker     test_func(src2, width, dst, kOutputStride, width, height, filter_params,
1958*77c1e3ccSAndroid Build Coastguard Worker               sub_pix, &conv_params, bit_depth);
1959*77c1e3ccSAndroid Build Coastguard Worker   }
1960*77c1e3ccSAndroid Build Coastguard Worker };
1961*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveXHighbdCompoundTest,RunTest)1962*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveXHighbdCompoundTest, RunTest) { RunTest(); }
1963*77c1e3ccSAndroid Build Coastguard Worker 
1964*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
1965*77c1e3ccSAndroid Build Coastguard Worker     C, AV1ConvolveXHighbdCompoundTest,
1966*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_x_c));
1967*77c1e3ccSAndroid Build Coastguard Worker 
1968*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE4_1
1969*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
1970*77c1e3ccSAndroid Build Coastguard Worker     SSE4_1, AV1ConvolveXHighbdCompoundTest,
1971*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_x_sse4_1));
1972*77c1e3ccSAndroid Build Coastguard Worker #endif
1973*77c1e3ccSAndroid Build Coastguard Worker 
1974*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
1975*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
1976*77c1e3ccSAndroid Build Coastguard Worker     AVX2, AV1ConvolveXHighbdCompoundTest,
1977*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_x_avx2));
1978*77c1e3ccSAndroid Build Coastguard Worker #endif
1979*77c1e3ccSAndroid Build Coastguard Worker 
1980*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
1981*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
1982*77c1e3ccSAndroid Build Coastguard Worker     NEON, AV1ConvolveXHighbdCompoundTest,
1983*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_x_neon));
1984*77c1e3ccSAndroid Build Coastguard Worker #endif
1985*77c1e3ccSAndroid Build Coastguard Worker 
1986*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SVE2
1987*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
1988*77c1e3ccSAndroid Build Coastguard Worker     SVE2, AV1ConvolveXHighbdCompoundTest,
1989*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_x_sve2));
1990*77c1e3ccSAndroid Build Coastguard Worker #endif
1991*77c1e3ccSAndroid Build Coastguard Worker 
1992*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
1993*77c1e3ccSAndroid Build Coastguard Worker 
1994*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////
1995*77c1e3ccSAndroid Build Coastguard Worker // Compound convolve-y functions (low bit-depth)
1996*77c1e3ccSAndroid Build Coastguard Worker ////////////////////////////////////////////////
1997*77c1e3ccSAndroid Build Coastguard Worker 
1998*77c1e3ccSAndroid Build Coastguard Worker // Note that the X and Y convolve functions have the same type signature and
1999*77c1e3ccSAndroid Build Coastguard Worker // logic; they only differentiate the filter parameters and reference function.
2000*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveYCompoundTest : public AV1ConvolveXCompoundTest {
2001*77c1e3ccSAndroid Build Coastguard Worker  protected:
FilterParams(InterpFilter f,const BlockSize & block) const2002*77c1e3ccSAndroid Build Coastguard Worker   const InterpFilterParams *FilterParams(
2003*77c1e3ccSAndroid Build Coastguard Worker       InterpFilter f, const BlockSize &block) const override {
2004*77c1e3ccSAndroid Build Coastguard Worker     return av1_get_interp_filter_params_with_block_size(f, block.Height());
2005*77c1e3ccSAndroid Build Coastguard Worker   }
2006*77c1e3ccSAndroid Build Coastguard Worker 
ReferenceFunc() const2007*77c1e3ccSAndroid Build Coastguard Worker   convolve_x_func ReferenceFunc() const override {
2008*77c1e3ccSAndroid Build Coastguard Worker     return av1_dist_wtd_convolve_y_c;
2009*77c1e3ccSAndroid Build Coastguard Worker   }
2010*77c1e3ccSAndroid Build Coastguard Worker };
2011*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveYCompoundTest,RunTest)2012*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveYCompoundTest, RunTest) { RunTest(); }
2013*77c1e3ccSAndroid Build Coastguard Worker 
2014*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1ConvolveYCompoundTest,
2015*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdLumaParams(av1_dist_wtd_convolve_y_c));
2016*77c1e3ccSAndroid Build Coastguard Worker 
2017*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE2
2018*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSE2, AV1ConvolveYCompoundTest,
2019*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdLumaParams(av1_dist_wtd_convolve_y_sse2));
2020*77c1e3ccSAndroid Build Coastguard Worker #endif
2021*77c1e3ccSAndroid Build Coastguard Worker 
2022*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
2023*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, AV1ConvolveYCompoundTest,
2024*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdLumaParams(av1_dist_wtd_convolve_y_avx2));
2025*77c1e3ccSAndroid Build Coastguard Worker #endif
2026*77c1e3ccSAndroid Build Coastguard Worker 
2027*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
2028*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1ConvolveYCompoundTest,
2029*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdLumaParams(av1_dist_wtd_convolve_y_neon));
2030*77c1e3ccSAndroid Build Coastguard Worker #endif
2031*77c1e3ccSAndroid Build Coastguard Worker 
2032*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
2033*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////
2034*77c1e3ccSAndroid Build Coastguard Worker // Compound convolve-y functions (high bit-depth)
2035*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////
2036*77c1e3ccSAndroid Build Coastguard Worker 
2037*77c1e3ccSAndroid Build Coastguard Worker // Again, the X and Y convolve functions have the same type signature and logic.
2038*77c1e3ccSAndroid Build Coastguard Worker class AV1ConvolveYHighbdCompoundTest : public AV1ConvolveXHighbdCompoundTest {
ReferenceFunc() const2039*77c1e3ccSAndroid Build Coastguard Worker   highbd_convolve_x_func ReferenceFunc() const override {
2040*77c1e3ccSAndroid Build Coastguard Worker     return av1_highbd_dist_wtd_convolve_y_c;
2041*77c1e3ccSAndroid Build Coastguard Worker   }
FilterParams(InterpFilter f,const BlockSize & block) const2042*77c1e3ccSAndroid Build Coastguard Worker   const InterpFilterParams *FilterParams(
2043*77c1e3ccSAndroid Build Coastguard Worker       InterpFilter f, const BlockSize &block) const override {
2044*77c1e3ccSAndroid Build Coastguard Worker     return av1_get_interp_filter_params_with_block_size(f, block.Height());
2045*77c1e3ccSAndroid Build Coastguard Worker   }
2046*77c1e3ccSAndroid Build Coastguard Worker };
2047*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1ConvolveYHighbdCompoundTest,RunTest)2048*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1ConvolveYHighbdCompoundTest, RunTest) { RunTest(); }
2049*77c1e3ccSAndroid Build Coastguard Worker 
2050*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2051*77c1e3ccSAndroid Build Coastguard Worker     C, AV1ConvolveYHighbdCompoundTest,
2052*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_y_c));
2053*77c1e3ccSAndroid Build Coastguard Worker 
2054*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE4_1
2055*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2056*77c1e3ccSAndroid Build Coastguard Worker     SSE4_1, AV1ConvolveYHighbdCompoundTest,
2057*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_y_sse4_1));
2058*77c1e3ccSAndroid Build Coastguard Worker #endif
2059*77c1e3ccSAndroid Build Coastguard Worker 
2060*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
2061*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2062*77c1e3ccSAndroid Build Coastguard Worker     AVX2, AV1ConvolveYHighbdCompoundTest,
2063*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_y_avx2));
2064*77c1e3ccSAndroid Build Coastguard Worker #endif
2065*77c1e3ccSAndroid Build Coastguard Worker 
2066*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
2067*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2068*77c1e3ccSAndroid Build Coastguard Worker     NEON, AV1ConvolveYHighbdCompoundTest,
2069*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_y_neon));
2070*77c1e3ccSAndroid Build Coastguard Worker #endif
2071*77c1e3ccSAndroid Build Coastguard Worker 
2072*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SVE2
2073*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2074*77c1e3ccSAndroid Build Coastguard Worker     SVE2, AV1ConvolveYHighbdCompoundTest,
2075*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_y_sve2));
2076*77c1e3ccSAndroid Build Coastguard Worker #endif
2077*77c1e3ccSAndroid Build Coastguard Worker 
2078*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
2079*77c1e3ccSAndroid Build Coastguard Worker 
2080*77c1e3ccSAndroid Build Coastguard Worker //////////////////////////////////////////////////////
2081*77c1e3ccSAndroid Build Coastguard Worker // Compound convolve-2d-copy functions (low bit-depth)
2082*77c1e3ccSAndroid Build Coastguard Worker //////////////////////////////////////////////////////
2083*77c1e3ccSAndroid Build Coastguard Worker typedef void (*compound_conv_2d_copy_func)(const uint8_t *src, int src_stride,
2084*77c1e3ccSAndroid Build Coastguard Worker                                            uint8_t *dst, int dst_stride, int w,
2085*77c1e3ccSAndroid Build Coastguard Worker                                            int h, ConvolveParams *conv_params);
2086*77c1e3ccSAndroid Build Coastguard Worker 
2087*77c1e3ccSAndroid Build Coastguard Worker class AV1Convolve2DCopyCompoundTest
2088*77c1e3ccSAndroid Build Coastguard Worker     : public AV1ConvolveTest<compound_conv_2d_copy_func> {
2089*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()2090*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
2091*77c1e3ccSAndroid Build Coastguard Worker     auto compound_params = GetCompoundParams();
2092*77c1e3ccSAndroid Build Coastguard Worker     for (const auto &compound : compound_params) {
2093*77c1e3ccSAndroid Build Coastguard Worker       TestConvolve(compound);
2094*77c1e3ccSAndroid Build Coastguard Worker     }
2095*77c1e3ccSAndroid Build Coastguard Worker   }
SpeedTest()2096*77c1e3ccSAndroid Build Coastguard Worker   void SpeedTest() {
2097*77c1e3ccSAndroid Build Coastguard Worker     for (const auto &compound : GetCompoundParams()) {
2098*77c1e3ccSAndroid Build Coastguard Worker       TestConvolveSpeed(compound, 100000);
2099*77c1e3ccSAndroid Build Coastguard Worker     }
2100*77c1e3ccSAndroid Build Coastguard Worker   }
2101*77c1e3ccSAndroid Build Coastguard Worker 
2102*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolve(const CompoundParam & compound)2103*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolve(const CompoundParam &compound) {
2104*77c1e3ccSAndroid Build Coastguard Worker     const BlockSize &block = GetParam().Block();
2105*77c1e3ccSAndroid Build Coastguard Worker     const int width = block.Width();
2106*77c1e3ccSAndroid Build Coastguard Worker     const int height = block.Height();
2107*77c1e3ccSAndroid Build Coastguard Worker 
2108*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input1 = FirstRandomInput8(GetParam());
2109*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input2 = SecondRandomInput8(GetParam());
2110*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
2111*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, CONV_BUF_TYPE, reference_conv_buf[MAX_SB_SQUARE]);
2112*77c1e3ccSAndroid Build Coastguard Worker     Convolve(av1_dist_wtd_convolve_2d_copy_c, input1, input2, reference,
2113*77c1e3ccSAndroid Build Coastguard Worker              reference_conv_buf, compound);
2114*77c1e3ccSAndroid Build Coastguard Worker 
2115*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
2116*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, CONV_BUF_TYPE, test_conv_buf[MAX_SB_SQUARE]);
2117*77c1e3ccSAndroid Build Coastguard Worker     Convolve(GetParam().TestFunction(), input1, input2, test, test_conv_buf,
2118*77c1e3ccSAndroid Build Coastguard Worker              compound);
2119*77c1e3ccSAndroid Build Coastguard Worker 
2120*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference_conv_buf, test_conv_buf, width, height);
2121*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
2122*77c1e3ccSAndroid Build Coastguard Worker   }
2123*77c1e3ccSAndroid Build Coastguard Worker 
TestConvolveSpeed(const CompoundParam & compound,const int num_iters)2124*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolveSpeed(const CompoundParam &compound, const int num_iters) {
2125*77c1e3ccSAndroid Build Coastguard Worker     const int width = GetParam().Block().Width();
2126*77c1e3ccSAndroid Build Coastguard Worker     const int height = GetParam().Block().Height();
2127*77c1e3ccSAndroid Build Coastguard Worker 
2128*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *src0 = FirstRandomInput8(GetParam());
2129*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *src1 = SecondRandomInput8(GetParam());
2130*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, dst[MAX_SB_SQUARE]);
2131*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, CONV_BUF_TYPE, conv_buf[MAX_SB_SQUARE]);
2132*77c1e3ccSAndroid Build Coastguard Worker 
2133*77c1e3ccSAndroid Build Coastguard Worker     const auto test_func = GetParam().TestFunction();
2134*77c1e3ccSAndroid Build Coastguard Worker 
2135*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params_0 =
2136*77c1e3ccSAndroid Build Coastguard Worker         GetConvolveParams(0, conv_buf, kOutputStride, 8, compound);
2137*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params_1 =
2138*77c1e3ccSAndroid Build Coastguard Worker         GetConvolveParams(1, conv_buf, kOutputStride, 8, compound);
2139*77c1e3ccSAndroid Build Coastguard Worker 
2140*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer timer;
2141*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
2142*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_iters; ++i) {
2143*77c1e3ccSAndroid Build Coastguard Worker       av1_dist_wtd_convolve_2d_copy_c(src0, width, dst, kOutputStride, width,
2144*77c1e3ccSAndroid Build Coastguard Worker                                       height, &conv_params_0);
2145*77c1e3ccSAndroid Build Coastguard Worker       av1_dist_wtd_convolve_2d_copy_c(src1, width, dst, kOutputStride, width,
2146*77c1e3ccSAndroid Build Coastguard Worker                                       height, &conv_params_1);
2147*77c1e3ccSAndroid Build Coastguard Worker     }
2148*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
2149*77c1e3ccSAndroid Build Coastguard Worker     const double time1 = static_cast<double>(aom_usec_timer_elapsed(&timer));
2150*77c1e3ccSAndroid Build Coastguard Worker 
2151*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_start(&timer);
2152*77c1e3ccSAndroid Build Coastguard Worker     for (int i = 0; i < num_iters; ++i) {
2153*77c1e3ccSAndroid Build Coastguard Worker       test_func(src0, width, dst, kOutputStride, width, height, &conv_params_0);
2154*77c1e3ccSAndroid Build Coastguard Worker       test_func(src1, width, dst, kOutputStride, width, height, &conv_params_1);
2155*77c1e3ccSAndroid Build Coastguard Worker     }
2156*77c1e3ccSAndroid Build Coastguard Worker     aom_usec_timer_mark(&timer);
2157*77c1e3ccSAndroid Build Coastguard Worker     const double time2 = static_cast<double>(aom_usec_timer_elapsed(&timer));
2158*77c1e3ccSAndroid Build Coastguard Worker     printf("Dist Weighted: %d %3dx%-3d:%7.2f/%7.2fns (%3.2f)\n",
2159*77c1e3ccSAndroid Build Coastguard Worker            compound.UseDistWtdCompAvg(), width, height, time1, time2,
2160*77c1e3ccSAndroid Build Coastguard Worker            time1 / time2);
2161*77c1e3ccSAndroid Build Coastguard Worker   }
2162*77c1e3ccSAndroid Build Coastguard Worker 
Convolve(compound_conv_2d_copy_func test_func,const uint8_t * src1,const uint8_t * src2,uint8_t * dst,uint16_t * conv_buf,const CompoundParam & compound)2163*77c1e3ccSAndroid Build Coastguard Worker   void Convolve(compound_conv_2d_copy_func test_func, const uint8_t *src1,
2164*77c1e3ccSAndroid Build Coastguard Worker                 const uint8_t *src2, uint8_t *dst, uint16_t *conv_buf,
2165*77c1e3ccSAndroid Build Coastguard Worker                 const CompoundParam &compound) {
2166*77c1e3ccSAndroid Build Coastguard Worker     const BlockSize &block = GetParam().Block();
2167*77c1e3ccSAndroid Build Coastguard Worker     const int width = block.Width();
2168*77c1e3ccSAndroid Build Coastguard Worker     const int height = block.Height();
2169*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params =
2170*77c1e3ccSAndroid Build Coastguard Worker         GetConvolveParams(0, conv_buf, kOutputStride, 8, compound);
2171*77c1e3ccSAndroid Build Coastguard Worker     test_func(src1, width, dst, kOutputStride, width, height, &conv_params);
2172*77c1e3ccSAndroid Build Coastguard Worker 
2173*77c1e3ccSAndroid Build Coastguard Worker     conv_params = GetConvolveParams(1, conv_buf, kOutputStride, 8, compound);
2174*77c1e3ccSAndroid Build Coastguard Worker     test_func(src2, width, dst, kOutputStride, width, height, &conv_params);
2175*77c1e3ccSAndroid Build Coastguard Worker   }
2176*77c1e3ccSAndroid Build Coastguard Worker };
2177*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1Convolve2DCopyCompoundTest,RunTest)2178*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1Convolve2DCopyCompoundTest, RunTest) { RunTest(); }
TEST_P(AV1Convolve2DCopyCompoundTest,DISABLED_SpeedTest)2179*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1Convolve2DCopyCompoundTest, DISABLED_SpeedTest) { SpeedTest(); }
2180*77c1e3ccSAndroid Build Coastguard Worker 
2181*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1Convolve2DCopyCompoundTest,
2182*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdLumaParams(av1_dist_wtd_convolve_2d_copy_c));
2183*77c1e3ccSAndroid Build Coastguard Worker 
2184*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE2
2185*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2186*77c1e3ccSAndroid Build Coastguard Worker     SSE2, AV1Convolve2DCopyCompoundTest,
2187*77c1e3ccSAndroid Build Coastguard Worker     BuildLowbdLumaParams(av1_dist_wtd_convolve_2d_copy_sse2));
2188*77c1e3ccSAndroid Build Coastguard Worker #endif
2189*77c1e3ccSAndroid Build Coastguard Worker 
2190*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
2191*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2192*77c1e3ccSAndroid Build Coastguard Worker     AVX2, AV1Convolve2DCopyCompoundTest,
2193*77c1e3ccSAndroid Build Coastguard Worker     BuildLowbdLumaParams(av1_dist_wtd_convolve_2d_copy_avx2));
2194*77c1e3ccSAndroid Build Coastguard Worker #endif
2195*77c1e3ccSAndroid Build Coastguard Worker 
2196*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
2197*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2198*77c1e3ccSAndroid Build Coastguard Worker     NEON, AV1Convolve2DCopyCompoundTest,
2199*77c1e3ccSAndroid Build Coastguard Worker     BuildLowbdLumaParams(av1_dist_wtd_convolve_2d_copy_neon));
2200*77c1e3ccSAndroid Build Coastguard Worker #endif
2201*77c1e3ccSAndroid Build Coastguard Worker 
2202*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
2203*77c1e3ccSAndroid Build Coastguard Worker ///////////////////////////////////////////////////////
2204*77c1e3ccSAndroid Build Coastguard Worker // Compound convolve-2d-copy functions (high bit-depth)
2205*77c1e3ccSAndroid Build Coastguard Worker ///////////////////////////////////////////////////////
2206*77c1e3ccSAndroid Build Coastguard Worker typedef void (*highbd_compound_conv_2d_copy_func)(const uint16_t *src,
2207*77c1e3ccSAndroid Build Coastguard Worker                                                   int src_stride, uint16_t *dst,
2208*77c1e3ccSAndroid Build Coastguard Worker                                                   int dst_stride, int w, int h,
2209*77c1e3ccSAndroid Build Coastguard Worker                                                   ConvolveParams *conv_params,
2210*77c1e3ccSAndroid Build Coastguard Worker                                                   int bd);
2211*77c1e3ccSAndroid Build Coastguard Worker 
2212*77c1e3ccSAndroid Build Coastguard Worker class AV1Convolve2DCopyHighbdCompoundTest
2213*77c1e3ccSAndroid Build Coastguard Worker     : public AV1ConvolveTest<highbd_compound_conv_2d_copy_func> {
2214*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()2215*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
2216*77c1e3ccSAndroid Build Coastguard Worker     auto compound_params = GetCompoundParams();
2217*77c1e3ccSAndroid Build Coastguard Worker     for (const auto &compound : compound_params) {
2218*77c1e3ccSAndroid Build Coastguard Worker       TestConvolve(compound);
2219*77c1e3ccSAndroid Build Coastguard Worker     }
2220*77c1e3ccSAndroid Build Coastguard Worker   }
2221*77c1e3ccSAndroid Build Coastguard Worker 
2222*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolve(const CompoundParam & compound)2223*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolve(const CompoundParam &compound) {
2224*77c1e3ccSAndroid Build Coastguard Worker     const BlockSize &block = GetParam().Block();
2225*77c1e3ccSAndroid Build Coastguard Worker     const int width = block.Width();
2226*77c1e3ccSAndroid Build Coastguard Worker     const int height = block.Height();
2227*77c1e3ccSAndroid Build Coastguard Worker 
2228*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input1 = FirstRandomInput16(GetParam());
2229*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input2 = SecondRandomInput16(GetParam());
2230*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
2231*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, CONV_BUF_TYPE, reference_conv_buf[MAX_SB_SQUARE]);
2232*77c1e3ccSAndroid Build Coastguard Worker     Convolve(av1_highbd_dist_wtd_convolve_2d_copy_c, input1, input2, reference,
2233*77c1e3ccSAndroid Build Coastguard Worker              reference_conv_buf, compound);
2234*77c1e3ccSAndroid Build Coastguard Worker 
2235*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
2236*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, CONV_BUF_TYPE, test_conv_buf[MAX_SB_SQUARE]);
2237*77c1e3ccSAndroid Build Coastguard Worker     Convolve(GetParam().TestFunction(), input1, input2, test, test_conv_buf,
2238*77c1e3ccSAndroid Build Coastguard Worker              compound);
2239*77c1e3ccSAndroid Build Coastguard Worker 
2240*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference_conv_buf, test_conv_buf, width, height);
2241*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
2242*77c1e3ccSAndroid Build Coastguard Worker   }
2243*77c1e3ccSAndroid Build Coastguard Worker 
Convolve(highbd_compound_conv_2d_copy_func test_func,const uint16_t * src1,const uint16_t * src2,uint16_t * dst,uint16_t * conv_buf,const CompoundParam & compound)2244*77c1e3ccSAndroid Build Coastguard Worker   void Convolve(highbd_compound_conv_2d_copy_func test_func,
2245*77c1e3ccSAndroid Build Coastguard Worker                 const uint16_t *src1, const uint16_t *src2, uint16_t *dst,
2246*77c1e3ccSAndroid Build Coastguard Worker                 uint16_t *conv_buf, const CompoundParam &compound) {
2247*77c1e3ccSAndroid Build Coastguard Worker     const BlockSize &block = GetParam().Block();
2248*77c1e3ccSAndroid Build Coastguard Worker     const int width = block.Width();
2249*77c1e3ccSAndroid Build Coastguard Worker     const int height = block.Height();
2250*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
2251*77c1e3ccSAndroid Build Coastguard Worker 
2252*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params =
2253*77c1e3ccSAndroid Build Coastguard Worker         GetConvolveParams(0, conv_buf, kOutputStride, bit_depth, compound);
2254*77c1e3ccSAndroid Build Coastguard Worker     test_func(src1, width, dst, kOutputStride, width, height, &conv_params,
2255*77c1e3ccSAndroid Build Coastguard Worker               bit_depth);
2256*77c1e3ccSAndroid Build Coastguard Worker 
2257*77c1e3ccSAndroid Build Coastguard Worker     conv_params =
2258*77c1e3ccSAndroid Build Coastguard Worker         GetConvolveParams(1, conv_buf, kOutputStride, bit_depth, compound);
2259*77c1e3ccSAndroid Build Coastguard Worker     test_func(src2, width, dst, kOutputStride, width, height, &conv_params,
2260*77c1e3ccSAndroid Build Coastguard Worker               bit_depth);
2261*77c1e3ccSAndroid Build Coastguard Worker   }
2262*77c1e3ccSAndroid Build Coastguard Worker };
2263*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1Convolve2DCopyHighbdCompoundTest,RunTest)2264*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1Convolve2DCopyHighbdCompoundTest, RunTest) { RunTest(); }
2265*77c1e3ccSAndroid Build Coastguard Worker 
2266*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2267*77c1e3ccSAndroid Build Coastguard Worker     C, AV1Convolve2DCopyHighbdCompoundTest,
2268*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_2d_copy_c));
2269*77c1e3ccSAndroid Build Coastguard Worker 
2270*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE4_1
2271*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2272*77c1e3ccSAndroid Build Coastguard Worker     SSE4_1, AV1Convolve2DCopyHighbdCompoundTest,
2273*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_2d_copy_sse4_1));
2274*77c1e3ccSAndroid Build Coastguard Worker #endif
2275*77c1e3ccSAndroid Build Coastguard Worker 
2276*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
2277*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2278*77c1e3ccSAndroid Build Coastguard Worker     AVX2, AV1Convolve2DCopyHighbdCompoundTest,
2279*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_2d_copy_avx2));
2280*77c1e3ccSAndroid Build Coastguard Worker #endif
2281*77c1e3ccSAndroid Build Coastguard Worker 
2282*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
2283*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2284*77c1e3ccSAndroid Build Coastguard Worker     NEON, AV1Convolve2DCopyHighbdCompoundTest,
2285*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_2d_copy_neon));
2286*77c1e3ccSAndroid Build Coastguard Worker #endif
2287*77c1e3ccSAndroid Build Coastguard Worker 
2288*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
2289*77c1e3ccSAndroid Build Coastguard Worker 
2290*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////
2291*77c1e3ccSAndroid Build Coastguard Worker // Compound convolve-2d functions (low bit-depth)
2292*77c1e3ccSAndroid Build Coastguard Worker /////////////////////////////////////////////////
2293*77c1e3ccSAndroid Build Coastguard Worker 
2294*77c1e3ccSAndroid Build Coastguard Worker class AV1Convolve2DCompoundTest : public AV1ConvolveTest<convolve_2d_func> {
2295*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()2296*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
2297*77c1e3ccSAndroid Build Coastguard Worker     auto compound_params = GetCompoundParams();
2298*77c1e3ccSAndroid Build Coastguard Worker     for (int h_f = EIGHTTAP_REGULAR; h_f < INTERP_FILTERS_ALL; ++h_f) {
2299*77c1e3ccSAndroid Build Coastguard Worker       for (int v_f = EIGHTTAP_REGULAR; v_f < INTERP_FILTERS_ALL; ++v_f) {
2300*77c1e3ccSAndroid Build Coastguard Worker         // Do not test the no-op filter.
2301*77c1e3ccSAndroid Build Coastguard Worker         for (int sub_x = 1; sub_x < 16; ++sub_x) {
2302*77c1e3ccSAndroid Build Coastguard Worker           for (int sub_y = 1; sub_y < 16; ++sub_y) {
2303*77c1e3ccSAndroid Build Coastguard Worker             for (const auto &compound : compound_params) {
2304*77c1e3ccSAndroid Build Coastguard Worker               TestConvolve(static_cast<InterpFilter>(h_f),
2305*77c1e3ccSAndroid Build Coastguard Worker                            static_cast<InterpFilter>(v_f), sub_x, sub_y,
2306*77c1e3ccSAndroid Build Coastguard Worker                            compound);
2307*77c1e3ccSAndroid Build Coastguard Worker             }
2308*77c1e3ccSAndroid Build Coastguard Worker           }
2309*77c1e3ccSAndroid Build Coastguard Worker         }
2310*77c1e3ccSAndroid Build Coastguard Worker       }
2311*77c1e3ccSAndroid Build Coastguard Worker     }
2312*77c1e3ccSAndroid Build Coastguard Worker   }
2313*77c1e3ccSAndroid Build Coastguard Worker 
2314*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolve(const InterpFilter h_f,const InterpFilter v_f,const int sub_x,const int sub_y,const CompoundParam & compound)2315*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolve(const InterpFilter h_f, const InterpFilter v_f,
2316*77c1e3ccSAndroid Build Coastguard Worker                     const int sub_x, const int sub_y,
2317*77c1e3ccSAndroid Build Coastguard Worker                     const CompoundParam &compound) {
2318*77c1e3ccSAndroid Build Coastguard Worker     const BlockSize &block = GetParam().Block();
2319*77c1e3ccSAndroid Build Coastguard Worker     const int width = block.Width();
2320*77c1e3ccSAndroid Build Coastguard Worker     const int height = block.Height();
2321*77c1e3ccSAndroid Build Coastguard Worker 
2322*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input1 = FirstRandomInput8(GetParam());
2323*77c1e3ccSAndroid Build Coastguard Worker     const uint8_t *input2 = SecondRandomInput8(GetParam());
2324*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, reference[MAX_SB_SQUARE]);
2325*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, CONV_BUF_TYPE, reference_conv_buf[MAX_SB_SQUARE]);
2326*77c1e3ccSAndroid Build Coastguard Worker     Convolve(av1_dist_wtd_convolve_2d_c, input1, input2, reference,
2327*77c1e3ccSAndroid Build Coastguard Worker              reference_conv_buf, compound, h_f, v_f, sub_x, sub_y);
2328*77c1e3ccSAndroid Build Coastguard Worker 
2329*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint8_t, test[MAX_SB_SQUARE]);
2330*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, CONV_BUF_TYPE, test_conv_buf[MAX_SB_SQUARE]);
2331*77c1e3ccSAndroid Build Coastguard Worker     Convolve(GetParam().TestFunction(), input1, input2, test, test_conv_buf,
2332*77c1e3ccSAndroid Build Coastguard Worker              compound, h_f, v_f, sub_x, sub_y);
2333*77c1e3ccSAndroid Build Coastguard Worker 
2334*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference_conv_buf, test_conv_buf, width, height);
2335*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
2336*77c1e3ccSAndroid Build Coastguard Worker   }
2337*77c1e3ccSAndroid Build Coastguard Worker 
2338*77c1e3ccSAndroid Build Coastguard Worker  private:
Convolve(convolve_2d_func test_func,const uint8_t * src1,const uint8_t * src2,uint8_t * dst,uint16_t * conv_buf,const CompoundParam & compound,const InterpFilter h_f,const InterpFilter v_f,const int sub_x,const int sub_y)2339*77c1e3ccSAndroid Build Coastguard Worker   void Convolve(convolve_2d_func test_func, const uint8_t *src1,
2340*77c1e3ccSAndroid Build Coastguard Worker                 const uint8_t *src2, uint8_t *dst, uint16_t *conv_buf,
2341*77c1e3ccSAndroid Build Coastguard Worker                 const CompoundParam &compound, const InterpFilter h_f,
2342*77c1e3ccSAndroid Build Coastguard Worker                 const InterpFilter v_f, const int sub_x, const int sub_y) {
2343*77c1e3ccSAndroid Build Coastguard Worker     const BlockSize &block = GetParam().Block();
2344*77c1e3ccSAndroid Build Coastguard Worker     const int width = block.Width();
2345*77c1e3ccSAndroid Build Coastguard Worker     const int height = block.Height();
2346*77c1e3ccSAndroid Build Coastguard Worker 
2347*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x =
2348*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(h_f, width);
2349*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y =
2350*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(v_f, height);
2351*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params =
2352*77c1e3ccSAndroid Build Coastguard Worker         GetConvolveParams(0, conv_buf, kOutputStride, 8, compound);
2353*77c1e3ccSAndroid Build Coastguard Worker 
2354*77c1e3ccSAndroid Build Coastguard Worker     test_func(src1, width, dst, kOutputStride, width, height, filter_params_x,
2355*77c1e3ccSAndroid Build Coastguard Worker               filter_params_y, sub_x, sub_y, &conv_params);
2356*77c1e3ccSAndroid Build Coastguard Worker 
2357*77c1e3ccSAndroid Build Coastguard Worker     conv_params = GetConvolveParams(1, conv_buf, kOutputStride, 8, compound);
2358*77c1e3ccSAndroid Build Coastguard Worker     test_func(src2, width, dst, kOutputStride, width, height, filter_params_x,
2359*77c1e3ccSAndroid Build Coastguard Worker               filter_params_y, sub_x, sub_y, &conv_params);
2360*77c1e3ccSAndroid Build Coastguard Worker   }
2361*77c1e3ccSAndroid Build Coastguard Worker };
2362*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1Convolve2DCompoundTest,RunTest)2363*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1Convolve2DCompoundTest, RunTest) { RunTest(); }
2364*77c1e3ccSAndroid Build Coastguard Worker 
2365*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(C, AV1Convolve2DCompoundTest,
2366*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdLumaParams(av1_dist_wtd_convolve_2d_c));
2367*77c1e3ccSAndroid Build Coastguard Worker 
2368*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSSE3
2369*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(SSSE3, AV1Convolve2DCompoundTest,
2370*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdLumaParams(av1_dist_wtd_convolve_2d_ssse3));
2371*77c1e3ccSAndroid Build Coastguard Worker #endif
2372*77c1e3ccSAndroid Build Coastguard Worker 
2373*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
2374*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(AVX2, AV1Convolve2DCompoundTest,
2375*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdLumaParams(av1_dist_wtd_convolve_2d_avx2));
2376*77c1e3ccSAndroid Build Coastguard Worker #endif
2377*77c1e3ccSAndroid Build Coastguard Worker 
2378*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
2379*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(NEON, AV1Convolve2DCompoundTest,
2380*77c1e3ccSAndroid Build Coastguard Worker                          BuildLowbdLumaParams(av1_dist_wtd_convolve_2d_neon));
2381*77c1e3ccSAndroid Build Coastguard Worker #endif
2382*77c1e3ccSAndroid Build Coastguard Worker 
2383*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON_DOTPROD
2384*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2385*77c1e3ccSAndroid Build Coastguard Worker     NEON_DOTPROD, AV1Convolve2DCompoundTest,
2386*77c1e3ccSAndroid Build Coastguard Worker     BuildLowbdLumaParams(av1_dist_wtd_convolve_2d_neon_dotprod));
2387*77c1e3ccSAndroid Build Coastguard Worker #endif
2388*77c1e3ccSAndroid Build Coastguard Worker 
2389*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON_I8MM
2390*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2391*77c1e3ccSAndroid Build Coastguard Worker     NEON_I8MM, AV1Convolve2DCompoundTest,
2392*77c1e3ccSAndroid Build Coastguard Worker     BuildLowbdLumaParams(av1_dist_wtd_convolve_2d_neon_i8mm));
2393*77c1e3ccSAndroid Build Coastguard Worker #endif
2394*77c1e3ccSAndroid Build Coastguard Worker 
2395*77c1e3ccSAndroid Build Coastguard Worker #if CONFIG_AV1_HIGHBITDEPTH
2396*77c1e3ccSAndroid Build Coastguard Worker //////////////////////////////////////////////////
2397*77c1e3ccSAndroid Build Coastguard Worker // Compound convolve-2d functions (high bit-depth)
2398*77c1e3ccSAndroid Build Coastguard Worker //////////////////////////////////////////////////
2399*77c1e3ccSAndroid Build Coastguard Worker 
2400*77c1e3ccSAndroid Build Coastguard Worker class AV1Convolve2DHighbdCompoundTest
2401*77c1e3ccSAndroid Build Coastguard Worker     : public AV1ConvolveTest<highbd_convolve_2d_func> {
2402*77c1e3ccSAndroid Build Coastguard Worker  public:
RunTest()2403*77c1e3ccSAndroid Build Coastguard Worker   void RunTest() {
2404*77c1e3ccSAndroid Build Coastguard Worker     auto compound_params = GetCompoundParams();
2405*77c1e3ccSAndroid Build Coastguard Worker     for (int h_f = EIGHTTAP_REGULAR; h_f < INTERP_FILTERS_ALL; ++h_f) {
2406*77c1e3ccSAndroid Build Coastguard Worker       for (int v_f = EIGHTTAP_REGULAR; v_f < INTERP_FILTERS_ALL; ++v_f) {
2407*77c1e3ccSAndroid Build Coastguard Worker         // Do not test the no-op filter.
2408*77c1e3ccSAndroid Build Coastguard Worker         for (int sub_x = 1; sub_x < 16; ++sub_x) {
2409*77c1e3ccSAndroid Build Coastguard Worker           for (int sub_y = 1; sub_y < 16; ++sub_y) {
2410*77c1e3ccSAndroid Build Coastguard Worker             for (const auto &compound : compound_params) {
2411*77c1e3ccSAndroid Build Coastguard Worker               TestConvolve(static_cast<InterpFilter>(h_f),
2412*77c1e3ccSAndroid Build Coastguard Worker                            static_cast<InterpFilter>(v_f), sub_x, sub_y,
2413*77c1e3ccSAndroid Build Coastguard Worker                            compound);
2414*77c1e3ccSAndroid Build Coastguard Worker             }
2415*77c1e3ccSAndroid Build Coastguard Worker           }
2416*77c1e3ccSAndroid Build Coastguard Worker         }
2417*77c1e3ccSAndroid Build Coastguard Worker       }
2418*77c1e3ccSAndroid Build Coastguard Worker     }
2419*77c1e3ccSAndroid Build Coastguard Worker   }
2420*77c1e3ccSAndroid Build Coastguard Worker 
2421*77c1e3ccSAndroid Build Coastguard Worker  private:
TestConvolve(const InterpFilter h_f,const InterpFilter v_f,const int sub_x,const int sub_y,const CompoundParam & compound)2422*77c1e3ccSAndroid Build Coastguard Worker   void TestConvolve(const InterpFilter h_f, const InterpFilter v_f,
2423*77c1e3ccSAndroid Build Coastguard Worker                     const int sub_x, const int sub_y,
2424*77c1e3ccSAndroid Build Coastguard Worker                     const CompoundParam &compound) {
2425*77c1e3ccSAndroid Build Coastguard Worker     const BlockSize &block = GetParam().Block();
2426*77c1e3ccSAndroid Build Coastguard Worker     const int width = block.Width();
2427*77c1e3ccSAndroid Build Coastguard Worker     const int height = block.Height();
2428*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input1 = FirstRandomInput16(GetParam());
2429*77c1e3ccSAndroid Build Coastguard Worker     const uint16_t *input2 = SecondRandomInput16(GetParam());
2430*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, reference[MAX_SB_SQUARE]);
2431*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, CONV_BUF_TYPE, reference_conv_buf[MAX_SB_SQUARE]);
2432*77c1e3ccSAndroid Build Coastguard Worker     Convolve(av1_highbd_dist_wtd_convolve_2d_c, input1, input2, reference,
2433*77c1e3ccSAndroid Build Coastguard Worker              reference_conv_buf, compound, h_f, v_f, sub_x, sub_y);
2434*77c1e3ccSAndroid Build Coastguard Worker 
2435*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, uint16_t, test[MAX_SB_SQUARE]);
2436*77c1e3ccSAndroid Build Coastguard Worker     DECLARE_ALIGNED(32, CONV_BUF_TYPE, test_conv_buf[MAX_SB_SQUARE]);
2437*77c1e3ccSAndroid Build Coastguard Worker     Convolve(GetParam().TestFunction(), input1, input2, test, test_conv_buf,
2438*77c1e3ccSAndroid Build Coastguard Worker              compound, h_f, v_f, sub_x, sub_y);
2439*77c1e3ccSAndroid Build Coastguard Worker 
2440*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference_conv_buf, test_conv_buf, width, height);
2441*77c1e3ccSAndroid Build Coastguard Worker     AssertOutputBufferEq(reference, test, width, height);
2442*77c1e3ccSAndroid Build Coastguard Worker   }
2443*77c1e3ccSAndroid Build Coastguard Worker 
2444*77c1e3ccSAndroid Build Coastguard Worker  private:
Convolve(highbd_convolve_2d_func test_func,const uint16_t * src1,const uint16_t * src2,uint16_t * dst,uint16_t * conv_buf,const CompoundParam & compound,const InterpFilter h_f,const InterpFilter v_f,const int sub_x,const int sub_y)2445*77c1e3ccSAndroid Build Coastguard Worker   void Convolve(highbd_convolve_2d_func test_func, const uint16_t *src1,
2446*77c1e3ccSAndroid Build Coastguard Worker                 const uint16_t *src2, uint16_t *dst, uint16_t *conv_buf,
2447*77c1e3ccSAndroid Build Coastguard Worker                 const CompoundParam &compound, const InterpFilter h_f,
2448*77c1e3ccSAndroid Build Coastguard Worker                 const InterpFilter v_f, const int sub_x, const int sub_y) {
2449*77c1e3ccSAndroid Build Coastguard Worker     const BlockSize &block = GetParam().Block();
2450*77c1e3ccSAndroid Build Coastguard Worker     const int width = block.Width();
2451*77c1e3ccSAndroid Build Coastguard Worker     const int height = block.Height();
2452*77c1e3ccSAndroid Build Coastguard Worker 
2453*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_x =
2454*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(h_f, width);
2455*77c1e3ccSAndroid Build Coastguard Worker     const InterpFilterParams *filter_params_y =
2456*77c1e3ccSAndroid Build Coastguard Worker         av1_get_interp_filter_params_with_block_size(v_f, height);
2457*77c1e3ccSAndroid Build Coastguard Worker     const int bit_depth = GetParam().BitDepth();
2458*77c1e3ccSAndroid Build Coastguard Worker     ConvolveParams conv_params =
2459*77c1e3ccSAndroid Build Coastguard Worker         GetConvolveParams(0, conv_buf, kOutputStride, bit_depth, compound);
2460*77c1e3ccSAndroid Build Coastguard Worker     test_func(src1, width, dst, kOutputStride, width, height, filter_params_x,
2461*77c1e3ccSAndroid Build Coastguard Worker               filter_params_y, sub_x, sub_y, &conv_params, bit_depth);
2462*77c1e3ccSAndroid Build Coastguard Worker 
2463*77c1e3ccSAndroid Build Coastguard Worker     conv_params =
2464*77c1e3ccSAndroid Build Coastguard Worker         GetConvolveParams(1, conv_buf, kOutputStride, bit_depth, compound);
2465*77c1e3ccSAndroid Build Coastguard Worker     test_func(src2, width, dst, kOutputStride, width, height, filter_params_x,
2466*77c1e3ccSAndroid Build Coastguard Worker               filter_params_y, sub_x, sub_y, &conv_params, bit_depth);
2467*77c1e3ccSAndroid Build Coastguard Worker   }
2468*77c1e3ccSAndroid Build Coastguard Worker };
2469*77c1e3ccSAndroid Build Coastguard Worker 
TEST_P(AV1Convolve2DHighbdCompoundTest,RunTest)2470*77c1e3ccSAndroid Build Coastguard Worker TEST_P(AV1Convolve2DHighbdCompoundTest, RunTest) { RunTest(); }
2471*77c1e3ccSAndroid Build Coastguard Worker 
2472*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2473*77c1e3ccSAndroid Build Coastguard Worker     C, AV1Convolve2DHighbdCompoundTest,
2474*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_2d_c));
2475*77c1e3ccSAndroid Build Coastguard Worker 
2476*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SSE4_1
2477*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2478*77c1e3ccSAndroid Build Coastguard Worker     SSE4_1, AV1Convolve2DHighbdCompoundTest,
2479*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_2d_sse4_1));
2480*77c1e3ccSAndroid Build Coastguard Worker #endif
2481*77c1e3ccSAndroid Build Coastguard Worker 
2482*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_AVX2
2483*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2484*77c1e3ccSAndroid Build Coastguard Worker     AVX2, AV1Convolve2DHighbdCompoundTest,
2485*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_2d_avx2));
2486*77c1e3ccSAndroid Build Coastguard Worker #endif
2487*77c1e3ccSAndroid Build Coastguard Worker 
2488*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_NEON
2489*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2490*77c1e3ccSAndroid Build Coastguard Worker     NEON, AV1Convolve2DHighbdCompoundTest,
2491*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_2d_neon));
2492*77c1e3ccSAndroid Build Coastguard Worker #endif
2493*77c1e3ccSAndroid Build Coastguard Worker 
2494*77c1e3ccSAndroid Build Coastguard Worker #if HAVE_SVE2
2495*77c1e3ccSAndroid Build Coastguard Worker INSTANTIATE_TEST_SUITE_P(
2496*77c1e3ccSAndroid Build Coastguard Worker     SVE2, AV1Convolve2DHighbdCompoundTest,
2497*77c1e3ccSAndroid Build Coastguard Worker     BuildHighbdLumaParams(av1_highbd_dist_wtd_convolve_2d_sve2));
2498*77c1e3ccSAndroid Build Coastguard Worker #endif
2499*77c1e3ccSAndroid Build Coastguard Worker 
2500*77c1e3ccSAndroid Build Coastguard Worker #endif  // CONFIG_AV1_HIGHBITDEPTH
2501*77c1e3ccSAndroid Build Coastguard Worker 
2502*77c1e3ccSAndroid Build Coastguard Worker }  // namespace
2503