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 (8) // 128 34 #define DOWNMIX_COEFF_COUNT_MAX 32 * 32 35 #define MAX_CHANNEL_COUNT (8) // 128 36 #define MAX_SUBBAND_CHANNEL_COUNT (128) 37 #define BAND_COUNT_MAX 8 38 #define SEQUENCE_COUNT_MAX 24 39 #define GAIN_SET_COUNT_MAX SEQUENCE_COUNT_MAX 40 #define MEASUREMENT_COUNT_MAX 16 41 #define DOWNMIX_INSTRUCTION_COUNT_MAX 16 42 #define DRC_COEFF_COUNT_MAX 8 43 #define DRC_INSTRUCTIONS_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20) 44 #define LOUDNESS_INFO_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20) 45 #define AUDIO_CODEC_FRAME_SIZE_MAX 4096 46 #define DRC_CODEC_FRAME_SIZE_MAX (AUDIO_CODEC_FRAME_SIZE_MAX / 8) 47 #define NODE_COUNT_MAX DRC_CODEC_FRAME_SIZE_MAX 48 #define CHANNEL_GROUP_COUNT_MAX SEQUENCE_COUNT_MAX 49 #define SUB_DRC_COUNT 4 50 #define SEL_DRC_COUNT 3 51 #define DOWNMIX_ID_COUNT_MAX 8 52 #define MAX_SIGNAL_DELAY 4500 53 54 #define NUM_ELE_IN_CPLX_NUM 2 55 #define MAX_BS_BUF_SIZE 768 56 #define MAX_NUM_DRC_PAYROLL 3 57 #define MAX_DRC_BS_BUF_SIZE (MAX_BS_BUF_SIZE * MAX_NUM_DRC_PAYROLL) 58 #define MAX_DRC_CONFG_BUF_SIZE MAX_BS_BUF_SIZE 59 #define MAX_LOUD_INFO_BUF_SIZE MAX_BS_BUF_SIZE 60 #define MAX_INTERFACE_BUF_SIZE MAX_BS_BUF_SIZE 61 #define MAX_GAIN_ELE_COUNT 15 /*MAX 4-bit Value*/ 62 63 #define NUM_GAIN_DEC_INSTANCES 2 64 65 #define MAX_DRC_FRAME_SIZE AUDIO_CODEC_FRAME_SIZE_MAX 66 #define ANALY_BUF_SIZE \ 67 (AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * sizeof(FLOAT32) * \ 68 NUM_ELE_IN_CPLX_NUM) 69 #define SYNTH_BUF_SIZE \ 70 (AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * sizeof(FLOAT32) * \ 71 NUM_ELE_IN_CPLX_NUM) 72 #define PEAK_LIM_BUF_SIZE \ 73 (AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * sizeof(FLOAT32) * \ 74 NUM_ELE_IN_CPLX_NUM) 75 76 /*7 bits read from the bitstream*/ 77 #define MAX_PARAM_DRC_LOOK_AHEAD_VAL 127 78 79 #define MAX_PARAM_DRC_LIM_ATTACK_VAL MAX_PARAM_DRC_LOOK_AHEAD_VAL 80 #define MAX_SAMP_FREQ_IN_KHZ 96 81 #define MAX_ATTACK_VAL (MAX_PARAM_DRC_LOOK_AHEAD_VAL * MAX_SAMP_FREQ_IN_KHZ) 82 83 /*int(sqrt(MAX_ATTACK_VAL + 1))*/ 84 #define MAX_SEC_LEN 110 85 #define MAX_NUMBUF_SEC_VAL (MAX_ATTACK_VAL / MAX_SEC_LEN) 86 87 /*(MAX_NUMBUF_SEC_VAL * MAX_SEC_LEN)*/ 88 #define PARAM_DRC_MAX_BUF_SZ 110 89 90 #define MAX_SUBBAND_DELAY (MAX_SIGNAL_DELAY / AUDIO_CODEC_SUBBAND_COUNT_QMF64) 91 92 #define DRC_BAND_COUNT_MAX BAND_COUNT_MAX 93 #define SPLIT_CHARACTERISTIC_COUNT_MAX 8 94 #define GAIN_SET_COUNT_MAX SEQUENCE_COUNT_MAX 95 #define SHAPE_FILTER_COUNT_MAX 8 96 #define DRC_SET_ID_COUNT_MAX 16 97 #define EQ_SET_ID_COUNT_MAX 8 98 #define LOUD_EQ_GAIN_SEQUENCE_COUNT_MAX 4 99 #define FILTER_ELEMENT_COUNT_MAX 16 100 #define REAL_ZERO_RADIUS_ONE_COUNT_MAX 14 101 #define REAL_ZERO_COUNT_MAX 64 102 #define COMPLEX_ZERO_COUNT_MAX 64 103 #define REAL_POLE_COUNT_MAX 16 104 #define COMPLEX_POLE_COUNT_MAX 16 105 #define FIR_ORDER_MAX 128 106 #define EQ_NODE_COUNT_MAX 33 107 #define EQ_SUBBAND_GAIN_COUNT_MAX 135 108 #define UNIQUE_SUBBAND_GAIN_COUNT_MAX 16 109 #define FILTER_BLOCK_COUNT_MAX 16 110 #define FILTER_ELEMENT_COUNT_MAX 16 111 112 #define EQ_CHANNEL_GROUP_COUNT_MAX 4 113 #define EQ_FILTER_BLOCK_COUNT_MAX 4 114 #define LOUD_EQ_INSTRUCTIONS_COUNT_MAX 8 115 #define EQ_INSTRUCTIONS_COUNT_MAX 8 116 #define SELECTED_EQ_SET_COUNT_MAX 2 117 #define SUB_EQ_COUNT 2 118 119 #define DELAY_MODE_REGULAR_DELAY 0 120 #define DELAY_MODE_LOW_DELAY 1 121 #define DELAY_MODE_DEFAULT DELAY_MODE_REGULAR_DELAY 122 123 #define FEATURE_REQUEST_COUNT_MAX 10 124 #define EFFECT_TYPE_REQUEST_COUNT_MAX 10 125 126 #define SELECTION_CANDIDATE_COUNT_MAX 32 127 128 #define MAX_NUM_COMPRESSION_EQ (16) 129 130 #define PROC_COMPLETE 1 131 #define UNEXPECTED_ERROR 2 132 #define PARAM_ERROR 3 133 #define EXTERNAL_ERROR 4 134 #define ERRORHANDLING 5 135 #define BITSTREAM_ERROR 6 136 137 #define UNDEFINED_LOUDNESS_VALUE 1000.0f 138 #define ID_FOR_BASE_LAYOUT 0x0 139 #define ID_FOR_ANY_DOWNMIX 0x7F 140 #define ID_FOR_NO_DRC 0x0 141 #define ID_FOR_ANY_DRC 0x3F 142 #define ID_FOR_ANY_EQ 0x3F 143 144 #define LOCATION_MP4_INSTREAM_UNIDRC 0x1 145 #define LOCATION_MP4_DYN_RANGE_INFO 0x2 146 #define LOCATION_MP4_COMPRESSION_VALUE 0x3 147 #define LOCATION_SELECTED LOCATION_MP4_INSTREAM_UNIDRC 148 149 #define AUDIO_CODEC_SUBBAND_COUNT_MAX 256 150 151 #define SUBBAND_DOMAIN_MODE_OFF 0 152 #define SUBBAND_DOMAIN_MODE_QMF64 1 153 #define SUBBAND_DOMAIN_MODE_QMF71 2 154 #define SUBBAND_DOMAIN_MODE_STFT256 3 155 156 #define AUDIO_CODEC_SUBBAND_COUNT_QMF64 64 157 #define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64 64 158 #define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_QMF64 320 159 160 #define AUDIO_CODEC_SUBBAND_COUNT_QMF71 71 161 #define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF71 64 162 #define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_QMF71 320 + 384 163 164 #define AUDIO_CODEC_SUBBAND_COUNT_STFT256 256 165 #define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256 256 166 #define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_STFT256 256 167 168 #define MAX_NUM_DOWNMIX_ID_REQUESTS 15 169 #define MAX_NUM_DRC_FEATURE_REQUESTS 7 170 #define MAX_NUM_DRC_EFFECT_TYPE_REQUESTS 15 171 #define MAX_SIGNATURE_DATA_LENGTH_PLUS_ONE 256 172 173 #define EXT_COUNT_MAX 8 174 #define UNIDRCGAINEXT_TERM 0x0 175 #define UNIDRCLOUDEXT_TERM 0x0 176 #define UNIDRCCONFEXT_TERM 0x0 177 #define UNIDRCINTERFACEEXT_TERM 0x0 178 179 #define UNIDRCCONFEXT_PARAM_DRC 0x1 180 181 #define PARAM_DRC_INSTRUCTIONS_COUNT_MAX 8 182 #define PARAM_DRC_INSTANCE_COUNT_MAX 8 183 184 #define PARAM_DRC_TYPE_FF 0x0 185 #define PARAM_DRC_TYPE_FF_NODE_COUNT_MAX 9 186 #define PARAM_DRC_TYPE_FF_LEVEL_ESTIM_FRAME_COUNT_MAX 64 187 188 #define PARAM_DRC_TYPE_LIM 0x1 189 #define PARAM_DRC_TYPE_LIM_THRESHOLD_DEFAULT (-1.f) 190 #define PARAM_DRC_TYPE_LIM_ATTACK_DEFAULT 5 191 #define PARAM_DRC_TYPE_LIM_RELEASE_DEFAULT 50 192 #define MAX_LOUDNESS_INFO_COUNT (16) 193 194 #define MAX_LOUDNESS_INFO_COUNT (16) 195 196 #define UNIDRCCONFEXT_V1 0x2 197 #define UNIDRCLOUDEXT_EQ 0x1 198 #define UNIDRCINTERFACEEXT_EQ 0x1 199 200 #define LOUD_EQ_REQUEST_OFF 0x0 201 #define LOUD_EQ_REQUEST_LIGHT 0x1 202 #define LOUD_EQ_REQUEST_REGULAR 0x2 203 #define LOUD_EQ_REQUEST_HEAVY 0x3 204 205 #define EQ_PURPOSE_EQ_OFF 0 206 #define EQ_PURPOSE_DEFAULT (1 << 0) 207 #define EQ_PURPOSE_LARGE_ROOM (1 << 1) 208 #define EQ_PURPOSE_SMALL_SPACE (1 << 2) 209 #define EQ_PURPOSE_AVERAGE_ROOM (1 << 3) 210 #define EQ_PURPOSE_CAR_CABIN (1 << 4) 211 #define EQ_PURPOSE_HEADPHONES (1 << 5) 212 #define EQ_PURPOSE_LATE_NIGHT (1 << 6) 213 214 #define MAXPACKETLOSSTIME 2.5f 215 216 #define SLOPE_FACTOR_DB_TO_LINEAR 0.1151f 217 218 #define MIN_DRC_SAMP_FREQ 1000 219 220 #ifndef min 221 #define min(a, b) ((a) < (b) ? (a) : (b)) 222 #endif 223 #ifndef max 224 #define max(a, b) ((a) > (b) ? (a) : (b)) 225 #endif 226 227 #ifndef bool 228 #define bool WORD32 229 #endif 230 231 typedef struct ia_drc_sel_proc_output_struct { 232 FLOAT32 output_peak_level_db; 233 FLOAT32 loudness_normalization_gain_db; 234 FLOAT32 output_loudness; 235 236 WORD32 sel_drc_set_ids[SUB_DRC_COUNT]; 237 WORD32 sel_downmix_ids[SUB_DRC_COUNT]; 238 WORD32 num_sel_drc_sets; 239 240 WORD32 active_downmix_id; 241 WORD32 base_channel_count; 242 WORD32 target_channel_count; 243 WORD32 target_layout; 244 WORD32 downmix_matrix_present; 245 FLOAT32 downmix_matrix[MAX_SUBBAND_CHANNEL_COUNT][MAX_SUBBAND_CHANNEL_COUNT]; 246 247 FLOAT32 boost; 248 FLOAT32 compress; 249 WORD32 drc_characteristic_target; 250 251 FLOAT32 mixing_level; 252 WORD32 sel_eq_set_ids[SELECTED_EQ_SET_COUNT_MAX]; 253 WORD32 sel_loud_eq_id; 254 } ia_drc_sel_proc_output_struct; 255 256 #ifdef __cplusplus 257 } 258 #endif 259 #endif 260