blob: 6510099ee8da222dac10bb4348ce8acb297ba025 [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 -070029
30using libaom_test::FhtFunc;
31using std::tr1::tuple;
Urvang Joshi2283d372017-10-02 17:16:45 -070032typedef tuple<FhtFunc, IhtFunc, TX_TYPE, aom_bit_depth_t, int> Ht8x8Param;
Yaowu Xuf883b422016-08-30 14:01:10 -070033
Lester Lud8b1ddc2017-07-06 16:13:29 -070034void fht8x8_ref(const int16_t *in, tran_low_t *out, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070035 TxfmParam *txfm_param) {
36 av1_fht8x8_c(in, out, stride, txfm_param);
Yaowu Xuf883b422016-08-30 14:01:10 -070037}
38
Lester Lud8b1ddc2017-07-06 16:13:29 -070039void iht8x8_ref(const tran_low_t *in, uint8_t *out, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070040 const TxfmParam *txfm_param) {
41 av1_iht8x8_64_add_c(in, out, stride, txfm_param);
Yi Luo8245b9a2016-11-17 14:56:43 -080042}
43
Yaowu Xuf883b422016-08-30 14:01:10 -070044typedef void (*IHbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride,
Urvang Joshi2283d372017-10-02 17:16:45 -070045 TX_TYPE tx_type, int bd);
Yaowu Xuf883b422016-08-30 14:01:10 -070046typedef void (*HbdHtFunc)(const int16_t *input, int32_t *output, int stride,
Urvang Joshi2283d372017-10-02 17:16:45 -070047 TX_TYPE tx_type, int bd);
Yaowu Xuf883b422016-08-30 14:01:10 -070048// Target optimized function, tx_type, bit depth
Urvang Joshi2283d372017-10-02 17:16:45 -070049typedef tuple<HbdHtFunc, TX_TYPE, int> HighbdHt8x8Param;
Yaowu Xuf883b422016-08-30 14:01:10 -070050
Urvang Joshi2283d372017-10-02 17:16:45 -070051void highbd_fht8x8_ref(const int16_t *in, int32_t *out, int stride,
52 TX_TYPE tx_type, int bd) {
Yaowu Xuf883b422016-08-30 14:01:10 -070053 av1_fwd_txfm2d_8x8_c(in, out, stride, tx_type, bd);
54}
Yaowu Xuf883b422016-08-30 14:01:10 -070055
56class AV1Trans8x8HT : public libaom_test::TransformTestBase,
57 public ::testing::TestWithParam<Ht8x8Param> {
58 public:
59 virtual ~AV1Trans8x8HT() {}
60
61 virtual void SetUp() {
62 fwd_txfm_ = GET_PARAM(0);
63 inv_txfm_ = GET_PARAM(1);
Yaowu Xuf883b422016-08-30 14:01:10 -070064 pitch_ = 8;
David Barker78250222016-10-13 15:10:14 +010065 height_ = 8;
Yaowu Xuf883b422016-08-30 14:01:10 -070066 fwd_txfm_ref = fht8x8_ref;
Yi Luo8245b9a2016-11-17 14:56:43 -080067 inv_txfm_ref = iht8x8_ref;
Yaowu Xuf883b422016-08-30 14:01:10 -070068 bit_depth_ = GET_PARAM(3);
69 mask_ = (1 << bit_depth_) - 1;
70 num_coeffs_ = GET_PARAM(4);
Lester Lu27319b62017-07-10 16:57:15 -070071 txfm_param_.tx_type = GET_PARAM(2);
Yaowu Xuf883b422016-08-30 14:01:10 -070072 }
73 virtual void TearDown() { libaom_test::ClearSystemState(); }
74
75 protected:
76 void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
Lester Lu27319b62017-07-10 16:57:15 -070077 fwd_txfm_(in, out, stride, &txfm_param_);
Yaowu Xuf883b422016-08-30 14:01:10 -070078 }
79
80 void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
Lester Lu27319b62017-07-10 16:57:15 -070081 inv_txfm_(out, dst, stride, &txfm_param_);
Yaowu Xuf883b422016-08-30 14:01:10 -070082 }
83
84 FhtFunc fwd_txfm_;
85 IhtFunc inv_txfm_;
86};
87
Yi Luo8245b9a2016-11-17 14:56:43 -080088TEST_P(AV1Trans8x8HT, MemCheck) { RunMemCheck(); }
Yaowu Xuf883b422016-08-30 14:01:10 -070089TEST_P(AV1Trans8x8HT, CoeffCheck) { RunCoeffCheck(); }
Yi Luo8245b9a2016-11-17 14:56:43 -080090// Note:
91// TODO(luoyi): Add tx_type, 9-15 for inverse transform.
92// Need cleanup since same tests may be done in fdct8x8_test.cc
93// TEST_P(AV1Trans8x8HT, AccuracyCheck) { RunAccuracyCheck(0); }
94// TEST_P(AV1Trans8x8HT, InvAccuracyCheck) { RunInvAccuracyCheck(0); }
95// TEST_P(AV1Trans8x8HT, InvCoeffCheck) { RunInvCoeffCheck(); }
Yaowu Xuf883b422016-08-30 14:01:10 -070096
Yaowu Xuf883b422016-08-30 14:01:10 -070097class AV1HighbdTrans8x8HT : public ::testing::TestWithParam<HighbdHt8x8Param> {
98 public:
99 virtual ~AV1HighbdTrans8x8HT() {}
100
101 virtual void SetUp() {
102 fwd_txfm_ = GET_PARAM(0);
103 fwd_txfm_ref_ = highbd_fht8x8_ref;
104 tx_type_ = GET_PARAM(1);
105 bit_depth_ = GET_PARAM(2);
106 mask_ = (1 << bit_depth_) - 1;
107 num_coeffs_ = 64;
108
109 input_ = reinterpret_cast<int16_t *>(
110 aom_memalign(16, sizeof(int16_t) * num_coeffs_));
111 output_ = reinterpret_cast<int32_t *>(
112 aom_memalign(16, sizeof(int32_t) * num_coeffs_));
113 output_ref_ = reinterpret_cast<int32_t *>(
114 aom_memalign(16, sizeof(int32_t) * num_coeffs_));
115 }
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_;
Urvang Joshi2283d372017-10-02 17:16:45 -0700130 TX_TYPE tx_type_;
Yaowu Xuf883b422016-08-30 14:01:10 -0700131 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 AV1HighbdTrans8x8HT::RunBitexactCheck() {
140 ACMRandom rnd(ACMRandom::DeterministicSeed());
141 int i, j;
142 const int stride = 8;
143 const int num_tests = 1000;
144 const int num_coeffs = 64;
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(AV1HighbdTrans8x8HT, HighbdCoeffCheck) { RunBitexactCheck(); }
Yaowu Xuf883b422016-08-30 14:01:10 -0700163
164using std::tr1::make_tuple;
165
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100166#if HAVE_SSE2
Yaowu Xuf883b422016-08-30 14:01:10 -0700167const Ht8x8Param kArrayHt8x8Param_sse2[] = {
Urvang Joshi2283d372017-10-02 17:16:45 -0700168 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, DCT_DCT, AOM_BITS_8,
169 64),
170 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, ADST_DCT, AOM_BITS_8,
171 64),
172 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, DCT_ADST, AOM_BITS_8,
173 64),
174 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, ADST_ADST, AOM_BITS_8,
175 64),
Urvang Joshi2283d372017-10-02 17:16:45 -0700176 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, FLIPADST_DCT,
177 AOM_BITS_8, 64),
178 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, DCT_FLIPADST,
179 AOM_BITS_8, 64),
180 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, FLIPADST_FLIPADST,
181 AOM_BITS_8, 64),
182 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, ADST_FLIPADST,
183 AOM_BITS_8, 64),
184 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, FLIPADST_ADST,
185 AOM_BITS_8, 64),
186 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, IDTX, AOM_BITS_8, 64),
187 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, V_DCT, AOM_BITS_8, 64),
188 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, H_DCT, AOM_BITS_8, 64),
189 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, V_ADST, AOM_BITS_8, 64),
190 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, H_ADST, AOM_BITS_8, 64),
191 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, V_FLIPADST, AOM_BITS_8,
192 64),
193 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, H_FLIPADST, AOM_BITS_8,
194 64)
Yaowu Xuf883b422016-08-30 14:01:10 -0700195};
196INSTANTIATE_TEST_CASE_P(SSE2, AV1Trans8x8HT,
197 ::testing::ValuesIn(kArrayHt8x8Param_sse2));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200198#endif // HAVE_SSE2
Yaowu Xuf883b422016-08-30 14:01:10 -0700199
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100200#if HAVE_SSE4_1
Yaowu Xuf883b422016-08-30 14:01:10 -0700201const HighbdHt8x8Param kArrayHBDHt8x8Param_sse4_1[] = {
Urvang Joshi2283d372017-10-02 17:16:45 -0700202 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, DCT_DCT, 10),
203 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, DCT_DCT, 12),
204 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, ADST_DCT, 10),
205 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, ADST_DCT, 12),
206 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, DCT_ADST, 10),
207 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, DCT_ADST, 12),
208 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, ADST_ADST, 10),
209 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, ADST_ADST, 12),
Urvang Joshi2283d372017-10-02 17:16:45 -0700210 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, FLIPADST_DCT, 10),
211 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, FLIPADST_DCT, 12),
212 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, DCT_FLIPADST, 10),
213 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, DCT_FLIPADST, 12),
214 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, FLIPADST_FLIPADST, 10),
215 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, FLIPADST_FLIPADST, 12),
216 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, ADST_FLIPADST, 10),
217 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, ADST_FLIPADST, 12),
218 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, FLIPADST_ADST, 10),
219 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, FLIPADST_ADST, 12),
Yaowu Xuf883b422016-08-30 14:01:10 -0700220};
221INSTANTIATE_TEST_CASE_P(SSE4_1, AV1HighbdTrans8x8HT,
222 ::testing::ValuesIn(kArrayHBDHt8x8Param_sse4_1));
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100223#endif // HAVE_SSE4_1
Yaowu Xuf883b422016-08-30 14:01:10 -0700224
225} // namespace