• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *                                                                            *
3  * Copyright (C) 2018 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 #ifndef IXHEAACD_STRUCT_DEF_H
21 #define IXHEAACD_STRUCT_DEF_H
22 
23 #include <setjmp.h>
24 
25 #define MAX_OUTPUT_CHANNELS (8)
26 #define MAX_NUM_OTT (1)
27 
28 #define MAX_ARBITRARY_TREE_LEVELS (2)
29 #define MAX_PARAMETER_SETS (8)
30 #define MAX_ARBITRARY_TREE_INDEX ((1 << (MAX_ARBITRARY_TREE_LEVELS + 1)) - 1)
31 #define MAX_NUM_QMF_BANDS (64)
32 #define MAX_NUM_OTT_AT \
33   (MAX_OUTPUT_CHANNELS * ((1 << MAX_ARBITRARY_TREE_LEVELS) - 1))
34 #define MAX_PARAMETER_BANDS (28)
35 #define MAX_DECOR_CONFIG_IDX (2)
36 
37 #define MAX_HYBRID_BANDS (MAX_NUM_QMF_BANDS - 3 + 10)
38 
39 #define MAX_TIME_SLOTS (72)
40 
41 #define MAX_M2_OUTPUT (8)
42 #define QMF_BANDS_TO_HYBRID (3)
43 #define PROTO_LEN (13)
44 #define BUFFER_LEN_LF (PROTO_LEN - 1 + MAX_TIME_SLOTS)
45 #define BUFFER_LEN_HF ((PROTO_LEN - 1) / 2)
46 #define MAX_TIME_SLOTS (72)
47 #define MAX_NO_TIME_SLOTS_DELAY (14)
48 
49 typedef struct {
50   WORD8 element_instance_tag;
51   WORD32 object_type;
52   WORD32 samp_freq_index;
53   WORD32 num_front_channel_elements;
54   WORD32 num_side_channel_elements;
55   WORD32 num_back_channel_elements;
56   WORD32 num_lfe_channel_elements;
57   WORD32 num_assoc_data_elements;
58   WORD32 num_valid_cc_elements;
59 
60   WORD8 front_element_is_cpe[16];
61   WORD8 front_element_tag_select[16];
62   WORD8 side_element_is_cpe[16];
63   WORD8 side_element_tag_select[16];
64   WORD8 back_element_is_cpe[16];
65   WORD8 back_element_tag_select[16];
66   WORD8 lfe_element_tag_select[16];
67 
68   WORD32 channels;
69   WORD32 alignment_bits;
70 
71 } ia_program_config_struct;
72 
73 typedef struct ia_enhaacplus_dec_ind_cc {
74   WORD8 cc_target_is_cpe[MAX_BS_ELEMENT];
75   WORD8 cc_target_tag_select[MAX_BS_ELEMENT];
76   WORD8 cc_l[MAX_BS_ELEMENT];
77   WORD8 cc_r[MAX_BS_ELEMENT];
78   WORD32 cc_gain[2 * MAX_BS_ELEMENT];
79   WORD8 elements_coupled[MAX_BS_ELEMENT];
80   WORD num_coupled_elements;
81 
82 } ia_enhaacplus_dec_ind_cc;
83 
84 typedef struct {
85   UWORD32 ui_pcm_wdsz;
86   UWORD32 ui_samp_freq;
87   UWORD32 ui_n_channels;
88   WORD32 i_channel_mask;
89   UWORD32 ui_channel_mode;
90   UWORD32 ui_sbr_mode;
91   WORD32 ui_effect_type;
92   WORD32 ui_target_loudness;
93   WORD32 ui_loud_norm_flag;
94 
95   UWORD32 flag_downmix;
96   UWORD32 flag_08khz_out;
97   UWORD32 flag_16khz_out;
98   UWORD32 flag_to_stereo;
99   UWORD32 down_sample_flag;
100   UWORD32 header_dec_done;
101   UWORD32 ui_mp4_flag;
102   UWORD32 ui_disable_sync;
103   UWORD32 ui_auto_sbr_upsample;
104   WORD32 frame_status;
105   UWORD32 ui_max_channels;
106   UWORD32 ui_pce_found_in_hdr;
107   UWORD32 ui_n_memtabs;
108 
109   WORD32 ui_drc_enable;
110   WORD32 ui_drc_boost;
111   WORD32 ui_drc_cut;
112   WORD32 ui_drc_target_level;
113   WORD32 ui_drc_set;
114   WORD32 ui_drc_heavy_comp;
115 
116   ia_program_config_struct str_prog_config;
117   WORD32 element_type[MAX_BS_ELEMENT + 1];
118   WORD32 slot_element[MAX_BS_ELEMENT + 1];
119 
120   WORD element_instance_order[MAX_BS_ELEMENT];
121   WORD ui_coupling_channel;
122   WORD downmix;
123   WORD32 loas_present;
124 
125   WORD framesize_480;
126   WORD ld_decoder;
127 
128   WORD eld_sbr_present;
129 
130   UWORD32 ui_out_channels;
131   WORD32 ui_channel_mask;
132 
133   WORD32 ui_dec_type;
134 
135   UWORD32 ui_qmf_bands;
136 
137   WORD32 ui_flush_cmd;
138 
139   ia_drc_config drc_config_struct;
140 
141 } ia_aac_dec_config_struct;
142 
143 typedef struct ia_aac_dec_state_struct {
144   ia_aac_dec_config_struct *p_config;
145 
146   AUDIO_OBJECT_TYPE audio_object_type;
147 
148   UWORD32 ui_in_bytes;
149   UWORD32 ui_out_bytes;
150   UWORD32 ui_exec_done;
151 
152   WORD16 b_n_raw_data_blk;
153   WORD16 s_adts_hdr_present;
154   WORD16 s_adif_hdr_present;
155   WORD16 num_channel_last;
156   UWORD32 sampling_rate;
157   UWORD32 extension_samp_rate;
158   UWORD32 bit_rate;
159   UWORD32 ui_init_done;
160   UWORD32 ui_input_over;
161   UWORD32 header_dec_done;
162   WORD32 frame_counter;
163   ia_aac_decoder_struct *pstr_aac_dec_info[MAX_BS_ELEMENT];
164 
165   UWORD32 ch_config;
166   struct ia_bit_buf_struct str_bit_buf, *pstr_bit_buf;
167   ia_aac_dec_sbr_bitstream_struct (*pstr_stream_sbr)[2];
168   ia_handle_sbr_dec_inst_struct str_sbr_dec_info[MAX_BS_ELEMENT];
169   WORD32 sbr_present_flag;
170   WORD32 ps_present;
171 
172   ia_bit_buf_struct *ptr_bit_stream;
173 
174   VOID *aac_scratch_mem_v;
175   VOID *aac_persistent_mem_v;
176 
177   VOID *sbr_persistent_mem_v;
178   WORD32 *ptr_overlap_buf;
179   WORD16 num_of_out_samples;
180   WORD32 last_frame_ok;
181   WORD32 i_bytes_consumed;
182 
183   WORD16 *coup_ch_output;
184   ia_enhaacplus_dec_ind_cc ind_cc_info;
185 
186   WORD8 protection_absent;
187   WORD32 crc_check;
188   WORD32 ui_flush_cmd;
189 
190   WORD32 frame_len_flag;
191   WORD32 depends_on_core_coder;
192   WORD32 extension_flag;
193 
194   WORD32 bs_format;
195   WORD32 bit_count;
196   WORD32 sync_status;
197   WORD32 extension_flag_3;
198 
199   ixheaacd_latm_struct latm_struct_element;
200   WORD32 latm_initialized;
201 
202   ia_drc_dec_struct str_drc_dec_info;
203   ia_drc_dec_struct drc_dummy;
204   ia_drc_dec_struct *pstr_drc_dec;
205   ixheaac_drc_data_struct *pstr_hdrc_data[MAX_BS_ELEMENT * 3];
206 
207   WORD32 prev_channel_mode;
208   WORD32 drc_cut_fac;
209   WORD32 drc_boost_fac;
210 
211   WORD32 first_drc_frame;
212 
213   ia_aac_err_config_struct str_err_config;
214   WORD32 frame_size;
215   WORD32 frame_length;
216 
217   WORD32 dwnsmp_signal;
218   ia_eld_specific_config_struct eld_specific_config;
219   FLAG usac_flag;
220 
221   WORD32 num_of_output_ch;
222   VOID *ia_audio_specific_config;
223   ia_mps_dec_state_struct mps_dec_handle;
224 
225   UWORD16 *huffman_code_book_scl;
226   UWORD32 *huffman_code_book_scl_index;
227 
228   ia_aac_dec_tables_struct *pstr_aac_tables;
229 
230   VOID *pstr_dec_data;
231   VOID *sbr_persistent_mem_u;
232   VOID *sbr_scratch_mem_u;
233   UWORD8 *header_ptr;
234   WORD32 header_length;
235   ia_sbr_header_data_struct str_sbr_config;
236   jmp_buf xaac_jmp_buf;
237   WORD32 decode_create_done;
238   WORD32 fatal_err_present;
239   WORD8 *pers_mem_ptr;
240 } ia_aac_dec_state_struct;
241 
242 typedef struct ia_exhaacplus_dec_api_struct {
243   ia_aac_dec_state_struct *p_state_aac;
244 
245   ia_aac_dec_config_struct aac_config;
246 
247   ia_mem_info_struct *p_mem_info_aac;
248 
249   pVOID *pp_mem_aac;
250 
251   ia_aac_dec_tables_struct aac_tables;
252   ixheaacd_misc_tables *common_tables;
253   ia_sbr_tables_struct str_sbr_tables;
254 
255 } ia_exhaacplus_dec_api_struct;
256 
257 WORD32 ixheaacd_aacdec_decodeframe(
258     ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec,
259     ia_aac_dec_scratch_struct *aac_scratch_ptrs, WORD16 *time_data,
260     FLAG frame_status, WORD *type, WORD *ch_idx, WORD init_flag, WORD channel,
261     WORD *element_index_order, WORD skip_full_decode, WORD ch_fac,
262     WORD slot_element, WORD max_channels, WORD32 total_channels,
263     WORD32 frame_length, WORD32 frame_size, ia_drc_dec_struct *pstr_drc_dec,
264     WORD32 object_type, WORD32 ch_config,
265     ia_eld_specific_config_struct eld_specific_config, WORD16 adtsheader,
266     ia_drc_dec_struct *drc_dummy);
267 
268 WORD ixheaacd_get_channel_mask(
269     ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec);
270 
271 VOID ixheaacd_allocate_mem_persistent(
272     ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec,
273     ia_aac_dec_state_struct *p_state_enhaacplus_dec, WORD channels,
274     WORD *persistent_used_total, WORD *sbr_persistent_start, WORD ps_enable);
275 
276 WORD32 ixheaacd_dec_mem_api(ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec,
277                             WORD32 i_cmd, WORD32 i_idx, VOID *pv_value);
278 
279 VOID ixheaacd_fill_aac_mem_tables(
280     ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec);
281 
282 WORD32 ixheaacd_decoder_2_ga_hdr(
283     ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec);
284 
285 WORD32 ixheaacd_decoder_flush_api(
286     ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec);
287 
288 WORD32 ixheaacd_fill_usac_mem_tables(ia_exhaacplus_dec_api_struct *self);
289 
290 WORD32 ixheaacd_dec_init(ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec);
291 
292 WORD32 ixheaacd_dec_execute(ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec);
293 
294 WORD32 ixheaacd_dec_table_api(
295     ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec, WORD32 i_cmd,
296     WORD32 i_idx, VOID *pv_value);
297 
298 #endif /* IXHEAACD_STRUCT_DEF_H */
299