1 /* -----------------------------------------------------------------------------
2 Software License for The Fraunhofer FDK AAC Codec Library for Android
3 
4 © Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
5 Forschung e.V. All rights reserved.
6 
7  1.    INTRODUCTION
8 The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
9 that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
10 scheme for digital audio. This FDK AAC Codec software is intended to be used on
11 a wide variety of Android devices.
12 
13 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
14 general perceptual audio codecs. AAC-ELD is considered the best-performing
15 full-bandwidth communications codec by independent studies and is widely
16 deployed. AAC has been standardized by ISO and IEC as part of the MPEG
17 specifications.
18 
19 Patent licenses for necessary patent claims for the FDK AAC Codec (including
20 those of Fraunhofer) may be obtained through Via Licensing
21 (www.vialicensing.com) or through the respective patent owners individually for
22 the purpose of encoding or decoding bit streams in products that are compliant
23 with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
24 Android devices already license these patent claims through Via Licensing or
25 directly from the patent owners, and therefore FDK AAC Codec software may
26 already be covered under those patent licenses when it is used for those
27 licensed purposes only.
28 
29 Commercially-licensed AAC software libraries, including floating-point versions
30 with enhanced sound quality, are also available from Fraunhofer. Users are
31 encouraged to check the Fraunhofer website for additional applications
32 information and documentation.
33 
34 2.    COPYRIGHT LICENSE
35 
36 Redistribution and use in source and binary forms, with or without modification,
37 are permitted without payment of copyright license fees provided that you
38 satisfy the following conditions:
39 
40 You must retain the complete text of this software license in redistributions of
41 the FDK AAC Codec or your modifications thereto in source code form.
42 
43 You must retain the complete text of this software license in the documentation
44 and/or other materials provided with redistributions of the FDK AAC Codec or
45 your modifications thereto in binary form. You must make available free of
46 charge copies of the complete source code of the FDK AAC Codec and your
47 modifications thereto to recipients of copies in binary form.
48 
49 The name of Fraunhofer may not be used to endorse or promote products derived
50 from this library without prior written permission.
51 
52 You may not charge copyright license fees for anyone to use, copy or distribute
53 the FDK AAC Codec software or your modifications thereto.
54 
55 Your modified versions of the FDK AAC Codec must carry prominent notices stating
56 that you changed the software and the date of any change. For modified versions
57 of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
58 must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
59 AAC Codec Library for Android."
60 
61 3.    NO PATENT LICENSE
62 
63 NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
64 limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
65 Fraunhofer provides no warranty of patent non-infringement with respect to this
66 software.
67 
68 You may use this FDK AAC Codec software or modifications thereto only for
69 purposes that are authorized by appropriate patent licenses.
70 
71 4.    DISCLAIMER
72 
73 This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
74 holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
75 including but not limited to the implied warranties of merchantability and
76 fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
77 CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
78 or consequential damages, including but not limited to procurement of substitute
79 goods or services; loss of use, data, or profits, or business interruption,
80 however caused and on any theory of liability, whether in contract, strict
81 liability, or tort (including negligence), arising in any way out of the use of
82 this software, even if advised of the possibility of such damage.
83 
84 5.    CONTACT INFORMATION
85 
86 Fraunhofer Institute for Integrated Circuits IIS
87 Attention: Audio and Multimedia Departments - FDK AAC LL
88 Am Wolfsmantel 33
89 91058 Erlangen, Germany
90 
91 www.iis.fraunhofer.de/amm
92 amm-info@iis.fraunhofer.de
93 ----------------------------------------------------------------------------- */
94 
95 /************************* MPEG-D DRC decoder library **************************
96 
97    Author(s):
98 
99    Description:
100 
101 *******************************************************************************/
102 
103 #ifndef DRCDEC_TYPES_H
104 #define DRCDEC_TYPES_H
105 
106 #include "common_fix.h"
107 
108 /* Data structures corresponding to static and dynamic DRC/Loudness payload
109    as defined in section 7 of MPEG-D DRC standard, ISO/IEC 23003-4 */
110 
111 /**************/
112 /* uniDrcGain */
113 /**************/
114 
115 typedef struct {
116   FIXP_SGL gainDb; /* e = 7 */
117   SHORT time;
118 } GAIN_NODE;
119 
120 /* uniDrcGainExtension() (Table 56) */
121 typedef struct {
122   UCHAR uniDrcGainExtType[8];
123   ULONG extBitSize[8 - 1];
124 } UNI_DRC_GAIN_EXTENSION;
125 
126 /* uniDrcGain() (Table 55) */
127 typedef struct {
128   UCHAR nNodes[12]; /* unsaturated value, i.e. as provided in bitstream */
129   GAIN_NODE gainNode[12][16];
130 
131   UCHAR uniDrcGainExtPresent;
132   UNI_DRC_GAIN_EXTENSION uniDrcGainExtension;
133 
134   /* derived data */
135   UCHAR status;
136 } UNI_DRC_GAIN, *HANDLE_UNI_DRC_GAIN;
137 
138 /****************/
139 /* uniDrcConfig */
140 /****************/
141 
142 typedef enum {
143   EB_NIGHT = 0x0001,
144   EB_NOISY = 0x0002,
145   EB_LIMITED = 0x0004,
146   EB_LOWLEVEL = 0x0008,
147   EB_DIALOG = 0x0010,
148   EB_GENERAL_COMPR = 0x0020,
149   EB_EXPAND = 0x0040,
150   EB_ARTISTIC = 0x0080,
151   EB_CLIPPING = 0x0100,
152   EB_FADE = 0x0200,
153   EB_DUCK_OTHER = 0x0400,
154   EB_DUCK_SELF = 0x0800
155 } EFFECT_BIT;
156 
157 typedef enum {
158   GCP_REGULAR = 0,
159   GCP_FADING = 1,
160   GCP_CLIPPING_DUCKING = 2,
161   GCP_CONSTANT = 3
162 } GAIN_CODING_PROFILE;
163 
164 typedef enum { GIT_SPLINE = 0, GIT_LINEAR = 1 } GAIN_INTERPOLATION_TYPE;
165 
166 typedef enum { CS_LEFT = 0, CS_RIGHT = 1 } CHARACTERISTIC_SIDE;
167 
168 typedef enum { CF_SIGMOID = 0, CF_NODES = 1 } CHARACTERISTIC_FORMAT;
169 
170 typedef enum {
171   GF_QMF32 = 0x1,
172   GF_QMFHYBRID39 = 0x2,
173   GF_QMF64 = 0x3,
174   GF_QMFHYBRID71 = 0x4,
175   GF_QMF128 = 0x5,
176   GF_QMFHYBRID135 = 0x6,
177   GF_UNIFORM = 0x7
178 } EQ_SUBBAND_GAIN_FORMAT;
179 
180 typedef struct {
181   UCHAR duckingScalingPresent;
182   FIXP_SGL duckingScaling; /* e = 2 */
183 } DUCKING_MODIFICATION;
184 
185 typedef struct {
186   UCHAR targetCharacteristicLeftPresent;
187   UCHAR targetCharacteristicLeftIndex;
188   UCHAR targetCharacteristicRightPresent;
189   UCHAR targetCharacteristicRightIndex;
190   UCHAR gainScalingPresent;
191   FIXP_SGL attenuationScaling;   /* e = 2 */
192   FIXP_SGL amplificationScaling; /* e = 2 */
193   UCHAR gainOffsetPresent;
194   FIXP_SGL gainOffset; /* e = 4 */
195 } GAIN_MODIFICATION;
196 
197 typedef union {
198   UCHAR crossoverFreqIndex;
199   USHORT startSubBandIndex;
200 } BAND_BORDER;
201 
202 typedef struct {
203   UCHAR left;
204   UCHAR right;
205 } CUSTOM_INDEX;
206 
207 typedef struct {
208   UCHAR present;
209   UCHAR isCICP;
210   union {
211     UCHAR cicpIndex;
212     CUSTOM_INDEX custom;
213   };
214 } DRC_CHARACTERISTIC;
215 
216 typedef struct {
217   UCHAR gainCodingProfile;
218   UCHAR gainInterpolationType;
219   UCHAR fullFrame;
220   UCHAR timeAlignment;
221   UCHAR timeDeltaMinPresent;
222   USHORT timeDeltaMin;
223   UCHAR bandCount;
224   UCHAR drcBandType;
225   UCHAR gainSequenceIndex[4];
226   DRC_CHARACTERISTIC drcCharacteristic[4];
227   BAND_BORDER bandBorder[4];
228 } GAIN_SET;
229 
230 typedef struct {
231   FIXP_SGL gain;    /* e = 6 */
232   FIXP_SGL ioRatio; /* e = 2 */
233   FIXP_SGL exp;     /* e = 5 */
234   UCHAR flipSign;
235 } CUSTOM_DRC_CHAR_SIGMOID;
236 
237 typedef struct {
238   UCHAR characteristicNodeCount;
239   FIXP_SGL nodeLevel[4 + 1]; /* e = 7 */
240   FIXP_SGL nodeGain[4 + 1];  /* e = 7 */
241 } CUSTOM_DRC_CHAR_NODES;
242 
243 typedef shouldBeUnion {
244   CUSTOM_DRC_CHAR_SIGMOID sigmoid;
245   CUSTOM_DRC_CHAR_NODES nodes;
246 }
247 CUSTOM_DRC_CHAR;
248 
249 /* drcCoefficientsUniDrc() (Table 67) */
250 typedef struct {
251   UCHAR drcLocation;
252   UCHAR drcFrameSizePresent;
253   USHORT drcFrameSize;
254   UCHAR characteristicLeftCount;
255   UCHAR characteristicLeftFormat[16];
256   CUSTOM_DRC_CHAR customCharacteristicLeft[16];
257   UCHAR characteristicRightCount;
258   UCHAR characteristicRightFormat[16];
259   CUSTOM_DRC_CHAR customCharacteristicRight[16];
260   UCHAR
261   gainSequenceCount;  /* unsaturated value, i.e. as provided in bitstream */
262   UCHAR gainSetCount; /* saturated to 12 */
263   GAIN_SET gainSet[12];
264   /* derived data */
265   UCHAR gainSetIndexForGainSequence[12];
266 } DRC_COEFFICIENTS_UNI_DRC;
267 
268 /* drcInstructionsUniDrc() (Table 72) */
269 typedef struct {
270   SCHAR drcSetId;
271   UCHAR drcSetComplexityLevel;
272   UCHAR drcLocation;
273   UCHAR drcApplyToDownmix;
274   UCHAR downmixIdCount;
275   UCHAR downmixId[8];
276   USHORT drcSetEffect;
277   UCHAR limiterPeakTargetPresent;
278   FIXP_SGL limiterPeakTarget; /* e = 5 */
279   UCHAR drcSetTargetLoudnessPresent;
280   SCHAR drcSetTargetLoudnessValueUpper;
281   SCHAR drcSetTargetLoudnessValueLower;
282   UCHAR dependsOnDrcSetPresent;
283   union {
284     SCHAR dependsOnDrcSet;
285     UCHAR noIndependentUse;
286   };
287   UCHAR requiresEq;
288   shouldBeUnion {
289     GAIN_MODIFICATION gainModificationForChannelGroup[8][4];
290     DUCKING_MODIFICATION duckingModificationForChannel[8];
291   };
292   SCHAR gainSetIndex[8];
293 
294   /* derived data */
295   UCHAR drcChannelCount;
296   UCHAR nDrcChannelGroups;
297   SCHAR gainSetIndexForChannelGroup[8];
298 } DRC_INSTRUCTIONS_UNI_DRC;
299 
300 /* channelLayout() (Table 62) */
301 typedef struct {
302   UCHAR baseChannelCount;
303   UCHAR layoutSignalingPresent;
304   UCHAR definedLayout;
305   UCHAR speakerPosition[8];
306 } CHANNEL_LAYOUT;
307 
308 /* downmixInstructions() (Table 63) */
309 typedef struct {
310   UCHAR downmixId;
311   UCHAR targetChannelCount;
312   UCHAR targetLayout;
313   UCHAR downmixCoefficientsPresent;
314   UCHAR bsDownmixOffset;
315   FIXP_DBL downmixCoefficient[8 * 8]; /* e = 2 */
316 } DOWNMIX_INSTRUCTIONS;
317 
318 typedef struct {
319   UCHAR uniDrcConfigExtType[8];
320   ULONG extBitSize[8 - 1];
321 } UNI_DRC_CONFIG_EXTENSION;
322 
323 /* uniDrcConfig() (Table 57) */
324 typedef struct {
325   UCHAR sampleRatePresent;
326   ULONG sampleRate;
327   UCHAR downmixInstructionsCountV0;
328   UCHAR downmixInstructionsCountV1;
329   UCHAR downmixInstructionsCount; /* saturated to 6 */
330   UCHAR drcCoefficientsUniDrcCountV0;
331   UCHAR drcCoefficientsUniDrcCountV1;
332   UCHAR drcCoefficientsUniDrcCount; /* saturated to 2 */
333   UCHAR drcInstructionsUniDrcCountV0;
334   UCHAR drcInstructionsUniDrcCountV1;
335   UCHAR drcInstructionsUniDrcCount; /* saturated to (12 + 1 + 6) */
336   CHANNEL_LAYOUT channelLayout;
337   DOWNMIX_INSTRUCTIONS downmixInstructions[6];
338   DRC_COEFFICIENTS_UNI_DRC drcCoefficientsUniDrc[2];
339   DRC_INSTRUCTIONS_UNI_DRC drcInstructionsUniDrc[(12 + 1 + 6)];
340   UCHAR uniDrcConfigExtPresent;
341   UNI_DRC_CONFIG_EXTENSION uniDrcConfigExt;
342 
343   /* derived data */
344   UCHAR drcInstructionsCountInclVirtual;
345   UCHAR diff;
346 } UNI_DRC_CONFIG, *HANDLE_UNI_DRC_CONFIG;
347 
348 /*******************/
349 /* loudnessInfoSet */
350 /*******************/
351 
352 typedef enum {
353   MD_UNKNOWN_OTHER = 0,
354   MD_PROGRAM_LOUDNESS = 1,
355   MD_ANCHOR_LOUDNESS = 2,
356   MD_MAX_OF_LOUDNESS_RANGE = 3,
357   MD_MOMENTARY_LOUDNESS_MAX = 4,
358   MD_SHORT_TERM_LOUDNESS_MAX = 5,
359   MD_LOUDNESS_RANGE = 6,
360   MD_MIXING_LEVEL = 7,
361   MD_ROOM_TYPE = 8,
362   MD_SHORT_TERM_LOUDNESS = 9
363 } METHOD_DEFINITION;
364 
365 typedef enum {
366   MS_UNKNOWN_OTHER = 0,
367   MS_EBU_R_128 = 1,
368   MS_BS_1770_4 = 2,
369   MS_BS_1770_4_PRE_PROCESSING = 3,
370   MS_USER = 4,
371   MS_EXPERT_PANEL = 5,
372   MS_BS_1771_1 = 6,
373   MS_RESERVED_A = 7,
374   MS_RESERVED_B = 8,
375   MS_RESERVED_C = 9,
376   MS_RESERVED_D = 10,
377   MS_RESERVED_E = 11
378 } MEASUREMENT_SYSTEM;
379 
380 typedef enum {
381   R_UKNOWN = 0,
382   R_UNVERIFIED = 1,
383   R_CEILING = 2,
384   R_ACCURATE = 3
385 } RELIABILITY;
386 
387 typedef struct {
388   UCHAR methodDefinition;
389   FIXP_DBL methodValue; /* e = 7 for all methodDefinitions */
390   UCHAR measurementSystem;
391   UCHAR reliability;
392 } LOUDNESS_MEASUREMENT;
393 
394 /* loudnessInfo() (Table 59) */
395 typedef struct {
396   SCHAR drcSetId;
397   UCHAR eqSetId;
398   UCHAR downmixId;
399   UCHAR samplePeakLevelPresent;
400   FIXP_DBL samplePeakLevel; /* e = 7 */
401   UCHAR truePeakLevelPresent;
402   FIXP_DBL truePeakLevel; /* e = 7 */
403   UCHAR truePeakLevelMeasurementSystem;
404   UCHAR truePeakLevelReliability;
405   UCHAR measurementCount; /* saturated to 8 */
406   LOUDNESS_MEASUREMENT loudnessMeasurement[8];
407 } LOUDNESS_INFO;
408 
409 /* loudnessInfoSetExtension() (Table 61) */
410 typedef struct {
411   UCHAR loudnessInfoSetExtType[8];
412   ULONG extBitSize[8 - 1];
413 } LOUDNESS_INFO_SET_EXTENSION;
414 
415 /* loudnessInfoSet() (Table 58) */
416 typedef struct {
417   UCHAR loudnessInfoAlbumCountV0;
418   UCHAR loudnessInfoAlbumCountV1;
419   UCHAR loudnessInfoAlbumCount; /* saturated to 12 */
420   UCHAR loudnessInfoCountV0;
421   UCHAR loudnessInfoCountV1;
422   UCHAR loudnessInfoCount; /* saturated to 12 */
423   LOUDNESS_INFO loudnessInfoAlbum[12];
424   LOUDNESS_INFO loudnessInfo[12];
425   UCHAR loudnessInfoSetExtPresent;
426   LOUDNESS_INFO_SET_EXTENSION loudnessInfoSetExt;
427   /* derived data */
428   UCHAR diff;
429 } LOUDNESS_INFO_SET, *HANDLE_LOUDNESS_INFO_SET;
430 
431 #endif
432