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 PLATFORM_INLINE VOID ixheaacd_equalize_filt_buff_exp(WORD16 *ptr_filt_buf, 54 WORD16 *nrg_gain_mant, 55 WORD32 subbands); 56 57 static PLATFORM_INLINE VOID ixheaacd_filt_buf_update(WORD16 *filt_buf_mant, 58 WORD16 *ptr_filt_buf_noise, 59 WORD16 *nrg_gain_mant, 60 WORD16 *noise_level_mant, 61 WORD32 num_sub_bands); 62 63 VOID ixheaacd_noise_level_rescaling(WORD16 *noise_level_mant, WORD32 diff, 64 WORD32 num_sub_bands, 65 WORD32 ixheaacd_drc_offset); 66 67 VOID ixheaacd_enery_calc_persfb(WORD32 **anal_buf_real, WORD32 **anal_buf_imag, 68 WORD32 num_sf_bands, WORD16 *freq_band_table, 69 WORD32 start_pos, WORD32 next_pos, 70 WORD32 max_qmf_subband_aac, WORD32 frame_exp, 71 WORD16 *nrg_est_m, FLAG low_pow_flag, 72 ia_sbr_tables_struct *ptr_sbr_tables); 73 74 VOID ixheaacd_avggain_calc(WORD16 *ptr_enrg_orig, WORD16 *nrg_est, 75 WORD32 sub_band_start, WORD32 sub_band_end, 76 WORD16 *sum_orig_mant, WORD16 *sum_orig_exp, 77 WORD16 *ptr_avg_gain_mant, WORD16 *ptr_avg_gain_exp, 78 ixheaacd_misc_tables *pstr_common_tables, 79 WORD32 flag); 80 81 VOID ixheaacd_adj_timeslot(WORD32 *ptr_buf_real, WORD32 *ptr_buf_imag, 82 WORD16 *ptr_filt_buf, WORD16 *ptr_filt_buf_noise, 83 WORD16 *ptr_gain_buf, WORD16 *ptr_noise_floor, 84 WORD16 *ptr_sine_lvl_buf, WORD16 noise_floor_exp, 85 WORD16 *ptr_harm_index, WORD16 sub_band_start, 86 WORD16 num_sub_bands, WORD16 scale_change, 87 WORD16 smooth_ratio, FLAG num_noise_flg, 88 WORD16 *ptr_phase_index, 89 ia_sbr_tables_struct *ptr_sbr_tables); 90 91 VOID ixheaacd_map_sineflags(WORD16 *freq_band_table, WORD16 num_sf_bands, 92 FLAG *add_harmonics, WORD8 *harm_flags_prev, 93 WORD16 transient_env, WORD8 *sine_mapped_matrix); 94 95 VOID ixheaacd_adjust_scale_dec(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 VOID ixheaacd_adjust_scale_armv7(WORD32 **re, WORD32 **im, WORD sub_band_start, 100 WORD num_sub_bands, WORD start_pos, 101 WORD next_pos, WORD shift, FLAG low_pow_flag); 102 103 WORD16 ixheaacd_expsubbandsamples_dec(WORD32 **anal_buf_real_mant, 104 WORD32 **anal_buf_imag_mant, 105 WORD sub_band_start, WORD sub_band_end, 106 WORD start_pos, WORD end_pos, 107 FLAG low_pow_flag); 108 109 WORD16 ixheaacd_expsubbandsamples_armv7(WORD32 **anal_buf_real_mant, 110 WORD32 **anal_buf_imag_mant, 111 WORD sub_band_start, WORD sub_band_end, 112 WORD start_pos, WORD end_pos, 113 FLAG low_pow_flag); 114 115 VOID ixheaacd_enery_calc_per_subband_dec(WORD32 start_pos, WORD32 next_pos, 116 WORD32 sub_band_start, 117 WORD32 sub_band_end, WORD32 frame_exp, 118 WORD16 *nrg_est_mant, 119 FLAG low_pow_flag, 120 ia_sbr_tables_struct *ptr_sbr_tables, 121 WORD32 *ptr_qmf_matrix); 122 123 VOID ixheaacd_enery_calc_per_subband_armv7( 124 WORD32 start_pos, WORD32 next_pos, WORD32 sub_band_start, 125 WORD32 sub_band_end, WORD32 frame_exp, WORD16 *nrg_est_mant, 126 FLAG low_pow_flag, ia_sbr_tables_struct *ptr_sbr_tables, 127 WORD32 *ptr_qmf_matrix); 128 129 WORD32 ixheaacd_reset_hf_generator(ia_sbr_hf_generator_struct *hf_generator, 130 ia_sbr_header_data_struct *ptr_header_data, 131 WORD audio_obj_type); 132 133 VOID ixheaacd_harm_idx_zerotwolp_dec(WORD32 *ptr_real_buf, WORD16 *ptr_gain_buf, 134 WORD scale_change, 135 WORD16 *ptr_sine_level_buf, 136 const WORD32 *ptr_rand_ph, 137 WORD16 *noise_lvl_me, WORD num_sub_bands, 138 FLAG noise_absc_flag, WORD32 harm_index); 139 140 VOID ixheaacd_harm_idx_zerotwolp_armv7(WORD32 *ptr_real_buf, 141 WORD16 *ptr_gain_buf, WORD scale_change, 142 WORD16 *ptr_sine_level_buf, 143 const WORD32 *ptr_rand_ph, 144 WORD16 *noise_lvl_me, WORD num_sub_bands, 145 FLAG noise_absc_flag, WORD32 harm_index); 146 147 VOID ixheaacd_harm_idx_onethreelp(WORD32 *ptr_real_buf, WORD16 *ptr_gain_buf, 148 WORD scale_change, WORD16 *ptr_sine_level_buf, 149 const WORD32 *ptr_rand_ph, 150 WORD16 *noise_lvl_me, WORD num_sub_bands, 151 FLAG noise_absc_flag, WORD freq_inv_flag, 152 WORD noise_e, WORD sub_band_start); 153 154 VOID ixheaacd_conv_ergtoamplitudelp_dec(WORD32 bands, WORD16 noise_e, 155 WORD16 *nrg_sine, WORD16 *nrg_gain, 156 WORD16 *noise_level_mant, 157 WORD16 *sqrt_table); 158 159 VOID ixheaacd_conv_ergtoamplitudelp_armv7(WORD32 bands, WORD16 noise_e, 160 WORD16 *nrg_sine, WORD16 *nrg_gain, 161 WORD16 *noise_level_mant, 162 WORD16 *sqrt_table); 163 164 VOID ixheaacd_conv_ergtoamplitude_dec(WORD32 bands, WORD16 noise_e, 165 WORD16 *nrg_sine, WORD16 *nrg_gain, 166 WORD16 *noise_level_mant, 167 WORD16 *sqrt_table); 168 169 VOID ixheaacd_conv_ergtoamplitude_armv7(WORD32 bands, WORD16 noise_e, 170 WORD16 *nrg_sine, WORD16 *nrg_gain, 171 WORD16 *noise_level_mant, 172 WORD16 *sqrt_table); 173 174 VOID ixheaacd_subbandgain_calc(WORD16 e_orig_mant_matrix, WORD16 tmp_noise_mant, 175 WORD16 nrg_est_mant, WORD16 nrg_est_exp, 176 WORD16 tmp_noise_exp, WORD16 nrg_ref_exp, 177 FLAG sine_present_flag, FLAG sine_mapped_matrix, 178 FLAG noise_absc_flag, WORD16 *ptr_nrg_gain_mant, 179 WORD16 *ptr_noise_floor_mant, 180 WORD16 *ptr_nrg_sine_m, 181 ixheaacd_misc_tables *pstr_common_tables); 182 183 PLATFORM_INLINE VOID ixheaacd_equalize_filt_buff_exp(WORD16 *ptr_filt_buf, 184 WORD16 *nrg_gain, 185 WORD32 subbands); 186 187 #endif 188