Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [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. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 12 | #ifndef AOM_AOM_DSP_TXFM_COMMON_H_ |
| 13 | #define AOM_AOM_DSP_TXFM_COMMON_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 15 | #include "aom_dsp/aom_dsp_common.h" |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 16 | #include "av1/common/enums.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 17 | |
| 18 | // Constants and Macros used by all idct/dct functions |
| 19 | #define DCT_CONST_BITS 14 |
| 20 | #define DCT_CONST_ROUNDING (1 << (DCT_CONST_BITS - 1)) |
| 21 | |
| 22 | #define UNIT_QUANT_SHIFT 2 |
| 23 | #define UNIT_QUANT_FACTOR (1 << UNIT_QUANT_SHIFT) |
| 24 | |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 25 | typedef struct txfm_param { |
| 26 | // for both forward and inverse transforms |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 27 | TX_TYPE tx_type; |
| 28 | TX_SIZE tx_size; |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 29 | int lossless; |
| 30 | int bd; |
Monty Montgomery | 26b8a99 | 2017-11-10 22:45:23 -0500 | [diff] [blame] | 31 | // are the pixel buffers octets or shorts? This should collapse to |
| 32 | // bd==8 implies !is_hbd, but that's not certain right now. |
| 33 | int is_hbd; |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame] | 34 | TxSetType tx_set_type; |
Sebastien Alaiwan | 23c511e | 2017-12-19 16:22:29 +0100 | [diff] [blame] | 35 | // for inverse transforms only |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 36 | int eob; |
| 37 | } TxfmParam; |
| 38 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 39 | // Constants: |
| 40 | // for (int i = 1; i< 32; ++i) |
| 41 | // printf("static const int cospi_%d_64 = %.0f;\n", i, |
David Turner | f2ea6e1 | 2018-10-19 11:04:25 +0100 | [diff] [blame] | 42 | // round(16384 * cos(i*PI/64))); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 43 | // Note: sin(k*Pi/64) = cos((32-k)*Pi/64) |
| 44 | static const tran_high_t cospi_1_64 = 16364; |
| 45 | static const tran_high_t cospi_2_64 = 16305; |
| 46 | static const tran_high_t cospi_3_64 = 16207; |
| 47 | static const tran_high_t cospi_4_64 = 16069; |
| 48 | static const tran_high_t cospi_5_64 = 15893; |
| 49 | static const tran_high_t cospi_6_64 = 15679; |
| 50 | static const tran_high_t cospi_7_64 = 15426; |
| 51 | static const tran_high_t cospi_8_64 = 15137; |
| 52 | static const tran_high_t cospi_9_64 = 14811; |
| 53 | static const tran_high_t cospi_10_64 = 14449; |
| 54 | static const tran_high_t cospi_11_64 = 14053; |
| 55 | static const tran_high_t cospi_12_64 = 13623; |
| 56 | static const tran_high_t cospi_13_64 = 13160; |
| 57 | static const tran_high_t cospi_14_64 = 12665; |
| 58 | static const tran_high_t cospi_15_64 = 12140; |
| 59 | static const tran_high_t cospi_16_64 = 11585; |
| 60 | static const tran_high_t cospi_17_64 = 11003; |
| 61 | static const tran_high_t cospi_18_64 = 10394; |
| 62 | static const tran_high_t cospi_19_64 = 9760; |
| 63 | static const tran_high_t cospi_20_64 = 9102; |
| 64 | static const tran_high_t cospi_21_64 = 8423; |
| 65 | static const tran_high_t cospi_22_64 = 7723; |
| 66 | static const tran_high_t cospi_23_64 = 7005; |
| 67 | static const tran_high_t cospi_24_64 = 6270; |
| 68 | static const tran_high_t cospi_25_64 = 5520; |
| 69 | static const tran_high_t cospi_26_64 = 4756; |
| 70 | static const tran_high_t cospi_27_64 = 3981; |
| 71 | static const tran_high_t cospi_28_64 = 3196; |
| 72 | static const tran_high_t cospi_29_64 = 2404; |
| 73 | static const tran_high_t cospi_30_64 = 1606; |
| 74 | static const tran_high_t cospi_31_64 = 804; |
| 75 | |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 76 | // 16384 * sqrt(2) * sin(kPi/9) * 2 / 3 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 77 | static const tran_high_t sinpi_1_9 = 5283; |
| 78 | static const tran_high_t sinpi_2_9 = 9929; |
| 79 | static const tran_high_t sinpi_3_9 = 13377; |
| 80 | static const tran_high_t sinpi_4_9 = 15212; |
| 81 | |
| 82 | // 16384 * sqrt(2) |
| 83 | static const tran_high_t Sqrt2 = 23170; |
Debargha Mukherjee | 570423c | 2017-10-01 00:35:20 -0700 | [diff] [blame] | 84 | static const tran_high_t InvSqrt2 = 11585; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 85 | |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 86 | static INLINE tran_high_t fdct_round_shift(tran_high_t input) { |
| 87 | tran_high_t rv = ROUND_POWER_OF_TWO(input, DCT_CONST_BITS); |
| 88 | return rv; |
| 89 | } |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 90 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 91 | #endif // AOM_AOM_DSP_TXFM_COMMON_H_ |