fdct4x4_test.cc 9.01 KB
Newer Older
Daniel Kang's avatar
Daniel Kang committed
1
/*
Yaowu Xu's avatar
Yaowu Xu committed
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Daniel Kang's avatar
Daniel Kang committed
3
 *
Yaowu Xu's avatar
Yaowu Xu committed
4 5 6 7 8 9
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Johann's avatar
Johann committed
10
 */
Daniel Kang's avatar
Daniel Kang committed
11 12 13 14 15

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

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

Yaowu Xu's avatar
Yaowu Xu committed
18 19
#include "./av1_rtcd.h"
#include "./aom_dsp_rtcd.h"
20 21 22
#include "test/acm_random.h"
#include "test/clear_system_state.h"
#include "test/register_state_check.h"
Yi Luo's avatar
Yi Luo committed
23
#include "test/transform_test_base.h"
24
#include "test/util.h"
25
#include "av1/common/entropy.h"
Yaowu Xu's avatar
Yaowu Xu committed
26 27
#include "aom/aom_codec.h"
#include "aom/aom_integer.h"
28
#include "aom_ports/mem.h"
29

30
using libaom_test::ACMRandom;
Daniel Kang's avatar
Daniel Kang committed
31

32
#if !CONFIG_DAALA_TX
Daniel Kang's avatar
Daniel Kang committed
33
namespace {
34 35 36
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,
37
                        const TxfmParam *txfm_param);
38
using libaom_test::FhtFunc;
39

40
typedef std::tr1::tuple<FdctFunc, IdctFunc, TX_TYPE, aom_bit_depth_t, int>
clang-format's avatar
clang-format committed
41
    Dct4x4Param;
42 43
typedef std::tr1::tuple<FhtFunc, IhtFunc, TX_TYPE, aom_bit_depth_t, int>
    Ht4x4Param;
44

45
void fdct4x4_ref(const int16_t *in, tran_low_t *out, int stride,
46
                 TxfmParam * /*txfm_param*/) {
Yaowu Xu's avatar
Yaowu Xu committed
47
  aom_fdct4x4_c(in, out, stride);
Jingning Han's avatar
Jingning Han committed
48
}
49

50
void fht4x4_ref(const int16_t *in, tran_low_t *out, int stride,
51 52
                TxfmParam *txfm_param) {
  av1_fht4x4_c(in, out, stride, txfm_param);
Jingning Han's avatar
Jingning Han committed
53 54
}

55
void fwht4x4_ref(const int16_t *in, tran_low_t *out, int stride,
56
                 TxfmParam * /*txfm_param*/) {
Yaowu Xu's avatar
Yaowu Xu committed
57
  av1_fwht4x4_c(in, out, stride);
Alex Converse's avatar
Alex Converse committed
58 59
}

60
void fht4x4_10(const int16_t *in, tran_low_t *out, int stride,
61 62
               TxfmParam *txfm_param) {
  av1_fwd_txfm2d_4x4_c(in, out, stride, txfm_param->tx_type, 10);
63 64
}

65
void fht4x4_12(const int16_t *in, tran_low_t *out, int stride,
66 67
               TxfmParam *txfm_param) {
  av1_fwd_txfm2d_4x4_c(in, out, stride, txfm_param->tx_type, 12);
68 69
}

70
void iht4x4_10(const tran_low_t *in, uint8_t *out, int stride,
71
               const TxfmParam *txfm_param) {
72
  av1_inv_txfm2d_add_4x4_c(in, CONVERT_TO_SHORTPTR(out), stride,
73
                           txfm_param->tx_type, 10);
74 75
}

76
void iht4x4_12(const tran_low_t *in, uint8_t *out, int stride,
77
               const TxfmParam *txfm_param) {
78
  av1_inv_txfm2d_add_4x4_c(in, CONVERT_TO_SHORTPTR(out), stride,
79
                           txfm_param->tx_type, 12);
80 81 82
}

void iwht4x4_10(const tran_low_t *in, uint8_t *out, int stride) {
Yaowu Xu's avatar
Yaowu Xu committed
83
  aom_highbd_iwht4x4_16_add_c(in, out, stride, 10);
84 85 86
}

