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 IMPD_PARAMETRIC_DRC_DEC_H 21 #define IMPD_PARAMETRIC_DRC_DEC_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 typedef struct ia_2nd_order_filt_coeff_struct_t { 28 FLOAT32 b0, b1, b2; 29 FLOAT32 a1, a2; 30 } ia_2nd_order_filt_coeff_struct; 31 32 typedef struct ia_2nd_order_filt_state_struct_t { 33 FLOAT32 z1, z2; 34 } ia_2nd_order_filt_state_struct; 35 36 typedef struct ia_parametric_drc_type_ff_params_struct_t { 37 WORD32 audio_num_chan; 38 WORD32 frame_size; 39 WORD32 sub_band_domain_mode; 40 WORD32 sub_band_count; 41 WORD32 level_estim_integration_time; 42 WORD32 level_estim_frame_index; 43 WORD32 level_estim_frame_count; 44 FLOAT32 level[PARAM_DRC_TYPE_FF_LEVEL_ESTIM_FRAME_COUNT_MAX]; 45 WORD32 start_up_phase; 46 FLOAT32 level_estim_ch_weight[MAX_CHANNEL_COUNT]; 47 WORD32 level_estim_k_weighting_type; 48 ia_2nd_order_filt_coeff_struct pre_filt_coeff; 49 ia_2nd_order_filt_coeff_struct rlb_filt_coeff; 50 ia_2nd_order_filt_state_struct pre_filt_state[MAX_CHANNEL_COUNT]; 51 ia_2nd_order_filt_state_struct rlb_filt_state[MAX_CHANNEL_COUNT]; 52 FLOAT32 weighting_filt[AUDIO_CODEC_SUBBAND_COUNT_MAX]; 53 WORD32 sub_band_compensation_type; 54 ia_2nd_order_filt_coeff_struct filt_coeff_subband; 55 ia_2nd_order_filt_state_struct filt_state_subband_real[MAX_CHANNEL_COUNT]; 56 ia_2nd_order_filt_state_struct filt_state_subband_imag[MAX_CHANNEL_COUNT]; 57 FLOAT32 ref_level_parametric_drc; 58 59 WORD32 node_count; 60 WORD32 node_level[PARAM_DRC_TYPE_FF_NODE_COUNT_MAX]; 61 WORD32 node_gain[PARAM_DRC_TYPE_FF_NODE_COUNT_MAX]; 62 63 FLOAT32 gain_smooth_attack_alpha_slow; 64 FLOAT32 gain_smooth_rel_alpha_slow; 65 FLOAT32 gain_smooth_attack_alpha_fast; 66 FLOAT32 gain_smooth_rel_alpha_fast; 67 WORD32 gain_smooth_attack_threshold; 68 WORD32 gain_smooth_rel_threshold; 69 WORD32 gain_smooth_hold_off_count; 70 FLOAT32 db_level_smooth; 71 FLOAT32 db_gain_smooth; 72 WORD32 hold_counter; 73 74 } ia_parametric_drc_type_ff_params_struct; 75 76 typedef struct ia_parametric_drc_type_lim_params_struct_t { 77 WORD32 audio_num_chan; 78 WORD32 frame_size; 79 FLOAT32 level_estim_ch_weight[MAX_CHANNEL_COUNT]; 80 81 UWORD32 attack; 82 FLOAT32 attack_constant; 83 FLOAT32 release_constant; 84 FLOAT32 attack_ms; 85 FLOAT32 release_ms; 86 FLOAT32 threshold; 87 UWORD32 channels; 88 UWORD32 sampling_rate; 89 FLOAT32 cor; 90 FLOAT32* max_buf; 91 FLOAT32* max_buf_slow; 92 UWORD32 max_buf_idx; 93 UWORD32 max_buf_slow_idx; 94 UWORD32 sec_len; 95 UWORD32 num_max_buf_sec; 96 UWORD32 max_buf_sec_idx; 97 UWORD32 max_buf_sec_ctr; 98 FLOAT64 smooth_state_0; 99 100 } ia_parametric_drc_type_lim_params_struct; 101 102 typedef struct ia_parametric_drc_instance_params_struct_t { 103 WORD32 disable_paramteric_drc; 104 WORD32 parametric_drc_type; 105 ia_spline_nodes_struct str_spline_nodes; 106 ia_parametric_drc_type_ff_params_struct str_parametric_drc_type_ff_params; 107 ia_parametric_drc_type_lim_params_struct str_parametric_drc_type_lim_params; 108 } ia_parametric_drc_instance_params_struct; 109 110 typedef struct ia_parametric_drc_params_struct_t { 111 WORD32 sampling_rate; 112 WORD32 audio_num_chan; 113 WORD32 sub_band_domain_mode; 114 WORD32 sub_band_count; 115 116 WORD32 num_nodes; 117 WORD32 drc_frame_size; 118 WORD32 parametric_drc_frame_size; 119 WORD32 parametric_drc_look_ahead_samples_max; 120 WORD32 reset_parametric_drc; 121 122 WORD32 parametric_drc_instance_count; 123 WORD32 parametric_drc_idx[PARAM_DRC_INSTANCE_COUNT_MAX]; 124 WORD32 gain_set_index[PARAM_DRC_INSTANCE_COUNT_MAX]; 125 WORD32 dwnmix_id_from_drc_instructions[PARAM_DRC_INSTANCE_COUNT_MAX]; 126 WORD32 channel_map[PARAM_DRC_INSTANCE_COUNT_MAX][MAX_CHANNEL_COUNT]; 127 128 ia_parametric_drc_instance_params_struct 129 str_parametric_drc_instance_params[PARAM_DRC_INSTANCE_COUNT_MAX]; 130 131 } ia_parametric_drc_params_struct; 132 133 WORD32 impd_init_parametric_drc( 134 WORD32 drc_frame_size, WORD32 sampling_rate, WORD32 sub_band_domain_mode, 135 ia_parametric_drc_params_struct* pstr_parametric_drc_params); 136 137 WORD32 impd_init_parametric_drc_after_config( 138 ia_drc_config* pstr_drc_config, 139 ia_drc_loudness_info_set_struct* pstr_loudness_info, 140 ia_parametric_drc_params_struct* pstr_parametric_drc_params, 141 pVOID* mem_ptr); 142 143 WORD32 144 impd_init_lvl_est_filt_time(WORD32 level_estim_k_weighting_type, 145 WORD32 sampling_rate, 146 ia_2nd_order_filt_coeff_struct* pre_filt_coeff, 147 ia_2nd_order_filt_coeff_struct* rlb_filt_coeff); 148 149 WORD32 150 impd_init_lvl_est_filt_subband( 151 WORD32 level_estim_k_weighting_type, WORD32 sampling_rate, 152 WORD32 sub_band_domain_mode, WORD32 sub_band_count, 153 WORD32 sub_band_compensation_type, FLOAT32* weighting_filt, 154 ia_2nd_order_filt_coeff_struct* filt_coeff_subband); 155 156 WORD32 157 impd_parametric_ffwd_type_drc_reset(ia_parametric_drc_type_ff_params_struct* 158 pstr_parametric_ffwd_type_drc_params); 159 160 WORD32 161 impd_parametric_lim_type_drc_reset(WORD32 instance_idx, 162 ia_parametric_drc_type_lim_params_struct* 163 pstr_parametric_lim_type_drc_params); 164 165 WORD32 166 impd_parametric_drc_instance_process( 167 FLOAT32* audio_in_out_buf[], FLOAT32* audio_real_buff[], 168 FLOAT32* audio_imag_buff[], 169 ia_parametric_drc_params_struct* pstr_parametric_drc_params, 170 ia_parametric_drc_instance_params_struct* 171 pstr_parametric_drc_instance_params); 172 173 WORD32 174 impd_parametric_ffwd_type_drc_process(FLOAT32* audio_in_out_buf[], 175 FLOAT32* audio_real_buff[], 176 FLOAT32* audio_imag_buff[], 177 WORD32 nodeIdx, 178 ia_parametric_drc_type_ff_params_struct* 179 pstr_parametric_ffwd_type_drc_params, 180 ia_spline_nodes_struct* str_spline_nodes); 181 182 WORD32 183 impd_parametric_lim_type_drc_process(FLOAT32* audio_in_out_buf[], 184 FLOAT32 loudness_normalization_gain_db, 185 ia_parametric_drc_type_lim_params_struct* 186 pstr_parametric_lim_type_drc_params, 187 FLOAT32* lpcm_gains); 188 189 #ifdef __cplusplus 190 } 191 #endif 192 #endif 193