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_COMMON_H
21#define IMPD_DRC_UNI_COMMON_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#define AMD1_SYNTAX 0
28#define MPEG_D_DRC_EXTENSION_V1 0
29#define AMD1_PARAMETRIC_LIMITER 0
30
31#define MPEG_H_SYNTAX 0
32
33#define EQ_IS_SUPPORTED 1
34
35#define MEASURE_AVERAGE_BITRATE 0
36#define DEBUG_NODES 0
37
38#define DRC_GAIN_DEBUG_FILE 0
39#define DEBUG_BITSTREAM 0
40#define DEBUG_DRC_SELECTION 0
41#define DEBUG_WARNINGS 0
42#define ENABLE_ADDITIONAL_TESTS 1
43
44#define SPEAKER_POS_COUNT_MAX 128
45#define DOWNMIX_COEFF_COUNT_MAX 32 * 32
46#define MAX_CHANNEL_COUNT 128
47#define BAND_COUNT_MAX 8
48#define SEQUENCE_COUNT_MAX 24
49#define GAIN_SET_COUNT_MAX SEQUENCE_COUNT_MAX
50#define MEASUREMENT_COUNT_MAX 16
51#define DOWNMIX_INSTRUCTION_COUNT_MAX 16
52#define DRC_COEFF_COUNT_MAX 8
53#define DRC_INSTRUCTIONS_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20)
54#define LOUDNESS_INFO_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20)
55#define AUDIO_CODEC_FRAME_SIZE_MAX 4096
56#define DRC_CODEC_FRAME_SIZE_MAX (AUDIO_CODEC_FRAME_SIZE_MAX / 8)
57#define NODE_COUNT_MAX DRC_CODEC_FRAME_SIZE_MAX
58#define CHANNEL_GROUP_COUNT_MAX SEQUENCE_COUNT_MAX
59#define SUB_DRC_COUNT 4
60#define SEL_DRC_COUNT 3
61#define DOWNMIX_ID_COUNT_MAX 8
62#define MAX_SIGNAL_DELAY 4500
63
64#define DELAY_MODE_REGULAR_DELAY 0
65#define DELAY_MODE_LOW_DELAY 1
66#define DELAY_MODE_DEFAULT DELAY_MODE_REGULAR_DELAY
67
68#define FEATURE_REQUEST_COUNT_MAX 10
69#define EFFECT_TYPE_REQUEST_COUNT_MAX 10
70
71#define SELECTION_CANDIDATE_COUNT_MAX 32
72
73#define PROC_COMPLETE 1
74#define UNEXPECTED_ERROR 2
75#define PARAM_ERROR 3
76#define EXTERNAL_ERROR 4
77#define ERRORHANDLING 5
78#define BITSTREAM_ERROR 6
79
80#define UNDEFINED_LOUDNESS_VALUE 1000.0f
81#define ID_FOR_BASE_LAYOUT 0x0
82#define ID_FOR_ANY_DOWNMIX 0x7F
83#define ID_FOR_NO_DRC 0x0
84#define ID_FOR_ANY_DRC 0x3F
85#define ID_FOR_ANY_EQ 0x3F
86
87#define LOCATION_MP4_INSTREAM_UNIDRC 0x1
88#define LOCATION_MP4_DYN_RANGE_INFO 0x2
89#define LOCATION_MP4_COMPRESSION_VALUE 0x3
90#define LOCATION_SELECTED LOCATION_MP4_INSTREAM_UNIDRC
91
92#define AUDIO_CODEC_SUBBAND_COUNT_MAX 256
93
94#define SUBBAND_DOMAIN_MODE_OFF 0
95#define SUBBAND_DOMAIN_MODE_QMF64 1
96#define SUBBAND_DOMAIN_MODE_QMF71 2
97#define SUBBAND_DOMAIN_MODE_STFT256 3
98
99#define AUDIO_CODEC_SUBBAND_COUNT_QMF64 64
100#define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64 64
101#define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_QMF64 320
102
103#define AUDIO_CODEC_SUBBAND_COUNT_QMF71 71
104#define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF71 64
105#define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_QMF71 320 + 384
106
107#define AUDIO_CODEC_SUBBAND_COUNT_STFT256 256
108#define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256 256
109#define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_STFT256 256
110
111#define MAX_NUM_DOWNMIX_ID_REQUESTS 15
112#define MAX_NUM_DRC_FEATURE_REQUESTS 7
113#define MAX_NUM_DRC_EFFECT_TYPE_REQUESTS 15
114#define MAX_SIGNATURE_DATA_LENGTH_PLUS_ONE 256
115
116#define EXT_COUNT_MAX 2
117#define UNIDRCGAINEXT_TERM 0x0
118#define UNIDRCLOUDEXT_TERM 0x0
119#define UNIDRCCONFEXT_TERM 0x0
120#define UNIDRCINTERFACEEXT_TERM 0x0
121
122#define MAXPACKETLOSSTIME 2.5f
123
124#define SLOPE_FACTOR_DB_TO_LINEAR 0.1151f
125
126#ifndef min
127#define min(a, b) ((a) < (b) ? (a) : (b))
128#endif
129#ifndef max
130#define max(a, b) ((a) > (b) ? (a) : (b))
131#endif
132
133#ifndef bool
134#define bool WORD32
135#endif
136
137typedef struct ia_drc_sel_proc_output_struct {
138  FLOAT32 output_peak_level_db;
139  FLOAT32 loudness_normalization_gain_db;
140  FLOAT32 output_loudness;
141
142  WORD32 sel_drc_set_ids[SUB_DRC_COUNT];
143  WORD32 sel_downmix_ids[SUB_DRC_COUNT];
144  WORD32 num_sel_drc_sets;
145
146  WORD32 active_downmix_id;
147  WORD32 base_channel_count;
148  WORD32 target_channel_count;
149  WORD32 target_layout;
150  WORD32 downmix_matrix_present;
151  FLOAT32 downmix_matrix[MAX_CHANNEL_COUNT][MAX_CHANNEL_COUNT];
152
153  FLOAT32 boost;
154  FLOAT32 compress;
155  WORD32 drc_characteristic_target;
156
157} ia_drc_sel_proc_output_struct;
158
159#ifdef __cplusplus
160}
161#endif
162#endif
163