void iwht4x4_12(const tran_low_t *in, uint8_t *out, int stride) {
Yaowu Xu's avatar
Yaowu Xu committed
87
  aom_highbd_iwht4x4_16_add_c(in, out, stride, 12);
88 89
}

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

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

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

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

Angie Chiang's avatar
Angie Chiang committed
120
TEST_P(Trans4x4DCT, AccuracyCheck) { RunAccuracyCheck(0, 0.00001); }
Daniel Kang's avatar
Daniel Kang committed
121

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

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

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

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

  virtual void SetUp() {
    fwd_txfm_ = GET_PARAM(0);
    inv_txfm_ = GET_PARAM(1);
clang-format's avatar
clang-format committed
136
    pitch_ = 4;
137
    height_ = 4;
138
    fwd_txfm_ref = fht4x4_ref;
139 140
    bit_depth_ = GET_PARAM(3);
    mask_ = (1 << bit_depth_) - 1;
Yi Luo's avatar
Yi Luo committed
141
    num_coeffs_ = GET_PARAM(4);
142
    txfm_param_.tx_type = GET_PARAM(2);
143 144 145 146 147
    switch (bit_depth_) {
      case AOM_BITS_10: fwd_txfm_ref = fht4x4_10; break;
      case AOM_BITS_12: fwd_txfm_ref = fht4x4_12; break;
      default: fwd_txfm_ref = fht4x4_ref; break;
    }
Daniel Kang's avatar
Daniel Kang committed
148
  }
149
  virtual void TearDown() { libaom_test::ClearSystemState(); }
Daniel Kang's avatar
Daniel Kang committed
150

151
 protected:
152
  void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
153
    fwd_txfm_(in, out, stride, &txfm_param_);
154 155
  }

156
  void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
157
    inv_txfm_(out, dst, stride, &txfm_param_);
158 159
  }

160 161
  FhtFunc fwd_txfm_;
  IhtFunc inv_txfm_;
162 163
};

164
TEST_P(Trans4x4HT, AccuracyCheck) { RunAccuracyCheck(1, 0.005); }
165

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

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

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

172
class Trans4x4WHT : public libaom_test::TransformTestBase,
clang-format's avatar
clang-format committed
173
                    public ::testing::TestWithParam<Dct4x4Param> {
Alex Converse's avatar
Alex Converse committed
174 175 176 177 178 179
 public:
  virtual ~Trans4x4WHT() {}

  virtual void SetUp() {
    fwd_txfm_ = GET_PARAM(0);
    inv_txfm_ = GET_PARAM(1);
clang-format's avatar
clang-format committed
180
    pitch_ = 4;
181
    height_ = 4;
Alex Converse's avatar
Alex Converse committed
182
    fwd_txfm_ref = fwht4x4_ref;
183 184
    bit_depth_ = GET_PARAM(3);
    mask_ = (1 << bit_depth_) - 1;
Yi Luo's avatar
Yi Luo committed
185
    num_coeffs_ = GET_PARAM(4);
Alex Converse's avatar
Alex Converse committed
186
  }
187
  virtual void TearDown() { libaom_test::ClearSystemState(); }
Alex Converse's avatar
Alex Converse committed
188 189

 protected:
190
  void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
Alex Converse's avatar
Alex Converse committed
191 192
    fwd_txfm_(in, out, stride);
  }
193
  void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
Alex Converse's avatar
Alex Converse committed
194 195 196
    inv_txfm_(out, dst, stride);
  }

197 198
  FdctFunc fwd_txfm_;
  IdctFunc inv_txfm_;
Alex Converse's avatar
Alex Converse committed
199 200
};

Angie Chiang's avatar
Angie Chiang committed
201
TEST_P(Trans4x4WHT, AccuracyCheck) { RunAccuracyCheck(0, 0.00001); }
Alex Converse's avatar
Alex Converse committed
202

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

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

clang-format's avatar
clang-format committed
207
TEST_P(Trans4x4WHT, InvAccuracyCheck) { RunInvAccuracyCheck(0); }
208 209
using std::tr1::make_tuple;

clang-format's avatar
clang-format committed
210
INSTANTIATE_TEST_CASE_P(C, Trans4x4DCT,
Yaowu Xu's avatar
Yaowu Xu committed
211
                        ::testing::Values(make_tuple(&aom_fdct4x4_c,
212 213
                                                     &aom_idct4x4_16_add_c,
                                                     DCT_DCT, AOM_BITS_8, 16)));
