blob: 8a7d471a3c20691f09e57a2a717c9539db6f190f [file] [log] [blame]
Angie Chiangb9341482015-10-27 16:41:38 -07001/*
Yaowu Xubde4ac82016-11-28 15:26:06 -08002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Angie Chiangb9341482015-10-27 16:41:38 -07003 *
Yaowu Xubde4ac82016-11-28 15:26:06 -08004 * 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.
Angie Chiangb9341482015-10-27 16:41:38 -070010 */
11
Yaowu Xuf883b422016-08-30 14:01:10 -070012#ifndef AV1_TXFM_TEST_H_
13#define AV1_TXFM_TEST_H_
Angie Chiangb9341482015-10-27 16:41:38 -070014
15#include <stdio.h>
16#include <stdlib.h>
Yaowu Xu4bc259d2015-11-09 12:07:25 -080017#ifdef _MSC_VER
18#define _USE_MATH_DEFINES
19#endif
Angie Chiangb9341482015-10-27 16:41:38 -070020#include <math.h>
21
Tom Finegan7a07ece2017-02-07 17:14:05 -080022#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
Angie Chiangb9341482015-10-27 16:41:38 -070023
24#include "test/acm_random.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070025#include "av1/common/enums.h"
Yaowu Xuf883b422016-08-30 14:01:10 -070026#include "av1/common/av1_txfm.h"
27#include "./av1_rtcd.h"
Angie Chiangb9341482015-10-27 16:41:38 -070028
Yaowu Xuc27fc142016-08-22 16:08:15 -070029namespace libaom_test {
Angie Chiangb9341482015-10-27 16:41:38 -070030typedef enum {
31 TYPE_DCT = 0,
32 TYPE_ADST,
Debargha Mukherjeeaa84f3e2018-01-04 12:45:10 -080033 TYPE_IDTX,
Angie Chiangb9341482015-10-27 16:41:38 -070034 TYPE_IDCT,
35 TYPE_IADST,
36 TYPE_LAST
37} TYPE_TXFM;
38
Angie Chiang716f1bd2016-05-11 16:41:36 -070039int get_txfm1d_size(TX_SIZE tx_size);
Angie Chiangb9341482015-10-27 16:41:38 -070040
clang-format3a826f12016-08-11 17:46:05 -070041void get_txfm1d_type(TX_TYPE txfm2d_type, TYPE_TXFM *type0, TYPE_TXFM *type1);
Angie Chiangb9341482015-10-27 16:41:38 -070042
clang-format3a826f12016-08-11 17:46:05 -070043void reference_dct_1d(const double *in, double *out, int size);
Sebastien Alaiwand02642f2017-07-10 11:41:44 +020044void reference_idct_1d(const double *in, double *out, int size);
Angie Chiangb9341482015-10-27 16:41:38 -070045
clang-format3a826f12016-08-11 17:46:05 -070046void reference_adst_1d(const double *in, double *out, int size);
Angie Chiangb9341482015-10-27 16:41:38 -070047
clang-format3a826f12016-08-11 17:46:05 -070048void reference_hybrid_1d(double *in, double *out, int size, int type);
Angie Chiangb9341482015-10-27 16:41:38 -070049
Urvang Joshiec6acb22017-12-13 18:54:51 -080050double get_amplification_factor(TX_TYPE tx_type, TX_SIZE tx_size);
51
52void reference_hybrid_2d(double *in, double *out, TX_TYPE tx_type,
53 TX_SIZE tx_size);
Angie Chiangb9341482015-10-27 16:41:38 -070054template <typename Type1, typename Type2>
clang-format3a826f12016-08-11 17:46:05 -070055static double compute_avg_abs_error(const Type1 *a, const Type2 *b,
Angie Chiangb9341482015-10-27 16:41:38 -070056 const int size) {
57 double error = 0;
58 for (int i = 0; i < size; i++) {
59 error += fabs(static_cast<double>(a[i]) - static_cast<double>(b[i]));
60 }
61 error = error / size;
62 return error;
63}
64
clang-format3a826f12016-08-11 17:46:05 -070065template <typename Type>
Urvang Joshi5fb50f82017-12-12 18:48:55 -080066void fliplr(Type *dest, int width, int height, int stride);
Angie Chiang6a752532016-05-11 18:50:47 -070067
clang-format3a826f12016-08-11 17:46:05 -070068template <typename Type>
Urvang Joshi5fb50f82017-12-12 18:48:55 -080069void flipud(Type *dest, int width, int height, int stride);
Angie Chiang6a752532016-05-11 18:50:47 -070070
clang-format3a826f12016-08-11 17:46:05 -070071template <typename Type>
Urvang Joshi5fb50f82017-12-12 18:48:55 -080072void fliplrud(Type *dest, int width, int height, int stride);
Angie Chiang6a752532016-05-11 18:50:47 -070073
Angie Chiangd4327bc2018-01-22 20:54:04 -080074typedef void (*TxfmFunc)(const int32_t *in, int32_t *out, const int8_t cos_bit,
clang-format3a826f12016-08-11 17:46:05 -070075 const int8_t *range_bit);
Angie Chiangb9341482015-10-27 16:41:38 -070076
Peng Bin58bd7ce2018-02-07 21:10:54 +080077typedef void (*FwdTxfm2dFunc)(const int16_t *, int32_t *, int, TX_TYPE, int);
78typedef void (*InvTxfm2dFunc)(const int32_t *, uint16_t *, int, TX_TYPE, int);
Peng Bin56750cf2018-03-02 17:01:19 +080079typedef void (*LbdInvTxfm2dFunc)(const int32_t *, uint8_t *, int, TX_TYPE,
80 TX_SIZE, int);
Angie Chiangb9341482015-10-27 16:41:38 -070081
82static const int bd = 10;
Angie Chiang218dfbd2016-04-19 11:59:00 -070083static const int input_base = (1 << bd);
Angie Chiangfdaad9f2016-05-12 17:11:27 -070084
Yunqing Wang80360582017-03-28 17:17:23 -070085#if CONFIG_AV1_ENCODER
Angie Chiangd2db6582017-08-06 20:46:48 -070086
Peng Bin58bd7ce2018-02-07 21:10:54 +080087static const FwdTxfm2dFunc fwd_txfm_func_ls[TX_SIZES_ALL] = {
Urvang Joshi5fb50f82017-12-12 18:48:55 -080088 av1_fwd_txfm2d_4x4_c, av1_fwd_txfm2d_8x8_c, av1_fwd_txfm2d_16x16_c,
Yaowu Xud3d41592018-02-14 13:26:52 -080089 av1_fwd_txfm2d_32x32_c, av1_fwd_txfm2d_64x64_c, av1_fwd_txfm2d_4x8_c,
90 av1_fwd_txfm2d_8x4_c, av1_fwd_txfm2d_8x16_c, av1_fwd_txfm2d_16x8_c,
91 av1_fwd_txfm2d_16x32_c, av1_fwd_txfm2d_32x16_c, av1_fwd_txfm2d_32x64_c,
92 av1_fwd_txfm2d_64x32_c, av1_fwd_txfm2d_4x16_c, av1_fwd_txfm2d_16x4_c,
93 av1_fwd_txfm2d_8x32_c, av1_fwd_txfm2d_32x8_c, av1_fwd_txfm2d_16x64_c,
94 av1_fwd_txfm2d_64x16_c,
clang-format3a826f12016-08-11 17:46:05 -070095};
Yunqing Wang80360582017-03-28 17:17:23 -070096#endif
Angie Chiangfdaad9f2016-05-12 17:11:27 -070097
Peng Bin58bd7ce2018-02-07 21:10:54 +080098static const InvTxfm2dFunc inv_txfm_func_ls[TX_SIZES_ALL] = {
Urvang Joshie035b5d2017-12-13 10:01:59 -080099 av1_inv_txfm2d_add_4x4_c, av1_inv_txfm2d_add_8x8_c,
100 av1_inv_txfm2d_add_16x16_c, av1_inv_txfm2d_add_32x32_c,
Yaowu Xud3d41592018-02-14 13:26:52 -0800101 av1_inv_txfm2d_add_64x64_c, av1_inv_txfm2d_add_4x8_c,
102 av1_inv_txfm2d_add_8x4_c, av1_inv_txfm2d_add_8x16_c,
103 av1_inv_txfm2d_add_16x8_c, av1_inv_txfm2d_add_16x32_c,
104 av1_inv_txfm2d_add_32x16_c, av1_inv_txfm2d_add_32x64_c,
105 av1_inv_txfm2d_add_64x32_c, av1_inv_txfm2d_add_4x16_c,
106 av1_inv_txfm2d_add_16x4_c, av1_inv_txfm2d_add_8x32_c,
107 av1_inv_txfm2d_add_32x8_c, av1_inv_txfm2d_add_16x64_c,
108 av1_inv_txfm2d_add_64x16_c,
clang-format3a826f12016-08-11 17:46:05 -0700109};
Angie Chiangfdaad9f2016-05-12 17:11:27 -0700110
Angie Chiang9c7089a2017-08-08 16:21:11 -0700111#define BD_NUM 3
112
113extern int bd_arr[];
114extern int8_t low_range_arr[];
115extern int8_t high_range_arr[];
116
117void txfm_stage_range_check(const int8_t *stage_range, int stage_num,
Angie Chiangd4327bc2018-01-22 20:54:04 -0800118 const int8_t cos_bit, int low_range,
Angie Chiang9c7089a2017-08-08 16:21:11 -0700119 int high_range);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700120} // namespace libaom_test
Yaowu Xuf883b422016-08-30 14:01:10 -0700121#endif // AV1_TXFM_TEST_H_