fdct4x4_test.cc 12.8 KB
Newer Older
Daniel Kang's avatar
Daniel Kang committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*
 *  Copyright (c) 2012 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include <math.h>
#include <stdlib.h>
#include <string.h>

#include "third_party/googletest/src/include/gtest/gtest.h"
16

Yaowu Xu's avatar
Yaowu Xu committed
17
#include "./vp10_rtcd.h"
18
#include "./vpx_dsp_rtcd.h"
19
20
21
#include "test/acm_random.h"
#include "test/clear_system_state.h"
#include "test/register_state_check.h"
Yi Luo's avatar
Yi Luo committed
22
#include "test/transform_test_base.h"
23
#include "test/util.h"
Yaowu Xu's avatar
Yaowu Xu committed
24
#include "vp10/common/entropy.h"
25
#include "vpx/vpx_codec.h"
26
#include "vpx/vpx_integer.h"
27
#include "vpx_ports/mem.h"
28

Daniel Kang's avatar
Daniel Kang committed
29
using libvpx_test::ACMRandom;
Daniel Kang's avatar
Daniel Kang committed
30

Daniel Kang's avatar
Daniel Kang committed
31
namespace {
32
33
34
typedef void (*FdctFunc)(const int16_t *in, tran_low_t *out, int stride);
typedef void (*IdctFunc)(const tran_low_t *in, uint8_t *out, int stride);
typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
35
                        int tx_type);
Yi Luo's avatar
Yi Luo committed
36
using libvpx_test::FhtFunc;
37

Yi Luo's avatar
Yi Luo committed
38
typedef std::tr1::tuple<FdctFunc, IdctFunc, int, vpx_bit_depth_t, int>
clang-format's avatar
clang-format committed
39
40
    Dct4x4Param;
typedef std::tr1::tuple<FhtFunc, IhtFunc, int, vpx_bit_depth_t, int> Ht4x4Param;
41

42
void fdct4x4_ref(const int16_t *in, tran_low_t *out, int stride,
43
                 int /*tx_type*/) {
44
  vpx_fdct4x4_c(in, out, stride);
Jingning Han's avatar
Jingning Han committed
45
}
46

47
void fht4x4_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
Yaowu Xu's avatar
Yaowu Xu committed
48
  vp10_fht4x4_c(in, out, stride, tx_type);
Jingning Han's avatar
Jingning Han committed
49
50
}

51
void fwht4x4_ref(const int16_t *in, tran_low_t *out, int stride,
52
                 int /*tx_type*/) {
Yaowu Xu's avatar
Yaowu Xu committed
53
  vp10_fwht4x4_c(in, out, stride);
Alex Converse's avatar
Alex Converse committed
54
55
}

56
57
#if CONFIG_VP9_HIGHBITDEPTH
void idct4x4_10(const tran_low_t *in, uint8_t *out, int stride) {
58
  vpx_highbd_idct4x4_16_add_c(in, out, stride, 10);
59
60
61
}

void idct4x4_12(const tran_low_t *in, uint8_t *out, int stride) {
62
  vpx_highbd_idct4x4_16_add_c(in, out, stride, 12);
63
64
65
}

void iht4x4_10(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
Yaowu Xu's avatar
Yaowu Xu committed
66
  vp10_highbd_iht4x4_16_add_c(in, out, stride, tx_type, 10);
67
68
69
}

void iht4x4_12(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
Yaowu Xu's avatar
Yaowu Xu committed
70
  vp10_highbd_iht4x4_16_add_c(in, out, stride, tx_type, 12);
71
72
73
}

void iwht4x4_10(const tran_low_t *in, uint8_t *out, int stride) {
74
  vpx_highbd_iwht4x4_16_add_c(in, out, stride, 10);
75
76
77
}

void iwht4x4_12(const tran_low_t *in, uint8_t *out, int stride) {
78
  vpx_highbd_iwht4x4_16_add_c(in, out, stride, 12);
79
}
80
81
82

#if HAVE_SSE2
void idct4x4_10_sse2(const tran_low_t *in, uint8_t *out, int stride) {
83
  vpx_highbd_idct4x4_16_add_sse2(in, out, stride, 10);
84
85
86
}

void idct4x4_12_sse2(const tran_low_t *in, uint8_t *out, int stride) {
87
  vpx_highbd_idct4x4_16_add_sse2(in, out, stride, 12);
88
89
90
}
#endif  // HAVE_SSE2
#endif  // CONFIG_VP9_HIGHBITDEPTH
91

