blob: 9963bb57a19188d1f6a28066353631c88190825a [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Krishna Rapaka7319db52021-09-28 20:35:29 -07002 * Copyright (c) 2021, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Vibhoothi41c6dd72021-10-12 18:48:26 +00004 * 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 Xuc27fc142016-08-22 16:08:15 -070011 */
12
James Zerne1cbb132018-08-22 14:10:36 -070013#ifndef AOM_AOM_DSP_TXFM_COMMON_H_
14#define AOM_AOM_DSP_TXFM_COMMON_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070015
Yaowu Xuf883b422016-08-30 14:01:10 -070016#include "aom_dsp/aom_dsp_common.h"
Urvang Joshi2283d372017-10-02 17:16:45 -070017#include "av1/common/enums.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070018
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 Lu27319b62017-07-10 16:57:15 -070026typedef struct txfm_param {
27 // for both forward and inverse transforms
Urvang Joshi2283d372017-10-02 17:16:45 -070028 TX_TYPE tx_type;
Madhu Peringassery Krishnanee0d2f02021-06-14 12:08:32 -070029 // for both forward and inverse secondary transforms
Madhu Peringassery Krishnanee0d2f02021-06-14 12:08:32 -070030 // Secondary transform type used for the current tx block.
xinzhaoaa594072022-01-20 13:03:10 -080031 TX_TYPE sec_tx_type;
Madhu Peringassery Krishnanee0d2f02021-06-14 12:08:32 -070032 // intra prediction mode used for the current tx block
33 PREDICTION_MODE intra_mode;
Lester Lu68b107b2022-12-20 21:24:24 +000034#if CONFIG_CROSS_CHROMA_TX
35 CctxType cctx_type;
36#endif // CONFIG_CROSS_CHROMA_TX
Urvang Joshi2283d372017-10-02 17:16:45 -070037 TX_SIZE tx_size;
Lester Lu27319b62017-07-10 16:57:15 -070038 int lossless;
39 int bd;
Sarah Parker90024e42017-10-06 16:50:47 -070040 TxSetType tx_set_type;
Sebastien Alaiwan23c511e2017-12-19 16:22:29 +010041 // for inverse transforms only
Lester Lu27319b62017-07-10 16:57:15 -070042 int eob;
43} TxfmParam;
44
Yaowu Xuc27fc142016-08-22 16:08:15 -070045// Constants:
46// for (int i = 1; i< 32; ++i)
47// printf("static const int cospi_%d_64 = %.0f;\n", i,
David Turnerf2ea6e12018-10-19 11:04:25 +010048// round(16384 * cos(i*PI/64)));
Yaowu Xuc27fc142016-08-22 16:08:15 -070049// Note: sin(k*Pi/64) = cos((32-k)*Pi/64)
50static const tran_high_t cospi_1_64 = 16364;
51static const tran_high_t cospi_2_64 = 16305;
52static const tran_high_t cospi_3_64 = 16207;
53static const tran_high_t cospi_4_64 = 16069;
54static const tran_high_t cospi_5_64 = 15893;
55static const tran_high_t cospi_6_64 = 15679;
56static const tran_high_t cospi_7_64 = 15426;
57static const tran_high_t cospi_8_64 = 15137;
58static const tran_high_t cospi_9_64 = 14811;
59static const tran_high_t cospi_10_64 = 14449;
60static const tran_high_t cospi_11_64 = 14053;
61static const tran_high_t cospi_12_64 = 13623;
62static const tran_high_t cospi_13_64 = 13160;
63static const tran_high_t cospi_14_64 = 12665;
64static const tran_high_t cospi_15_64 = 12140;
65static const tran_high_t cospi_16_64 = 11585;
66static const tran_high_t cospi_17_64 = 11003;
67static const tran_high_t cospi_18_64 = 10394;
68static const tran_high_t cospi_19_64 = 9760;
69static const tran_high_t cospi_20_64 = 9102;
70static const tran_high_t cospi_21_64 = 8423;
71static const tran_high_t cospi_22_64 = 7723;
72static const tran_high_t cospi_23_64 = 7005;
73static const tran_high_t cospi_24_64 = 6270;
74static const tran_high_t cospi_25_64 = 5520;
75static const tran_high_t cospi_26_64 = 4756;
76static const tran_high_t cospi_27_64 = 3981;
77static const tran_high_t cospi_28_64 = 3196;
78static const tran_high_t cospi_29_64 = 2404;
79static const tran_high_t cospi_30_64 = 1606;
80static const tran_high_t cospi_31_64 = 804;
81
Yaowu Xu9c01aa12016-09-01 14:32:49 -070082// 16384 * sqrt(2) * sin(kPi/9) * 2 / 3
Yaowu Xuc27fc142016-08-22 16:08:15 -070083static const tran_high_t sinpi_1_9 = 5283;
84static const tran_high_t sinpi_2_9 = 9929;
85static const tran_high_t sinpi_3_9 = 13377;
86static const tran_high_t sinpi_4_9 = 15212;
87
88// 16384 * sqrt(2)
89static const tran_high_t Sqrt2 = 23170;
Debargha Mukherjee570423c2017-10-01 00:35:20 -070090static const tran_high_t InvSqrt2 = 11585;
Yaowu Xuc27fc142016-08-22 16:08:15 -070091
Sarah Parker31c66502017-05-19 16:51:07 -070092static 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 Luad8290b2017-06-12 18:26:18 -070096
James Zerne1cbb132018-08-22 14:10:36 -070097#endif // AOM_AOM_DSP_TXFM_COMMON_H_