blob: 075646c71376f5e97ea4f574de06f2f39d78c8a9 [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);
28using std::tr1::tuple;
29using libaom_test::FhtFunc;
30typedef tuple<FhtFunc, IhtFunc, int, aom_bit_depth_t, int> Ht4x4Param;
31
32void fht4x4_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
33 av1_fht4x4_c(in, out, stride, tx_type);
34}
35
36#if CONFIG_AOM_HIGHBITDEPTH
37typedef void (*IhighbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride,
38 int tx_type, int bd);
39typedef void (*HBDFhtFunc)(const int16_t *input, int32_t *output, int stride,
40 int tx_type, int bd);
41
42// HighbdHt4x4Param argument list:
43// <Target optimized function, tx_type, bit depth>
44typedef tuple<HBDFhtFunc, int, int> HighbdHt4x4Param;
45
46void highbe_fht4x4_ref(const int16_t *in, int32_t *out, int stride, int tx_type,
47 int bd) {
48 av1_fwd_txfm2d_4x4_c(in, out, stride, tx_type, bd);
49}
50#endif // CONFIG_AOM_HIGHBITDEPTH
51
52class AV1Trans4x4HT : public libaom_test::TransformTestBase,
53 public ::testing::TestWithParam<Ht4x4Param> {
54 public:
55 virtual ~AV1Trans4x4HT() {}
56
57 virtual void SetUp() {
58 fwd_txfm_ = GET_PARAM(0);
59 inv_txfm_ = GET_PARAM(1);
60 tx_type_ = GET_PARAM(2);
61 pitch_ = 4;
David Barker78250222016-10-13 15:10:14 +010062 height_ = 4;
Yaowu Xuf883b422016-08-30 14:01:10 -070063 fwd_txfm_ref = fht4x4_ref;
64 bit_depth_ = GET_PARAM(3);
65 mask_ = (1 << bit_depth_) - 1;
66 num_coeffs_ = GET_PARAM(4);
67 }
68 virtual void TearDown() { libaom_test::ClearSystemState(); }
69
70 protected:
71 void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
72 fwd_txfm_(in, out, stride, tx_type_);
73 }
74
75 void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
76 inv_txfm_(out, dst, stride, tx_type_);
77 }
78
79 FhtFunc fwd_txfm_;
80 IhtFunc inv_txfm_;
81};
82
83TEST_P(AV1Trans4x4HT, CoeffCheck) { RunCoeffCheck(); }
84
85#if CONFIG_AOM_HIGHBITDEPTH
86class AV1HighbdTrans4x4HT : public ::testing::TestWithParam<HighbdHt4x4Param> {
87 public:
88 virtual ~AV1HighbdTrans4x4HT() {}
89
90 virtual void SetUp() {
91 fwd_txfm_ = GET_PARAM(0);
92 fwd_txfm_ref_ = highbe_fht4x4_ref;
93 tx_type_ = GET_PARAM(1);
94 bit_depth_ = GET_PARAM(2);
95 mask_ = (1 << bit_depth_) - 1;
96 num_coeffs_ = 16;
97
98 input_ = reinterpret_cast<int16_t *>(
99 aom_memalign(16, sizeof(int16_t) * num_coeffs_));
100 output_ = reinterpret_cast<int32_t *>(
101 aom_memalign(16, sizeof(int32_t) * num_coeffs_));
102 output_ref_ = reinterpret_cast<int32_t *>(
103 aom_memalign(16, sizeof(int32_t) * num_coeffs_));
104 }
105
106 virtual void TearDown() {
107 aom_free(input_);
108 aom_free(output_);
109 aom_free(output_ref_);
110 libaom_test::ClearSystemState();
111 }
112
113 protected:
114 void RunBitexactCheck();
115
116 private:
117 HBDFhtFunc fwd_txfm_;
118 HBDFhtFunc fwd_txfm_ref_;
119 int tx_type_;
120 int bit_depth_;
121 int mask_;
122 int num_coeffs_;
123 int16_t *input_;
124 int32_t *output_;
125 int32_t *output_ref_;
126};
127
128void AV1HighbdTrans4x4HT::RunBitexactCheck() {
129 ACMRandom rnd(ACMRandom::DeterministicSeed());
130 int i, j;
131 const int stride = 4;
132 const int num_tests = 1000;
133 const int num_coeffs = 16;
134
135 for (i = 0; i < num_tests; ++i) {
136 for (j = 0; j < num_coeffs; ++j) {
137 input_[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
138 }
139
140 fwd_txfm_ref_(input_, output_ref_, stride, tx_type_, bit_depth_);
141 fwd_txfm_(input_, output_, stride, tx_type_, bit_depth_);
142
143 for (j = 0; j < num_coeffs; ++j) {
144 EXPECT_EQ(output_[j], output_ref_[j])
145 << "Not bit-exact result at index: " << j << " at test block: " << i;
146 }
147 }
148}
149
150TEST_P(AV1HighbdTrans4x4HT, HighbdCoeffCheck) { RunBitexactCheck(); }
151#endif // CONFIG_AOM_HIGHBITDEPTH
152
153using std::tr1::make_tuple;
154
155#if HAVE_SSE2
156const Ht4x4Param kArrayHt4x4Param_sse2[] = {
157 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 0, AOM_BITS_8, 16),
158 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 1, AOM_BITS_8, 16),
159 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 2, AOM_BITS_8, 16),
160 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 3, AOM_BITS_8, 16),
161#if CONFIG_EXT_TX
162 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 4, AOM_BITS_8, 16),
163 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 5, AOM_BITS_8, 16),
164 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 6, AOM_BITS_8, 16),
165 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 7, AOM_BITS_8, 16),
166 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 8, AOM_BITS_8, 16),
167 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 10, AOM_BITS_8, 16),
168 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 11, AOM_BITS_8, 16),
169 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 12, AOM_BITS_8, 16),
170 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 13, AOM_BITS_8, 16),
171 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 14, AOM_BITS_8, 16),
172 make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_sse2, 15, AOM_BITS_8, 16)
173#endif // CONFIG_EXT_TX
174};
175INSTANTIATE_TEST_CASE_P(SSE2, AV1Trans4x4HT,
176 ::testing::ValuesIn(kArrayHt4x4Param_sse2));
177#endif // HAVE_SSE2
178
179#if HAVE_SSE4_1 && CONFIG_AOM_HIGHBITDEPTH
180const HighbdHt4x4Param kArrayHighbdHt4x4Param[] = {
181 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 0, 10),
182 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 0, 12),
183 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 1, 10),
184 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 1, 12),
185 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 2, 10),
186 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 2, 12),
187 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 3, 10),
188 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 3, 12),
189#if CONFIG_EXT_TX
190 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 4, 10),
191 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 4, 12),
192 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 5, 10),
193 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 5, 12),
194 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 6, 10),
195 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 6, 12),
196 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 7, 10),
197 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 7, 12),
198 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 8, 10),
199 make_tuple(&av1_fwd_txfm2d_4x4_sse4_1, 8, 12),
200#endif // CONFIG_EXT_TX
201};
202
203INSTANTIATE_TEST_CASE_P(SSE4_1, AV1HighbdTrans4x4HT,
204 ::testing::ValuesIn(kArrayHighbdHt4x4Param));
205
206#endif // HAVE_SSE4_1 && CONFIG_AOM_HIGHBITDEPTH
207
208} // namespace