blob: b31d2f4931704ba05b00bf184ec430d2613c3d02 [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,
Lester Lu27319b62017-07-10 16:57:15 -070028 const TxfmParam *txfm_param);
Yi Luofed8e1c2016-10-07 09:46:05 -070029using libaom_test::FhtFunc;
Johann123e8a62017-12-28 14:40:49 -080030using std::tr1::tuple;
Urvang Joshi2283d372017-10-02 17:16:45 -070031typedef tuple<FhtFunc, IhtFunc, TX_TYPE, aom_bit_depth_t, int> Ht32x32Param;
Yi Luofed8e1c2016-10-07 09:46:05 -070032
Lester Lud8b1ddc2017-07-06 16:13:29 -070033void fht32x32_ref(const int16_t *in, tran_low_t *out, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070034 TxfmParam *txfm_param) {
35 av1_fht32x32_c(in, out, stride, txfm_param);
Yi Luofed8e1c2016-10-07 09:46:05 -070036}
37
Yi Luofed8e1c2016-10-07 09:46:05 -070038typedef void (*IHbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride,
Urvang Joshi2283d372017-10-02 17:16:45 -070039 TX_TYPE tx_type, int bd);
Yi Luofed8e1c2016-10-07 09:46:05 -070040typedef void (*HbdHtFunc)(const int16_t *input, int32_t *output, int stride,
Urvang Joshi2283d372017-10-02 17:16:45 -070041 TX_TYPE tx_type, int bd);
Yi Luofed8e1c2016-10-07 09:46:05 -070042
43// Target optimized function, tx_type, bit depth
Urvang Joshi2283d372017-10-02 17:16:45 -070044typedef tuple<HbdHtFunc, TX_TYPE, int> HighbdHt32x32Param;
Yi Luofed8e1c2016-10-07 09:46:05 -070045
46void highbd_fht32x32_ref(const int16_t *in, int32_t *out, int stride,
Urvang Joshi2283d372017-10-02 17:16:45 -070047 TX_TYPE tx_type, int bd) {
Yi Luofed8e1c2016-10-07 09:46:05 -070048 av1_fwd_txfm2d_32x32_c(in, out, stride, tx_type, bd);
49}
Yi Luofed8e1c2016-10-07 09:46:05 -070050
Sebastien Alaiwan58596362018-01-26 10:11:35 +010051#if (HAVE_SSE2 || HAVE_AVX2)
Yi Luofed8e1c2016-10-07 09:46:05 -070052void dummy_inv_txfm(const tran_low_t *in, uint8_t *out, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070053 const TxfmParam *txfm_param) {
Yi Luofed8e1c2016-10-07 09:46:05 -070054 (void)in;
55 (void)out;
56 (void)stride;
Lester Lu27319b62017-07-10 16:57:15 -070057 (void)txfm_param;
Yi Luofed8e1c2016-10-07 09:46:05 -070058}
59#endif
60
61class AV1Trans32x32HT : public libaom_test::TransformTestBase,
62 public ::testing::TestWithParam<Ht32x32Param> {
63 public:
64 virtual ~AV1Trans32x32HT() {}
65
66 virtual void SetUp() {
67 fwd_txfm_ = GET_PARAM(0);
68 inv_txfm_ = GET_PARAM(1);
Yi Luofed8e1c2016-10-07 09:46:05 -070069 pitch_ = 32;
Yi Luo157e45a2016-10-17 11:18:50 -070070 height_ = 32;
Yi Luofed8e1c2016-10-07 09:46:05 -070071 fwd_txfm_ref = fht32x32_ref;
72 bit_depth_ = GET_PARAM(3);
73 mask_ = (1 << bit_depth_) - 1;
74 num_coeffs_ = GET_PARAM(4);
Lester Lu27319b62017-07-10 16:57:15 -070075 txfm_param_.tx_type = GET_PARAM(2);
Yi Luofed8e1c2016-10-07 09:46:05 -070076 }
77 virtual void TearDown() { libaom_test::ClearSystemState(); }
78
79 protected:
80 void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
Lester Lu27319b62017-07-10 16:57:15 -070081 fwd_txfm_(in, out, stride, &txfm_param_);
Yi Luofed8e1c2016-10-07 09:46:05 -070082 }
83
84 void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
Lester Lu27319b62017-07-10 16:57:15 -070085 inv_txfm_(out, dst, stride, &txfm_param_);
Yi Luofed8e1c2016-10-07 09:46:05 -070086 }
87
88 FhtFunc fwd_txfm_;
89 IhtFunc inv_txfm_;
90};
91
92TEST_P(AV1Trans32x32HT, CoeffCheck) { RunCoeffCheck(); }
Yi Luo157e45a2016-10-17 11:18:50 -070093TEST_P(AV1Trans32x32HT, MemCheck) { RunMemCheck(); }
Yi Luofed8e1c2016-10-07 09:46:05 -070094
Yi Luofed8e1c2016-10-07 09:46:05 -070095class AV1HighbdTrans32x32HT
96 : public ::testing::TestWithParam<HighbdHt32x32Param> {
97 public:
98 virtual ~AV1HighbdTrans32x32HT() {}
99
100 virtual void SetUp() {
101 fwd_txfm_ = GET_PARAM(0);
102 fwd_txfm_ref_ = highbd_fht32x32_ref;
103 tx_type_ = GET_PARAM(1);
104 bit_depth_ = GET_PARAM(2);
105 mask_ = (1 << bit_depth_) - 1;
106 num_coeffs_ = 1024;
107
108 input_ = reinterpret_cast<int16_t *>(
109 aom_memalign(32, sizeof(int16_t) * num_coeffs_));
110 output_ = reinterpret_cast<int32_t *>(
111 aom_memalign(32, sizeof(int32_t) * num_coeffs_));
112 output_ref_ = reinterpret_cast<int32_t *>(
113 aom_memalign(32, sizeof(int32_t) * num_coeffs_));
114 }
115
116 virtual void TearDown() {
117 aom_free(input_);
118 aom_free(output_);
119 aom_free(output_ref_);
120 libaom_test::ClearSystemState();
121 }
122
123 protected:
124 void RunBitexactCheck();
125
126 private:
127 HbdHtFunc fwd_txfm_;
128 HbdHtFunc fwd_txfm_ref_;
Urvang Joshi2283d372017-10-02 17:16:45 -0700129 TX_TYPE tx_type_;
Yi Luofed8e1c2016-10-07 09:46:05 -0700130 int bit_depth_;
131 int mask_;
132 int num_coeffs_;
133 int16_t *input_;
134 int32_t *output_;
135 int32_t *output_ref_;
136};
137
138void AV1HighbdTrans32x32HT::RunBitexactCheck() {
139 ACMRandom rnd(ACMRandom::DeterministicSeed());
140 int i, j;
141 const int stride = 32;
142 const int num_tests = 1000;
143
144 for (i = 0; i < num_tests; ++i) {
145 for (j = 0; j < num_coeffs_; ++j) {
146 input_[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
147 }
148
149 fwd_txfm_ref_(input_, output_ref_, stride, tx_type_, bit_depth_);
150 ASM_REGISTER_STATE_CHECK(
151 fwd_txfm_(input_, output_, stride, tx_type_, bit_depth_));
152
153 for (j = 0; j < num_coeffs_; ++j) {
154 EXPECT_EQ(output_ref_[j], output_[j])
155 << "Not bit-exact result at index: " << j << " at test block: " << i;
156 }
157 }
158}
159
160TEST_P(AV1HighbdTrans32x32HT, HighbdCoeffCheck) { RunBitexactCheck(); }
Yi Luofed8e1c2016-10-07 09:46:05 -0700161
162using std::tr1::make_tuple;
163
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100164#if HAVE_SSE2
Yi Luo9a3d29e2017-03-29 11:40:03 -0700165const Ht32x32Param kArrayHt32x32Param_sse2[] = {
Urvang Joshi2283d372017-10-02 17:16:45 -0700166 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, DCT_DCT, AOM_BITS_8, 1024),
167 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, ADST_DCT, AOM_BITS_8, 1024),
168 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, DCT_ADST, AOM_BITS_8, 1024),
169 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, ADST_ADST, AOM_BITS_8, 1024),
Urvang Joshi2283d372017-10-02 17:16:45 -0700170 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, FLIPADST_DCT, AOM_BITS_8,
171 1024),
172 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, DCT_FLIPADST, AOM_BITS_8,
173 1024),
174 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, FLIPADST_FLIPADST, AOM_BITS_8,
175 1024),
176 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, ADST_FLIPADST, AOM_BITS_8,
177 1024),
178 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, FLIPADST_ADST, AOM_BITS_8,
179 1024),
180 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, IDTX, AOM_BITS_8, 1024),
181 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, V_DCT, AOM_BITS_8, 1024),
182 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, H_DCT, AOM_BITS_8, 1024),
183 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, V_ADST, AOM_BITS_8, 1024),
184 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, H_ADST, AOM_BITS_8, 1024),
185 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, V_FLIPADST, AOM_BITS_8, 1024),
186 make_tuple(&av1_fht32x32_sse2, &dummy_inv_txfm, H_FLIPADST, AOM_BITS_8, 1024)
Yi Luo9a3d29e2017-03-29 11:40:03 -0700187};
188INSTANTIATE_TEST_CASE_P(SSE2, AV1Trans32x32HT,
189 ::testing::ValuesIn(kArrayHt32x32Param_sse2));
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100190#endif // HAVE_SSE2
Yi Luo9a3d29e2017-03-29 11:40:03 -0700191
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100192#if HAVE_AVX2
Yi Luofed8e1c2016-10-07 09:46:05 -0700193const Ht32x32Param kArrayHt32x32Param_avx2[] = {
Urvang Joshi2283d372017-10-02 17:16:45 -0700194 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, DCT_DCT, AOM_BITS_8, 1024),
195 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, ADST_DCT, AOM_BITS_8, 1024),
196 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, DCT_ADST, AOM_BITS_8, 1024),
197 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, ADST_ADST, AOM_BITS_8, 1024),
Urvang Joshi2283d372017-10-02 17:16:45 -0700198 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, FLIPADST_DCT, AOM_BITS_8,
199 1024),
200 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, DCT_FLIPADST, AOM_BITS_8,
201 1024),
202 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, FLIPADST_FLIPADST, AOM_BITS_8,
203 1024),
204 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, ADST_FLIPADST, AOM_BITS_8,
205 1024),
206 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, FLIPADST_ADST, AOM_BITS_8,
207 1024),
208 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, IDTX, AOM_BITS_8, 1024),
209 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, V_DCT, AOM_BITS_8, 1024),
210 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, H_DCT, AOM_BITS_8, 1024),
211 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, V_ADST, AOM_BITS_8, 1024),
212 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, H_ADST, AOM_BITS_8, 1024),
213 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, V_FLIPADST, AOM_BITS_8, 1024),
214 make_tuple(&av1_fht32x32_avx2, &dummy_inv_txfm, H_FLIPADST, AOM_BITS_8, 1024)
Yi Luofed8e1c2016-10-07 09:46:05 -0700215};
216INSTANTIATE_TEST_CASE_P(AVX2, AV1Trans32x32HT,
217 ::testing::ValuesIn(kArrayHt32x32Param_avx2));
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100218#endif // HAVE_AVX2
Yi Luofed8e1c2016-10-07 09:46:05 -0700219} // namespace