xref: /aosp_15_r20/external/libxaac/decoder/ixheaacd_config.h (revision 15dc779a375ca8b5125643b829a8aa4b70d7f451)
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_CONFIG_H
21 #define IXHEAACD_CONFIG_H
22 
23 #define USAC_MAX_ELEMENTS (16)
24 
25 #define USAC_MAX_CONFIG_EXTENSIONS (16)
26 
27 #define ID_USAC_SCE 0
28 #define ID_USAC_CPE 1
29 #define ID_USAC_LFE 2
30 #define ID_USAC_EXT 3
31 #define ID_USAC_INVALID 0xFF
32 
33 #define USAC_SBR_RATIO_NO_SBR 0
34 #define USAC_SBR_RATIO_INDEX_2_1 1
35 #define USAC_SBR_RATIO_INDEX_8_3 2
36 #define USAC_SBR_RATIO_INDEX_4_1 3
37 
38 #define USAC_OUT_FRAMELENGTH_768 768
39 #define USAC_OUT_FRAMELENGTH_1024 1024
40 #define USAC_OUT_FRAMELENGTH_2048 2048
41 #define USAC_OUT_FRAMELENGTH_4096 4096
42 
43 #define MAX_CORE_SBR_FRAME_LEN_IDX (4)
44 #define IA_MAX_INP_BUFFER_SIZE (8 * 1024 + 11)
45 
46 #define ID_EXT_ELE_FILL 0
47 #define ID_EXT_ELE_MPEGS 1
48 #define ID_EXT_ELE_SAOC 2
49 #define ID_EXT_ELE_AUDIOPREROLL 3
50 #define ID_EXT_ELE_UNI_DRC 4
51 
52 #define ID_CONFIG_EXT_FILL 0
53 #define ID_CONFIG_EXT_LOUDNESS_INFO (2)
54 
55 #define MAX_PARAMETER_BANDS (28)
56 #define MAX_NUM_OTT (5)
57 #define MAX_NUM_TTT (1)
58 #define MAX_INPUT_CHANNELS (2)
59 #define MAX_RESIDUAL_CHANNELS (3)
60 #define MAX_OUTPUT_CHANNELS (7)
61 #define MAX_NUM_EXT_TYPES (8)
62 #define MAX_M_INPUT (2)
63 #define MAX_M_OUTPUT (2)
64 #define QMF_BANDS_TO_HYBRID (3)
65 #define MAX_HYBRID_ONLY_BANDS_PER_QMF (8)
66 #define MAX_ARBITRARY_TREE_LEVELS (2)
67 #define MAX_OUTPUT_CHANNELS_AT \
68   (MAX_OUTPUT_CHANNELS * (1 << MAX_ARBITRARY_TREE_LEVELS))
69 #define MAX_ARBITRARY_TREE_INDEX ((1 << (MAX_ARBITRARY_TREE_LEVELS + 1)) - 1)
70 
71 #define MAX_RES_SAMP_FREQ_IDX 11
72 
73 typedef UWORD8 UINT8;
74 typedef UWORD32 UINT32;
75 
76 typedef struct {
77   UINT32 harmonic_sbr;
78   UINT32 bs_inter_tes;
79   UINT32 bs_pvc;
80   WORD16 dflt_start_freq;
81   WORD16 dflt_stop_freq;
82   WORD16 dflt_header_extra1;
83   WORD16 dflt_header_extra2;
84   WORD16 dflt_freq_scale;
85   WORD16 dflt_alter_scale;
86   WORD16 dflt_noise_bands;
87   WORD16 dflt_limiter_bands;
88   WORD16 dflt_limiter_gains;
89   WORD16 dflt_interpol_freq;
90   WORD16 dflt_smoothing_mode;
91 } ia_usac_dec_sbr_config_struct;
92 
93 typedef struct {
94   UINT32 bs_freq_res;
95   UINT32 bs_fixed_gain_dmx;
96   UINT32 bs_temp_shape_config;
97   UINT32 bs_decorr_config;
98   UINT32 bs_high_rate_mode;
99   UINT32 bs_phase_coding;
100   UINT32 bs_ott_bands_phase_present;
101   UINT32 bs_ott_bands_phase;
102   UINT32 bs_residual_bands;
103   UINT32 bs_pseudo_lr;
104   UINT32 bs_env_quant_mode;
105   UINT32 ldmps_present_flag;
106 
107   UINT32 bs_sampling_freq_index;
108   UINT32 bs_fampling_frequency;
109   UINT32 bs_frame_length;
110   UINT32 bs_tree_config;
111   UINT32 bs_quant_mode;
112   UINT32 bs_one_icc;
113   UINT32 bs_arbitrary_downmix;
114   UINT32 bs_residual_coding;
115   UINT32 bs_fixed_gain_sur;
116   UINT32 bs_fixed_gain_LFE;
117   UINT32 bs_matrix_mode;
118   UINT32 bs_3D_audio_mode;
119   UINT32 bs_3D_audio_HRTF_set;
120   UINT32 bs_HRTF_freq_res;
121   UINT32 HRTF_num_band;
122   UINT32 HRTF_num_phase;  // new
123   UINT32 bs_HRTF_num_chan;
124   UINT32 bs_HRTF_asymmetric;
125   UINT32 bs_HRTF_level_left[MAX_OUTPUT_CHANNELS][MAX_PARAMETER_BANDS];
126   UINT32 bs_HRTF_level_right[MAX_OUTPUT_CHANNELS][MAX_PARAMETER_BANDS];
127   UINT32 bs_HRTF_phase[MAX_OUTPUT_CHANNELS];
128   UINT32 bs_HRTF_phase_LR[MAX_OUTPUT_CHANNELS][MAX_PARAMETER_BANDS];
129   UINT32 bs_HRTF_icc[MAX_OUTPUT_CHANNELS];
130   UINT32 bs_HRTF_icc_LR[MAX_OUTPUT_CHANNELS][MAX_PARAMETER_BANDS];
131   UINT32 bs_ott_bands[MAX_NUM_OTT];
132   UINT32 bs_ttt_dual_mode[MAX_NUM_TTT];
133   UINT32 bs_ttt_mode_low[MAX_NUM_TTT];
134   UINT32 bs_ttt_mode_high[MAX_NUM_TTT];
135   UINT32 bs_ttt_bands_low[MAX_NUM_TTT];
136   UINT32 bs_ttt_bands_high[MAX_NUM_TTT];
137 
138   UINT32 bs_sac_ext_type[MAX_NUM_EXT_TYPES];
139   UINT32 sac_ext_cnt;
140 
141   UINT32 bs_residual_present[MAX_RESIDUAL_CHANNELS];
142   UINT32 bs_residual_sampling_freq_index;
143   UINT32 bs_residual_frames_per_spatial_frame;
144 
145   UINT32 bs_residual_bands_ld_mps[MAX_RESIDUAL_CHANNELS];
146 
147   UINT32 bs_arbitrary_downmix_residual_sampling_freq_index;
148   UINT32 bs_arbitrary_downmix_residual_frames_per_spatial_frame;
149   WORD32 bs_arbitrary_downmix_residual_bands;
150 
151   UINT32 num_out_chan_AT;
152   UINT32 num_ott_boxes_AT;
153   UINT32 bs_output_channel_pos_AT[MAX_OUTPUT_CHANNELS_AT];
154   UINT32 bs_ott_box_present_AT[MAX_OUTPUT_CHANNELS][MAX_ARBITRARY_TREE_INDEX];
155   UINT32 bs_ott_default_cld_AT[MAX_OUTPUT_CHANNELS * MAX_ARBITRARY_TREE_INDEX];
156   UINT32 bs_ott_mode_lfe_AT[MAX_OUTPUT_CHANNELS * MAX_ARBITRARY_TREE_INDEX];
157   UINT32 bs_ott_bands_AT[MAX_OUTPUT_CHANNELS * MAX_ARBITRARY_TREE_INDEX];
158 
159   WORD32 num_ott_boxes;
160   WORD32 num_ttt_boxes;
161   WORD32 num_input_channels;
162   WORD32 num_output_channels;
163   WORD32 ott_mode_lfe[MAX_NUM_OTT];  // new
164   WORD32 no_ldsbr_present;
165 } ia_usac_dec_mps_config_struct;
166 
167 #define BS_OUTPUT_CHANNEL_POS_NA -1   /* n/a                                */
168 #define BS_OUTPUT_CHANNEL_POS_L 0     /* Left Front                          */
169 #define BS_OUTPUT_CHANNEL_POS_R 1     /* Right Front                         */
170 #define BS_OUTPUT_CHANNEL_POS_C 2     /* Center Front                        */
171 #define BS_OUTPUT_CHANNEL_POS_LFE 3   /* Low Frequency Enhancement           */
172 #define BS_OUTPUT_CHANNEL_POS_LS 4    /* Left Surround                       */
173 #define BS_OUTPUT_CHANNEL_POS_RS 5    /* Right Surround                      */
174 #define BS_OUTPUT_CHANNEL_POS_LC 6    /* Left Front Center                   */
175 #define BS_OUTPUT_CHANNEL_POS_RC 7    /* Right Front Center                  */
176 #define BS_OUTPUT_CHANNEL_POS_LSR 8   /* Rear Surround Left                  */
177 #define BS_OUTPUT_CHANNEL_POS_RSR 9   /* Rear Surround Right                 */
178 #define BS_OUTPUT_CHANNEL_POS_CS 10   /* Rear Center                         */
179 #define BS_OUTPUT_CHANNEL_POS_LSD 11  /* Left Surround Direct                */
180 #define BS_OUTPUT_CHANNEL_POS_RSD 12  /* Right Surround Direct               */
181 #define BS_OUTPUT_CHANNEL_POS_LSS 13  /* Left Side Surround                  */
182 #define BS_OUTPUT_CHANNEL_POS_RSS 14  /* Right Side Surround                 */
183 #define BS_OUTPUT_CHANNEL_POS_LW 15   /* Left Wide Front                     */
184 #define BS_OUTPUT_CHANNEL_POS_RW 16   /* Right Wide Front                    */
185 #define BS_OUTPUT_CHANNEL_POS_LV 17   /* Left Front Vertical Height          */
186 #define BS_OUTPUT_CHANNEL_POS_RV 18   /* Right Front Vertical Height         */
187 #define BS_OUTPUT_CHANNEL_POS_CV 19   /* Center Front Vertical Height        */
188 #define BS_OUTPUT_CHANNEL_POS_LVR 20  /* Left Surround Vertical Height Rear  */
189 #define BS_OUTPUT_CHANNEL_POS_RVR 21  /* Right Surround Vertical Height Rear */
190 #define BS_OUTPUT_CHANNEL_POS_CVR 22  /* Center Vertical Height Rear         */
191 #define BS_OUTPUT_CHANNEL_POS_LVSS 23 /* Left Vertical Height Side Surround */
192 #define BS_OUTPUT_CHANNEL_POS_RVSS                                             \
193   24                                /* Right Vertical Height Side Surround \ \ \
194                                        */
195 #define BS_OUTPUT_CHANNEL_POS_TS 25 /* Top Center Surround                 */
196 #define BS_OUTPUT_CHANNEL_POS_LFE2 26 /* Low Frequency Enhancement 2 */
197 #define BS_OUTPUT_CHANNEL_POS_LB 27   /* Left Front Vertical Bottom          */
198 #define BS_OUTPUT_CHANNEL_POS_RB 28   /* Right Front Vertical Bottom         */
199 #define BS_OUTPUT_CHANNEL_POS_CB 29   /* Center Front Vertical Bottom        */
200 #define BS_OUTPUT_CHANNEL_POS_LVS 30  /* Left Vertical Height Surround       */
201 #define BS_OUTPUT_CHANNEL_POS_RVS 31  /* Right Vertical Height Surround      */
202 
203 #define BS_MAX_NUM_OUT_CHANNELS (255)
204 
205 #define EXT_COUNT_MAX (2)
206 #define MAX_CHANNEL_COUNT (128)
207 #define SEQUENCE_COUNT_MAX (24)
208 #define PARAM_DRC_TYPE_FF_NODE_COUNT_MAX (9)
209 #define PARAM_DRC_INSTRUCTIONS_COUNT_MAX (8)
210 #define DOWNMIX_ID_COUNT_MAX (8)
211 #define DRC_SET_ID_COUNT_MAX (16)
212 #define EQ_SET_ID_COUNT_MAX (8)
213 #define LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX (4)
214 #define LOUD_EQ_INSTRUCTIONS_COUNT_MAX (8)
215 #define FILTER_ELEMENT_COUNT_MAX (16)
216 #define FILTER_BLOCK_COUNT_MAX (16)
217 #define REAL_ZERO_RADIUS_ONE_COUNT_MAX (14)
218 #define REAL_ZERO_COUNT_MAX (64)
219 #define COMPLEX_ZERO_COUNT_MAX (64)
220 #define REAL_POLE_COUNT_MAX (16)
221 #define COMPLEX_POLE_COUNT_MAX (16)
222 #define FIR_ORDER_MAX (128)
223 #define EQ_NODE_COUNT_MAX (33)
224 #define UNIQUE_SUBBAND_GAIN_COUNT_MAX (16)
225 #define EQ_SUBBAND_GAIN_COUNT_MAX (135)
226 #define EQ_CHANNEL_GROUP_COUNT_MAX (4)
227 #define EQ_FILTER_BLOCK_COUNT_MAX (4)
228 #define EQ_INSTRUCTIONS_COUNT_MAX (8)
229 #define DRC_COEFF_COUNT_MAX (8)
230 #define DOWNMIX_INSTRUCTION_COUNT_MAX (16)
231 #define DRC_INSTRUCTIONS_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20)
232 #define BAND_COUNT_MAX (8)
233 
234 #define N_DELTA_TIME_CODE_TABLE_ENTRIES_MAX (512 + 14)
235 #define GAIN_SET_COUNT_MAX SEQUENCE_COUNT_MAX
236 #define SPLIT_CHARACTERISTIC_NODE_COUNT_MAX (4)
237 #define SPLIT_CHARACTERISTIC_COUNT_MAX (8)
238 #define SHAPE_FILTER_COUNT_MAX (8)
239 #define CHANNEL_GROUP_COUNT_MAX SEQUENCE_COUNT_MAX
240 #define DRC_BAND_COUNT_MAX BAND_COUNT_MAX
241 #define SPEAKER_POS_COUNT_MAX (128)
242 #define DOWNMIX_COEFF_COUNT_MAX (32 * 32)
243 #define MAX_AUDIO_PREROLLS 3
244 
245 typedef struct {
246   UINT32 tw_mdct;
247   UINT32 noise_filling;
248   UINT32 stereo_config_index;
249 
250   UINT32 usac_ext_eleme_def_len;
251   UINT32 usac_ext_elem_pld_frag;
252 
253   ia_usac_dec_sbr_config_struct str_usac_sbr_config;
254   ia_usac_dec_mps_config_struct str_usac_mps212_config;
255 
256 } ia_usac_dec_element_config_struct;
257 
258 typedef struct {
259   UWORD32 num_elements;
260   UWORD32 num_config_extensions;
261   UWORD32 usac_element_type[USAC_MAX_ELEMENTS];
262   ia_usac_dec_element_config_struct str_usac_element_config[USAC_MAX_ELEMENTS];
263 
264   WORD32 usac_cfg_ext_info_present[USAC_MAX_CONFIG_EXTENSIONS];
265   WORD32 usac_ext_ele_payload_present[USAC_MAX_ELEMENTS];
266   WORD32 usac_cfg_ext_info_len[USAC_MAX_CONFIG_EXTENSIONS];
267   WORD32 usac_ext_ele_payload_len[USAC_MAX_ELEMENTS];
268   WORD32 usac_ext_gain_payload_len[MAX_AUDIO_PREROLLS + 2];
269   UWORD8 usac_cfg_ext_info_buf[USAC_MAX_CONFIG_EXTENSIONS][768];
270   UWORD8 usac_ext_ele_payload_buf[USAC_MAX_ELEMENTS][768];
271   UWORD8 usac_ext_gain_payload_buf[MAX_AUDIO_PREROLLS * 768];
272   UWORD32 preroll_bytes[MAX_AUDIO_PREROLLS +
273                         2];  // Contain the number of bytes in each preroll
274   WORD32 preroll_counter;    // count the number of prerolls in a frame.
275 
276   WORD32 preroll_flag;
277 
278 } ia_usac_decoder_config_struct;
279 
280 typedef struct {
281   UINT32 usac_sampling_frequency_index;
282   UINT32 usac_sampling_frequency;
283   UINT32 core_sbr_framelength_index;
284   UINT32 channel_configuration_index;
285 
286   UINT32 num_out_channels;
287   UINT32 output_channel_pos[BS_MAX_NUM_OUT_CHANNELS];
288   ia_usac_decoder_config_struct str_usac_dec_config;
289 
290 } ia_usac_config_struct;
291 
292 typedef struct {
293   WORD32 parametric_lim_threshold_present;
294   FLOAT32 parametric_lim_threshold;
295   WORD32 parametric_lim_attack;
296   WORD32 parametric_lim_release_present;
297   WORD32 parametric_lim_release;
298   WORD32 drc_characteristic;
299 
300   WORD32 disable_paramteric_drc;
301 } ia_parametric_drc_lim_struct;
302 typedef struct {
303   WORD32 level_estim_k_weighting_type;
304   WORD32 level_estim_integration_time_present;
305   WORD32 level_estim_integration_time;
306   WORD32 drc_curve_definition_type;
307   WORD32 drc_characteristic;
308   WORD32 node_count;
309   WORD32 node_level[PARAM_DRC_TYPE_FF_NODE_COUNT_MAX];
310   WORD32 node_gain[PARAM_DRC_TYPE_FF_NODE_COUNT_MAX];
311   WORD32 drc_gain_smooth_parameters_present;
312   WORD32 gain_smooth_attack_time_slow;
313   WORD32 gain_smooth_release_time_slow;
314   WORD32 gain_smooth_time_fast_present;
315   WORD32 gain_smooth_attack_time_fast;
316   WORD32 gain_smooth_release_time_fast;
317   WORD32 gain_smooth_threshold_present;
318   WORD32 gain_smooth_attack_threshold;
319   WORD32 gain_smooth_rel_threshold;
320   WORD32 gain_smooth_hold_off_count_present;
321   WORD32 gain_smooth_hold_off;
322 
323   WORD32 disable_paramteric_drc;
324 } ia_parametric_drc_type_feed_forward_struct;
325 typedef struct {
326   WORD32 parametric_drc_id;
327   WORD32 parametric_drc_look_ahead_flag;
328   WORD32 parametric_drc_look_ahead;
329   WORD32 parametric_drc_preset_id_present;
330   WORD32 parametric_drc_preset_id;
331   WORD32 parametric_drc_type;
332   WORD32 len_bit_size;
333   ia_parametric_drc_type_feed_forward_struct
334       str_parametric_drc_type_feed_forward;
335   ia_parametric_drc_lim_struct parametric_drc_lim;
336 
337   WORD32 drc_characteristic;
338   WORD32 disable_paramteric_drc;
339 } ia_parametric_drc_instructions_struct;
340 
341 typedef struct {
342   WORD32 parametric_drc_id;
343   WORD32 side_chain_config_type;
344   WORD32 downmix_id;
345   WORD32 level_estim_channel_weight_format;
346   FLOAT32 level_estim_ch_weight[MAX_CHANNEL_COUNT];
347   WORD32 drc_input_loudness_present;
348   FLOAT32 drc_input_loudness;
349 
350   WORD32 ch_count_from_dwnmix_id;
351 } ia_parametric_drc_gain_set_params_struct;
352 
353 typedef struct {
354   WORD32 drc_location;
355   WORD32 parametric_drc_frame_size_format;
356   WORD32 parametric_drc_frame_size;
357   WORD32 parametric_drc_delay_max_present;
358   WORD32 parametric_drc_delay_max;
359   WORD32 reset_parametric_drc;
360   WORD32 parametric_drc_gain_set_count;
361   ia_parametric_drc_gain_set_params_struct
362       str_parametric_drc_gain_set_params[SEQUENCE_COUNT_MAX];
363 } ia_drc_coeff_parametric_drc_struct;
364 
365 typedef struct {
366   WORD32 loud_eq_set_id;
367   WORD32 drc_location;
368   WORD32 dwnmix_id_count;
369   WORD32 downmix_id[DOWNMIX_ID_COUNT_MAX];
370   WORD32 drc_set_id_count;
371   WORD32 drc_set_id[DRC_SET_ID_COUNT_MAX];
372   WORD32 eq_set_id_count;
373   WORD32 eq_set_id[EQ_SET_ID_COUNT_MAX];
374   WORD32 loudness_after_drc;
375   WORD32 loudness_after_eq;
376   WORD32 loud_eq_gain_sequence_count;
377   WORD32 gain_seq_idx[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX];
378   WORD32 drc_characteristic_format_is_cicp[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX];
379   WORD32 drc_characteristic[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX];
380   WORD32 drc_characteristic_left_index[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX];
381   WORD32 drc_characteristic_right_index[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX];
382   WORD32 frequency_range_index[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX];
383   FLOAT32 loud_eq_scaling[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX];
384   FLOAT32 loud_eq_offset[LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX];
385 } ia_loud_eq_instructions_struct;
386 
387 typedef struct {
388   WORD32 filt_ele_idx;
389   WORD32 filt_ele_gain_flag;
390   FLOAT32 filt_ele_gain;
391 } ia_filt_ele_struct;
392 
393 typedef struct {
394   WORD32 filter_element_count;
395   ia_filt_ele_struct str_filter_element[FILTER_ELEMENT_COUNT_MAX];
396 } ia_filt_block_struct;
397 
398 typedef struct {
399   WORD32 eq_filter_format;
400   WORD32 bs_real_zero_radius_one_count;
401   WORD32 real_zero_count;
402   WORD32 generic_zero_count;
403   WORD32 real_pole_count;
404   WORD32 cmplx_pole_count;
405   WORD32 zero_sign[REAL_ZERO_RADIUS_ONE_COUNT_MAX];
406   FLOAT32 real_zero_radius[REAL_ZERO_COUNT_MAX];
407   FLOAT32 generic_zero_radius[COMPLEX_ZERO_COUNT_MAX];
408   FLOAT32 generic_zero_angle[COMPLEX_ZERO_COUNT_MAX];
409   FLOAT32 real_pole_radius[REAL_POLE_COUNT_MAX];
410   FLOAT32 complex_pole_radius[COMPLEX_POLE_COUNT_MAX];
411   FLOAT32 complex_pole_angle[COMPLEX_POLE_COUNT_MAX];
412   WORD32 fir_filt_order;
413   WORD32 fir_symmetry;
414   FLOAT32 fir_coeff[FIR_ORDER_MAX / 2];
415 } ia_unique_td_filt_element;
416 typedef struct {
417   WORD32 num_eq_nodes;
418   FLOAT32 eq_slope[EQ_NODE_COUNT_MAX];
419   WORD32 eq_freq_delta[EQ_NODE_COUNT_MAX];
420   FLOAT32 eq_gain_initial;
421   FLOAT32 eq_gain_delta[EQ_NODE_COUNT_MAX];
422 } ia_eq_subband_gain_spline_struct;
423 typedef struct {
424   FLOAT32 eq_subband_gain[EQ_SUBBAND_GAIN_COUNT_MAX];
425 } ia_eq_subband_gain_vector;
426 typedef struct {
427   WORD32 eq_delay_max_present;
428   WORD32 eq_delay_max;
429   WORD32 unique_filter_block_count;
430   ia_filt_block_struct str_filter_block[FILTER_BLOCK_COUNT_MAX];
431   WORD32 unique_td_filter_element_count;
432   ia_unique_td_filt_element unique_td_filt_ele[FILTER_ELEMENT_COUNT_MAX];
433   WORD32 unique_eq_subband_gains_count;
434   WORD32 eq_subband_gain_representation;
435   WORD32 eq_subband_gain_format;
436   WORD32 eq_subband_gain_count;
437   ia_eq_subband_gain_spline_struct
438       str_eq_subband_gain_spline[UNIQUE_SUBBAND_GAIN_COUNT_MAX];
439   ia_eq_subband_gain_vector
440       str_eq_subband_gain_vector[UNIQUE_SUBBAND_GAIN_COUNT_MAX];
441 } ia_eq_coeff_struct;
442 typedef struct {
443   WORD32 filter_block_count;
444   WORD32 filter_block_index[EQ_FILTER_BLOCK_COUNT_MAX];
445 } ia_filter_block_refs_struct;
446 typedef struct {
447   WORD32 eq_cascade_gain_present[EQ_CHANNEL_GROUP_COUNT_MAX];
448   FLOAT32 eq_cascade_gain[EQ_CHANNEL_GROUP_COUNT_MAX];
449   ia_filter_block_refs_struct str_filter_block_refs[EQ_CHANNEL_GROUP_COUNT_MAX];
450   WORD32 eq_phase_alignment_present;
451   WORD32 eq_phase_alignment[EQ_CHANNEL_GROUP_COUNT_MAX]
452                            [EQ_CHANNEL_GROUP_COUNT_MAX];
453 } ia_td_filter_cascade_struct;
454 
455 typedef struct {
456   WORD32 eq_set_id;
457   WORD32 eq_set_complexity_level;
458   WORD32 dwnmix_id_count;
459   WORD32 downmix_id[DOWNMIX_ID_COUNT_MAX];
460   WORD32 eq_apply_to_downmix;
461   WORD32 drc_set_id_count;
462   WORD32 drc_set_id[DRC_SET_ID_COUNT_MAX];
463   WORD32 eq_set_purpose;
464   WORD32 depends_on_eq_set_present;
465   WORD32 depends_on_eq_set;
466   WORD32 no_independent_eq_use;
467   WORD32 eq_channel_count;
468   WORD32 eq_ch_group_count;
469   WORD32 eq_ch_group_of_channel[MAX_CHANNEL_COUNT];
470   WORD32 td_filter_cascade_present;
471   ia_td_filter_cascade_struct str_td_filter_cascade;
472   WORD32 subband_gains_present;
473   WORD32 subband_gains_index[EQ_CHANNEL_GROUP_COUNT_MAX];
474   WORD32 eq_transition_duration_present;
475   WORD32 eq_transition_duration;
476 } ia_eq_instructions_struct;
477 
478 typedef struct {
479   WORD32 drc_config_ext_type[EXT_COUNT_MAX];
480   WORD32 ext_bit_size[EXT_COUNT_MAX - 1];
481 
482   WORD32 parametric_drc_present;
483   ia_drc_coeff_parametric_drc_struct str_drc_coeff_param_drc;
484   WORD32 parametric_drc_instructions_count;
485   ia_parametric_drc_instructions_struct
486       str_parametric_drc_instructions[PARAM_DRC_INSTRUCTIONS_COUNT_MAX];
487   WORD32 drc_extension_v1_present;
488   WORD32 loud_eq_instructions_flag;
489   WORD32 loud_eq_instructions_count;
490   ia_loud_eq_instructions_struct
491       loud_eq_instructions[LOUD_EQ_INSTRUCTIONS_COUNT_MAX];
492   WORD32 eq_flag;
493   ia_eq_coeff_struct str_eq_coeff;
494   WORD32 eq_instructions_count;
495   ia_eq_instructions_struct str_eq_instructions[EQ_INSTRUCTIONS_COUNT_MAX];
496 } ia_drc_config_ext;
497 
498 typedef struct {
499   WORD32 drc_location;
500   WORD32 drc_characteristic;
501 } ia_drc_coefficients_basic_struct;
502 
503 typedef struct {
504   WORD32 drc_set_id;
505   WORD32 drc_location;
506   WORD32 dwnmix_id_count;
507   WORD32 downmix_id[DOWNMIX_ID_COUNT_MAX];
508   WORD32 drc_set_effect;
509   WORD32 limiter_peak_target_present;
510   FLOAT32 limiter_peak_target;
511   WORD32 drc_set_target_loudness_present;
512   WORD32 drc_set_target_loudness_value_upper;
513   WORD32 drc_set_target_loudness_value_lower_present;
514   WORD32 drc_set_target_loudness_value_lower;
515 } ia_drc_instructions_basic_struct;
516 
517 typedef struct {
518   WORD32 gain_seq_idx;
519   WORD32 drc_characteristic;
520   WORD32 drc_characteristic_present;
521   WORD32 drc_characteristic_format_is_cicp;
522   WORD32 drc_characteristic_left_index;
523   WORD32 drc_characteristic_right_index;
524   WORD32 crossover_freq_idx;
525   WORD32 start_subband_index;
526 } ia_gain_params_struct;
527 typedef struct {
528   WORD32 size;
529   WORD32 code;
530   WORD32 value;
531 } ia_delta_time_code_table_entry_struct;
532 typedef struct {
533   ia_delta_time_code_table_entry_struct
534       delta_time_code_table[N_DELTA_TIME_CODE_TABLE_ENTRIES_MAX];
535 } ia_tables_struct;
536 
537 typedef struct {
538   WORD32 gain_coding_profile;
539   WORD32 gain_interpolation_type;
540   WORD32 full_frame;
541   WORD32 time_alignment;
542   WORD32 time_delt_min_flag;
543   WORD32 time_delt_min_val;
544   WORD32 band_count;
545   WORD32 drc_band_type;
546   ia_gain_params_struct gain_params[BAND_COUNT_MAX];
547 
548   WORD32 num_gain_max_values;
549   ia_tables_struct str_tables;
550 } ia_gain_set_params_struct;
551 
552 typedef struct {
553   WORD32 characteristic_format;
554   FLOAT32 in_out_ratio;
555   FLOAT32 gain;
556   FLOAT32 exp;
557   WORD32 flip_sign;
558   WORD32 characteristic_node_count;
559   FLOAT32 node_level[SPLIT_CHARACTERISTIC_NODE_COUNT_MAX + 1];
560   FLOAT32 node_gain[SPLIT_CHARACTERISTIC_NODE_COUNT_MAX + 1];
561 } ia_split_drc_characteristic_struct;
562 
563 typedef struct {
564   WORD32 corner_freq_index;
565   WORD32 filter_strength_index;
566 } ia_shape_filter_params_struct;
567 
568 typedef struct {
569   WORD32 lf_cut_filter_present;
570   ia_shape_filter_params_struct str_lf_cut_params;
571   WORD32 lf_boost_filter_present;
572   ia_shape_filter_params_struct str_lf_boost_params;
573   WORD32 hf_cut_filter_present;
574   ia_shape_filter_params_struct str_hf_cut_params;
575   WORD32 hf_boost_filter_present;
576   ia_shape_filter_params_struct str_hf_boost_params;
577 } ia_shape_filter_block_params_struct;
578 
579 typedef struct {
580   WORD32 version;
581   WORD32 drc_location;
582   WORD32 drc_frame_size_present;
583   WORD32 drc_frame_size;
584   WORD32 gain_set_count;
585   ia_gain_set_params_struct gain_set_params[GAIN_SET_COUNT_MAX];
586   WORD32 drc_characteristic_left_present;
587   WORD32 characteristic_left_count;
588   ia_split_drc_characteristic_struct
589       str_split_characteristic_left[SPLIT_CHARACTERISTIC_COUNT_MAX];
590   WORD32 drc_characteristic_right_present;
591   WORD32 characteristic_right_count;
592   ia_split_drc_characteristic_struct
593       str_split_characteristic_right[SPLIT_CHARACTERISTIC_COUNT_MAX];
594   WORD32 shape_filters_present;
595   WORD32 shape_num_filter;
596   ia_shape_filter_block_params_struct
597       str_shape_filter_block_params[SHAPE_FILTER_COUNT_MAX + 1];
598   WORD32 gain_sequence_count;
599   WORD32 gain_set_params_index_for_gain_sequence[SEQUENCE_COUNT_MAX];
600   WORD32 gain_set_count_plus;
601 
602 } ia_uni_drc_coeffs_struct;
603 
604 typedef struct {
605   WORD32 target_characteristic_left_present[DRC_BAND_COUNT_MAX];
606   WORD32 target_characteristic_left_index[DRC_BAND_COUNT_MAX];
607   WORD32 target_characteristic_right_present[DRC_BAND_COUNT_MAX];
608   WORD32 target_characteristic_right_index[DRC_BAND_COUNT_MAX];
609   WORD32 shape_filter_flag;
610   WORD32 shape_filter_idx;
611   WORD32 gain_scaling_flag[BAND_COUNT_MAX];
612   FLOAT32 attn_scaling[BAND_COUNT_MAX];
613   FLOAT32 ampl_scaling[BAND_COUNT_MAX];
614   WORD32 gain_offset_flag[BAND_COUNT_MAX];
615   FLOAT32 gain_offset[BAND_COUNT_MAX];
616 } ia_gain_modifiers_struct;
617 
618 typedef struct {
619   WORD32 ducking_scaling_flag;
620   FLOAT32 ducking_scaling;
621   FLOAT32 ducking_scaling_quantized;
622 } ia_ducking_modifiers_struct;
623 
624 typedef struct {
625   WORD32 drc_set_id;
626   WORD32 drc_set_complexity_level;
627   WORD32 requires_eq;
628   WORD32 drc_apply_to_dwnmix;
629   WORD32 drc_location;
630   WORD32 dwnmix_id_count;
631   WORD32 downmix_id[DOWNMIX_ID_COUNT_MAX];
632   WORD32 depends_on_drc_set_present;
633   WORD32 depends_on_drc_set;
634   WORD32 no_independent_use;
635   WORD32 drc_set_effect;
636   WORD32 gain_set_index[MAX_CHANNEL_COUNT];
637   ia_gain_modifiers_struct
638       str_gain_modifiers_of_ch_group[CHANNEL_GROUP_COUNT_MAX];
639   ia_ducking_modifiers_struct
640       str_ducking_modifiers_for_channel[MAX_CHANNEL_COUNT];
641   WORD32 limiter_peak_target_present;
642   FLOAT32 limiter_peak_target;
643   WORD32 drc_set_target_loudness_present;
644   WORD32 drc_set_target_loudness_value_upper;
645   WORD32 drc_set_target_loudness_value_lower_present;
646   WORD32 drc_set_target_loudness_value_lower;
647 
648   WORD32 audio_num_chan;
649   WORD32 num_drc_ch_groups;
650   WORD32 gain_set_index_for_channel_group[CHANNEL_GROUP_COUNT_MAX];
651   WORD32 band_count_of_ch_group[CHANNEL_GROUP_COUNT_MAX];
652   WORD32 gain_interpolation_type_for_channel_group[CHANNEL_GROUP_COUNT_MAX];
653   WORD32 time_delta_min_for_channel_group[CHANNEL_GROUP_COUNT_MAX];
654   WORD32 time_alignment_for_channel_group[CHANNEL_GROUP_COUNT_MAX];
655   ia_ducking_modifiers_struct
656       str_ducking_modifiers_for_channel_group[CHANNEL_GROUP_COUNT_MAX];
657   WORD32 channel_group_of_ch[MAX_CHANNEL_COUNT];
658   WORD32 num_chan_per_ch_group[CHANNEL_GROUP_COUNT_MAX];
659   WORD32 gain_element_count;
660   WORD32 multiband_audio_sig_count;
661   WORD32 ch_group_parametric_drc_flag[CHANNEL_GROUP_COUNT_MAX];
662   WORD32 gain_set_idx_of_ch_group_parametric_drc[CHANNEL_GROUP_COUNT_MAX];
663   WORD32 parametric_drc_look_ahead_samples[CHANNEL_GROUP_COUNT_MAX];
664   WORD32 parametric_drc_look_ahead_samples_max;
665 } ia_drc_instructions_struct;
666 
667 typedef struct {
668   WORD32 base_channel_count;
669   WORD32 layout_signaling_present;
670   WORD32 defined_layout;
671   WORD32 speaker_position[SPEAKER_POS_COUNT_MAX];
672 } ia_channel_layout_struct;
673 typedef struct {
674   WORD32 downmix_id;
675   WORD32 target_channel_count;
676   WORD32 target_layout;
677   WORD32 downmix_coefficients_present;
678   FLOAT32 downmix_coefficient[DOWNMIX_COEFF_COUNT_MAX];
679 } ia_downmix_instructions_struct;
680 typedef struct ia_drc_config {
681   WORD32 sample_rate_present;
682   WORD32 sampling_rate;
683   WORD32 dwnmix_instructions_count;
684   WORD32 drc_coefficients_drc_count;
685   WORD32 drc_instructions_uni_drc_count;
686   WORD32 drc_instructions_count_plus;
687   WORD32 drc_description_basic_present;
688   WORD32 drc_coefficients_basic_count;
689   WORD32 drc_instructions_basic_count;
690   WORD32 drc_config_ext_present;
691   WORD32 apply_drc;
692   ia_drc_config_ext str_drc_config_ext;
693   ia_drc_coefficients_basic_struct
694       str_drc_coefficients_basic[DRC_COEFF_COUNT_MAX];
695   ia_drc_instructions_basic_struct
696       str_drc_instructions_basic[DRC_INSTRUCTIONS_COUNT_MAX];
697   ia_uni_drc_coeffs_struct
698       str_p_loc_drc_coefficients_uni_drc[DRC_COEFF_COUNT_MAX];
699   ia_drc_instructions_struct
700       str_drc_instruction_str[DRC_INSTRUCTIONS_COUNT_MAX];
701   ia_channel_layout_struct channel_layout;
702   ia_downmix_instructions_struct
703       dwnmix_instructions[DOWNMIX_INSTRUCTION_COUNT_MAX];
704 } ia_drc_config;
705 
706 VOID ixheaacd_conf_default(ia_usac_config_struct *pstr_usac_conf);
707 
708 UWORD32 ixheaacd_sbr_ratio(UWORD32 core_sbr_frame_len_idx);
709 
710 UWORD32 ixheaacd_sbr_params(UWORD32 core_sbr_frame_len_idx,
711                             WORD32 *output_frame_length, WORD32 *block_size,
712                             WORD32 *output_samples, WORD32 *sampling_freq,
713                             UWORD32 *sample_freq_indx);
714 
715 WORD32 ixheaacd_config(ia_bit_buf_struct *bit_buff,
716                        ia_usac_config_struct *pstr_usac_conf, UINT32 *chan, WORD32 ec_flag);
717 
718 #endif /* IXHEAACD_CONFIG_H */
719