clang-format's avatar
clang-format committed
92
93
class Trans4x4DCT : public libvpx_test::TransformTestBase,
                    public ::testing::TestWithParam<Dct4x4Param> {
94
95
96
97
98
99
 public:
  virtual ~Trans4x4DCT() {}

  virtual void SetUp() {
    fwd_txfm_ = GET_PARAM(0);
    inv_txfm_ = GET_PARAM(1);
clang-format's avatar
clang-format committed
100
101
    tx_type_ = GET_PARAM(2);
    pitch_ = 4;
102
    fwd_txfm_ref = fdct4x4_ref;
103
104
    bit_depth_ = GET_PARAM(3);
    mask_ = (1 << bit_depth_) - 1;
Yi Luo's avatar
Yi Luo committed
105
    num_coeffs_ = GET_PARAM(4);
Daniel Kang's avatar
Daniel Kang committed
106
  }
107
108
109
  virtual void TearDown() { libvpx_test::ClearSystemState(); }

 protected:
110
  void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
111
112
    fwd_txfm_(in, out, stride);
  }
113
  void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
114
115
116
    inv_txfm_(out, dst, stride);
  }

117
118
  FdctFunc fwd_txfm_;
  IdctFunc inv_txfm_;
119
120
};

clang-format's avatar
clang-format committed
121
TEST_P(Trans4x4DCT, AccuracyCheck) { RunAccuracyCheck(1); }
Daniel Kang's avatar
Daniel Kang committed
122

clang-format's avatar
clang-format committed
123
TEST_P(Trans4x4DCT, CoeffCheck) { RunCoeffCheck(); }
124

clang-format's avatar
clang-format committed
125
TEST_P(Trans4x4DCT, MemCheck) { RunMemCheck(); }
Daniel Kang's avatar
Daniel Kang committed
126

clang-format's avatar
clang-format committed
127
TEST_P(Trans4x4DCT, InvAccuracyCheck) { RunInvAccuracyCheck(1); }
128

clang-format's avatar
clang-format committed
129
130
class Trans4x4HT : public libvpx_test::TransformTestBase,
                   public ::testing::TestWithParam<Ht4x4Param> {
131
132
133
134
135
136
 public:
  virtual ~Trans4x4HT() {}

  virtual void SetUp() {
    fwd_txfm_ = GET_PARAM(0);
    inv_txfm_ = GET_PARAM(1);
clang-format's avatar
clang-format committed
137
138
    tx_type_ = GET_PARAM(2);
    pitch_ = 4;
139
    fwd_txfm_ref = fht4x4_ref;
140
141
    bit_depth_ = GET_PARAM(3);
    mask_ = (1 << bit_depth_) - 1;
Yi Luo's avatar
Yi Luo committed
142
    num_coeffs_ = GET_PARAM(4);
Daniel Kang's avatar
Daniel Kang committed
143
  }
144
  virtual void TearDown() { libvpx_test::ClearSystemState(); }
Daniel Kang's avatar
Daniel Kang committed
145

146
 protected:
147
  void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
148
149
150
    fwd_txfm_(in, out, stride, tx_type_);
  }

151
  void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
152
153
154
    inv_txfm_(out, dst, stride, tx_type_);
  }

155
156
  FhtFunc fwd_txfm_;
  IhtFunc inv_txfm_;
157
158
};

clang-format's avatar
clang-format committed
159
TEST_P(Trans4x4HT, AccuracyCheck) { RunAccuracyCheck(1); }
160

clang-format's avatar
clang-format committed
161
TEST_P(Trans4x4HT, CoeffCheck) { RunCoeffCheck(); }
162

clang-format's avatar
clang-format committed
163
TEST_P(Trans4x4HT, MemCheck) { RunMemCheck(); }
164

clang-format's avatar
clang-format committed
165
TEST_P(Trans4x4HT, InvAccuracyCheck) { RunInvAccuracyCheck(1); }
Daniel Kang's avatar
Daniel Kang committed
166

