1 /******************************************************************************
2  *
3  * Copyright (C) 2015 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_UNI_GAIN_DEC_H
21 #define IMPD_DRC_UNI_GAIN_DEC_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef struct {
28   ia_node_struct str_node;
29   ia_node_struct prev_node;
30   FLOAT32 lpcm_gains[2 * AUDIO_CODEC_FRAME_SIZE_MAX + MAX_SIGNAL_DELAY];
31 } ia_interp_buf_struct;
32 
33 typedef struct {
34 #if DRC_GAIN_DEBUG_FILE
35   FILE* f_gain_debug;
36 #endif
37   WORD32 buf_interpolation_count;
38   ia_interp_buf_struct* buf_interpolation;
39 } ia_gain_buffer_struct;
40 
41 typedef struct {
42   ia_gain_buffer_struct pstr_gain_buf[SEL_DRC_COUNT];
43 } ia_drc_gain_buffers_struct;
44 
45 typedef struct {
46   WORD32 gain_interpolation_type;
47   WORD32 gain_modification_flag;
48   WORD32 ducking_flag;
49   WORD32 clipping_flag;
50   ia_ducking_modifiers_struct* pstr_ducking_modifiers;
51   ia_gain_modifiers_struct* pstr_gain_modifiers;
52   WORD32 limiter_peak_target_present;
53   FLOAT32 limiter_peak_target;
54   FLOAT32 loudness_normalization_gain_db;
55   WORD32 delta_tmin;
56   WORD32 characteristic_index;
57   FLOAT32 compress;
58   FLOAT32 boost;
59 } ia_interp_params_struct;
60 
61 typedef struct {
62   WORD32 drc_instructions_index;
63   WORD32 drc_coeff_idx;
64   WORD32 dwnmix_instructions_index;
65 } ia_sel_drc_struct;
66 
67 typedef struct {
68   WORD32 sample_rate;
69   WORD32 delta_tmin_default;
70   WORD32 drc_frame_size;
71   WORD32 delay_mode;
72   WORD32 sub_band_domain_mode;
73   WORD32 gain_delay_samples;
74   WORD32 audio_delay_samples;
75   WORD32 drc_set_counter;
76   WORD32 multiband_sel_drc_idx;
77 
78   ia_sel_drc_struct sel_drc_array[SEL_DRC_COUNT];
79 
80 } ia_drc_params_struct;
81 
82 WORD32
83 impd_gain_buf_init(WORD32 index, WORD32 gain_element_count,
84                    WORD32 drc_frame_size, ia_gain_buffer_struct* pstr_gain_buf);
85 
86 WORD32
87 impd_advance_buf(WORD32 drc_frame_size, ia_gain_buffer_struct* pstr_gain_buf);
88 
89 WORD32
90 impd_map_gain(FLOAT32 gain_in_db, FLOAT32* gain_out_db);
91 
92 WORD32
93 impd_conv_to_linear_domain(ia_interp_params_struct* interp_params_str,
94                            WORD32 drc_band, FLOAT32 loc_db_gain,
95                            FLOAT32 in_param_db_slope,
96                            FLOAT32* out_param_lin_gain,
97                            FLOAT32* out_param_lin_slope);
98 
99 WORD32
100 impd_interpolate_drc_gain(ia_interp_params_struct* interp_params_str,
101                           WORD32 drc_band, WORD32 gain_step_tdomain,
102                           FLOAT32 gain0, FLOAT32 gain1, FLOAT32 slope0,
103                           FLOAT32 slope1, FLOAT32* result);
104 
105 WORD32
106 impd_concatenate_segments(WORD32 drc_frame_size, WORD32 drc_band,
107                           ia_interp_params_struct* interp_params_str,
108                           ia_spline_nodes_struct* str_spline_nodes,
109                           ia_interp_buf_struct* buf_interpolation);
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 #endif
115