blob: cdd91533735771410a61b10c0df3bfba3f649302 [file] [log] [blame]
Yi Luofed8e1c2016-10-07 09:46:05 -07001/*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11
Tom Finegan7a07ece2017-02-07 17:14:05 -080012#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
Yi Luofed8e1c2016-10-07 09:46:05 -070013
14#include "./av1_rtcd.h"
15#include "./aom_dsp_rtcd.h"
16
17#include "test/acm_random.h"
18#include "test/clear_system_state.h"
19#include "test/register_state_check.h"
20#include "test/transform_test_base.h"
21#include "test/util.h"
22#include "aom_ports/mem.h"
23
24using libaom_test::ACMRandom;
25
26namespace {
27typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
28 int tx_type);
29using std::tr1::tuple;
30using libaom_test::FhtFunc;
31typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht32x32Param;
32
33void fht32x32_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
34 av1_fht32x32_c(in, out, stride, tx_type);
35}
36
Sebastien Alaiwan71e87842017-04-12 16:03:28 +020037#if CONFIG_HIGHBITDEPTH
Yi Luofed8e1c2016-10-07 09:46:05 -070038typedef void (*IHbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride,
39 int tx_type, int bd);
40typedef void (*HbdHtFunc)(const int16_t *input, int32_t *output, int stride,
41 int tx_type, int bd);
42
43// Target optimized function, tx_type, bit depth
44typedef tuple<HbdHtFunc, int, int> HighbdHt32x32Param;
45
46void highbd_fht32x32_ref(const int16_t *in, int32_t *out, int stride,
47 int tx_type, int bd) {
48 av1_fwd_txfm2d_32x32_c(in, out, stride, tx_type, bd);
49}
Sebastien Alaiwan71e87842017-04-12 16:03:28 +020050#endif // CONFIG_HIGHBITDEPTH
Yi Luofed8e1c2016-10-07 09:46:05 -070051
Yi Luo3e629b92017-05-15 11:03:23 -070052#if HAVE_SSE2 || HAVE_AVX2
Yi Luofed8e1c2016-10-07 09:46:05 -070053void dummy_inv_txfm(const tran_low_t *in, uint8_t *out, int stride,
54 int tx_type) {
55 (void)in;
56 (void)out;
57 (void)stride;
58 (void)tx_type;
59}
60#endif
61
62class AV1Trans32x32HT : public libaom_test::TransformTestBase,
63 public ::testing::TestWithParam<Ht32x32Param> {
64 public:
65 virtual ~AV1Trans32x32HT() {}
66
67 virtual void SetUp() {
68 fwd_txfm_ = GET_PARAM(0);
69 inv_txfm_ = GET_PARAM(1);
70 tx_type_ = GET_PARAM(2);
71 pitch_ = 32;
Yi Luo157e45a2016-10-17 11:18:50 -070072 height_ = 32;
Yi Luofed8e1c2016-10-07 09:46:05 -070073 fwd_txfm_ref = fht32x32_ref;
74 bit_depth_ = GET_PARAM(3);
75 mask_ = (1 << bit_depth_) - 1;
76 num_coeffs_ = GET_PARAM(4);
77 }
78 virtual void TearDown() { libaom_test::ClearSystemState(); }
79
80 protected:
81 void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
82 fwd_txfm_(in, out, stride, tx_type_);
83 }
84
85 void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
86 inv_txfm_(out, dst, stride, tx_type_);
87 }
88
89 FhtFunc fwd_txfm_;
90 IhtFunc inv_txfm_;
91};
92
93TEST_P(AV1Trans32x32HT, CoeffCheck) { RunCoeffCheck(); }
Yi Luo157e45a2016-10-17 11:18:50 -070094TEST_P(AV1Trans32x32HT, MemCheck) { RunMemCheck(); }
Yi Luofed8e1c2016-10-07 09:46:05 -070095
Sebastien Alaiwan71e87842017-04-12 16:03:28 +020096#if CONFIG_HIGHBITDEPTH
Yi Luofed8e1c2016-10-07 09:46:05 -070097class AV1HighbdTrans32x32HT
98 : public ::testing::TestWithParam<HighbdHt32x32Param> {
99 public:
100 virtual ~AV1HighbdTrans32x32HT() {}
101
102 virtual void SetUp() {
103 fwd_txfm_ = GET_PARAM(0);
104 fwd_txfm_ref_ = highbd_fht32x32_ref;
105 tx_type_ = GET_PARAM(1);
106 bit_depth_ = GET_PARAM(2);
107 mask_ = (1 << bit_depth_) - 1;
108 num_coeffs_ = 1024;
109
110 input_ = reinterpret_cast<int16_t *>(
111 aom_memalign(32, sizeof(int16_t) * num_coeffs_));
112 output_ = reinterpret_cast<int32_t *>(
113 aom_memalign(32, sizeof(int32_t) * num_coeffs_));
114 output_ref_ = reinterpret_cast<int32_t *>(
115 aom_memalign(32, sizeof(int32_t) * num_coeffs_));
116 }
117
118 virtual void TearDown() {
119 aom_free(input_);
120 aom_free(output_);
121 aom_free(output_ref_);
122 libaom_test::ClearSystemState();
123 }
124
125 protected:
126 void RunBitexactCheck();
127
128 private:
129 HbdHtFunc fwd_txfm_;
130 HbdHtFunc fwd_txfm_ref_;
131 int tx_type_;
132 int bit_depth_;
133 int mask_;
134 int num_coeffs_;
135 int16_t *input_;
136 int32_t *output_;
137 int32_t *output_ref_;
138};
139
140void AV1HighbdTrans32x32HT::RunBitexactCheck() {
141 ACMRandom rnd(ACMRandom::DeterministicSeed());
142 int i, j;
143 const int stride = 32;
144 const int num_tests = 1000;
145
146 for (i = 0; i < num_tests; ++i) {
147 for (j = 0; j < num_coeffs_; ++j) {
148 input_[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
149 }
150
151 fwd_txfm_ref_(input_, output_ref_, stride, tx_type_, bit_depth_);
152 ASM_REGISTER_STATE_CHECK(
153 fwd_txfm_(input_, output_, stride, tx_type_, bit_depth_));
154
155 for (j = 0; j < num_coeffs_; ++j) {
156 EXPECT_EQ(output_ref_[j], output_[j])
157 << "Not bit-exact result at index: " << j << " at test block: " << i;
158 }
159 }
160}
161
162TEST_P(AV1HighbdTrans32x32HT, HighbdCoeffCheck) { RunBitexactCheck(); }
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200163#endif // CONFIG_HIGHBITDEPTH
Yi Luofed8e1c2016-10-07 09:46:05 -0700164
165using std::tr1::make_tuple;
166
Yi Luo9a3d29e2017-03-29 11:40:03 -0700167#if HAVE_SSE2
168const Ht32x32Param kArrayHt32x32Param_sse2[] = {
169 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 0, AOM_BITS_8, 1024),
170 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 1, AOM_BITS_8, 1024),
171 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 2, AOM_BITS_8, 1024),
172 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 3, AOM_BITS_8, 1024),
173#if CONFIG_EXT_TX
174 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 4, AOM_BITS_8, 1024),
175 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 5, AOM_BITS_8, 1024),
176 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 6, AOM_BITS_8, 1024),
177 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 7, AOM_BITS_8, 1024),
178 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 8, AOM_BITS_8, 1024),
179 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 9, AOM_BITS_8, 1024),
180 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 10, AOM_BITS_8, 1024),
181 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 11, AOM_BITS_8, 1024),
182 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 12, AOM_BITS_8, 1024),
183 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 13, AOM_BITS_8, 1024),
184 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 14, AOM_BITS_8, 1024),
185 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, 15, AOM_BITS_8, 1024)
186#endif // CONFIG_EXT_TX
187};
188INSTANTIATE_TEST_CASE_P(SSE2, AV1Trans32x32HT,
189 ::testing::ValuesIn(kArrayHt32x32Param_sse2));
190#endif // HAVE_SSE2
191
Yi Luofed8e1c2016-10-07 09:46:05 -0700192#if HAVE_AVX2
193const Ht32x32Param kArrayHt32x32Param_avx2[] = {
Tom Finegan29ba6752017-01-31 16:30:55 -0800194 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 0, AOM_BITS_8, 1024),
195 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 1, AOM_BITS_8, 1024),
196 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 2, AOM_BITS_8, 1024),
197 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 3, AOM_BITS_8, 1024),
Yi Luofed8e1c2016-10-07 09:46:05 -0700198#if CONFIG_EXT_TX
Tom Finegan29ba6752017-01-31 16:30:55 -0800199 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 4, AOM_BITS_8, 1024),
200 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 5, AOM_BITS_8, 1024),
201 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 6, AOM_BITS_8, 1024),
202 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 7, AOM_BITS_8, 1024),
203 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 8, AOM_BITS_8, 1024),
Yi Luo13d2aee2017-03-29 17:48:13 -0700204 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 9, AOM_BITS_8, 1024),
Tom Finegan29ba6752017-01-31 16:30:55 -0800205 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 10, AOM_BITS_8, 1024),
206 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 11, AOM_BITS_8, 1024),
207 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 12, AOM_BITS_8, 1024),
208 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 13, AOM_BITS_8, 1024),
209 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 14, AOM_BITS_8, 1024),
210 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, 15, AOM_BITS_8, 1024)
Yi Luofed8e1c2016-10-07 09:46:05 -0700211#endif // CONFIG_EXT_TX
212};
213INSTANTIATE_TEST_CASE_P(AVX2, AV1Trans32x32HT,
214 ::testing::ValuesIn(kArrayHt32x32Param_avx2));
215#endif // HAVE_AVX2
216} // namespace