blob: e1032ef241d69f5b668a663bffad09a6c252f7c9 [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,
28 int tx_type);
29using std::tr1::tuple;
30using libaom_test::FhtFunc;
31typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht16x16Param;
32
33void fht16x16_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
34 av1_fht16x16_c(in, out, stride, tx_type);
35}
36
Yi Luo73172002016-10-28 10:52:04 -070037void iht16x16_ref(const tran_low_t *in, uint8_t *dest, int stride,
38 int tx_type) {
39 av1_iht16x16_256_add_c(in, dest, stride, tx_type);
40}
41
Sebastien Alaiwan71e87842017-04-12 16:03:28 +020042#if CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -070043typedef void (*IHbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride,
44 int tx_type, int bd);
45typedef void (*HbdHtFunc)(const int16_t *input, int32_t *output, int stride,
46 int tx_type, int bd);
47
48// Target optimized function, tx_type, bit depth
49typedef tuple<HbdHtFunc, int, int> HighbdHt16x16Param;
50
51void highbd_fht16x16_ref(const int16_t *in, int32_t *out, int stride,
52 int tx_type, int bd) {
53 av1_fwd_txfm2d_16x16_c(in, out, stride, tx_type, bd);
54}
Sebastien Alaiwan71e87842017-04-12 16:03:28 +020055#endif // CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -070056
57class AV1Trans16x16HT : public libaom_test::TransformTestBase,
58 public ::testing::TestWithParam<Ht16x16Param> {
59 public:
60 virtual ~AV1Trans16x16HT() {}
61
62 virtual void SetUp() {
63 fwd_txfm_ = GET_PARAM(0);
64 inv_txfm_ = GET_PARAM(1);
65 tx_type_ = GET_PARAM(2);
66 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);
73 }
74 virtual void TearDown() { libaom_test::ClearSystemState(); }
75
76 protected:
77 void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
78 fwd_txfm_(in, out, stride, tx_type_);
79 }
80
81 void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
82 inv_txfm_(out, dst, stride, tx_type_);
83 }
84
85 FhtFunc fwd_txfm_;
86 IhtFunc inv_txfm_;
87};
88
Yi Luo8245b9a2016-11-17 14:56:43 -080089TEST_P(AV1Trans16x16HT, MemCheck) { RunMemCheck(); }
Angie Chiange6aece82017-01-09 17:27:56 -080090TEST_P(AV1Trans16x16HT, AccuracyCheck) { RunAccuracyCheck(1, 0.001); }
Yi Luo8245b9a2016-11-17 14:56:43 -080091TEST_P(AV1Trans16x16HT, InvAccuracyCheck) { RunInvAccuracyCheck(1); }
Yaowu Xuf883b422016-08-30 14:01:10 -070092TEST_P(AV1Trans16x16HT, CoeffCheck) { RunCoeffCheck(); }
Yi Luo73172002016-10-28 10:52:04 -070093TEST_P(AV1Trans16x16HT, InvCoeffCheck) { RunInvCoeffCheck(); }
Yaowu Xuf883b422016-08-30 14:01:10 -070094
Sebastien Alaiwan71e87842017-04-12 16:03:28 +020095#if CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -070096class AV1HighbdTrans16x16HT
97 : public ::testing::TestWithParam<HighbdHt16x16Param> {
98 public:
99 virtual ~AV1HighbdTrans16x16HT() {}
100
101 virtual void SetUp() {
102 fwd_txfm_ = GET_PARAM(0);
103 fwd_txfm_ref_ = highbd_fht16x16_ref;
104 tx_type_ = GET_PARAM(1);
105 bit_depth_ = GET_PARAM(2);
106 mask_ = (1 << bit_depth_) - 1;
107 num_coeffs_ = 256;
108
109 input_ = reinterpret_cast<int16_t *>(
Yi Luoe8e8cd82016-09-21 10:45:01 -0700110 aom_memalign(32, sizeof(int16_t) * num_coeffs_));
Yaowu Xuf883b422016-08-30 14:01:10 -0700111 output_ = reinterpret_cast<int32_t *>(
Yi Luoe8e8cd82016-09-21 10:45:01 -0700112 aom_memalign(32, sizeof(int32_t) * num_coeffs_));
Yaowu Xuf883b422016-08-30 14:01:10 -0700113 output_ref_ = reinterpret_cast<int32_t *>(
Yi Luoe8e8cd82016-09-21 10:45:01 -0700114 aom_memalign(32, sizeof(int32_t) * num_coeffs_));
Yaowu Xuf883b422016-08-30 14:01:10 -0700115 }
116
117 virtual void TearDown() {
118 aom_free(input_);
119 aom_free(output_);
120 aom_free(output_ref_);
121 libaom_test::ClearSystemState();
122 }
123
124 protected:
125 void RunBitexactCheck();
126
127 private:
128 HbdHtFunc fwd_txfm_;
129 HbdHtFunc fwd_txfm_ref_;
130 int tx_type_;
131 int bit_depth_;
132 int mask_;
133 int num_coeffs_;
134 int16_t *input_;
135 int32_t *output_;
136 int32_t *output_ref_;
137};
138
139void AV1HighbdTrans16x16HT::RunBitexactCheck() {
140 ACMRandom rnd(ACMRandom::DeterministicSeed());
141 int i, j;
142 const int stride = 16;
143 const int num_tests = 1000;
144
145 for (i = 0; i < num_tests; ++i) {
146 for (j = 0; j < num_coeffs_; ++j) {
147 input_[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
148 }
149
150 fwd_txfm_ref_(input_, output_ref_, stride, tx_type_, bit_depth_);
151 ASM_REGISTER_STATE_CHECK(
152 fwd_txfm_(input_, output_, stride, tx_type_, bit_depth_));
153
154 for (j = 0; j < num_coeffs_; ++j) {
155 EXPECT_EQ(output_ref_[j], output_[j])
156 << "Not bit-exact result at index: " << j << " at test block: " << i;
157 }
158 }
159}
160
161TEST_P(AV1HighbdTrans16x16HT, HighbdCoeffCheck) { RunBitexactCheck(); }
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200162#endif // CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -0700163
164using std::tr1::make_tuple;
165
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200166#if HAVE_SSE2
Yaowu Xuf883b422016-08-30 14:01:10 -0700167const Ht16x16Param kArrayHt16x16Param_sse2[] = {
168 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 0, AOM_BITS_8,
169 256),
170 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 1, AOM_BITS_8,
171 256),
172 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 2, AOM_BITS_8,
173 256),
174 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 3, AOM_BITS_8,
175 256),
176#if CONFIG_EXT_TX
177 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 4, AOM_BITS_8,
178 256),
179 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 5, AOM_BITS_8,
180 256),
181 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 6, AOM_BITS_8,
182 256),
183 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 7, AOM_BITS_8,
184 256),
185 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 8, AOM_BITS_8,
186 256),
Yi Luo13d2aee2017-03-29 17:48:13 -0700187 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 9, AOM_BITS_8,
188 256),
Yaowu Xuf883b422016-08-30 14:01:10 -0700189 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 10, AOM_BITS_8,
190 256),
191 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 11, AOM_BITS_8,
192 256),
193 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 12, AOM_BITS_8,
194 256),
195 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 13, AOM_BITS_8,
196 256),
197 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 14, AOM_BITS_8,
198 256),
199 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, 15, AOM_BITS_8,
200 256)
201#endif // CONFIG_EXT_TX
202};
203INSTANTIATE_TEST_CASE_P(SSE2, AV1Trans16x16HT,
204 ::testing::ValuesIn(kArrayHt16x16Param_sse2));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200205#endif // HAVE_SSE2
Yaowu Xuf883b422016-08-30 14:01:10 -0700206
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200207#if HAVE_AVX2
Yi Luoe8e8cd82016-09-21 10:45:01 -0700208const Ht16x16Param kArrayHt16x16Param_avx2[] = {
Tom Finegan29ba6752017-01-31 16:30:55 -0800209 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 0, AOM_BITS_8,
210 256),
211 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 1, AOM_BITS_8,
212 256),
213 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 2, AOM_BITS_8,
214 256),
215 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 3, AOM_BITS_8,
216 256),
Yi Luoe8e8cd82016-09-21 10:45:01 -0700217#if CONFIG_EXT_TX
Tom Finegan29ba6752017-01-31 16:30:55 -0800218 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 4, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700219 256),
Tom Finegan29ba6752017-01-31 16:30:55 -0800220 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 5, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700221 256),
Tom Finegan29ba6752017-01-31 16:30:55 -0800222 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 6, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700223 256),
Tom Finegan29ba6752017-01-31 16:30:55 -0800224 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 7, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700225 256),
Tom Finegan29ba6752017-01-31 16:30:55 -0800226 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 8, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700227 256),
Yi Luo13d2aee2017-03-29 17:48:13 -0700228 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 9, AOM_BITS_8,
229 256),
Tom Finegan29ba6752017-01-31 16:30:55 -0800230 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 10, AOM_BITS_8,
231 256),
232 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 11, AOM_BITS_8,
233 256),
234 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 12, AOM_BITS_8,
235 256),
236 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 13, AOM_BITS_8,
237 256),
238 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 14, AOM_BITS_8,
239 256),
240 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, 15, AOM_BITS_8,
241 256)
Yi Luoe8e8cd82016-09-21 10:45:01 -0700242#endif // CONFIG_EXT_TX
243};
244INSTANTIATE_TEST_CASE_P(AVX2, AV1Trans16x16HT,
245 ::testing::ValuesIn(kArrayHt16x16Param_avx2));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200246#endif // HAVE_AVX2
Yi Luoe8e8cd82016-09-21 10:45:01 -0700247
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200248#if HAVE_SSE4_1 && CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -0700249const HighbdHt16x16Param kArrayHBDHt16x16Param_sse4_1[] = {
250 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 0, 10),
251 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 0, 12),
252 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 1, 10),
253 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 1, 12),
254 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 2, 10),
255 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 2, 12),
256 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 3, 10),
257 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 3, 12),
258#if CONFIG_EXT_TX
259 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 4, 10),
260 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 4, 12),
261 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 5, 10),
262 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 5, 12),
263 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 6, 10),
264 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 6, 12),
265 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 7, 10),
266 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 7, 12),
267 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 8, 10),
268 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, 8, 12),
269#endif // CONFIG_EXT_TX
270};
271INSTANTIATE_TEST_CASE_P(SSE4_1, AV1HighbdTrans16x16HT,
272 ::testing::ValuesIn(kArrayHBDHt16x16Param_sse4_1));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200273#endif // HAVE_SSE4_1 && CONFIG_HIGHBITDEPTH
Yaowu Xuf883b422016-08-30 14:01:10 -0700274
275} // namespace