clang-format's avatar
clang-format committed
167
168
class Trans4x4WHT : public libvpx_test::TransformTestBase,
                    public ::testing::TestWithParam<Dct4x4Param> {
Alex Converse's avatar
Alex Converse committed
169
170
171
172
173
174
 public:
  virtual ~Trans4x4WHT() {}

  virtual void SetUp() {
    fwd_txfm_ = GET_PARAM(0);
    inv_txfm_ = GET_PARAM(1);
clang-format's avatar
clang-format committed
175
176
    tx_type_ = GET_PARAM(2);
    pitch_ = 4;
Alex Converse's avatar
Alex Converse committed
177
    fwd_txfm_ref = fwht4x4_ref;
178
179
    bit_depth_ = GET_PARAM(3);
    mask_ = (1 << bit_depth_) - 1;
Yi Luo's avatar
Yi Luo committed
180
    num_coeffs_ = GET_PARAM(4);
Alex Converse's avatar
Alex Converse committed
181
182
183
184
  }
  virtual void TearDown() { libvpx_test::ClearSystemState(); }

 protected:
185
  void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
Alex Converse's avatar
Alex Converse committed
186
187
    fwd_txfm_(in, out, stride);
  }
188
  void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
Alex Converse's avatar
Alex Converse committed
189
190
191
    inv_txfm_(out, dst, stride);
  }

192
193
  FdctFunc fwd_txfm_;
  IdctFunc inv_txfm_;
Alex Converse's avatar
Alex Converse committed
194
195
};

clang-format's avatar
clang-format committed
196
TEST_P(Trans4x4WHT, AccuracyCheck) { RunAccuracyCheck(0); }
Alex Converse's avatar
Alex Converse committed
197

clang-format's avatar
clang-format committed
198
TEST_P(Trans4x4WHT, CoeffCheck) { RunCoeffCheck(); }
Alex Converse's avatar
Alex Converse committed
199

clang-format's avatar
clang-format committed
200
TEST_P(Trans4x4WHT, MemCheck) { RunMemCheck(); }
Alex Converse's avatar
Alex Converse committed
201

clang-format's avatar
clang-format committed
202
TEST_P(Trans4x4WHT, InvAccuracyCheck) { RunInvAccuracyCheck(0); }
203
204
using std::tr1::make_tuple;

205
#if CONFIG_VP9_HIGHBITDEPTH
206
207
208
INSTANTIATE_TEST_CASE_P(
    C, Trans4x4DCT,
    ::testing::Values(
Yi Luo's avatar
Yi Luo committed
209
210
211
        make_tuple(&vpx_highbd_fdct4x4_c, &idct4x4_10, 0, VPX_BITS_10, 16),
        make_tuple(&vpx_highbd_fdct4x4_c, &idct4x4_12, 0, VPX_BITS_12, 16),
        make_tuple(&vpx_fdct4x4_c, &vpx_idct4x4_16_add_c, 0, VPX_BITS_8, 16)));
212
#else
clang-format's avatar
clang-format committed
213
214
215
216
INSTANTIATE_TEST_CASE_P(C, Trans4x4DCT,
                        ::testing::Values(make_tuple(&vpx_fdct4x4_c,
                                                     &vpx_idct4x4_16_add_c, 0,
                                                     VPX_BITS_8, 16)));
217
#endif  // CONFIG_VP9_HIGHBITDEPTH
218
219

#if CONFIG_VP9_HIGHBITDEPTH
220
221
222
INSTANTIATE_TEST_CASE_P(
    C, Trans4x4HT,
    ::testing::Values(
Yaowu Xu's avatar
Yaowu Xu committed
223
224
225
226
227
228
229
230
231
232
233
234
        make_tuple(&vp10_highbd_fht4x4_c, &iht4x4_10, 0, VPX_BITS_10, 16),
        make_tuple(&vp10_highbd_fht4x4_c, &iht4x4_10, 1, VPX_BITS_10, 16),
        make_tuple(&vp10_highbd_fht4x4_c, &iht4x4_10, 2, VPX_BITS_10, 16),
        make_tuple(&vp10_highbd_fht4x4_c, &iht4x4_10, 3, VPX_BITS_10, 16),
        make_tuple(&vp10_highbd_fht4x4_c, &iht4x4_12, 0, VPX_BITS_12, 16),
        make_tuple(&vp10_highbd_fht4x4_c, &iht4x4_12, 1, VPX_BITS_12, 16),
        make_tuple(&vp10_highbd_fht4x4_c, &iht4x4_12, 2, VPX_BITS_12, 16),
        make_tuple(&vp10_highbd_fht4x4_c, &iht4x4_12, 3, VPX_BITS_12, 16),
        make_tuple(&vp10_fht4x4_c, &vp10_iht4x4_16_add_c, 0, VPX_BITS_8, 16),
        make_tuple(&vp10_fht4x4_c, &vp10_iht4x4_16_add_c, 1, VPX_BITS_8, 16),
        make_tuple(&vp10_fht4x4_c, &vp10_iht4x4_16_add_c, 2, VPX_BITS_8, 16),
        make_tuple(&vp10_fht4x4_c, &vp10_iht4x4_16_add_c, 3, VPX_BITS_8, 16)));
