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