blob: c0f6974c615c29429a971bb5872f950c62229950 [file] [log] [blame]
Yaowu Xuf883b422016-08-30 14:01:10 -07001/*
Yaowu Xubde4ac82016-11-28 15:26:06 -08002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuf883b422016-08-30 14:01:10 -07003 *
Yaowu Xubde4ac82016-11-28 15:26:06 -08004 * 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.
Yaowu Xuf883b422016-08-30 14:01:10 -070010 */
11
Tom Finegan7a07ece2017-02-07 17:14:05 -080012#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
Yaowu Xuf883b422016-08-30 14:01:10 -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,
Lester Lu27319b62017-07-10 16:57:15 -070028 const TxfmParam *txfm_param);
Yaowu Xuf883b422016-08-30 14:01:10 -070029using std::tr1::tuple;
30using libaom_test::FhtFunc;
31typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht16x16Param;
32
Lester Lud8b1ddc2017-07-06 16:13:29 -070033void fht16x16_ref(const int16_t *in, tran_low_t *out, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070034 TxfmParam *txfm_param) {
35 av1_fht16x16_c(in, out, stride, txfm_param);
Yaowu Xuf883b422016-08-30 14:01:10 -070036}
37
Yi Luo73172002016-10-28 10:52:04 -070038void iht16x16_ref(const tran_low_t *in, uint8_t *dest, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070039 const TxfmParam *txfm_param) {
40 av1_iht16x16_256_add_c(in, dest, stride, txfm_param);
Yi Luo73172002016-10-28 10:52:04 -070041}
42
Sebastien Alaiwan71e87842017-04-12 16:03:28 +020043#if CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -070044typedef void (*IHbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride,
45 int tx_type, int bd);
46typedef void (*HbdHtFunc)(const int16_t *input, int32_t *output, int stride,
47 int tx_type, int bd);
48
49// Target optimized function, tx_type, bit depth
50typedef tuple<HbdHtFunc, int, int> HighbdHt16x16Param;
51
52void highbd_fht16x16_ref(const int16_t *in, int32_t *out, int stride,
53 int tx_type, int bd) {
54 av1_fwd_txfm2d_16x16_c(in, out, stride, tx_type, bd);
55}
Sebastien Alaiwan71e87842017-04-12 16:03:28 +020056#endif // CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -070057
58class AV1Trans16x16HT : public libaom_test::TransformTestBase,
59 public ::testing::TestWithParam<Ht16x16Param> {
60 public:
61 virtual ~AV1Trans16x16HT() {}
62
63 virtual void SetUp() {
64 fwd_txfm_ = GET_PARAM(0);
65 inv_txfm_ = GET_PARAM(1);
Yaowu Xuf883b422016-08-30 14:01:10 -070066 pitch_ = 16;
David Barker78250222016-10-13 15:10:14 +010067 height_ = 16;
Yaowu Xuf883b422016-08-30 14:01:10 -070068 fwd_txfm_ref = fht16x16_ref;
Yi Luo73172002016-10-28 10:52:04 -070069 inv_txfm_ref = iht16x16_ref;
Yaowu Xuf883b422016-08-30 14:01:10 -070070 bit_depth_ = GET_PARAM(3);
71 mask_ = (1 << bit_depth_) - 1;
72 num_coeffs_ = GET_PARAM(4);
Lester Lu27319b62017-07-10 16:57:15 -070073 txfm_param_.tx_type = GET_PARAM(2);
Yaowu Xuf883b422016-08-30 14:01:10 -070074 }
75 virtual void TearDown() { libaom_test::ClearSystemState(); }
76
77 protected:
78 void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
Lester Lu27319b62017-07-10 16:57:15 -070079 fwd_txfm_(in, out, stride, &txfm_param_);
Yaowu Xuf883b422016-08-30 14:01:10 -070080 }
81
82 void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
Lester Lu27319b62017-07-10 16:57:15 -070083 inv_txfm_(out, dst, stride, &txfm_param_);
Yaowu Xuf883b422016-08-30 14:01:10 -070084 }
85
86 FhtFunc fwd_txfm_;
87 IhtFunc inv_txfm_;
88};
89
Yi Luo8245b9a2016-11-17 14:56:43 -080090TEST_P(AV1Trans16x16HT, MemCheck) { RunMemCheck(); }
Angie Chiange6aece82017-01-09 17:27:56 -080091TEST_P(AV1Trans16x16HT, AccuracyCheck) { RunAccuracyCheck(1, 0.001); }
Yi Luo8245b9a2016-11-17 14:56:43 -080092TEST_P(AV1Trans16x16HT, InvAccuracyCheck) { RunInvAccuracyCheck(1); }
Yaowu Xuf883b422016-08-30 14:01:10 -070093TEST_P(AV1Trans16x16HT, CoeffCheck) { RunCoeffCheck(); }
Yi Luo73172002016-10-28 10:52:04 -070094TEST_P(AV1Trans16x16HT, InvCoeffCheck) { RunInvCoeffCheck(); }
Yaowu Xuf883b422016-08-30 14:01:10 -070095
Sebastien Alaiwan71e87842017-04-12 16:03:28 +020096#if CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -070097class AV1HighbdTrans16x16HT
98 : public ::testing::TestWithParam<HighbdHt16x16Param> {
99 public:
100 virtual ~AV1HighbdTrans16x16HT() {}
101
102 virtual void SetUp() {
103 fwd_txfm_ = GET_PARAM(0);
104 fwd_txfm_ref_ = highbd_fht16x16_ref;
105 tx_type_ = GET_PARAM(1);
106 bit_depth_ = GET_PARAM(2);
107 mask_ = (1 << bit_depth_) - 1;
108 num_coeffs_ = 256;
109
110 input_ = reinterpret_cast<int16_t *>(
Yi Luoe8e8cd82016-09-21 10:45:01 -0700111 aom_memalign(32, sizeof(int16_t) * num_coeffs_));
Yaowu Xuf883b422016-08-30 14:01:10 -0700112 output_ = reinterpret_cast<int32_t *>(
Yi Luoe8e8cd82016-09-21 10:45:01 -0700113 aom_memalign(32, sizeof(int32_t) * num_coeffs_));
Yaowu Xuf883b422016-08-30 14:01:10 -0700114 output_ref_ = reinterpret_cast<int32_t *>(
Yi Luoe8e8cd82016-09-21 10:45:01 -0700115 aom_memalign(32, sizeof(int32_t) * num_coeffs_));
Yaowu Xuf883b422016-08-30 14:01:10 -0700116 }
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 AV1HighbdTrans16x16HT::RunBitexactCheck() {
141 ACMRandom rnd(ACMRandom::DeterministicSeed());
142 int i, j;
143 const int stride = 16;
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(AV1HighbdTrans16x16HT, HighbdCoeffCheck) { RunBitexactCheck(); }
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200163#endif // CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -0700164
165using std::tr1::make_tuple;
166
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200167#if HAVE_SSE2
Yaowu Xuf883b422016-08-30 14:01:10 -0700168const Ht16x16Param kArrayHt16x16Param_sse2[] = {
169 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 0, AOM_BITS_8,
170 256),
171 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 1, AOM_BITS_8,
172 256),
173 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 2, AOM_BITS_8,
174 256),
175 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 3, AOM_BITS_8,
176 256),
177#if CONFIG_EXT_TX
178 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 4, AOM_BITS_8,
179 256),
180 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 5, AOM_BITS_8,
181 256),
182 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 6, AOM_BITS_8,
183 256),
184 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 7, AOM_BITS_8,
185 256),
186 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 8, AOM_BITS_8,
187 256),
Yi Luo13d2aee2017-03-29 17:48:13 -0700188 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 9, AOM_BITS_8,
189 256),
Yaowu Xuf883b422016-08-30 14:01:10 -0700190 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 10, AOM_BITS_8,
191 256),
192 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 11, AOM_BITS_8,
193 256),
194 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 12, AOM_BITS_8,
195 256),
196 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 13, AOM_BITS_8,
197 256),
198 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 14, AOM_BITS_8,
199 256),
200 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 15, AOM_BITS_8,
201 256)
202#endif // CONFIG_EXT_TX
203};
204INSTANTIATE_TEST_CASE_P(SSE2, AV1Trans16x16HT,
205 ::testing::ValuesIn(kArrayHt16x16Param_sse2));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200206#endif // HAVE_SSE2
Yaowu Xuf883b422016-08-30 14:01:10 -0700207
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200208#if HAVE_AVX2
Yi Luoe8e8cd82016-09-21 10:45:01 -0700209const Ht16x16Param kArrayHt16x16Param_avx2[] = {
Tom Finegan29ba6752017-01-31 16:30:55 -0800210 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 0, AOM_BITS_8,
211 256),
212 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 1, AOM_BITS_8,
213 256),
214 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 2, AOM_BITS_8,
215 256),
216 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 3, AOM_BITS_8,
217 256),
Yi Luoe8e8cd82016-09-21 10:45:01 -0700218#if CONFIG_EXT_TX
Tom Finegan29ba6752017-01-31 16:30:55 -0800219 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 4, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700220 256),
Tom Finegan29ba6752017-01-31 16:30:55 -0800221 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 5, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700222 256),
Tom Finegan29ba6752017-01-31 16:30:55 -0800223 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 6, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700224 256),
Tom Finegan29ba6752017-01-31 16:30:55 -0800225 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 7, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700226 256),
Tom Finegan29ba6752017-01-31 16:30:55 -0800227 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 8, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700228 256),
Yi Luo13d2aee2017-03-29 17:48:13 -0700229 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 9, AOM_BITS_8,
230 256),
Tom Finegan29ba6752017-01-31 16:30:55 -0800231 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 10, AOM_BITS_8,
232 256),
233 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 11, AOM_BITS_8,
234 256),
235 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 12, AOM_BITS_8,
236 256),
237 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 13, AOM_BITS_8,
238 256),
239 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 14, AOM_BITS_8,
240 256),
241 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 15, AOM_BITS_8,
242 256)
Yi Luoe8e8cd82016-09-21 10:45:01 -0700243#endif // CONFIG_EXT_TX
244};
245INSTANTIATE_TEST_CASE_P(AVX2, AV1Trans16x16HT,
246 ::testing::ValuesIn(kArrayHt16x16Param_avx2));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200247#endif // HAVE_AVX2
Yi Luoe8e8cd82016-09-21 10:45:01 -0700248
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200249#if HAVE_SSE4_1 && CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -0700250const HighbdHt16x16Param kArrayHBDHt16x16Param_sse4_1[] = {
251 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 0, 10),
252 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 0, 12),
253 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 1, 10),
254 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 1, 12),
255 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 2, 10),
256 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 2, 12),
257 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 3, 10),
258 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 3, 12),
259#if CONFIG_EXT_TX
260 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 4, 10),
261 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 4, 12),
262 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 5, 10),
263 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 5, 12),
264 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 6, 10),
265 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 6, 12),
266 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 7, 10),
267 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 7, 12),
268 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 8, 10),
269 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 8, 12),
270#endif // CONFIG_EXT_TX
271};
272INSTANTIATE_TEST_CASE_P(SSE4_1, AV1HighbdTrans16x16HT,
273 ::testing::ValuesIn(kArrayHBDHt16x16Param_sse4_1));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200274#endif // HAVE_SSE4_1 && CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -0700275
276} // namespace