• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DRC_FILTER_BANK_H
21 #define IMPD_DRC_FILTER_BANK_H
22 
23 #define FILTER_BANK_PARAMETER_COUNT 16
24 #define CASCADE_ALLPASS_COUNT_MAX 9
25 #define QMF_NUM_FILT_BANDS 64
26 #define QMF_FILT_RESOLUTION 64
27 
28 typedef struct ia_drc_qmf_filt_struct {
29   FLOAT64* ana_buff;
30   FLOAT64* syn_buff;
31   FLOAT64 ana_tab_real[QMF_NUM_FILT_BANDS][2 * QMF_NUM_FILT_BANDS];
32   FLOAT64 ana_tab_imag[QMF_NUM_FILT_BANDS][2 * QMF_NUM_FILT_BANDS];
33   FLOAT64 syn_tab_real[2 * QMF_NUM_FILT_BANDS][QMF_NUM_FILT_BANDS];
34   FLOAT64 syn_tab_imag[2 * QMF_NUM_FILT_BANDS][QMF_NUM_FILT_BANDS];
35 
36 } ia_drc_qmf_filt_struct;
37 
38 typedef struct {
39   FLOAT32 f_cross_norm;
40   FLOAT32 gamma;
41   FLOAT32 delta;
42 } ia_filter_bank_params_struct;
43 
44 typedef struct {
45   FLOAT32 s00;
46   FLOAT32 s01;
47   FLOAT32 s10;
48   FLOAT32 s11;
49 } ia_lr_filter_state_struct;
50 
51 typedef struct {
52   FLOAT32 s0;
53   FLOAT32 s1;
54 } ia_all_pass_filter_state_struct;
55 
56 typedef struct {
57   FLOAT32 a0;
58   FLOAT32 a1;
59   FLOAT32 a2;
60   FLOAT32 b0;
61   FLOAT32 b1;
62   FLOAT32 b2;
63   FLOAT32 x_p[MAX_CHANNEL_COUNT * 2];
64   FLOAT32 y_p[MAX_CHANNEL_COUNT * 2];
65 } ia_iir_filter_struct;
66 typedef struct {
67   ia_iir_filter_struct low_pass;
68   ia_iir_filter_struct high_pass;
69 } ia_two_band_filt_struct;
70 
71 typedef struct {
72   ia_iir_filter_struct str_low_pass_stage_1;
73   ia_iir_filter_struct str_high_pass_stage_1;
74   ia_iir_filter_struct str_low_pass_stage_2;
75   ia_iir_filter_struct str_high_pass_stage_2;
76   ia_iir_filter_struct str_all_pass_stage_2;
77 } ia_three_band_filt_struct;
78 
79 typedef struct {
80   ia_iir_filter_struct str_low_pass_stage_1;
81   ia_iir_filter_struct str_high_pass_stage_1;
82   ia_iir_filter_struct str_all_pass_stage_2_high;
83   ia_iir_filter_struct str_all_pass_stage_2_low;
84   ia_iir_filter_struct str_low_pass_stage_3_high;
85   ia_iir_filter_struct str_high_pass_stage_3_high;
86   ia_iir_filter_struct str_low_pass_stage_3_low;
87   ia_iir_filter_struct str_high_pass_stage_3_low;
88 } ia_four_band_filt_struct;
89 
90 typedef struct {
91   ia_iir_filter_struct str_all_pass_stage;
92 } ia_all_pass_filter_sturct;
93 
94 typedef struct {
95   ia_all_pass_filter_sturct
96       str_all_pass_cascade_filter[CASCADE_ALLPASS_COUNT_MAX];
97   WORD32 num_filter;
98 } ia_all_pass_cascade_struct;
99 
100 typedef struct {
101   WORD32 num_bands;
102   WORD32 complexity;
103   ia_two_band_filt_struct str_two_band_bank;
104   ia_three_band_filt_struct str_three_band_bank;
105   ia_four_band_filt_struct str_four_band_bank;
106   ia_all_pass_cascade_struct str_all_pass_cascade;
107 } ia_drc_filter_bank_struct;
108 
109 typedef struct {
110   WORD32 nfilter_banks;
111   WORD32 num_ph_align_ch_groups;
112   WORD32 complexity;
113   ia_drc_filter_bank_struct str_drc_filter_bank[8];
114 } ia_filter_banks_struct;
115 
116 WORD32
117 impd_init_all_filter_banks(
118     ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc,
119     ia_drc_instructions_struct* str_drc_instruction_str,
120     ia_filter_banks_struct* ia_filter_banks_struct);
121 
122 VOID impd_two_band_filter_process(ia_two_band_filt_struct* str_two_band_bank,
123                                   WORD32 c, WORD32 size, FLOAT32* audio_in,
124                                   FLOAT32* audio_out[]);
125 
126 VOID impd_three_band_filter_process(
127     ia_three_band_filt_struct* str_three_band_bank, WORD32 c, WORD32 size,
128     FLOAT32* audio_in, FLOAT32* audio_out[]);
129 
130 VOID impd_four_band_filter_process(ia_four_band_filt_struct* str_four_band_bank,
131                                    WORD32 c, WORD32 size, FLOAT32* audio_in,
132                                    FLOAT32* audio_out[]);
133 
134 VOID impd_all_pass_cascade_process(
135     ia_all_pass_cascade_struct* str_all_pass_cascade, WORD32 c, WORD32 size,
136     FLOAT32* audio_in);
137 
138 VOID impd_shape_filt_block_init(
139     ia_shape_filter_block_params_struct* pstr_shape_filter_block_params,
140     shape_filter_block* shape_filter_block);
141 
142 VOID impd_shape_filt_block_adapt(const FLOAT32 drc_gain,
143                                  shape_filter_block* shape_filter_block);
144 
145 VOID impd_shape_filt_block_time_process(shape_filter_block* shape_filter_block,
146                                         FLOAT32* drc_gain, const WORD32 channel,
147                                         FLOAT32* audio_in, WORD32 start,
148                                         WORD32 end);
149 #endif
150