av1_txfm_test.h 4.23 KB
Newer Older
Angie Chiang's avatar
Angie Chiang committed
1
/*
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Angie Chiang's avatar
Angie Chiang committed
3
 *
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.
Angie Chiang's avatar
Angie Chiang committed
10 11
 */

12 13
#ifndef AV1_TXFM_TEST_H_
#define AV1_TXFM_TEST_H_
Angie Chiang's avatar
Angie Chiang committed
14 15 16

#include <stdio.h>
#include <stdlib.h>
Yaowu Xu's avatar
Yaowu Xu committed
17 18 19
#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#endif
Angie Chiang's avatar
Angie Chiang committed
20 21
#include <math.h>

22
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
Angie Chiang's avatar
Angie Chiang committed
23 24

#include "test/acm_random.h"
25
#include "av1/common/enums.h"
26 27
#include "av1/common/av1_txfm.h"
#include "./av1_rtcd.h"
Angie Chiang's avatar
Angie Chiang committed
28

29
namespace libaom_test {
Angie Chiang's avatar
Angie Chiang committed
30 31 32
typedef enum {
  TYPE_DCT = 0,
  TYPE_ADST,
33
  TYPE_IDTX,
Angie Chiang's avatar
Angie Chiang committed
34 35 36 37 38
  TYPE_IDCT,
  TYPE_IADST,
  TYPE_LAST
} TYPE_TXFM;

39
int get_txfm1d_size(TX_SIZE tx_size);
Angie Chiang's avatar
Angie Chiang committed
40

clang-format's avatar
clang-format committed
41
void get_txfm1d_type(TX_TYPE txfm2d_type, TYPE_TXFM *type0, TYPE_TXFM *type1);
Angie Chiang's avatar
Angie Chiang committed
42

clang-format's avatar
clang-format committed
43
void reference_dct_1d(const double *in, double *out, int size);
44
void reference_idct_1d(const double *in, double *out, int size);
Angie Chiang's avatar
Angie Chiang committed
45

clang-format's avatar
clang-format committed
46
void reference_adst_1d(const double *in, double *out, int size);
Angie Chiang's avatar
Angie Chiang committed
47

clang-format's avatar
clang-format committed
48
void reference_hybrid_1d(double *in, double *out, int size, int type);
Angie Chiang's avatar
Angie Chiang committed
49

50 51 52 53
double get_amplification_factor(TX_TYPE tx_type, TX_SIZE tx_size);

void reference_hybrid_2d(double *in, double *out, TX_TYPE tx_type,
                         TX_SIZE tx_size);
Angie Chiang's avatar
Angie Chiang committed
54
template <typename Type1, typename Type2>
clang-format's avatar
clang-format committed
55
static double compute_avg_abs_error(const Type1 *a, const Type2 *b,
Angie Chiang's avatar
Angie Chiang committed
56 57 58 59 60 61 62 63 64
                                    const int size) {
  double error = 0;
  for (int i = 0; i < size; i++) {
    error += fabs(static_cast<double>(a[i]) - static_cast<double>(b[i]));
  }
  error = error / size;
  return error;
}

clang-format's avatar
clang-format committed
65
template <typename Type>
66
void fliplr(Type *dest, int width, int height, int stride);
67

clang-format's avatar
clang-format committed
68
template <typename Type>
69
void flipud(Type *dest, int width, int height, int stride);
70

clang-format's avatar
clang-format committed
71
template <typename Type>
72
void fliplrud(Type *dest, int width, int height, int stride);
73

74
typedef void (*TxfmFunc)(const int32_t *in, int32_t *out, const int8_t cos_bit,
clang-format's avatar
clang-format committed
75
                         const int8_t *range_bit);
Angie Chiang's avatar
Angie Chiang committed
76

77 78
typedef void (*Fwd_Txfm2d_Func)(const int16_t *, int32_t *, int, TX_TYPE, int);
typedef void (*Inv_Txfm2d_Func)(const int32_t *, uint16_t *, int, TX_TYPE, int);
Angie Chiang's avatar
Angie Chiang committed
79 80

static const int bd = 10;
81
static const int input_base = (1 << bd);
82

83
#if CONFIG_AV1_ENCODER
Angie Chiang's avatar
Angie Chiang committed
84 85

static const Fwd_Txfm2d_Func fwd_txfm_func_ls[TX_SIZES_ALL] = {
86
  av1_fwd_txfm2d_4x4_c,   av1_fwd_txfm2d_8x8_c,   av1_fwd_txfm2d_16x16_c,
Angie Chiang's avatar
Angie Chiang committed
87 88 89
  av1_fwd_txfm2d_32x32_c,
#if CONFIG_TX64X64
  av1_fwd_txfm2d_64x64_c,
90
#endif  // CONFIG_TX64X64
91 92
  av1_fwd_txfm2d_4x8_c,   av1_fwd_txfm2d_8x4_c,   av1_fwd_txfm2d_8x16_c,
  av1_fwd_txfm2d_16x8_c,  av1_fwd_txfm2d_16x32_c, av1_fwd_txfm2d_32x16_c,
93
#if CONFIG_TX64X64
94 95 96 97 98 99
  av1_fwd_txfm2d_32x64_c, av1_fwd_txfm2d_64x32_c,
#endif  // CONFIG_TX64X64
  av1_fwd_txfm2d_4x16_c,  av1_fwd_txfm2d_16x4_c,  av1_fwd_txfm2d_8x32_c,
  av1_fwd_txfm2d_32x8_c,
#if CONFIG_TX64X64
  av1_fwd_txfm2d_16x64_c, av1_fwd_txfm2d_64x16_c,
100
#endif  // CONFIG_TX64X64
clang-format's avatar
clang-format committed
101
};
102
#endif
103

Angie Chiang's avatar
Angie Chiang committed
104
static const Inv_Txfm2d_Func inv_txfm_func_ls[TX_SIZES_ALL] = {
105 106
  av1_inv_txfm2d_add_4x4_c,   av1_inv_txfm2d_add_8x8_c,
  av1_inv_txfm2d_add_16x16_c, av1_inv_txfm2d_add_32x32_c,
Angie Chiang's avatar
Angie Chiang committed
107 108
#if CONFIG_TX64X64
  av1_inv_txfm2d_add_64x64_c,
109
#endif  // CONFIG_TX64X64
110 111 112
  av1_inv_txfm2d_add_4x8_c,   av1_inv_txfm2d_add_8x4_c,
  av1_inv_txfm2d_add_8x16_c,  av1_inv_txfm2d_add_16x8_c,
  av1_inv_txfm2d_add_16x32_c, av1_inv_txfm2d_add_32x16_c,
113
#if CONFIG_TX64X64
114 115 116 117 118 119
  av1_inv_txfm2d_add_32x64_c, av1_inv_txfm2d_add_64x32_c,
#endif  // CONFIG_TX64X64
  av1_inv_txfm2d_add_4x16_c,  av1_inv_txfm2d_add_16x4_c,
  av1_inv_txfm2d_add_8x32_c,  av1_inv_txfm2d_add_32x8_c,
#if CONFIG_TX64X64
  av1_inv_txfm2d_add_16x64_c, av1_inv_txfm2d_add_64x16_c,
120
#endif  // CONFIG_TX64X64
clang-format's avatar
clang-format committed
121
};
122

Angie Chiang's avatar
Angie Chiang committed
123 124 125 126 127 128 129
#define BD_NUM 3

extern int bd_arr[];
extern int8_t low_range_arr[];
extern int8_t high_range_arr[];

void txfm_stage_range_check(const int8_t *stage_range, int stage_num,
130
                            const int8_t cos_bit, int low_range,
Angie Chiang's avatar
Angie Chiang committed
131
                            int high_range);
132
}  // namespace libaom_test
133
#endif  // AV1_TXFM_TEST_H_