xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_psy_const.h (revision 15dc779a375ca8b5125643b829a8aa4b70d7f451)
1 /******************************************************************************
2  *                                                                            *
3  * Copyright (C) 2023 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************
18  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19  */
20 
21 #pragma once
22 #ifndef TRUE
23 #define TRUE (1)
24 #endif
25 #ifndef FALSE
26 #define FALSE (0)
27 #endif
28 
29 #define TRANS_FAC 8
30 #define FRAME_LEN_SHORT_128 (128)
31 #define FRAME_LEN_SHORT_120 (120)
32 
33 /* Block types */
34 enum { LONG_WINDOW = 0, START_WINDOW, SHORT_WINDOW, STOP_WINDOW };
35 
36 /* Window shapes */
37 enum { SINE_WINDOW = 0, KBD_WINDOW = 1 };
38 
39 enum { LD_WINDOW = 1 };
40 
41 /*  MS stuff */
42 enum { SI_MS_MASK_NONE = 0, SI_MS_MASK_SOME = 1, SI_MS_MASK_ALL = 2 };
43 
44 #define MDCT_LEN 480
45 #define MDCT_LEN_BY2 240
46 #define FFT5 (5)
47 #define FFT2 (2)
48 #define FFT16 (16)
49 #define FFT4 (4)
50 #define FFT3 (3)
51 #define FFT15 (15)
52 #define FFT15X2 (30)
53 #define FFT32 (32)
54 #define FFT16X2 (32)
55 #define FFT32X2 (FFT32 * 2)
56 
57 #define MAX_FLT_VAL (3.402823466e+38F)
58 #define MIN_FLT_VAL (1.175494351e-38F)
59 #define MIN_SHRT_VAL (-32768)
60 #define MAX_SHRT_VAL (32767)
61 
62 #define MAXIMUM_NO_OF_GROUPS 4
63 
64 #define MAXIMUM_SCALE_FACTOR_BAND_SHORT 15
65 #define MAXIMUM_SCALE_FACTOR_BAND_LONG 51
66 
67 /* = MAXIMUM_SCALE_FACTOR_BAND_LONG */
68 #define MAXIMUM_SCALE_FACTOR_BAND                                   \
69   (MAXIMUM_SCALE_FACTOR_BAND_SHORT > MAXIMUM_SCALE_FACTOR_BAND_LONG \
70        ? MAXIMUM_SCALE_FACTOR_BAND_SHORT                            \
71        : MAXIMUM_SCALE_FACTOR_BAND_LONG)
72 #define MAXIMUM_GROUPED_SCALE_FACTOR_BAND                                                  \
73   (MAXIMUM_NO_OF_GROUPS * MAXIMUM_SCALE_FACTOR_BAND_SHORT > MAXIMUM_SCALE_FACTOR_BAND_LONG \
74        ? MAXIMUM_NO_OF_GROUPS * MAXIMUM_SCALE_FACTOR_BAND_SHORT                            \
75        : MAXIMUM_SCALE_FACTOR_BAND_LONG)
76 
77 #define MAX_CHANNELS (2)
78 /* For 2:1 resampler -> max phase delay * resamp_fac */
79 #define MAX_DS_2_1_FILTER_DELAY (16)
80 
81 /* For 4:1 resampler -> max phase delay * resamp_fac */
82 #define MAX_DS_4_1_FILTER_DELAY (64)
83 
84 /* For 8:1 resampler -> max phase delay * resamp_fac */
85 #define MAX_DS_8_1_FILTER_DELAY (248)
86 
87 /* For 1:3 resampler -> max phase delay * resamp_fac */
88 #define MAX_DS_1_3_FILTER_DELAY (36)
89 
90 #define BLK_SWITCH_OFFSET_LC_128 (1 * 1024 + 3 * 128 + 64 + 128)
91 #define BLK_SWITCH_OFFSET_LC_120 (1 * 960 + 3 * 120 + 60 + 120)
92 #define BLK_SWITCH_OFFSET_LD (2048)
93 
94 #define MAXIMUM_CHANNEL_BITS_1024 6144
95 #define MAXIMUM_CHANNEL_BITS_960 5760
96 #define MAXIMUM_CHANNEL_BITS_512 3072
97 #define MAXIMUM_CHANNEL_BITS_480 2880
98 
99 #define TRANSFORM_OFFSET_SHORT_128 448
100 #define TRANSFORM_OFFSET_SHORT_120 420
101 
102 #define PCM_LEVEL 1.0f
103 #define NORMALIZED_PCM (PCM_LEVEL)
104 #define CLIP_ENERGY_VALUE_LONG (1.0e9f)
105 #define FADE_OUT_LEN (6)
106 #define MIN_THRESH_FAC (0.01f)
107