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