blob: f13d69092d8d97128610fbb45c85f3dff2107641 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004 * 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 Xuc27fc142016-08-22 16:08:15 -070010 */
11
James Zerne1cbb132018-08-22 14:10:36 -070012#ifndef AOM_AOM_DSP_TXFM_COMMON_H_
13#define AOM_AOM_DSP_TXFM_COMMON_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
Yaowu Xuf883b422016-08-30 14:01:10 -070015#include "aom_dsp/aom_dsp_common.h"
Urvang Joshi2283d372017-10-02 17:16:45 -070016#include "av1/common/enums.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070017
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 Lu27319b62017-07-10 16:57:15 -070025typedef struct txfm_param {
26 // for both forward and inverse transforms
Urvang Joshi2283d372017-10-02 17:16:45 -070027 TX_TYPE tx_type;
28 TX_SIZE tx_size;
Lester Lu27319b62017-07-10 16:57:15 -070029 int lossless;
30 int bd;
Monty Montgomery26b8a992017-11-10 22:45:23 -050031 // 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 Parker90024e42017-10-06 16:50:47 -070034 TxSetType tx_set_type;
Sebastien Alaiwan23c511e2017-12-19 16:22:29 +010035 // for inverse transforms only
Lester Lu27319b62017-07-10 16:57:15 -070036 int eob;
37} TxfmParam;
38
Yaowu Xuc27fc142016-08-22 16:08:15 -070039// Constants:
40// for (int i = 1; i< 32; ++i)
41// printf("static const int cospi_%d_64 = %.0f;\n", i,
David Turnerf2ea6e12018-10-19 11:04:25 +010042// round(16384 * cos(i*PI/64)));
Yaowu Xuc27fc142016-08-22 16:08:15 -070043// Note: sin(k*Pi/64) = cos((32-k)*Pi/64)
44static const tran_high_t cospi_1_64 = 16364;
45static const tran_high_t cospi_2_64 = 16305;
46static const tran_high_t cospi_3_64 = 16207;
47static const tran_high_t cospi_4_64 = 16069;
48static const tran_high_t cospi_5_64 = 15893;
49static const tran_high_t cospi_6_64 = 15679;
50static const tran_high_t cospi_7_64 = 15426;
51static const tran_high_t cospi_8_64 = 15137;
52static const tran_high_t cospi_9_64 = 14811;
53static const tran_high_t cospi_10_64 = 14449;
54static const tran_high_t cospi_11_64 = 14053;
55static const tran_high_t cospi_12_64 = 13623;
56static const tran_high_t cospi_13_64 = 13160;
57static const tran_high_t cospi_14_64 = 12665;
58static const tran_high_t cospi_15_64 = 12140;
59static const tran_high_t cospi_16_64 = 11585;
60static const tran_high_t cospi_17_64 = 11003;
61static const tran_high_t cospi_18_64 = 10394;
62static const tran_high_t cospi_19_64 = 9760;
63static const tran_high_t cospi_20_64 = 9102;
64static const tran_high_t cospi_21_64 = 8423;
65static const tran_high_t cospi_22_64 = 7723;
66static const tran_high_t cospi_23_64 = 7005;
67static const tran_high_t cospi_24_64 = 6270;
68static const tran_high_t cospi_25_64 = 5520;
69static const tran_high_t cospi_26_64 = 4756;
70static const tran_high_t cospi_27_64 = 3981;
71static const tran_high_t cospi_28_64 = 3196;
72static const tran_high_t cospi_29_64 = 2404;
73static const tran_high_t cospi_30_64 = 1606;
74static const tran_high_t cospi_31_64 = 804;
75
Yaowu Xu9c01aa12016-09-01 14:32:49 -070076// 16384 * sqrt(2) * sin(kPi/9) * 2 / 3
Yaowu Xuc27fc142016-08-22 16:08:15 -070077static const tran_high_t sinpi_1_9 = 5283;
78static const tran_high_t sinpi_2_9 = 9929;
79static const tran_high_t sinpi_3_9 = 13377;
80static const tran_high_t sinpi_4_9 = 15212;
81
82// 16384 * sqrt(2)
83static const tran_high_t Sqrt2 = 23170;
Debargha Mukherjee570423c2017-10-01 00:35:20 -070084static const tran_high_t InvSqrt2 = 11585;
Yaowu Xuc27fc142016-08-22 16:08:15 -070085
Sarah Parker31c66502017-05-19 16:51:07 -070086static 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 Luad8290b2017-06-12 18:26:18 -070090
James Zerne1cbb132018-08-22 14:10:36 -070091#endif // AOM_AOM_DSP_TXFM_COMMON_H_