214

215 216
INSTANTIATE_TEST_CASE_P(
    DISABLED_C, Trans4x4HT,
217 218 219 220 221
    ::testing::Values(
        make_tuple(&fht4x4_12, &iht4x4_12, DCT_DCT, AOM_BITS_12, 16),
        make_tuple(&fht4x4_12, &iht4x4_12, ADST_DCT, AOM_BITS_12, 16),
        make_tuple(&fht4x4_12, &iht4x4_12, DCT_ADST, AOM_BITS_12, 16),
        make_tuple(&fht4x4_12, &iht4x4_12, ADST_ADST, AOM_BITS_12, 16)));
222

223 224 225
INSTANTIATE_TEST_CASE_P(
    C, Trans4x4HT,
    ::testing::Values(
226 227 228 229 230 231 232 233 234 235 236 237
        make_tuple(&fht4x4_10, &iht4x4_10, DCT_DCT, AOM_BITS_10, 16),
        make_tuple(&fht4x4_10, &iht4x4_10, ADST_DCT, AOM_BITS_10, 16),
        make_tuple(&fht4x4_10, &iht4x4_10, DCT_ADST, AOM_BITS_10, 16),
        make_tuple(&fht4x4_10, &iht4x4_10, ADST_ADST, AOM_BITS_10, 16),
        make_tuple(&av1_fht4x4_c, &av1_iht4x4_16_add_c, DCT_DCT, AOM_BITS_8,
                   16),
        make_tuple(&av1_fht4x4_c, &av1_iht4x4_16_add_c, ADST_DCT, AOM_BITS_8,
                   16),
        make_tuple(&av1_fht4x4_c, &av1_iht4x4_16_add_c, DCT_ADST, AOM_BITS_8,
                   16),
        make_tuple(&av1_fht4x4_c, &av1_iht4x4_16_add_c, ADST_ADST, AOM_BITS_8,
                   16)));
238 239 240

INSTANTIATE_TEST_CASE_P(
    C, Trans4x4WHT,
241 242 243 244 245 246
    ::testing::Values(make_tuple(&av1_highbd_fwht4x4_c, &iwht4x4_10, DCT_DCT,
                                 AOM_BITS_10, 16),
                      make_tuple(&av1_highbd_fwht4x4_c, &iwht4x4_12, DCT_DCT,
                                 AOM_BITS_12, 16),
                      make_tuple(&av1_fwht4x4_c, &aom_iwht4x4_16_add_c, DCT_DCT,
                                 AOM_BITS_8, 16)));
James Zern's avatar
James Zern committed
247

248
#if HAVE_SSE2 && !CONFIG_DAALA_TX4
249 250
INSTANTIATE_TEST_CASE_P(
    SSE2, Trans4x4WHT,
251
    ::testing::Values(make_tuple(&av1_fwht4x4_c, &aom_iwht4x4_16_add_c, DCT_DCT,
Yaowu Xu's avatar
Yaowu Xu committed
252
                                 AOM_BITS_8, 16),
253 254
                      make_tuple(&av1_fwht4x4_c, &aom_iwht4x4_16_add_sse2,
                                 DCT_DCT, AOM_BITS_8, 16)));
255 256
#endif

257
#if HAVE_SSE2 && !CONFIG_DAALA_TX4
258 259
INSTANTIATE_TEST_CASE_P(
    SSE2, Trans4x4HT,
260 261 262 263 264 265 266 267
    ::testing::Values(make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_c,
                                 DCT_DCT, AOM_BITS_8, 16),
                      make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_c,
                                 ADST_DCT, AOM_BITS_8, 16),
                      make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_c,
                                 DCT_ADST, AOM_BITS_8, 16),
                      make_tuple(&av1_fht4x4_sse2, &av1_iht4x4_16_add_c,
                                 ADST_ADST, AOM_BITS_8, 16)));
268
#endif  // HAVE_SSE2 && !CONFIG_DAALA_TX4
269

Daniel Kang's avatar
Daniel Kang committed
270
}  // namespace
271
#endif  // !CONFIG_DAALA_TX