2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
12 #ifndef AV1_TXFM_TEST_H_
13 #define AV1_TXFM_TEST_H_
18 #define _USE_MATH_DEFINES
22 #include "config/av1_rtcd.h"
24 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
26 #include "test/acm_random.h"
27 #include "av1/common/av1_txfm.h"
28 #include "av1/common/blockd.h"
29 #include "av1/common/enums.h"
31 namespace libaom_test
{
41 int get_txfm1d_size(TX_SIZE tx_size
);
43 void get_txfm1d_type(TX_TYPE txfm2d_type
, TYPE_TXFM
*type0
, TYPE_TXFM
*type1
);
45 void reference_dct_1d(const double *in
, double *out
, int size
);
46 void reference_idct_1d(const double *in
, double *out
, int size
);
48 void reference_adst_1d(const double *in
, double *out
, int size
);
50 void reference_hybrid_1d(double *in
, double *out
, int size
, int type
);
52 double get_amplification_factor(TX_TYPE tx_type
, TX_SIZE tx_size
);
54 void reference_hybrid_2d(double *in
, double *out
, TX_TYPE tx_type
,
56 template <typename Type1
, typename Type2
>
57 static double compute_avg_abs_error(const Type1
*a
, const Type2
*b
,
60 for (int i
= 0; i
< size
; i
++) {
61 error
+= fabs(static_cast<double>(a
[i
]) - static_cast<double>(b
[i
]));
67 template <typename Type
>
68 void fliplr(Type
*dest
, int width
, int height
, int stride
);
70 template <typename Type
>
71 void flipud(Type
*dest
, int width
, int height
, int stride
);
73 template <typename Type
>
74 void fliplrud(Type
*dest
, int width
, int height
, int stride
);
76 typedef void (*TxfmFunc
)(const int32_t *in
, int32_t *out
, const int8_t cos_bit
,
77 const int8_t *range_bit
);
79 typedef void (*InvTxfm2dFunc
)(const int32_t *, uint16_t *, int, TX_TYPE
, int);
80 typedef void (*LbdInvTxfm2dFunc
)(const int32_t *, uint8_t *, int, TX_TYPE
,
83 static const int bd
= 10;
84 static const int input_base
= (1 << bd
);
86 static INLINE
bool IsTxSizeTypeValid(TX_SIZE tx_size
, TX_TYPE tx_type
) {
87 const TX_SIZE tx_size_sqr_up
= txsize_sqr_up_map
[tx_size
];
88 TxSetType tx_set_type
;
89 if (tx_size_sqr_up
> TX_32X32
) {
90 tx_set_type
= EXT_TX_SET_DCTONLY
;
91 } else if (tx_size_sqr_up
== TX_32X32
) {
92 tx_set_type
= EXT_TX_SET_DCT_IDTX
;
94 tx_set_type
= EXT_TX_SET_ALL16
;
96 return av1_ext_tx_used
[tx_set_type
][tx_type
] != 0;
99 #if CONFIG_AV1_ENCODER
101 static const FwdTxfm2dFunc fwd_txfm_func_ls
[TX_SIZES_ALL
] = {
102 av1_fwd_txfm2d_4x4_c
, av1_fwd_txfm2d_8x8_c
, av1_fwd_txfm2d_16x16_c
,
103 av1_fwd_txfm2d_32x32_c
, av1_fwd_txfm2d_64x64_c
, av1_fwd_txfm2d_4x8_c
,
104 av1_fwd_txfm2d_8x4_c
, av1_fwd_txfm2d_8x16_c
, av1_fwd_txfm2d_16x8_c
,
105 av1_fwd_txfm2d_16x32_c
, av1_fwd_txfm2d_32x16_c
, av1_fwd_txfm2d_32x64_c
,
106 av1_fwd_txfm2d_64x32_c
, av1_fwd_txfm2d_4x16_c
, av1_fwd_txfm2d_16x4_c
,
107 av1_fwd_txfm2d_8x32_c
, av1_fwd_txfm2d_32x8_c
, av1_fwd_txfm2d_16x64_c
,
108 av1_fwd_txfm2d_64x16_c
,
112 static const InvTxfm2dFunc inv_txfm_func_ls
[TX_SIZES_ALL
] = {
113 av1_inv_txfm2d_add_4x4_c
, av1_inv_txfm2d_add_8x8_c
,
114 av1_inv_txfm2d_add_16x16_c
, av1_inv_txfm2d_add_32x32_c
,
115 av1_inv_txfm2d_add_64x64_c
, av1_inv_txfm2d_add_4x8_c
,
116 av1_inv_txfm2d_add_8x4_c
, av1_inv_txfm2d_add_8x16_c
,
117 av1_inv_txfm2d_add_16x8_c
, av1_inv_txfm2d_add_16x32_c
,
118 av1_inv_txfm2d_add_32x16_c
, av1_inv_txfm2d_add_32x64_c
,
119 av1_inv_txfm2d_add_64x32_c
, av1_inv_txfm2d_add_4x16_c
,
120 av1_inv_txfm2d_add_16x4_c
, av1_inv_txfm2d_add_8x32_c
,
121 av1_inv_txfm2d_add_32x8_c
, av1_inv_txfm2d_add_16x64_c
,
122 av1_inv_txfm2d_add_64x16_c
,
128 extern int8_t low_range_arr
[];
129 extern int8_t high_range_arr
[];
131 void txfm_stage_range_check(const int8_t *stage_range
, int stage_num
,
132 const int8_t cos_bit
, int low_range
,
134 } // namespace libaom_test
135 #endif // AV1_TXFM_TEST_H_