235
236
237
238
#else
INSTANTIATE_TEST_CASE_P(
    C, Trans4x4HT,
    ::testing::Values(
Yaowu Xu's avatar
Yaowu Xu committed
239
240
241
242
        make_tuple(&vp10_fht4x4_c, &vp10_iht4x4_16_add_c, 0, VPX_BITS_8, 16),
        make_tuple(&vp10_fht4x4_c, &vp10_iht4x4_16_add_c, 1, VPX_BITS_8, 16),
        make_tuple(&vp10_fht4x4_c, &vp10_iht4x4_16_add_c, 2, VPX_BITS_8, 16),
        make_tuple(&vp10_fht4x4_c, &vp10_iht4x4_16_add_c, 3, VPX_BITS_8, 16)));
243
#endif  // CONFIG_VP9_HIGHBITDEPTH
244
245
246
247
248

#if CONFIG_VP9_HIGHBITDEPTH
INSTANTIATE_TEST_CASE_P(
    C, Trans4x4WHT,
    ::testing::Values(
Yaowu Xu's avatar
Yaowu Xu committed
249
250
251
        make_tuple(&vp10_highbd_fwht4x4_c, &iwht4x4_10, 0, VPX_BITS_10, 16),
        make_tuple(&vp10_highbd_fwht4x4_c, &iwht4x4_12, 0, VPX_BITS_12, 16),
        make_tuple(&vp10_fwht4x4_c, &vpx_iwht4x4_16_add_c, 0, VPX_BITS_8, 16)));
252
#else
clang-format's avatar
clang-format committed
253
254
255
256
INSTANTIATE_TEST_CASE_P(C, Trans4x4WHT,
                        ::testing::Values(make_tuple(&vp10_fwht4x4_c,
                                                     &vpx_iwht4x4_16_add_c, 0,
                                                     VPX_BITS_8, 16)));
257
#endif  // CONFIG_VP9_HIGHBITDEPTH
258

259
#if HAVE_NEON_ASM && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
clang-format's avatar
clang-format committed
260
261
262
263
INSTANTIATE_TEST_CASE_P(NEON, Trans4x4DCT,
                        ::testing::Values(make_tuple(&vpx_fdct4x4_c,
                                                     &vpx_idct4x4_16_add_neon,
                                                     0, VPX_BITS_8, 16)));
264
265
266
#endif  // HAVE_NEON_ASM && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE

#if HAVE_NEON && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
James Zern's avatar
James Zern committed
267
INSTANTIATE_TEST_CASE_P(
268
    NEON, Trans4x4HT,
James Zern's avatar
James Zern committed
269
    ::testing::Values(
clang-format's avatar
clang-format committed
270
271
272
273
274
        make_tuple(&vp10_fht4x4_c, &vp10_iht4x4_16_add_neon, 0, VPX_BITS_8, 16),
        make_tuple(&vp10_fht4x4_c, &vp10_iht4x4_16_add_neon, 1, VPX_BITS_8, 16),
        make_tuple(&vp10_fht4x4_c, &vp10_iht4x4_16_add_neon, 2, VPX_BITS_8, 16),
        make_tuple(&vp10_fht4x4_c, &vp10_iht4x4_16_add_neon, 3, VPX_BITS_8,
                   16)));
275
#endif  // HAVE_NEON && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
James Zern's avatar
James Zern committed
276

277
#if HAVE_SSE2 && !CONFIG_EMULATE_HARDWARE
278
279
INSTANTIATE_TEST_CASE_P(
    SSE2, Trans4x4WHT,
clang-format's avatar
clang-format committed
280
281
282
283
    ::testing::Values(make_tuple(&vp10_fwht4x4_c, &vpx_iwht4x4_16_add_c, 0,
                                 VPX_BITS_8, 16),
                      make_tuple(&vp10_fwht4x4_c, &vpx_iwht4x4_16_add_sse2, 0,
                                 VPX_BITS_8, 16)));
284
285
#endif

