blob: 24f4c780bf297841dcaa131877ac4b8e9a0ae8f3 [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 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> Ht16x16Param;
Yaowu Xuf883b422016-08-30 14:01:10 -070032
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
Yaowu Xuf883b422016-08-30 14:01:10 -070043typedef void (*IHbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride,
Urvang Joshi2283d372017-10-02 17:16:45 -070044 TX_TYPE tx_type, int bd);
Yaowu Xuf883b422016-08-30 14:01:10 -070045typedef void (*HbdHtFunc)(const int16_t *input, int32_t *output, int stride,
Urvang Joshi2283d372017-10-02 17:16:45 -070046 TX_TYPE tx_type, int bd);
Yaowu Xuf883b422016-08-30 14:01:10 -070047
48// Target optimized function, tx_type, bit depth
Urvang Joshi2283d372017-10-02 17:16:45 -070049typedef tuple<HbdHtFunc, TX_TYPE, int> HighbdHt16x16Param;
Yaowu Xuf883b422016-08-30 14:01:10 -070050
51void highbd_fht16x16_ref(const int16_t *in, int32_t *out, int stride,
Urvang Joshi2283d372017-10-02 17:16:45 -070052 TX_TYPE tx_type, int bd) {
Yaowu Xuf883b422016-08-30 14:01:10 -070053 av1_fwd_txfm2d_16x16_c(in, out, stride, tx_type, bd);
54}
Yaowu Xuf883b422016-08-30 14:01:10 -070055
56class AV1Trans16x16HT : public libaom_test::TransformTestBase,
57 public ::testing::TestWithParam<Ht16x16Param> {
58 public:
59 virtual ~AV1Trans16x16HT() {}
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_ = 16;
David Barker78250222016-10-13 15:10:14 +010065 height_ = 16;
Yaowu Xuf883b422016-08-30 14:01:10 -070066 fwd_txfm_ref = fht16x16_ref;
Yi Luo73172002016-10-28 10:52:04 -070067 inv_txfm_ref = iht16x16_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(AV1Trans16x16HT, MemCheck) { RunMemCheck(); }
Angie Chiange6aece82017-01-09 17:27:56 -080089TEST_P(AV1Trans16x16HT, AccuracyCheck) { RunAccuracyCheck(1, 0.001); }
Yi Luo8245b9a2016-11-17 14:56:43 -080090TEST_P(AV1Trans16x16HT, InvAccuracyCheck) { RunInvAccuracyCheck(1); }
Yaowu Xuf883b422016-08-30 14:01:10 -070091TEST_P(AV1Trans16x16HT, CoeffCheck) { RunCoeffCheck(); }
Yi Luo73172002016-10-28 10:52:04 -070092TEST_P(AV1Trans16x16HT, InvCoeffCheck) { RunInvCoeffCheck(); }
Yaowu Xuf883b422016-08-30 14:01:10 -070093
Yaowu Xuf883b422016-08-30 14:01:10 -070094class AV1HighbdTrans16x16HT
95 : public ::testing::TestWithParam<HighbdHt16x16Param> {
96 public:
97 virtual ~AV1HighbdTrans16x16HT() {}
98
99 virtual void SetUp() {
100 fwd_txfm_ = GET_PARAM(0);
101 fwd_txfm_ref_ = highbd_fht16x16_ref;
102 tx_type_ = GET_PARAM(1);
103 bit_depth_ = GET_PARAM(2);
104 mask_ = (1 << bit_depth_) - 1;
105 num_coeffs_ = 256;
106
107 input_ = reinterpret_cast<int16_t *>(
Yi Luoe8e8cd82016-09-21 10:45:01 -0700108 aom_memalign(32, sizeof(int16_t) * num_coeffs_));
Yaowu Xuf883b422016-08-30 14:01:10 -0700109 output_ = reinterpret_cast<int32_t *>(
Yi Luoe8e8cd82016-09-21 10:45:01 -0700110 aom_memalign(32, sizeof(int32_t) * num_coeffs_));
Yaowu Xuf883b422016-08-30 14:01:10 -0700111 output_ref_ = 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 }
114
115 virtual void TearDown() {
116 aom_free(input_);
117 aom_free(output_);
118 aom_free(output_ref_);
119 libaom_test::ClearSystemState();
120 }
121
122 protected:
123 void RunBitexactCheck();
124
125 private:
126 HbdHtFunc fwd_txfm_;
127 HbdHtFunc fwd_txfm_ref_;
Urvang Joshi2283d372017-10-02 17:16:45 -0700128 TX_TYPE tx_type_;
Yaowu Xuf883b422016-08-30 14:01:10 -0700129 int bit_depth_;
130 int mask_;
131 int num_coeffs_;
132 int16_t *input_;
133 int32_t *output_;
134 int32_t *output_ref_;
135};
136
137void AV1HighbdTrans16x16HT::RunBitexactCheck() {
138 ACMRandom rnd(ACMRandom::DeterministicSeed());
139 int i, j;
140 const int stride = 16;
141 const int num_tests = 1000;
142
143 for (i = 0; i < num_tests; ++i) {
144 for (j = 0; j < num_coeffs_; ++j) {
145 input_[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
146 }
147
148 fwd_txfm_ref_(input_, output_ref_, stride, tx_type_, bit_depth_);
149 ASM_REGISTER_STATE_CHECK(
150 fwd_txfm_(input_, output_, stride, tx_type_, bit_depth_));
151
152 for (j = 0; j < num_coeffs_; ++j) {
153 EXPECT_EQ(output_ref_[j], output_[j])
154 << "Not bit-exact result at index: " << j << " at test block: " << i;
155 }
156 }
157}
158
159TEST_P(AV1HighbdTrans16x16HT, HighbdCoeffCheck) { RunBitexactCheck(); }
Yaowu Xuf883b422016-08-30 14:01:10 -0700160
161using std::tr1::make_tuple;
162
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100163#if HAVE_SSE2
Yaowu Xuf883b422016-08-30 14:01:10 -0700164const Ht16x16Param kArrayHt16x16Param_sse2[] = {
Urvang Joshi2283d372017-10-02 17:16:45 -0700165 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, DCT_DCT,
166 AOM_BITS_8, 256),
167 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, ADST_DCT,
168 AOM_BITS_8, 256),
169 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, DCT_ADST,
170 AOM_BITS_8, 256),
171 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, ADST_ADST,
172 AOM_BITS_8, 256),
Urvang Joshi2283d372017-10-02 17:16:45 -0700173 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, FLIPADST_DCT,
174 AOM_BITS_8, 256),
175 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, DCT_FLIPADST,
176 AOM_BITS_8, 256),
177 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, FLIPADST_FLIPADST,
178 AOM_BITS_8, 256),
179 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, ADST_FLIPADST,
180 AOM_BITS_8, 256),
181 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, FLIPADST_ADST,
182 AOM_BITS_8, 256),
183 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, IDTX, AOM_BITS_8,
Yaowu Xuf883b422016-08-30 14:01:10 -0700184 256),
Urvang Joshi2283d372017-10-02 17:16:45 -0700185 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, V_DCT, AOM_BITS_8,
Yaowu Xuf883b422016-08-30 14:01:10 -0700186 256),
Urvang Joshi2283d372017-10-02 17:16:45 -0700187 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, H_DCT, AOM_BITS_8,
Yaowu Xuf883b422016-08-30 14:01:10 -0700188 256),
Urvang Joshi2283d372017-10-02 17:16:45 -0700189 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, V_ADST, AOM_BITS_8,
Yaowu Xuf883b422016-08-30 14:01:10 -0700190 256),
Urvang Joshi2283d372017-10-02 17:16:45 -0700191 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, H_ADST, AOM_BITS_8,
Yaowu Xuf883b422016-08-30 14:01:10 -0700192 256),
Urvang Joshi2283d372017-10-02 17:16:45 -0700193 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, V_FLIPADST,
194 AOM_BITS_8, 256),
195 make_tuple(&av1_fht16x16_sse2, &av1_iht16x16_256_add_sse2, H_FLIPADST,
196 AOM_BITS_8, 256)
Yaowu Xuf883b422016-08-30 14:01:10 -0700197};
198INSTANTIATE_TEST_CASE_P(SSE2, AV1Trans16x16HT,
199 ::testing::ValuesIn(kArrayHt16x16Param_sse2));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200200#endif // HAVE_SSE2
Yaowu Xuf883b422016-08-30 14:01:10 -0700201
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100202#if HAVE_AVX2
Yi Luoe8e8cd82016-09-21 10:45:01 -0700203const Ht16x16Param kArrayHt16x16Param_avx2[] = {
Urvang Joshi2283d372017-10-02 17:16:45 -0700204 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, DCT_DCT,
205 AOM_BITS_8, 256),
206 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, ADST_DCT,
207 AOM_BITS_8, 256),
208 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, DCT_ADST,
209 AOM_BITS_8, 256),
210 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, ADST_ADST,
211 AOM_BITS_8, 256),
Urvang Joshi2283d372017-10-02 17:16:45 -0700212 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, FLIPADST_DCT,
213 AOM_BITS_8, 256),
214 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, DCT_FLIPADST,
215 AOM_BITS_8, 256),
216 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, FLIPADST_FLIPADST,
217 AOM_BITS_8, 256),
218 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, ADST_FLIPADST,
219 AOM_BITS_8, 256),
220 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, FLIPADST_ADST,
221 AOM_BITS_8, 256),
222 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, IDTX, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700223 256),
Urvang Joshi2283d372017-10-02 17:16:45 -0700224 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, V_DCT, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700225 256),
Urvang Joshi2283d372017-10-02 17:16:45 -0700226 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, H_DCT, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700227 256),
Urvang Joshi2283d372017-10-02 17:16:45 -0700228 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, V_ADST, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700229 256),
Urvang Joshi2283d372017-10-02 17:16:45 -0700230 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, H_ADST, AOM_BITS_8,
Yi Luo73172002016-10-28 10:52:04 -0700231 256),
Urvang Joshi2283d372017-10-02 17:16:45 -0700232 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, V_FLIPADST,
233 AOM_BITS_8, 256),
234 make_tuple(&av1_fht16x16_avx2, &av1_iht16x16_256_add_avx2, H_FLIPADST,
235 AOM_BITS_8, 256)
Yi Luoe8e8cd82016-09-21 10:45:01 -0700236};
237INSTANTIATE_TEST_CASE_P(AVX2, AV1Trans16x16HT,
238 ::testing::ValuesIn(kArrayHt16x16Param_avx2));
Sebastien Alaiwanc6a48a22017-04-20 10:12:43 +0200239#endif // HAVE_AVX2
Yi Luoe8e8cd82016-09-21 10:45:01 -0700240
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100241#if HAVE_SSE4_1
Yaowu Xuf883b422016-08-30 14:01:10 -0700242const HighbdHt16x16Param kArrayHBDHt16x16Param_sse4_1[] = {
Urvang Joshi2283d372017-10-02 17:16:45 -0700243 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, DCT_DCT, 10),
244 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, DCT_DCT, 12),
245 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, ADST_DCT, 10),
246 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, ADST_DCT, 12),
247 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, DCT_ADST, 10),
248 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, DCT_ADST, 12),
249 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, ADST_ADST, 10),
250 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, ADST_ADST, 12),
Urvang Joshi2283d372017-10-02 17:16:45 -0700251 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, FLIPADST_DCT, 10),
252 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, FLIPADST_DCT, 12),
253 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, DCT_FLIPADST, 10),
254 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, DCT_FLIPADST, 12),
255 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, FLIPADST_FLIPADST, 10),
256 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, FLIPADST_FLIPADST, 12),
257 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, ADST_FLIPADST, 10),
258 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, ADST_FLIPADST, 12),
259 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, FLIPADST_ADST, 10),
260 make_tuple(&av1_fwd_txfm2d_16x16_sse4_1, FLIPADST_ADST, 12),
Yaowu Xuf883b422016-08-30 14:01:10 -0700261};
262INSTANTIATE_TEST_CASE_P(SSE4_1, AV1HighbdTrans16x16HT,
263 ::testing::ValuesIn(kArrayHBDHt16x16Param_sse4_1));
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100264#endif // HAVE_SSE4_1
Yaowu Xuf883b422016-08-30 14:01:10 -0700265
266} // namespace