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 23 #define IXHEAACE_IPD_MASK_NEGATED (0x00001000) 24 #define IXHEAACE_INVF_SMOOTHING_LENGTH (2) 25 26 #define IXHEAACE_LD_TRAN (1) 27 #define IXHEAACE_SBR_TRAN_BITS (4) 28 #define IXHEAACE_SBR_ENVT_NUMENV (0) 29 #define IXHEAACE_SBR_ENVT_TRANIDX (3) 30 31 typedef struct { 32 const WORD32 a_hyb_res[3]; 33 const WORD32 hi_res_band_borders[8 + 12 + 1]; 34 const WORD32 grp_borders_mix[28 + 1]; 35 const WORD32 shift_in_bins[20]; 36 const WORD32 bins_2_goup_map[28 + 1]; 37 const FLOAT32 p4_13[13]; 38 const FLOAT32 p8_13[13]; 39 const FLOAT32 pan_class[7]; 40 const FLOAT32 sa_class[7]; 41 /*Huffman tables for PS*/ 42 const WORD32 a_book_ps_iid_time_code[29]; 43 const WORD8 a_book_ps_iid_time_length[29]; 44 const WORD32 a_book_ps_iid_freq_code[29]; 45 const WORD8 a_book_ps_iid_freq_length[29]; 46 const WORD16 a_book_ps_icc_time_code[15]; 47 const WORD8 a_book_ps_icc_time_length[15]; 48 const WORD16 a_book_ps_icc_freq_code[15]; 49 const WORD8 a_book_ps_icc_freq_length[15]; 50 } ixheaace_str_ps_tab; 51 52 typedef enum { 53 IXHEAACE_INVF_OFF = 0, 54 IXHEAACE_INVF_LOW_LEVEL, 55 IXHEAACE_INVF_MID_LEVEL, 56 IXHEAACE_INVF_HIGH_LEVEL, 57 IXHEAACE_INVF_SWITCHED 58 } ixheaace_invf_mode; 59 60 typedef struct { 61 const FLOAT32 quant_steps_sbr[4]; 62 const FLOAT32 quant_steps_org[4]; 63 const FLOAT32 energy_brdrs[4]; 64 WORD32 num_regions_sbr; 65 WORD32 num_regions_orig; 66 WORD32 num_regions_nrg; 67 ixheaace_invf_mode region_space[5][5]; 68 ixheaace_invf_mode region_space_transient[5][5]; 69 WORD32 energy_comp_factor[5]; 70 } ixheaace_str_det_params; 71 72 typedef struct { 73 WORD32 n_envelopes; 74 WORD32 borders[IXHEAACE_MAX_ENV + 1]; 75 ixheaace_freq_res freq_res[IXHEAACE_MAX_ENV]; 76 WORD32 short_env; 77 WORD32 n_noise_envelopes; 78 WORD32 borders_noise[MAXIMUM_NOISE_ENVELOPES + 1]; 79 } ixheaace_str_frame_info_sbr; 80 81 typedef struct { 82 WORD32 num_noise_bands; 83 WORD32 noise_floor_offset; 84 WORD32 noise_max_level; 85 86 } ixheaace_noise_config; 87 88 typedef struct { 89 WORD32 start_freq; 90 WORD32 stop_freq; 91 } ixheaace_freq_range; 92 93 typedef struct { 94 UWORD32 bitrate_from; 95 UWORD32 bitrate_to; 96 97 ixheaace_freq_range freq_band; 98 WORD32 freq_scale; 99 100 ixheaace_noise_config noise; 101 ixheaace_sbr_stereo_mode stereo_mode; 102 } ixheaace_sbr_tuning_tables; 103 104 typedef struct { 105 const FLOAT32 sbr_qmf_64_640[QMF_FILTER_LENGTH + 10]; 106 const FLOAT32 sbr_cld_fb[CLD_FILTER_LENGTH]; 107 const FLOAT32 sbr_p_64_640_qmf[QMF_FILTER_LENGTH]; 108 const FLOAT32 sbr_alt_sin_twiddle[19]; 109 const FLOAT32 sbr_cos_sin_twiddle[32]; 110 const FLOAT32 cos_sin_fct4_32[32]; 111 const FLOAT32 cos_sin_fct4_16[16]; 112 const FLOAT32 cos_sin_fct4_8[8]; 113 const ixheaace_str_det_params detector_params_aac; /*Not part of QMF filtering*/ 114 const ixheaace_str_det_params detector_params_aac_speech; /*but included here for convenience*/ 115 ixheaace_str_frame_info_sbr frame_info1_2048; 116 ixheaace_str_frame_info_sbr frame_info2_2048; 117 ixheaace_str_frame_info_sbr frame_info4_2048; 118 ixheaace_str_frame_info_sbr frame_480_info1_2048; 119 ixheaace_str_frame_info_sbr frame_480_info2_2048; 120 ixheaace_str_frame_info_sbr frame_480_info4_2048; 121 const FLOAT32 ptr_smooth_filter[4]; 122 UWORD32 supported_sample_rate[9]; 123 ixheaace_sbr_tuning_tables sbr_tuning_table_lc[10][2][10]; 124 ixheaace_sbr_tuning_tables sbr_tuning_table_ld[10][2][10]; 125 } ixheaace_str_qmf_tabs; 126 127 typedef struct { 128 const WORD32 v_huff_env_lvl_c10t[121]; 129 const UWORD8 v_huff_env_lvl_l10t[121]; 130 const WORD32 v_huff_env_lvl_c10f[121]; 131 const UWORD8 v_huff_env_lvl_l10f[121]; 132 const WORD32 book_sbr_env_bal_c10t[49]; 133 const UWORD8 book_sbr_env_bal_l10t[49]; 134 const WORD32 book_sbr_env_bal_c10f[49]; 135 const UWORD8 book_sbr_env_bal_l10f[49]; 136 const WORD32 v_huff_env_lvl_c11t[63]; 137 const UWORD8 v_huff_env_lvl_l11t[63]; 138 const WORD32 v_huff_env_lvl_c11f[63]; 139 const UWORD8 v_huff_env_lvl_l11f[63]; 140 const WORD32 book_sbr_env_bal_c11t[25]; 141 const UWORD8 book_sbr_env_bal_l11t[25]; 142 const WORD32 book_sbr_env_bal_c11f[25]; 143 const UWORD8 book_sbr_env_bal_l11f[25]; 144 const WORD32 v_huff_noise_lvl_c11t[63]; 145 const UWORD8 v_huff_noise_lvl_l11t[63]; 146 const WORD32 book_sbr_noise_bal_c11t[25]; 147 const UWORD8 book_sbr_noise_bal_l11t[25]; 148 } ixheaace_str_sbr_huff_tabs; 149 150 typedef struct { 151 const WORD32 sfb_bins_8k[21]; 152 const WORD32 sfb_bins_11k[23]; 153 const WORD32 sfb_bins_12k[23]; 154 const WORD32 sfb_bins_16k[23]; 155 const WORD32 sfb_bins_22k[25]; 156 const WORD32 sfb_bins_24k[25]; 157 const WORD32 sfb_bins_32k[27]; 158 const WORD32 sfb_bins_44k[26]; 159 const WORD32 sfb_bins_48k[26]; 160 } ixheaace_str_esbr_sfb_bin_tabs; 161 162 typedef struct { 163 ixheaace_str_ps_tab *ptr_ps_tab; 164 ixheaace_str_qmf_tabs *ptr_qmf_tab; 165 ixheaace_str_sbr_huff_tabs *ptr_sbr_huff_tab; 166 ixheaace_resampler_table *ptr_resamp_tab; 167 ixheaace_resampler_sos_table *ptr_sos_downsamp_tab; 168 ixheaace_resampler_sos_table *ptr_sos_upsamp_tab; 169 ixheaace_str_esbr_sfb_bin_tabs *ptr_esbr_sfb_tab; 170 } ixheaace_str_sbr_tabs; 171 172 extern const ixheaace_str_ps_tab ia_enhaacplus_enc_ps_tab; 173 extern const ixheaace_str_qmf_tabs ixheaace_qmf_tab; 174 extern const WORD32 vector_offset_16k[]; 175 extern const WORD32 vector_offset_22k[]; 176 extern const WORD32 vector_offset_24k[]; 177 extern const WORD32 vector_offset_32k[]; 178 extern const WORD32 vector_offset_44_48_64[]; 179 extern const WORD32 vector_offset_88_96[]; 180 extern const WORD32 vector_offset_def[]; 181 extern const WORD32 vector_stop_freq_32[14]; 182 extern const WORD32 vector_stop_freq_44[14]; 183 extern const WORD32 vector_stop_freq_48[14]; 184 185 /* Resampler tables */ 186 extern const ixheaace_resampler_table ixheaace_resamp_2_to_1_iir_filt_params; 187 extern const ixheaace_resampler_table ixheaace_resamp_4_to_1_iir_filt_params; 188 extern const ixheaace_resampler_sos_table iixheaace_resamp_1_to_3_filt_params; 189 extern const ixheaace_resampler_sos_table iixheaace_resamp_8_to_1_filt_params; 190 extern const ixheaace_str_sbr_huff_tabs ixheaace_sbr_huff_tab; 191 extern const ixheaace_str_esbr_sfb_bin_tabs ia_esbr_sfb_bin_tabs; 192 extern const WORD32 ixheaace_ld_env_tab_480[15][4]; 193 extern const WORD32 ixheaace_ld_env_tab_512[16][4]; 194 extern const WORD32 ixheaace_start_freq_16k_4_1[SBR_START_FREQ_OFFSET_TBL_LEN]; 195 extern const WORD32 ixheaace_start_freq_22k_4_1[SBR_START_FREQ_OFFSET_TBL_LEN]; 196 extern const WORD32 ixheaace_start_freq_24k_4_1[SBR_START_FREQ_OFFSET_TBL_LEN]; 197 extern const WORD32 ixheaace_start_freq_32k_4_1[SBR_START_FREQ_OFFSET_TBL_LEN]; 198 extern const WORD32 ixheaace_start_freq_48k_4_1[SBR_START_FREQ_OFFSET_TBL_LEN]; 199 extern const WORD32 ixheaace_start_freq_96k_4_1[SBR_START_FREQ_OFFSET_TBL_LEN]; 200 extern const WORD32 ixheaace_start_freq_dflt_4_1[SBR_START_FREQ_OFFSET_TBL_LEN]; 201 202 extern const WORD32 ixheaace_stop_freq_16k_4_1[SBR_STOP_FREQ_OFFSET_TBL_LEN]; 203 extern const WORD32 ixheaace_stop_freq_22k_4_1[SBR_STOP_FREQ_OFFSET_TBL_LEN]; 204 extern const WORD32 ixheaace_stop_freq_24k_4_1[SBR_STOP_FREQ_OFFSET_TBL_LEN]; 205 extern const WORD32 ixheaace_stop_freq_32k_4_1[SBR_STOP_FREQ_OFFSET_TBL_LEN]; 206 extern const WORD32 ixheaace_stop_freq_44k_4_1[SBR_STOP_FREQ_OFFSET_TBL_LEN]; 207 extern const WORD32 ixheaace_stop_freq_48k_4_1[SBR_STOP_FREQ_OFFSET_TBL_LEN]; 208 209 extern const WORD32 ixheaace_usac_stop_freq_16k[14]; 210 extern const WORD32 ixheaace_usac_stop_freq_22k[14]; 211 extern const WORD32 ixheaace_usac_stop_freq_24k[14]; 212 213 extern const WORD32 ixheaace_stop_freq_16k[14]; 214 extern const WORD32 ixheaace_stop_freq_22k[14]; 215 extern const WORD32 ixheaace_stop_freq_24k[14]; 216 extern const WORD32 ixheaace_stop_freq_32k[14]; 217 extern const WORD32 ixheaace_stop_freq_44k[14]; 218 extern const WORD32 ixheaace_stop_freq_48k[14]; 219 extern const FLOAT32 filter[IXHEAACE_INVF_SMOOTHING_LENGTH + 1]; 220 221 extern const FLOAT32 long_window_sine_ld_64[IXHEAACE_QMF_CHANNELS]; 222 extern const FLOAT32 fft_twiddle_tab_32[IXHEAACE_QMF_TIME_SLOTS]; 223 extern const FLOAT32 sbr_sin_cos_window[IXHEAACE_QMF_CHANNELS * 2]; 224 extern const FLOAT32 cld_fb_64_640[CLD_FILTER_LENGTH]; 225