286
#if HAVE_SSE2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
clang-format's avatar
clang-format committed
287
288
289
290
INSTANTIATE_TEST_CASE_P(SSE2, Trans4x4DCT,
                        ::testing::Values(make_tuple(&vpx_fdct4x4_sse2,
                                                     &vpx_idct4x4_16_add_sse2,
                                                     0, VPX_BITS_8, 16)));
291
292
INSTANTIATE_TEST_CASE_P(
    SSE2, Trans4x4HT,
clang-format's avatar
clang-format committed
293
294
295
296
297
298
299
300
    ::testing::Values(make_tuple(&vp10_fht4x4_sse2, &vp10_iht4x4_16_add_sse2, 0,
                                 VPX_BITS_8, 16),
                      make_tuple(&vp10_fht4x4_sse2, &vp10_iht4x4_16_add_sse2, 1,
                                 VPX_BITS_8, 16),
                      make_tuple(&vp10_fht4x4_sse2, &vp10_iht4x4_16_add_sse2, 2,
                                 VPX_BITS_8, 16),
                      make_tuple(&vp10_fht4x4_sse2, &vp10_iht4x4_16_add_sse2, 3,
                                 VPX_BITS_8, 16)));
301
302
303
304
305
306
#endif  // HAVE_SSE2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE

#if HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
INSTANTIATE_TEST_CASE_P(
    SSE2, Trans4x4DCT,
    ::testing::Values(
clang-format's avatar
clang-format committed
307
308
309
310
311
312
313
314
        make_tuple(&vpx_highbd_fdct4x4_c, &idct4x4_10_sse2, 0, VPX_BITS_10, 16),
        make_tuple(&vpx_highbd_fdct4x4_sse2, &idct4x4_10_sse2, 0, VPX_BITS_10,
                   16),
        make_tuple(&vpx_highbd_fdct4x4_c, &idct4x4_12_sse2, 0, VPX_BITS_12, 16),
        make_tuple(&vpx_highbd_fdct4x4_sse2, &idct4x4_12_sse2, 0, VPX_BITS_12,
                   16),
        make_tuple(&vpx_fdct4x4_sse2, &vpx_idct4x4_16_add_c, 0, VPX_BITS_8,
                   16)));
315

316
317
318
INSTANTIATE_TEST_CASE_P(
    SSE2, Trans4x4HT,
    ::testing::Values(
clang-format's avatar
clang-format committed
319
320
321
322
323
        make_tuple(&vp10_fht4x4_sse2, &vp10_iht4x4_16_add_c, 0, VPX_BITS_8, 16),
        make_tuple(&vp10_fht4x4_sse2, &vp10_iht4x4_16_add_c, 1, VPX_BITS_8, 16),
        make_tuple(&vp10_fht4x4_sse2, &vp10_iht4x4_16_add_c, 2, VPX_BITS_8, 16),
        make_tuple(&vp10_fht4x4_sse2, &vp10_iht4x4_16_add_c, 3, VPX_BITS_8,
                   16)));
324
#endif  // HAVE_SSE2 && CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
325

326
#if HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
clang-format's avatar
clang-format committed
327
328
329
330
INSTANTIATE_TEST_CASE_P(MSA, Trans4x4DCT,
                        ::testing::Values(make_tuple(&vpx_fdct4x4_msa,
                                                     &vpx_idct4x4_16_add_msa, 0,
                                                     VPX_BITS_8, 16)));
331
#if !CONFIG_EXT_TX
332
333
INSTANTIATE_TEST_CASE_P(
    MSA, Trans4x4HT,
clang-format's avatar
clang-format committed
334
335
336
337
338
339
340
341
    ::testing::Values(make_tuple(&vp10_fht4x4_msa, &vp10_iht4x4_16_add_msa, 0,
                                 VPX_BITS_8, 16),
                      make_tuple(&vp10_fht4x4_msa, &vp10_iht4x4_16_add_msa, 1,
                                 VPX_BITS_8, 16),
                      make_tuple(&vp10_fht4x4_msa, &vp10_iht4x4_16_add_msa, 2,
                                 VPX_BITS_8, 16),
                      make_tuple(&vp10_fht4x4_msa, &vp10_iht4x4_16_add_msa, 3,
                                 VPX_BITS_8, 16)));
342
#endif  // !CONFIG_EXT_TX
343
#endif  // HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE
Daniel Kang's avatar
Daniel Kang committed
344
}  // namespace