Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Krishna Rapaka | 7319db5 | 2021-09-28 20:35:29 -0700 | [diff] [blame] | 2 | * Copyright (c) 2021, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Vibhoothi | 41c6dd7 | 2021-10-12 18:48:26 +0000 | [diff] [blame] | 4 | * This source code is subject to the terms of the BSD 3-Clause Clear License |
| 5 | * and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear |
| 6 | * License was not distributed with this source code in the LICENSE file, you |
| 7 | * can obtain it at aomedia.org/license/software-license/bsd-3-c-c/. If the |
| 8 | * Alliance for Open Media Patent License 1.0 was not distributed with this |
| 9 | * source code in the PATENTS file, you can obtain it at |
| 10 | * aomedia.org/license/patent-license/. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 11 | */ |
| 12 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 13 | #ifndef AOM_AOM_DSP_TXFM_COMMON_H_ |
| 14 | #define AOM_AOM_DSP_TXFM_COMMON_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 15 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 16 | #include "aom_dsp/aom_dsp_common.h" |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 17 | #include "av1/common/enums.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 18 | |
| 19 | // Constants and Macros used by all idct/dct functions |
| 20 | #define DCT_CONST_BITS 14 |
| 21 | #define DCT_CONST_ROUNDING (1 << (DCT_CONST_BITS - 1)) |
| 22 | |
| 23 | #define UNIT_QUANT_SHIFT 2 |
| 24 | #define UNIT_QUANT_FACTOR (1 << UNIT_QUANT_SHIFT) |
| 25 | |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 26 | typedef struct txfm_param { |
| 27 | // for both forward and inverse transforms |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 28 | TX_TYPE tx_type; |
Madhu Peringassery Krishnan | ee0d2f0 | 2021-06-14 12:08:32 -0700 | [diff] [blame] | 29 | // for both forward and inverse secondary transforms |
Madhu Peringassery Krishnan | ee0d2f0 | 2021-06-14 12:08:32 -0700 | [diff] [blame] | 30 | // Secondary transform type used for the current tx block. |
xinzhao | aa59407 | 2022-01-20 13:03:10 -0800 | [diff] [blame] | 31 | TX_TYPE sec_tx_type; |
Madhu Peringassery Krishnan | ee0d2f0 | 2021-06-14 12:08:32 -0700 | [diff] [blame] | 32 | // intra prediction mode used for the current tx block |
| 33 | PREDICTION_MODE intra_mode; |
Lester Lu | 68b107b | 2022-12-20 21:24:24 +0000 | [diff] [blame] | 34 | #if CONFIG_CROSS_CHROMA_TX |
| 35 | CctxType cctx_type; |
| 36 | #endif // CONFIG_CROSS_CHROMA_TX |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 37 | TX_SIZE tx_size; |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 38 | int lossless; |
| 39 | int bd; |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame] | 40 | TxSetType tx_set_type; |
Sebastien Alaiwan | 23c511e | 2017-12-19 16:22:29 +0100 | [diff] [blame] | 41 | // for inverse transforms only |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 42 | int eob; |
| 43 | } TxfmParam; |
| 44 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 45 | // Constants: |
| 46 | // for (int i = 1; i< 32; ++i) |
| 47 | // printf("static const int cospi_%d_64 = %.0f;\n", i, |
David Turner | f2ea6e1 | 2018-10-19 11:04:25 +0100 | [diff] [blame] | 48 | // round(16384 * cos(i*PI/64))); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 49 | // Note: sin(k*Pi/64) = cos((32-k)*Pi/64) |
| 50 | static const tran_high_t cospi_1_64 = 16364; |
| 51 | static const tran_high_t cospi_2_64 = 16305; |
| 52 | static const tran_high_t cospi_3_64 = 16207; |
| 53 | static const tran_high_t cospi_4_64 = 16069; |
| 54 | static const tran_high_t cospi_5_64 = 15893; |
| 55 | static const tran_high_t cospi_6_64 = 15679; |
| 56 | static const tran_high_t cospi_7_64 = 15426; |
| 57 | static const tran_high_t cospi_8_64 = 15137; |
| 58 | static const tran_high_t cospi_9_64 = 14811; |
| 59 | static const tran_high_t cospi_10_64 = 14449; |
| 60 | static const tran_high_t cospi_11_64 = 14053; |
| 61 | static const tran_high_t cospi_12_64 = 13623; |
| 62 | static const tran_high_t cospi_13_64 = 13160; |
| 63 | static const tran_high_t cospi_14_64 = 12665; |
| 64 | static const tran_high_t cospi_15_64 = 12140; |
| 65 | static const tran_high_t cospi_16_64 = 11585; |
| 66 | static const tran_high_t cospi_17_64 = 11003; |
| 67 | static const tran_high_t cospi_18_64 = 10394; |
| 68 | static const tran_high_t cospi_19_64 = 9760; |
| 69 | static const tran_high_t cospi_20_64 = 9102; |
| 70 | static const tran_high_t cospi_21_64 = 8423; |
| 71 | static const tran_high_t cospi_22_64 = 7723; |
| 72 | static const tran_high_t cospi_23_64 = 7005; |
| 73 | static const tran_high_t cospi_24_64 = 6270; |
| 74 | static const tran_high_t cospi_25_64 = 5520; |
| 75 | static const tran_high_t cospi_26_64 = 4756; |
| 76 | static const tran_high_t cospi_27_64 = 3981; |
| 77 | static const tran_high_t cospi_28_64 = 3196; |
| 78 | static const tran_high_t cospi_29_64 = 2404; |
| 79 | static const tran_high_t cospi_30_64 = 1606; |
| 80 | static const tran_high_t cospi_31_64 = 804; |
| 81 | |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 82 | // 16384 * sqrt(2) * sin(kPi/9) * 2 / 3 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 83 | static const tran_high_t sinpi_1_9 = 5283; |
| 84 | static const tran_high_t sinpi_2_9 = 9929; |
| 85 | static const tran_high_t sinpi_3_9 = 13377; |
| 86 | static const tran_high_t sinpi_4_9 = 15212; |
| 87 | |
| 88 | // 16384 * sqrt(2) |
| 89 | static const tran_high_t Sqrt2 = 23170; |
Debargha Mukherjee | 570423c | 2017-10-01 00:35:20 -0700 | [diff] [blame] | 90 | static const tran_high_t InvSqrt2 = 11585; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 91 | |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 92 | static INLINE tran_high_t fdct_round_shift(tran_high_t input) { |
| 93 | tran_high_t rv = ROUND_POWER_OF_TWO(input, DCT_CONST_BITS); |
| 94 | return rv; |
| 95 | } |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 96 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 97 | #endif // AOM_AOM_DSP_TXFM_COMMON_H_ |