Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 The WebM project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 11 | #ifndef AV1_TXFM_TEST_H_ |
| 12 | #define AV1_TXFM_TEST_H_ |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 13 | |
| 14 | #include <stdio.h> |
| 15 | #include <stdlib.h> |
Yaowu Xu | 4bc259d | 2015-11-09 12:07:25 -0800 | [diff] [blame] | 16 | #ifdef _MSC_VER |
| 17 | #define _USE_MATH_DEFINES |
| 18 | #endif |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 19 | #include <math.h> |
| 20 | |
| 21 | #include "third_party/googletest/src/include/gtest/gtest.h" |
| 22 | |
| 23 | #include "test/acm_random.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 24 | #include "av1/common/enums.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 25 | #include "av1/common/av1_txfm.h" |
| 26 | #include "./av1_rtcd.h" |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 27 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 28 | namespace libaom_test { |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 29 | typedef enum { |
| 30 | TYPE_DCT = 0, |
| 31 | TYPE_ADST, |
| 32 | TYPE_IDCT, |
| 33 | TYPE_IADST, |
| 34 | TYPE_LAST |
| 35 | } TYPE_TXFM; |
| 36 | |
Angie Chiang | 716f1bd | 2016-05-11 16:41:36 -0700 | [diff] [blame] | 37 | int get_txfm1d_size(TX_SIZE tx_size); |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 38 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 39 | 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] | 40 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 41 | void reference_dct_1d(const double *in, double *out, int size); |
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_adst_1d(const double *in, double *out, int size); |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 44 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 45 | void reference_hybrid_1d(double *in, double *out, int size, int type); |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 46 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 47 | void reference_hybrid_2d(double *in, double *out, int size, int type0, |
| 48 | int type1); |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 49 | template <typename Type1, typename Type2> |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 50 | static double compute_avg_abs_error(const Type1 *a, const Type2 *b, |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 51 | const int size) { |
| 52 | double error = 0; |
| 53 | for (int i = 0; i < size; i++) { |
| 54 | error += fabs(static_cast<double>(a[i]) - static_cast<double>(b[i])); |
| 55 | } |
| 56 | error = error / size; |
| 57 | return error; |
| 58 | } |
| 59 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 60 | template <typename Type> |
Angie Chiang | 6a75253 | 2016-05-11 18:50:47 -0700 | [diff] [blame] | 61 | void fliplr(Type *dest, int stride, int length); |
| 62 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 63 | template <typename Type> |
Angie Chiang | 6a75253 | 2016-05-11 18:50:47 -0700 | [diff] [blame] | 64 | void flipud(Type *dest, int stride, int length); |
| 65 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 66 | template <typename Type> |
Angie Chiang | 6a75253 | 2016-05-11 18:50:47 -0700 | [diff] [blame] | 67 | void fliplrud(Type *dest, int stride, int length); |
| 68 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 69 | typedef void (*TxfmFunc)(const int32_t *in, int32_t *out, const int8_t *cos_bit, |
| 70 | const int8_t *range_bit); |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 71 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 72 | typedef void (*Fwd_Txfm2d_Func)(const int16_t *, int32_t *, int, int, int); |
| 73 | typedef void (*Inv_Txfm2d_Func)(const int32_t *, uint16_t *, int, int, int); |
Angie Chiang | b934148 | 2015-10-27 16:41:38 -0700 | [diff] [blame] | 74 | |
| 75 | static const int bd = 10; |
Angie Chiang | 218dfbd | 2016-04-19 11:59:00 -0700 | [diff] [blame] | 76 | static const int input_base = (1 << bd); |
Angie Chiang | fdaad9f | 2016-05-12 17:11:27 -0700 | [diff] [blame] | 77 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 78 | #if CONFIG_AOM_HIGHBITDEPTH |
Angie Chiang | fdaad9f | 2016-05-12 17:11:27 -0700 | [diff] [blame] | 79 | static const Fwd_Txfm2d_Func fwd_txfm_func_ls[TX_SIZES] = { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 80 | av1_fwd_txfm2d_4x4_c, av1_fwd_txfm2d_8x8_c, av1_fwd_txfm2d_16x16_c, |
| 81 | av1_fwd_txfm2d_32x32_c |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 82 | }; |
Angie Chiang | fdaad9f | 2016-05-12 17:11:27 -0700 | [diff] [blame] | 83 | |
| 84 | static const Inv_Txfm2d_Func inv_txfm_func_ls[TX_SIZES] = { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 85 | av1_inv_txfm2d_add_4x4_c, av1_inv_txfm2d_add_8x8_c, |
| 86 | av1_inv_txfm2d_add_16x16_c, av1_inv_txfm2d_add_32x32_c |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 87 | }; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 88 | #endif // CONFIG_AOM_HIGHBITDEPTH |
Angie Chiang | fdaad9f | 2016-05-12 17:11:27 -0700 | [diff] [blame] | 89 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 90 | } // namespace libaom_test |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 91 | #endif // AV1_TXFM_TEST_H_ |