• 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_COMMON_H
21 #define IMPD_DRC_COMMON_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #define EQ_IS_SUPPORTED 1
28 
29 #define MEASURE_AVERAGE_BITRATE 0
30 
31 #define ENABLE_ADDITIONAL_TESTS 1
32 
33 #define SPEAKER_POS_COUNT_MAX 128
34 #define DOWNMIX_COEFF_COUNT_MAX 32 * 32
35 #define MAX_CHANNEL_COUNT 128
36 #define BAND_COUNT_MAX 8
37 #define SEQUENCE_COUNT_MAX 24
38 #define GAIN_SET_COUNT_MAX SEQUENCE_COUNT_MAX
39 #define MEASUREMENT_COUNT_MAX 16
40 #define DOWNMIX_INSTRUCTION_COUNT_MAX 16
41 #define DRC_COEFF_COUNT_MAX 8
42 #define DRC_INSTRUCTIONS_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20)
43 #define LOUDNESS_INFO_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20)
44 #define AUDIO_CODEC_FRAME_SIZE_MAX 4096
45 #define DRC_CODEC_FRAME_SIZE_MAX (AUDIO_CODEC_FRAME_SIZE_MAX / 8)
46 #define NODE_COUNT_MAX DRC_CODEC_FRAME_SIZE_MAX
47 #define CHANNEL_GROUP_COUNT_MAX SEQUENCE_COUNT_MAX
48 #define SUB_DRC_COUNT 4
49 #define SEL_DRC_COUNT 3
50 #define DOWNMIX_ID_COUNT_MAX 8
51 #define MAX_SIGNAL_DELAY 4500
52 
53 #define DRC_BAND_COUNT_MAX BAND_COUNT_MAX
54 #define SPLIT_CHARACTERISTIC_COUNT_MAX 8
55 #define GAIN_SET_COUNT_MAX SEQUENCE_COUNT_MAX
56 #define SHAPE_FILTER_COUNT_MAX 8
57 #define DRC_SET_ID_COUNT_MAX 16
58 #define EQ_SET_ID_COUNT_MAX 8
59 #define LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX 4
60 #define FILTER_ELEMENT_COUNT_MAX 16
61 #define REAL_ZERO_RADIUS_ONE_COUNT_MAX 14
62 #define REAL_ZERO_COUNT_MAX 64
63 #define COMPLEX_ZERO_COUNT_MAX 64
64 #define REAL_POLE_COUNT_MAX 16
65 #define COMPLEX_POLE_COUNT_MAX 16
66 #define FIR_ORDER_MAX 128
67 #define EQ_NODE_COUNT_MAX 33
68 #define EQ_SUBBAND_GAIN_COUNT_MAX 135
69 #define UNIQUE_SUBBAND_GAIN_COUNT_MAX 16
70 #define FILTER_BLOCK_COUNT_MAX 16
71 #define FILTER_ELEMENT_COUNT_MAX 16
72 #define UNIQUE_SUBBAND_GAINS_COUNT_MAX 8
73 #define EQ_CHANNEL_GROUP_COUNT_MAX 4
74 #define EQ_FILTER_BLOCK_COUNT_MAX 4
75 #define LOUD_EQ_INSTRUCTIONS_COUNT_MAX 8
76 #define EQ_INSTRUCTIONS_COUNT_MAX 8
77 #define SELECTED_EQ_SET_COUNT_MAX 2
78 #define SUB_EQ_COUNT 2
79 
80 #define DELAY_MODE_REGULAR_DELAY 0
81 #define DELAY_MODE_LOW_DELAY 1
82 #define DELAY_MODE_DEFAULT DELAY_MODE_REGULAR_DELAY
83 
84 #define FEATURE_REQUEST_COUNT_MAX 10
85 #define EFFECT_TYPE_REQUEST_COUNT_MAX 10
86 
87 #define SELECTION_CANDIDATE_COUNT_MAX 32
88 
89 #define PROC_COMPLETE 1
90 #define UNEXPECTED_ERROR 2
91 #define PARAM_ERROR 3
92 #define EXTERNAL_ERROR 4
93 #define ERRORHANDLING 5
94 #define BITSTREAM_ERROR 6
95 
96 #define UNDEFINED_LOUDNESS_VALUE 1000.0f
97 #define ID_FOR_BASE_LAYOUT 0x0
98 #define ID_FOR_ANY_DOWNMIX 0x7F
99 #define ID_FOR_NO_DRC 0x0
100 #define ID_FOR_ANY_DRC 0x3F
101 #define ID_FOR_ANY_EQ 0x3F
102 
103 #define LOCATION_MP4_INSTREAM_UNIDRC 0x1
104 #define LOCATION_MP4_DYN_RANGE_INFO 0x2
105 #define LOCATION_MP4_COMPRESSION_VALUE 0x3
106 #define LOCATION_SELECTED LOCATION_MP4_INSTREAM_UNIDRC
107 
108 #define AUDIO_CODEC_SUBBAND_COUNT_MAX 256
109 
110 #define SUBBAND_DOMAIN_MODE_OFF 0
111 #define SUBBAND_DOMAIN_MODE_QMF64 1
112 #define SUBBAND_DOMAIN_MODE_QMF71 2
113 #define SUBBAND_DOMAIN_MODE_STFT256 3
114 
115 #define AUDIO_CODEC_SUBBAND_COUNT_QMF64 64
116 #define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64 64
117 #define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_QMF64 320
118 
119 #define AUDIO_CODEC_SUBBAND_COUNT_QMF71 71
120 #define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF71 64
121 #define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_QMF71 320 + 384
122 
123 #define AUDIO_CODEC_SUBBAND_COUNT_STFT256 256
124 #define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256 256
125 #define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_STFT256 256
126 
127 #define MAX_NUM_DOWNMIX_ID_REQUESTS 15
128 #define MAX_NUM_DRC_FEATURE_REQUESTS 7
129 #define MAX_NUM_DRC_EFFECT_TYPE_REQUESTS 15
130 #define MAX_SIGNATURE_DATA_LENGTH_PLUS_ONE 256
131 
132 #define EXT_COUNT_MAX 2
133 #define UNIDRCGAINEXT_TERM 0x0
134 #define UNIDRCLOUDEXT_TERM 0x0
135 #define UNIDRCCONFEXT_TERM 0x0
136 #define UNIDRCINTERFACEEXT_TERM 0x0
137 
138 #define UNIDRCCONFEXT_PARAM_DRC 0x1
139 
140 #define PARAM_DRC_INSTRUCTIONS_COUNT_MAX 8
141 #define PARAM_DRC_INSTANCE_COUNT_MAX 8
142 
143 #define PARAM_DRC_TYPE_FF 0x0
144 #define PARAM_DRC_TYPE_FF_NODE_COUNT_MAX 9
145 #define PARAM_DRC_TYPE_FF_LEVEL_ESTIM_FRAME_COUNT_MAX 64
146 
147 #define PARAM_DRC_TYPE_LIM 0x1
148 #define PARAM_DRC_TYPE_LIM_THRESHOLD_DEFAULT (-1.f)
149 #define PARAM_DRC_TYPE_LIM_ATTACK_DEFAULT 5
150 #define PARAM_DRC_TYPE_LIM_RELEASE_DEFAULT 50
151 
152 #define UNIDRCCONFEXT_V1 0x2
153 #define UNIDRCLOUDEXT_EQ 0x1
154 #define UNIDRCINTERFACEEXT_EQ 0x1
155 
156 #define LOUD_EQ_REQUEST_OFF 0x0
157 #define LOUD_EQ_REQUEST_LIGHT 0x1
158 #define LOUD_EQ_REQUEST_REGULAR 0x2
159 #define LOUD_EQ_REQUEST_HEAVY 0x3
160 
161 #define EQ_PURPOSE_EQ_OFF 0
162 #define EQ_PURPOSE_DEFAULT (1 << 0)
163 #define EQ_PURPOSE_LARGE_ROOM (1 << 1)
164 #define EQ_PURPOSE_SMALL_SPACE (1 << 2)
165 #define EQ_PURPOSE_AVERAGE_ROOM (1 << 3)
166 #define EQ_PURPOSE_CAR_CABIN (1 << 4)
167 #define EQ_PURPOSE_HEADPHONES (1 << 5)
168 #define EQ_PURPOSE_LATE_NIGHT (1 << 6)
169 
170 #define MAXPACKETLOSSTIME 2.5f
171 
172 #define SLOPE_FACTOR_DB_TO_LINEAR 0.1151f
173 
174 #ifndef min
175 #define min(a, b) ((a) < (b) ? (a) : (b))
176 #endif
177 #ifndef max
178 #define max(a, b) ((a) > (b) ? (a) : (b))
179 #endif
180 
181 #ifndef bool
182 #define bool WORD32
183 #endif
184 
185 typedef struct ia_drc_sel_proc_output_struct {
186   FLOAT32 output_peak_level_db;
187   FLOAT32 loudness_normalization_gain_db;
188   FLOAT32 output_loudness;
189 
190   WORD32 sel_drc_set_ids[SUB_DRC_COUNT];
191   WORD32 sel_downmix_ids[SUB_DRC_COUNT];
192   WORD32 num_sel_drc_sets;
193 
194   WORD32 active_downmix_id;
195   WORD32 base_channel_count;
196   WORD32 target_channel_count;
197   WORD32 target_layout;
198   WORD32 downmix_matrix_present;
199   FLOAT32 downmix_matrix[MAX_CHANNEL_COUNT][MAX_CHANNEL_COUNT];
200 
201   FLOAT32 boost;
202   FLOAT32 compress;
203   WORD32 drc_characteristic_target;
204 
205   FLOAT32 mixing_level;
206   WORD32 sel_eq_set_ids[SELECTED_EQ_SET_COUNT_MAX];
207   WORD32 sel_loud_eq_id;
208 } ia_drc_sel_proc_output_struct;
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 #endif
214