xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_aac_constants.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 // FLOAT values
23 #define IXHEAACE_COS_PI_BY_4 (0.70709228515625f)      // 0.7071067812f
24 #define IXHEAACE_COS_PI_BY_8 (0.92388916015625f)      // 0.923879532511287f
25 #define IXHEAACE_SIN_PI_BY_8 (0.3826904296875f)       // 0.382683432365090f
26 #define IXHEAACE_COS_PI_BY_16 (0.98077392578125f)     // 0.980785280403230f
27 #define IXHEAACE_SIN_PI_BY_16 (0.195098876953125f)    // 0.195090322016128f
28 #define IXHEAACE_COS_3_PI_BY_16 (0.83148193359375f)   // 0.831469612302545f
29 #define IXHEAACE_SIN_3_PI_BY_16 (0.555572509765625f)  // 0.555570233019602f
30 #define IXHEAACE_INV_SQRT2 (7.071067811865475e-1f)
31 #define IXHEAACE_COS_PI_DIV8 (0.923879532511287f)
32 #define IXHEAACE_COS_3PI_DIV8 (3.826834323650898e-1f)
33 #define IXHEAACE_SQRT2PLUS1 (2.414213562373095f)
34 #define IXHEAACE_SQRT2MINUS1 (4.142135623730952e-1f)
35 
36 #define INV_SQRT_2_FLOAT 0x3F3504F3  // 1/sqrt(2) in float
37 
38 #define Q_POWER2_TABLE 30
39 
40 #define DIV_FAC_24_BIT_PCM (256.0f)
41 #define DIV_FAC_32_BIT_PCM (65536.0f)
42 
43 #define AUDIO_PROFILE_AAC_LC_L5 (0x2B)
44 #define AUDIO_PROFILE_HEAAC_L5 (0x2F)
45 #define AUDIO_PROFILE_HEAAC_V2_L5 (0x33)
46 #define AUDIO_PROFILE_AAC_LD_L4 (0x19)
47 #define AUDIO_PROFILE_AAC_ELD_L1 (0x4C)
48 #define AUDIO_PROFILE_AAC_ELD_L2 (0x4D)
49 #define AUDIO_PROFILE_AAC_ELD_L4 (0x4F)
50 #define AUDIO_PROFILE_USAC_L2 (0x45)
51 #define AUDIO_PROFILE_NOT_SPECIFIED (0xFE)
52 
53 #define CLIP_SAVE_LO_LONG (0.2f)
54 #define CLIP_SAVE_HI_LONG (0.95f)
55 #define MIN_BITS_SAVE_LONG (-0.05f)
56 #define MAX_BITS_SAVE_LONG (0.3f)
57 #define CLIP_SPEND_LO_LONG (0.2f)
58 #define CLIP_SPEND_HI_LONG (0.95f)
59 #define MIN_BITS_SPEND_LONG (-0.10f)
60 #define MAX_BITS_SPEND_LONG (0.4f)
61 #define CLIP_SAVE_LO_SHORT (0.2f)
62 #define CLIP_SAVE_HI_SHORT (0.75f)
63 #define MIN_BITS_SAVE_SHORT (0.0f)
64 #define MAX_BITS_SAVE_SHORT (0.2f)
65 #define CLIP_SPEND_LO_SHORT (0.2f)
66 #define CLIP_SPEND_HI_SHORT (0.75f)
67 #define MIN_BITS_SPEND_SHORT (-0.05f)
68 #define MAX_BITS_SPEND_SHORT (0.5f)
69 typedef struct {
70   FLOAT32 re;
71   FLOAT32 im;
72 } complex;
73 
74 typedef struct {
75   UWORD8 *data;       /* data bits */
76   WORD32 num_bit;     /* number of bits in buffer */
77   WORD32 size;        /* buffer size in bytes */
78   WORD32 current_bit; /* current bit position in bit stream */
79 } ixheaace_bitstream_params;
80 
81 /* bits in byte (char) */
82 #define BYTE_NUMBIT 8
83 #define EIGHT_BYTE_SIZE (8)
84 
85 /* here we distinguish between stereo and the mono only encoder */
86 #define IXHEAACE_MAX_CH_IN_BS_ELE (2)
87 
88 #define MAXIMUM_BS_ELE \
89   8 /* 1 <SCE> 2 <CPE> 3<CPE> 4<CPE> 5<LFE> 6<SCE> - 8.1 channel + 2 cc channels*/
90 
91 #define FRAME_LEN_1024 1024
92 #define FRAME_LEN_512 512
93 #define FRAME_LEN_480 480
94 #define FRAME_LEN_960 960
95 
96 #define AACENC_TRANS_FAC 8   /* encoder WORD16 long ratio */
97 #define AACENC_PCM_LEVEL 1.0 /* encoder pcm 0db refernence */
98 
99 #define MAX_INPUT_CHAN (IXHEAACE_MAX_CH_IN_BS_ELE)
100 
101 #define MAX_FRAME_LEN (1024)
102 
103 /* channel masking*/
104 #define CH_MASK_CENTER_FRONT (0x4)
105 #define CH_MASK_LEFT_RIGHT_FRONT (0x3)
106 #define CH_MASK_REAR_CENTER (0x100)
107 #define CH_MASK_LEFT_RIGHT_BACK (0X30)
108 #define CH_MASK_LFE (0x08)
109 
110 // Change to accommodate 4:1 resampler - input = 4096 samples per channel
111 #define MAX_INPUT_SAMPLES (MAX_FRAME_LEN * MAX_INPUT_CHAN * 4)
112 
113 #define NUM_CHANS_MONO (1)
114 #define NUM_CHANS_STEREO (2)
115 #define MAX_NUM_CORE_CODER_CHANNELS (6)
116 #define MIN_NUM_CORE_CODER_CHANNELS (1)
117 /*-------------------------- defines --------------------------------------*/
118 
119 #define BUFFERSIZE 1024 /* anc data */
120 #define MAX_GAIN_INDEX (128)