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_ENV_CALC_H 21 #define IXHEAACD_ENV_CALC_H 22 23 typedef struct { 24 WORD16 *filt_buf_me; 25 WORD16 *filt_buf_noise_m; 26 WORD32 filt_buf_noise_e; 27 FLAG start_up; 28 WORD16 ph_index; 29 WORD16 tansient_env_prev; 30 WORD8 harm_flags_prev[MAX_FREQ_COEFFS]; 31 WORD16 harm_index; 32 } ia_sbr_calc_env_struct; 33 34 IA_ERRORCODE ixheaacd_calc_sbrenvelope( 35 ia_sbr_scale_fact_struct *sbr_scale_factor, 36 ia_sbr_calc_env_struct *ptr_sbr_calc_env, 37 ia_sbr_header_data_struct *ptr_header_data, 38 ia_sbr_frame_info_data_struct *ptr_frame_data, 39 ia_sbr_prev_frame_data_struct *ptr_prev_frame_data, 40 WORD32 **anal_buf_real_mant, WORD32 **anal_buf_imag_mant, 41 WORD16 *degree_alias, FLAG low_pow_flag, 42 ia_sbr_tables_struct *ptr_sbr_tables, 43 ixheaacd_misc_tables *pstr_common_tables, WORD32 *ptr_qmf_matrix, 44 WORD32 audio_object_type); 45 46 VOID ixheaacd_reset_sbrenvelope_calc(ia_sbr_calc_env_struct *ptr_calc_env); 47 48 VOID ixheaacd_derive_lim_band_tbl( 49 ia_sbr_header_data_struct *ptr_header_data, 50 const ia_patch_param_struct *p_str_patch_param, WORD16 num_patches, 51 ixheaacd_misc_tables *pstr_common_tables); 52 53 VOID ixheaacd_filt_buf_update(WORD16 *filt_buf_mant, 54 WORD16 *ptr_filt_buf_noise, 55 WORD16 *nrg_gain_mant, 56 WORD16 *noise_level_mant, 57 WORD32 num_sub_bands); 58 59 VOID ixheaacd_noise_level_rescaling(WORD16 *noise_level_mant, WORD32 diff, 60 WORD32 num_sub_bands, 61 WORD32 ixheaacd_drc_offset); 62 63 VOID ixheaacd_enery_calc_persfb(WORD32 **anal_buf_real, WORD32 **anal_buf_imag, 64 WORD32 num_sf_bands, WORD16 *freq_band_table, 65 WORD32 start_pos, WORD32 next_pos, 66 WORD32 max_qmf_subband_aac, WORD32 frame_exp, 67 WORD16 *nrg_est_m, FLAG low_pow_flag, 68 ia_sbr_tables_struct *ptr_sbr_tables); 69 70 VOID ixheaacd_avggain_calc(WORD16 *ptr_enrg_orig, WORD16 *nrg_est, 71 WORD32 sub_band_start, WORD32 sub_band_end, 72 WORD16 *sum_orig_mant, WORD16 *sum_orig_exp, 73 WORD16 *ptr_avg_gain_mant, WORD16 *ptr_avg_gain_exp, 74 ixheaacd_misc_tables *pstr_common_tables, 75 WORD32 flag); 76 77 VOID ixheaacd_adj_timeslot(WORD32 *ptr_buf_real, WORD32 *ptr_buf_imag, 78 WORD16 *ptr_filt_buf, WORD16 *ptr_filt_buf_noise, 79 WORD16 *ptr_gain_buf, WORD16 *ptr_noise_floor, 80 WORD16 *ptr_sine_lvl_buf, WORD16 noise_floor_exp, 81 WORD16 *ptr_harm_index, WORD16 sub_band_start, 82 WORD16 num_sub_bands, WORD16 scale_change, 83 WORD16 smooth_ratio, FLAG num_noise_flg, 84 WORD16 *ptr_phase_index, 85 ia_sbr_tables_struct *ptr_sbr_tables); 86 87 VOID ixheaacd_map_sineflags(WORD16 *freq_band_table, WORD16 num_sf_bands, 88 FLAG *add_harmonics, WORD8 *harm_flags_prev, 89 WORD16 transient_env, WORD8 *sine_mapped_matrix); 90 91 VOID ixheaacd_adjust_scale_dec(WORD32 **re, WORD32 **im, WORD sub_band_start, 92 WORD num_sub_bands, WORD start_pos, 93 WORD next_pos, WORD shift, FLAG low_pow_flag); 94 95 VOID ixheaacd_adjust_scale_armv7(WORD32 **re, WORD32 **im, WORD sub_band_start, 96 WORD num_sub_bands, WORD start_pos, 97 WORD next_pos, WORD shift, FLAG low_pow_flag); 98 99 WORD16 ixheaacd_expsubbandsamples_dec(WORD32 **anal_buf_real_mant, 100 WORD32 **anal_buf_imag_mant, 101 WORD sub_band_start, WORD sub_band_end, 102 WORD start_pos, WORD end_pos, 103 FLAG low_pow_flag); 104 105 WORD16 ixheaacd_expsubbandsamples_armv7(WORD32 **anal_buf_real_mant, 106 WORD32 **anal_buf_imag_mant, 107 WORD sub_band_start, WORD sub_band_end, 108 WORD start_pos, WORD end_pos, 109 FLAG low_pow_flag); 110 111 VOID ixheaacd_enery_calc_per_subband_dec(WORD32 start_pos, WORD32 next_pos, 112 WORD32 sub_band_start, 113 WORD32 sub_band_end, WORD32 frame_exp, 114 WORD16 *nrg_est_mant, 115 FLAG low_pow_flag, 116 ia_sbr_tables_struct *ptr_sbr_tables, 117 WORD32 *ptr_qmf_matrix); 118 119 VOID ixheaacd_enery_calc_per_subband_armv7( 120 WORD32 start_pos, WORD32 next_pos, WORD32 sub_band_start, 121 WORD32 sub_band_end, WORD32 frame_exp, WORD16 *nrg_est_mant, 122 FLAG low_pow_flag, ia_sbr_tables_struct *ptr_sbr_tables, 123 WORD32 *ptr_qmf_matrix); 124 125 WORD32 ixheaacd_reset_hf_generator(ia_sbr_hf_generator_struct *hf_generator, 126 ia_sbr_header_data_struct *ptr_header_data, 127 WORD audio_obj_type); 128 129 VOID ixheaacd_harm_idx_zerotwolp_dec(WORD32 *ptr_real_buf, WORD16 *ptr_gain_buf, 130 WORD scale_change, 131 WORD16 *ptr_sine_level_buf, 132 const WORD32 *ptr_rand_ph, 133 WORD16 *noise_lvl_me, WORD num_sub_bands, 134 FLAG noise_absc_flag, WORD32 harm_index); 135 136 VOID ixheaacd_harm_idx_zerotwolp_armv7(WORD32 *ptr_real_buf, 137 WORD16 *ptr_gain_buf, WORD scale_change, 138 WORD16 *ptr_sine_level_buf, 139 const WORD32 *ptr_rand_ph, 140 WORD16 *noise_lvl_me, WORD num_sub_bands, 141 FLAG noise_absc_flag, WORD32 harm_index); 142 143 VOID ixheaacd_harm_idx_onethreelp(WORD32 *ptr_real_buf, WORD16 *ptr_gain_buf, 144 WORD scale_change, WORD16 *ptr_sine_level_buf, 145 const WORD32 *ptr_rand_ph, 146 WORD16 *noise_lvl_me, WORD num_sub_bands, 147 FLAG noise_absc_flag, WORD freq_inv_flag, 148 WORD noise_e, WORD sub_band_start); 149 150 VOID ixheaacd_conv_ergtoamplitudelp_dec(WORD32 bands, WORD16 noise_e, 151 WORD16 *nrg_sine, WORD16 *nrg_gain, 152 WORD16 *noise_level_mant, 153 WORD16 *sqrt_table); 154 155 VOID ixheaacd_conv_ergtoamplitudelp_armv7(WORD32 bands, WORD16 noise_e, 156 WORD16 *nrg_sine, WORD16 *nrg_gain, 157 WORD16 *noise_level_mant, 158 WORD16 *sqrt_table); 159 160 VOID ixheaacd_conv_ergtoamplitude_dec(WORD32 bands, WORD16 noise_e, 161 WORD16 *nrg_sine, WORD16 *nrg_gain, 162 WORD16 *noise_level_mant, 163 WORD16 *sqrt_table); 164 165 VOID ixheaacd_conv_ergtoamplitude_armv7(WORD32 bands, WORD16 noise_e, 166 WORD16 *nrg_sine, WORD16 *nrg_gain, 167 WORD16 *noise_level_mant, 168 WORD16 *sqrt_table); 169 170 VOID ixheaacd_subbandgain_calc(WORD16 e_orig_mant_matrix, WORD16 tmp_noise_mant, 171 WORD16 nrg_est_mant, WORD16 nrg_est_exp, 172 WORD16 tmp_noise_exp, WORD16 nrg_ref_exp, 173 FLAG sine_present_flag, FLAG sine_mapped_matrix, 174 FLAG noise_absc_flag, WORD16 *ptr_nrg_gain_mant, 175 WORD16 *ptr_noise_floor_mant, 176 WORD16 *ptr_nrg_sine_m, 177 ixheaacd_misc_tables *pstr_common_tables); 178 179 VOID ixheaacd_equalize_filt_buff_exp(WORD16 *ptr_filt_buf, 180 WORD16 *nrg_gain, 181 WORD32 subbands); 182 183 #endif 184