blob: 54cb405e28e3be56344a971299ba344a9aae9f05 [file] [log] [blame]
Yaowu Xuf883b422016-08-30 14:01:10 -07001/*
2 * Copyright (c) 2016 The WebM project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "third_party/googletest/src/include/gtest/gtest.h"
12
13#include "./av1_rtcd.h"
14#include "./aom_dsp_rtcd.h"
15
16#include "test/acm_random.h"
17#include "test/clear_system_state.h"
18#include "test/register_state_check.h"
19#include "test/transform_test_base.h"
20#include "test/util.h"
21#include "aom_ports/mem.h"
22
23using libaom_test::ACMRandom;
24
25namespace {
26typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
27 int tx_type);
28
29using libaom_test::FhtFunc;
30using std::tr1::tuple;
31typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht8x8Param;
32
33void fht8x8_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
34 av1_fht8x8_c(in, out, stride, tx_type);
35}
36
37#if CONFIG_AOM_HIGHBITDEPTH
38typedef void (*IHbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride,
39 int tx_type, int bd);
40typedef void (*HbdHtFunc)(const int16_t *input, int32_t *output, int stride,
41 int tx_type, int bd);
42// Target optimized function, tx_type, bit depth
43typedef tuple<HbdHtFunc, int, int> HighbdHt8x8Param;
44
45void highbd_fht8x8_ref(const int16_t *in, int32_t *out, int stride, int tx_type,
46 int bd) {
47 av1_fwd_txfm2d_8x8_c(in, out, stride, tx_type, bd);
48}
49#endif // CONFIG_AOM_HIGHBITDEPTH
50
51class AV1Trans8x8HT : public libaom_test::TransformTestBase,
52 public ::testing::TestWithParam<Ht8x8Param> {
53 public:
54 virtual ~AV1Trans8x8HT() {}
55
56 virtual void SetUp() {
57 fwd_txfm_ = GET_PARAM(0);
58 inv_txfm_ = GET_PARAM(1);
59 tx_type_ = GET_PARAM(2);
60 pitch_ = 8;
David Barker78250222016-10-13 15:10:14 +010061 height_ = 8;
Yaowu Xuf883b422016-08-30 14:01:10 -070062 fwd_txfm_ref = fht8x8_ref;
63 bit_depth_ = GET_PARAM(3);
64 mask_ = (1 << bit_depth_) - 1;
65 num_coeffs_ = GET_PARAM(4);
66 }
67 virtual void TearDown() { libaom_test::ClearSystemState(); }
68
69 protected:
70 void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
71 fwd_txfm_(in, out, stride, tx_type_);
72 }
73
74 void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
75 inv_txfm_(out, dst, stride, tx_type_);
76 }
77
78 FhtFunc fwd_txfm_;
79 IhtFunc inv_txfm_;
80};
81
82TEST_P(AV1Trans8x8HT, CoeffCheck) { RunCoeffCheck(); }
83
84#if CONFIG_AOM_HIGHBITDEPTH
85class AV1HighbdTrans8x8HT : public ::testing::TestWithParam<HighbdHt8x8Param> {
86 public:
87 virtual ~AV1HighbdTrans8x8HT() {}
88
89 virtual void SetUp() {
90 fwd_txfm_ = GET_PARAM(0);
91 fwd_txfm_ref_ = highbd_fht8x8_ref;
92 tx_type_ = GET_PARAM(1);
93 bit_depth_ = GET_PARAM(2);
94 mask_ = (1 << bit_depth_) - 1;
95 num_coeffs_ = 64;
96
97 input_ = reinterpret_cast<int16_t *>(
98 aom_memalign(16, sizeof(int16_t) * num_coeffs_));
99 output_ = reinterpret_cast<int32_t *>(
100 aom_memalign(16, sizeof(int32_t) * num_coeffs_));
101 output_ref_ = reinterpret_cast<int32_t *>(
102 aom_memalign(16, sizeof(int32_t) * num_coeffs_));
103 }
104
105 virtual void TearDown() {
106 aom_free(input_);
107 aom_free(output_);
108 aom_free(output_ref_);
109 libaom_test::ClearSystemState();
110 }
111
112 protected:
113 void RunBitexactCheck();
114
115 private:
116 HbdHtFunc fwd_txfm_;
117 HbdHtFunc fwd_txfm_ref_;
118 int tx_type_;
119 int bit_depth_;
120 int mask_;
121 int num_coeffs_;
122 int16_t *input_;
123 int32_t *output_;
124 int32_t *output_ref_;
125};
126
127void AV1HighbdTrans8x8HT::RunBitexactCheck() {
128 ACMRandom rnd(ACMRandom::DeterministicSeed());
129 int i, j;
130 const int stride = 8;
131 const int num_tests = 1000;
132 const int num_coeffs = 64;
133
134 for (i = 0; i < num_tests; ++i) {
135 for (j = 0; j < num_coeffs; ++j) {
136 input_[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
137 }
138
139 fwd_txfm_ref_(input_, output_ref_, stride, tx_type_, bit_depth_);
140 ASM_REGISTER_STATE_CHECK(
141 fwd_txfm_(input_, output_, stride, tx_type_, bit_depth_));
142
143 for (j = 0; j < num_coeffs; ++j) {
144 EXPECT_EQ(output_ref_[j], output_[j])
145 << "Not bit-exact result at index: " << j << " at test block: " << i;
146 }
147 }
148}
149
150TEST_P(AV1HighbdTrans8x8HT, HighbdCoeffCheck) { RunBitexactCheck(); }
151#endif // CONFIG_AOM_HIGHBITDEPTH
152
153using std::tr1::make_tuple;
154
155#if HAVE_SSE2
156const Ht8x8Param kArrayHt8x8Param_sse2[] = {
157 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 0, AOM_BITS_8, 64),
158 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 1, AOM_BITS_8, 64),
159 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 2, AOM_BITS_8, 64),
160 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 3, AOM_BITS_8, 64),
161#if CONFIG_EXT_TX
162 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 4, AOM_BITS_8, 64),
163 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 5, AOM_BITS_8, 64),
164 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 6, AOM_BITS_8, 64),
165 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 7, AOM_BITS_8, 64),
166 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 8, AOM_BITS_8, 64),
167 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 10, AOM_BITS_8, 64),
168 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 11, AOM_BITS_8, 64),
169 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 12, AOM_BITS_8, 64),
170 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 13, AOM_BITS_8, 64),
171 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 14, AOM_BITS_8, 64),
172 make_tuple(&av1_fht8x8_sse2, &av1_iht8x8_64_add_sse2, 15, AOM_BITS_8, 64)
173#endif // CONFIG_EXT_TX
174};
175INSTANTIATE_TEST_CASE_P(SSE2, AV1Trans8x8HT,
176 ::testing::ValuesIn(kArrayHt8x8Param_sse2));
177#endif // HAVE_SSE2
178
179#if HAVE_SSE4_1 && CONFIG_AOM_HIGHBITDEPTH
180const HighbdHt8x8Param kArrayHBDHt8x8Param_sse4_1[] = {
181 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 0, 10),
182 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 0, 12),
183 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 1, 10),
184 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 1, 12),
185 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 2, 10),
186 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 2, 12),
187 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 3, 10),
188 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 3, 12),
189#if CONFIG_EXT_TX
190 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 4, 10),
191 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 4, 12),
192 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 5, 10),
193 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 5, 12),
194 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 6, 10),
195 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 6, 12),
196 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 7, 10),
197 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 7, 12),
198 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 8, 10),
199 make_tuple(&av1_fwd_txfm2d_8x8_sse4_1, 8, 12),
200#endif // CONFIG_EXT_TX
201};
202INSTANTIATE_TEST_CASE_P(SSE4_1, AV1HighbdTrans8x8HT,
203 ::testing::ValuesIn(kArrayHBDHt8x8Param_sse4_1));
204#endif // HAVE_SSE4_1 && CONFIG_AOM_HIGHBITDEPTH
205
206} // namespace