2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
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.
12 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
14 #include "./av1_rtcd.h"
15 #include "./aom_dsp_rtcd.h"
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"
24 using libaom_test::ACMRandom
;
28 typedef void (*IhtFunc
)(const tran_low_t
*in
, uint8_t *out
, int stride
,
29 const TxfmParam
*txfm_param
);
31 using libaom_test::FhtFunc
;
32 using std::tr1::tuple
;
33 typedef tuple
<FhtFunc
, IhtFunc
, TX_TYPE
, aom_bit_depth_t
, int> Ht8x8Param
;
35 void fht8x8_ref(const int16_t *in
, tran_low_t
*out
, int stride
,
36 TxfmParam
*txfm_param
) {
37 av1_fht8x8_c(in
, out
, stride
, txfm_param
);
40 void iht8x8_ref(const tran_low_t
*in
, uint8_t *out
, int stride
,
41 const TxfmParam
*txfm_param
) {
42 av1_iht8x8_64_add_c(in
, out
, stride
, txfm_param
);
45 typedef void (*IHbdHtFunc
)(const tran_low_t
*in
, uint8_t *out
, int stride
,
46 TX_TYPE tx_type
, int bd
);
47 typedef void (*HbdHtFunc
)(const int16_t *input
, int32_t *output
, int stride
,
48 TX_TYPE tx_type
, int bd
);
49 // Target optimized function, tx_type, bit depth
50 typedef tuple
<HbdHtFunc
, TX_TYPE
, int> HighbdHt8x8Param
;
52 void highbd_fht8x8_ref(const int16_t *in
, int32_t *out
, int stride
,
53 TX_TYPE tx_type
, int bd
) {
54 av1_fwd_txfm2d_8x8_c(in
, out
, stride
, tx_type
, bd
);
57 class AV1Trans8x8HT
: public libaom_test::TransformTestBase
,
58 public ::testing::TestWithParam
<Ht8x8Param
> {
60 virtual ~AV1Trans8x8HT() {}
62 virtual void SetUp() {
63 fwd_txfm_
= GET_PARAM(0);
64 inv_txfm_
= GET_PARAM(1);
67 fwd_txfm_ref
= fht8x8_ref
;
68 inv_txfm_ref
= iht8x8_ref
;
69 bit_depth_
= GET_PARAM(3);
70 mask_
= (1 << bit_depth_
) - 1;
71 num_coeffs_
= GET_PARAM(4);
72 txfm_param_
.tx_type
= GET_PARAM(2);
74 virtual void TearDown() { libaom_test::ClearSystemState(); }
77 void RunFwdTxfm(const int16_t *in
, tran_low_t
*out
, int stride
) {
78 fwd_txfm_(in
, out
, stride
, &txfm_param_
);
81 void RunInvTxfm(const tran_low_t
*out
, uint8_t *dst
, int stride
) {
82 inv_txfm_(out
, dst
, stride
, &txfm_param_
);
89 TEST_P(AV1Trans8x8HT
, MemCheck
) { RunMemCheck(); }
90 TEST_P(AV1Trans8x8HT
, CoeffCheck
) { RunCoeffCheck(); }
92 // TODO(luoyi): Add tx_type, 9-15 for inverse transform.
93 // Need cleanup since same tests may be done in fdct8x8_test.cc
94 // TEST_P(AV1Trans8x8HT, AccuracyCheck) { RunAccuracyCheck(0); }
95 // TEST_P(AV1Trans8x8HT, InvAccuracyCheck) { RunInvAccuracyCheck(0); }
96 // TEST_P(AV1Trans8x8HT, InvCoeffCheck) { RunInvCoeffCheck(); }
98 class AV1HighbdTrans8x8HT
: public ::testing::TestWithParam
<HighbdHt8x8Param
> {
100 virtual ~AV1HighbdTrans8x8HT() {}
102 virtual void SetUp() {
103 fwd_txfm_
= GET_PARAM(0);
104 fwd_txfm_ref_
= highbd_fht8x8_ref
;
105 tx_type_
= GET_PARAM(1);
106 bit_depth_
= GET_PARAM(2);
107 mask_
= (1 << bit_depth_
) - 1;
110 input_
= reinterpret_cast<int16_t *>(
111 aom_memalign(16, sizeof(int16_t) * num_coeffs_
));
112 output_
= reinterpret_cast<int32_t *>(
113 aom_memalign(16, sizeof(int32_t) * num_coeffs_
));
114 output_ref_
= reinterpret_cast<int32_t *>(
115 aom_memalign(16, sizeof(int32_t) * num_coeffs_
));
118 virtual void TearDown() {
121 aom_free(output_ref_
);
122 libaom_test::ClearSystemState();
126 void RunBitexactCheck();
130 HbdHtFunc fwd_txfm_ref_
;
137 int32_t *output_ref_
;
140 void AV1HighbdTrans8x8HT::RunBitexactCheck() {
141 ACMRandom
rnd(ACMRandom::DeterministicSeed());
143 const int stride
= 8;
144 const int num_tests
= 1000;
145 const int num_coeffs
= 64;
147 for (i
= 0; i
< num_tests
; ++i
) {
148 for (j
= 0; j
< num_coeffs
; ++j
) {
149 input_
[j
] = (rnd
.Rand16() & mask_
) - (rnd
.Rand16() & mask_
);
152 fwd_txfm_ref_(input_
, output_ref_
, stride
, tx_type_
, bit_depth_
);
153 ASM_REGISTER_STATE_CHECK(
154 fwd_txfm_(input_
, output_
, stride
, tx_type_
, bit_depth_
));
156 for (j
= 0; j
< num_coeffs
; ++j
) {
157 EXPECT_EQ(output_ref_
[j
], output_
[j
])
158 << "Not bit-exact result at index: " << j
<< " at test block: " << i
;
163 TEST_P(AV1HighbdTrans8x8HT
, HighbdCoeffCheck
) { RunBitexactCheck(); }
165 using std::tr1::make_tuple
;
167 #if HAVE_SSE2 && !CONFIG_DAALA_TX8
168 const Ht8x8Param kArrayHt8x8Param_sse2
[] = {
169 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, DCT_DCT
, AOM_BITS_8
,
171 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, ADST_DCT
, AOM_BITS_8
,
173 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, DCT_ADST
, AOM_BITS_8
,
175 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, ADST_ADST
, AOM_BITS_8
,
177 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, FLIPADST_DCT
,
179 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, DCT_FLIPADST
,
181 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, FLIPADST_FLIPADST
,
183 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, ADST_FLIPADST
,
185 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, FLIPADST_ADST
,
187 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, IDTX
, AOM_BITS_8
, 64),
188 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, V_DCT
, AOM_BITS_8
, 64),
189 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, H_DCT
, AOM_BITS_8
, 64),
190 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, V_ADST
, AOM_BITS_8
, 64),
191 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, H_ADST
, AOM_BITS_8
, 64),
192 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, V_FLIPADST
, AOM_BITS_8
,
194 make_tuple(&av1_fht8x8_sse2
, &av1_iht8x8_64_add_sse2
, H_FLIPADST
, AOM_BITS_8
,
197 INSTANTIATE_TEST_CASE_P(SSE2
, AV1Trans8x8HT
,
198 ::testing::ValuesIn(kArrayHt8x8Param_sse2
));
201 #if HAVE_SSE4_1 && !CONFIG_DAALA_TX8
202 const HighbdHt8x8Param kArrayHBDHt8x8Param_sse4_1
[] = {
203 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, DCT_DCT
, 10),
204 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, DCT_DCT
, 12),
205 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, ADST_DCT
, 10),
206 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, ADST_DCT
, 12),
207 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, DCT_ADST
, 10),
208 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, DCT_ADST
, 12),
209 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, ADST_ADST
, 10),
210 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, ADST_ADST
, 12),
211 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, FLIPADST_DCT
, 10),
212 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, FLIPADST_DCT
, 12),
213 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, DCT_FLIPADST
, 10),
214 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, DCT_FLIPADST
, 12),
215 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, FLIPADST_FLIPADST
, 10),
216 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, FLIPADST_FLIPADST
, 12),
217 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, ADST_FLIPADST
, 10),
218 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, ADST_FLIPADST
, 12),
219 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, FLIPADST_ADST
, 10),
220 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1
, FLIPADST_ADST
, 12),
222 INSTANTIATE_TEST_CASE_P(SSE4_1
, AV1HighbdTrans8x8HT
,
223 ::testing::ValuesIn(kArrayHBDHt8x8Param_sse4_1
));
224 #endif // HAVE_SSE4_1 && !CONFIG_DAALA_TX8
227 #endif // !CONFIG_DAALA_TX