Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | bde4ac8 | 2016-11-28 15:26:06 -0800 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | bde4ac8 | 2016-11-28 15:26:06 -0800 | [diff] [blame] | 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. |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 12 | #ifndef AV1_TXFM_TEST_H_ |
| 13 | #define AV1_TXFM_TEST_H_ |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 14 | |
| 15 | #include <stdio.h> |
| 16 | #include <stdlib.h> |
Yaowu Xu | 4bc259d | 2015-11-09 12:07:25 -0800 | [diff] [blame] | 17 | #ifdef _MSC_VER |
| 18 | #define _USE_MATH_DEFINES |
| 19 | #endif |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 20 | #include <math.h> |
| 21 | |
Tom Finegan | 7a07ece | 2017-02-07 17:14:05 -0800 | [diff] [blame] | 22 | #include "third_party/googletest/src/googletest/include/gtest/gtest.h" |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 23 | |
| 24 | #include "test/acm_random.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 25 | #include "av1/common/enums.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 26 | #include "av1/common/av1_txfm.h" |
| 27 | #include "./av1_rtcd.h" |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 28 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 29 | namespace libaom_test { |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 30 | typedef enum { |
| 31 | TYPE_DCT = 0, |
| 32 | TYPE_ADST, |
Debargha Mukherjee | aa84f3e | 2018-01-04 12:45:10 -0800 | [diff] [blame] | 33 | TYPE_IDTX, |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 34 | TYPE_IDCT, |
| 35 | TYPE_IADST, |
| 36 | TYPE_LAST |
| 37 | } TYPE_TXFM; |
| 38 | |
Angie Chiang | 716f1bd | 2016-05-11 16:41:36 -0700 | [diff] [blame] | 39 | int get_txfm1d_size(TX_SIZE tx_size); |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 40 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 41 | void get_txfm1d_type(TX_TYPE txfm2d_type, TYPE_TXFM *type0, TYPE_TXFM *type1); |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 42 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 43 | void reference_dct_1d(const double *in, double *out, int size); |
Sebastien Alaiwan | d02642f | 2017-07-10 11:41:44 +0200 | [diff] [blame] | 44 | void reference_idct_1d(const double *in, double *out, int size); |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 45 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 46 | void reference_adst_1d(const double *in, double *out, int size); |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 47 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 48 | void reference_hybrid_1d(double *in, double *out, int size, int type); |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 49 | |
Urvang Joshi | ec6acb2 | 2017-12-13 18:54:51 -0800 | [diff] [blame] | 50 | double get_amplification_factor(TX_TYPE tx_type, TX_SIZE tx_size); |
| 51 | |
| 52 | void reference_hybrid_2d(double *in, double *out, TX_TYPE tx_type, |
| 53 | TX_SIZE tx_size); |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 54 | template <typename Type1, typename Type2> |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 55 | static double compute_avg_abs_error(const Type1 *a, const Type2 *b, |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 56 | 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-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 65 | template <typename Type> |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 66 | void fliplr(Type *dest, int width, int height, int stride); |
Angie Chiang | 6a75253 | 2016-05-11 18:50:47 -0700 | [diff] [blame] | 67 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 68 | template <typename Type> |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 69 | void flipud(Type *dest, int width, int height, int stride); |
Angie Chiang | 6a75253 | 2016-05-11 18:50:47 -0700 | [diff] [blame] | 70 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 71 | template <typename Type> |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 72 | void fliplrud(Type *dest, int width, int height, int stride); |
Angie Chiang | 6a75253 | 2016-05-11 18:50:47 -0700 | [diff] [blame] | 73 | |
Angie Chiang | d4327bc | 2018-01-22 20:54:04 -0800 | [diff] [blame] | 74 | typedef void (*TxfmFunc)(const int32_t *in, int32_t *out, const int8_t cos_bit, |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 75 | const int8_t *range_bit); |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 76 | |
Peng Bin | 58bd7ce | 2018-02-07 21:10:54 +0800 | [diff] [blame] | 77 | typedef void (*FwdTxfm2dFunc)(const int16_t *, int32_t *, int, TX_TYPE, int); |
| 78 | typedef void (*InvTxfm2dFunc)(const int32_t *, uint16_t *, int, TX_TYPE, int); |
Peng Bin | 56750cf | 2018-03-02 17:01:19 +0800 | [diff] [blame] | 79 | typedef void (*LbdInvTxfm2dFunc)(const int32_t *, uint8_t *, int, TX_TYPE, |
| 80 | TX_SIZE, int); |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 81 | |
| 82 | static const int bd = 10; |
Angie Chiang | 218dfbd | 2016-04-19 11:59:00 -0700 | [diff] [blame] | 83 | static const int input_base = (1 << bd); |
Angie Chiang | fdaad9f | 2016-05-12 17:11:27 -0700 | [diff] [blame] | 84 | |
Yunqing Wang | 8036058 | 2017-03-28 17:17:23 -0700 | [diff] [blame] | 85 | #if CONFIG_AV1_ENCODER |
Angie Chiang | d2db658 | 2017-08-06 20:46:48 -0700 | [diff] [blame] | 86 | |
Peng Bin | 58bd7ce | 2018-02-07 21:10:54 +0800 | [diff] [blame] | 87 | static const FwdTxfm2dFunc fwd_txfm_func_ls[TX_SIZES_ALL] = { |
Urvang Joshi | 5fb50f8 | 2017-12-12 18:48:55 -0800 | [diff] [blame] | 88 | av1_fwd_txfm2d_4x4_c, av1_fwd_txfm2d_8x8_c, av1_fwd_txfm2d_16x16_c, |
Yaowu Xu | d3d4159 | 2018-02-14 13:26:52 -0800 | [diff] [blame] | 89 | 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-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 95 | }; |
Yunqing Wang | 8036058 | 2017-03-28 17:17:23 -0700 | [diff] [blame] | 96 | #endif |
Angie Chiang | fdaad9f | 2016-05-12 17:11:27 -0700 | [diff] [blame] | 97 | |
Peng Bin | 58bd7ce | 2018-02-07 21:10:54 +0800 | [diff] [blame] | 98 | static const InvTxfm2dFunc inv_txfm_func_ls[TX_SIZES_ALL] = { |
Urvang Joshi | e035b5d | 2017-12-13 10:01:59 -0800 | [diff] [blame] | 99 | 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 Xu | d3d4159 | 2018-02-14 13:26:52 -0800 | [diff] [blame] | 101 | 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-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 109 | }; |
Angie Chiang | fdaad9f | 2016-05-12 17:11:27 -0700 | [diff] [blame] | 110 | |
Angie Chiang | 9c7089a | 2017-08-08 16:21:11 -0700 | [diff] [blame] | 111 | #define BD_NUM 3 |
| 112 | |
| 113 | extern int bd_arr[]; |
| 114 | extern int8_t low_range_arr[]; |
| 115 | extern int8_t high_range_arr[]; |
| 116 | |
| 117 | void txfm_stage_range_check(const int8_t *stage_range, int stage_num, |
Angie Chiang | d4327bc | 2018-01-22 20:54:04 -0800 | [diff] [blame] | 118 | const int8_t cos_bit, int low_range, |
Angie Chiang | 9c7089a | 2017-08-08 16:21:11 -0700 | [diff] [blame] | 119 | int high_range); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 120 | } // namespace libaom_test |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 121 | #endif // AV1_TXFM_TEST_H_ |