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 /************************* System integration library **************************
96
97 Author(s): Manuel Jander
98
99 Description:
100
101 *******************************************************************************/
102
103 /** \file FDK_audio.h
104 * \brief Global audio struct and constant definitions.
105 */
106
107 #ifndef FDK_AUDIO_H
108 #define FDK_AUDIO_H
109
110 #include "machine_type.h"
111 #include "genericStds.h"
112 #include "syslib_channelMapDescr.h"
113
114 #ifdef __cplusplus
115 extern "C" {
116 #endif
117
118 /**
119 * File format identifiers.
120 */
121 typedef enum {
122 FF_UNKNOWN = -1, /**< Unknown format. */
123 FF_RAW = 0, /**< No container, bit stream data conveyed "as is". */
124
125 FF_MP4_3GPP = 3, /**< 3GPP file format. */
126 FF_MP4_MP4F = 4, /**< MPEG-4 File format. */
127
128 FF_RAWPACKETS = 5 /**< Proprietary raw packet file. */
129
130 } FILE_FORMAT;
131
132 /**
133 * Transport type identifiers.
134 */
135 typedef enum {
136 TT_UNKNOWN = -1, /**< Unknown format. */
137 TT_MP4_RAW = 0, /**< "as is" access units (packet based since there is
138 obviously no sync layer) */
139 TT_MP4_ADIF = 1, /**< ADIF bitstream format. */
140 TT_MP4_ADTS = 2, /**< ADTS bitstream format. */
141
142 TT_MP4_LATM_MCP1 = 6, /**< Audio Mux Elements with muxConfigPresent = 1 */
143 TT_MP4_LATM_MCP0 = 7, /**< Audio Mux Elements with muxConfigPresent = 0, out
144 of band StreamMuxConfig */
145
146 TT_MP4_LOAS = 10, /**< Audio Sync Stream. */
147
148 TT_DRM = 12 /**< Digital Radio Mondial (DRM30/DRM+) bitstream format. */
149
150 } TRANSPORT_TYPE;
151
152 #define TT_IS_PACKET(x) \
153 (((x) == TT_MP4_RAW) || ((x) == TT_DRM) || ((x) == TT_MP4_LATM_MCP0) || \
154 ((x) == TT_MP4_LATM_MCP1))
155
156 /**
157 * Audio Object Type definitions.
158 */
159 typedef enum {
160 AOT_NONE = -1,
161 AOT_NULL_OBJECT = 0,
162 AOT_AAC_MAIN = 1, /**< Main profile */
163 AOT_AAC_LC = 2, /**< Low Complexity object */
164 AOT_AAC_SSR = 3,
165 AOT_AAC_LTP = 4,
166 AOT_SBR = 5,
167 AOT_AAC_SCAL = 6,
168 AOT_TWIN_VQ = 7,
169 AOT_CELP = 8,
170 AOT_HVXC = 9,
171 AOT_RSVD_10 = 10, /**< (reserved) */
172 AOT_RSVD_11 = 11, /**< (reserved) */
173 AOT_TTSI = 12, /**< TTSI Object */
174 AOT_MAIN_SYNTH = 13, /**< Main Synthetic object */
175 AOT_WAV_TAB_SYNTH = 14, /**< Wavetable Synthesis object */
176 AOT_GEN_MIDI = 15, /**< General MIDI object */
177 AOT_ALG_SYNTH_AUD_FX = 16, /**< Algorithmic Synthesis and Audio FX object */
178 AOT_ER_AAC_LC = 17, /**< Error Resilient(ER) AAC Low Complexity */
179 AOT_RSVD_18 = 18, /**< (reserved) */
180 AOT_ER_AAC_LTP = 19, /**< Error Resilient(ER) AAC LTP object */
181 AOT_ER_AAC_SCAL = 20, /**< Error Resilient(ER) AAC Scalable object */
182 AOT_ER_TWIN_VQ = 21, /**< Error Resilient(ER) TwinVQ object */
183 AOT_ER_BSAC = 22, /**< Error Resilient(ER) BSAC object */
184 AOT_ER_AAC_LD = 23, /**< Error Resilient(ER) AAC LowDelay object */
185 AOT_ER_CELP = 24, /**< Error Resilient(ER) CELP object */
186 AOT_ER_HVXC = 25, /**< Error Resilient(ER) HVXC object */
187 AOT_ER_HILN = 26, /**< Error Resilient(ER) HILN object */
188 AOT_ER_PARA = 27, /**< Error Resilient(ER) Parametric object */
189 AOT_RSVD_28 = 28, /**< might become SSC */
190 AOT_PS = 29, /**< PS, Parametric Stereo (includes SBR) */
191 AOT_MPEGS = 30, /**< MPEG Surround */
192
193 AOT_ESCAPE = 31, /**< Signal AOT uses more than 5 bits */
194
195 AOT_MP3ONMP4_L1 = 32, /**< MPEG-Layer1 in mp4 */
196 AOT_MP3ONMP4_L2 = 33, /**< MPEG-Layer2 in mp4 */
197 AOT_MP3ONMP4_L3 = 34, /**< MPEG-Layer3 in mp4 */
198 AOT_RSVD_35 = 35, /**< might become DST */
199 AOT_RSVD_36 = 36, /**< might become ALS */
200 AOT_AAC_SLS = 37, /**< AAC + SLS */
201 AOT_SLS = 38, /**< SLS */
202 AOT_ER_AAC_ELD = 39, /**< AAC Enhanced Low Delay */
203
204 AOT_USAC = 42, /**< USAC */
205 AOT_SAOC = 43, /**< SAOC */
206 AOT_LD_MPEGS = 44, /**< Low Delay MPEG Surround */
207
208 /* Pseudo AOTs */
209 AOT_MP2_AAC_LC = 129, /**< Virtual AOT MP2 Low Complexity profile */
210 AOT_MP2_SBR = 132, /**< Virtual AOT MP2 Low Complexity Profile with SBR */
211
212 AOT_DRM_AAC = 143, /**< Virtual AOT for DRM (ER-AAC-SCAL without SBR) */
213 AOT_DRM_SBR = 144, /**< Virtual AOT for DRM (ER-AAC-SCAL with SBR) */
214 AOT_DRM_MPEG_PS =
215 145, /**< Virtual AOT for DRM (ER-AAC-SCAL with SBR and MPEG-PS) */
216 AOT_DRM_SURROUND =
217 146, /**< Virtual AOT for DRM Surround (ER-AAC-SCAL (+SBR) +MPS) */
218 AOT_DRM_USAC = 147 /**< Virtual AOT for DRM with USAC */
219
220 } AUDIO_OBJECT_TYPE;
221
222 #define CAN_DO_PS(aot) \
223 ((aot) == AOT_AAC_LC || (aot) == AOT_SBR || (aot) == AOT_PS || \
224 (aot) == AOT_ER_BSAC || (aot) == AOT_DRM_AAC)
225
226 #define IS_USAC(aot) ((aot) == AOT_USAC)
227
228 #define IS_LOWDELAY(aot) ((aot) == AOT_ER_AAC_LD || (aot) == AOT_ER_AAC_ELD)
229
230 /** Channel Mode ( 1-7 equals MPEG channel configurations, others are
231 * arbitrary). */
232 typedef enum {
233 MODE_INVALID = -1,
234 MODE_UNKNOWN = 0,
235 MODE_1 = 1, /**< C */
236 MODE_2 = 2, /**< L+R */
237 MODE_1_2 = 3, /**< C, L+R */
238 MODE_1_2_1 = 4, /**< C, L+R, Rear */
239 MODE_1_2_2 = 5, /**< C, L+R, LS+RS */
240 MODE_1_2_2_1 = 6, /**< C, L+R, LS+RS, LFE */
241 MODE_1_2_2_2_1 = 7, /**< C, LC+RC, L+R, LS+RS, LFE */
242
243 MODE_6_1 = 11, /**< C, L+R, LS+RS, Crear, LFE */
244 MODE_7_1_BACK = 12, /**< C, L+R, LS+RS, Lrear+Rrear, LFE */
245 MODE_7_1_TOP_FRONT = 14, /**< C, L+R, LS+RS, LFE, Ltop+Rtop */
246
247 MODE_7_1_REAR_SURROUND = 33, /**< C, L+R, LS+RS, Lrear+Rrear, LFE */
248 MODE_7_1_FRONT_CENTER = 34, /**< C, LC+RC, L+R, LS+RS, LFE */
249
250 MODE_212 = 128 /**< 212 configuration, used in ELDv2 */
251
252 } CHANNEL_MODE;
253
254 /**
255 * Speaker description tags.
256 * Do not change the enumeration values unless it keeps the following
257 * segmentation:
258 * - Bit 0-3: Horizontal postion (0: none, 1: front, 2: side, 3: back, 4: lfe)
259 * - Bit 4-7: Vertical position (0: normal, 1: top, 2: bottom)
260 */
261 typedef enum {
262 ACT_NONE = 0x00,
263 ACT_FRONT = 0x01, /*!< Front speaker position (at normal height) */
264 ACT_SIDE = 0x02, /*!< Side speaker position (at normal height) */
265 ACT_BACK = 0x03, /*!< Back speaker position (at normal height) */
266 ACT_LFE = 0x04, /*!< Low frequency effect speaker postion (front) */
267
268 ACT_TOP =
269 0x10, /*!< Top speaker area (for combination with speaker positions) */
270 ACT_FRONT_TOP = 0x11, /*!< Top front speaker = (ACT_FRONT|ACT_TOP) */
271 ACT_SIDE_TOP = 0x12, /*!< Top side speaker = (ACT_SIDE |ACT_TOP) */
272 ACT_BACK_TOP = 0x13, /*!< Top back speaker = (ACT_BACK |ACT_TOP) */
273
274 ACT_BOTTOM =
275 0x20, /*!< Bottom speaker area (for combination with speaker positions) */
276 ACT_FRONT_BOTTOM = 0x21, /*!< Bottom front speaker = (ACT_FRONT|ACT_BOTTOM) */
277 ACT_SIDE_BOTTOM = 0x22, /*!< Bottom side speaker = (ACT_SIDE |ACT_BOTTOM) */
278 ACT_BACK_BOTTOM = 0x23 /*!< Bottom back speaker = (ACT_BACK |ACT_BOTTOM) */
279
280 } AUDIO_CHANNEL_TYPE;
281
282 typedef enum {
283 SIG_UNKNOWN = -1,
284 SIG_IMPLICIT = 0,
285 SIG_EXPLICIT_BW_COMPATIBLE = 1,
286 SIG_EXPLICIT_HIERARCHICAL = 2
287
288 } SBR_PS_SIGNALING;
289
290 /**
291 * Audio Codec flags.
292 */
293 #define AC_ER_VCB11 \
294 0x000001 /*!< aacSectionDataResilienceFlag flag (from ASC): 1 means use \
295 virtual codebooks */
296 #define AC_ER_RVLC \
297 0x000002 /*!< aacSpectralDataResilienceFlag flag (from ASC): 1 means use \
298 huffman codeword reordering */
299 #define AC_ER_HCR \
300 0x000004 /*!< aacSectionDataResilienceFlag flag (from ASC): 1 means use \
301 virtual codebooks */
302 #define AC_SCALABLE 0x000008 /*!< AAC Scalable*/
303 #define AC_ELD 0x000010 /*!< AAC-ELD */
304 #define AC_LD 0x000020 /*!< AAC-LD */
305 #define AC_ER 0x000040 /*!< ER syntax */
306 #define AC_BSAC 0x000080 /*!< BSAC */
307 #define AC_USAC 0x000100 /*!< USAC */
308 #define AC_RSV603DA 0x000200 /*!< RSVD60 3D audio */
309 #define AC_HDAAC 0x000400 /*!< HD-AAC */
310 #define AC_RSVD50 0x004000 /*!< Rsvd50 */
311 #define AC_SBR_PRESENT 0x008000 /*!< SBR present flag (from ASC) */
312 #define AC_SBRCRC \
313 0x010000 /*!< SBR CRC present flag. Only relevant for AAC-ELD for now. */
314 #define AC_PS_PRESENT 0x020000 /*!< PS present flag (from ASC or implicit) */
315 #define AC_MPS_PRESENT \
316 0x040000 /*!< MPS present flag (from ASC or implicit) \
317 */
318 #define AC_DRM 0x080000 /*!< DRM bit stream syntax */
319 #define AC_INDEP 0x100000 /*!< Independency flag */
320 #define AC_MPEGD_RES 0x200000 /*!< MPEG-D residual individual channel data. */
321 #define AC_SAOC_PRESENT 0x400000 /*!< SAOC Present Flag */
322 #define AC_DAB 0x800000 /*!< DAB bit stream syntax */
323 #define AC_ELD_DOWNSCALE 0x1000000 /*!< ELD Downscaled playout */
324 #define AC_LD_MPS 0x2000000 /*!< Low Delay MPS. */
325 #define AC_DRC_PRESENT \
326 0x4000000 /*!< Dynamic Range Control (DRC) data found. \
327 */
328 #define AC_USAC_SCFGI3 \
329 0x8000000 /*!< USAC flag: If stereoConfigIndex is 3 the flag is set. */
330 /**
331 * Audio Codec flags (reconfiguration).
332 */
333 #define AC_CM_DET_CFG_CHANGE \
334 0x000001 /*!< Config mode signalizes the callback to work in config change \
335 detection mode */
336 #define AC_CM_ALLOC_MEM \
337 0x000002 /*!< Config mode signalizes the callback to work in memory \
338 allocation mode */
339
340 /**
341 * Audio Codec flags (element specific).
342 */
343 #define AC_EL_USAC_TW 0x000001 /*!< USAC time warped filter bank is active */
344 #define AC_EL_USAC_NOISE 0x000002 /*!< USAC noise filling is active */
345 #define AC_EL_USAC_ITES 0x000004 /*!< USAC SBR inter-TES tool is active */
346 #define AC_EL_USAC_PVC \
347 0x000008 /*!< USAC SBR predictive vector coding tool is active */
348 #define AC_EL_USAC_MPS212 0x000010 /*!< USAC MPS212 tool is active */
349 #define AC_EL_USAC_LFE 0x000020 /*!< USAC element is LFE */
350 #define AC_EL_USAC_CP_POSSIBLE \
351 0x000040 /*!< USAC may use Complex Stereo Prediction in this channel element \
352 */
353 #define AC_EL_ENHANCED_NOISE 0x000080 /*!< Enhanced noise filling*/
354 #define AC_EL_IGF_AFTER_TNS 0x000100 /*!< IGF after TNS */
355 #define AC_EL_IGF_INDEP_TILING 0x000200 /*!< IGF independent tiling */
356 #define AC_EL_IGF_USE_ENF 0x000400 /*!< IGF use enhanced noise filling */
357 #define AC_EL_FULLBANDLPD 0x000800 /*!< enable fullband LPD tools */
358 #define AC_EL_LPDSTEREOIDX 0x001000 /*!< LPD-stereo-tool stereo index */
359 #define AC_EL_LFE 0x002000 /*!< The element is of type LFE. */
360
361 /* CODER_CONFIG::flags */
362 #define CC_MPEG_ID 0x00100000
363 #define CC_IS_BASELAYER 0x00200000
364 #define CC_PROTECTION 0x00400000
365 #define CC_SBR 0x00800000
366 #define CC_SBRCRC 0x00010000
367 #define CC_SAC 0x00020000
368 #define CC_RVLC 0x01000000
369 #define CC_VCB11 0x02000000
370 #define CC_HCR 0x04000000
371 #define CC_PSEUDO_SURROUND 0x08000000
372 #define CC_USAC_NOISE 0x10000000
373 #define CC_USAC_TW 0x20000000
374 #define CC_USAC_HBE 0x40000000
375
376 /** Generic audio coder configuration structure. */
377 typedef struct {
378 AUDIO_OBJECT_TYPE aot; /**< Audio Object Type (AOT). */
379 AUDIO_OBJECT_TYPE extAOT; /**< Extension Audio Object Type (SBR). */
380 CHANNEL_MODE channelMode; /**< Channel mode. */
381 UCHAR channelConfigZero; /**< Use channel config zero + pce although a
382 standard channel config could be signaled. */
383 INT samplingRate; /**< Sampling rate. */
384 INT extSamplingRate; /**< Extended samplerate (SBR). */
385 INT downscaleSamplingRate; /**< Downscale sampling rate (ELD downscaled mode)
386 */
387 INT bitRate; /**< Average bitrate. */
388 int samplesPerFrame; /**< Number of PCM samples per codec frame and audio
389 channel. */
390 int noChannels; /**< Number of audio channels. */
391 int bitsFrame;
392 int nSubFrames; /**< Amount of encoder subframes. 1 means no subframing. */
393 int BSACnumOfSubFrame; /**< The number of the sub-frames which are grouped and
394 transmitted in a super-frame (BSAC). */
395 int BSAClayerLength; /**< The average length of the large-step layers in bytes
396 (BSAC). */
397 UINT flags; /**< flags */
398 UCHAR matrixMixdownA; /**< Matrix mixdown index to put into PCE. Default value
399 0 means no mixdown coefficient, valid values are 1-4
400 which correspond to matrix_mixdown_idx 0-3. */
401 UCHAR headerPeriod; /**< Frame period for sending in band configuration
402 buffers in the transport layer. */
403
404 UCHAR stereoConfigIndex; /**< USAC MPS stereo mode */
405 UCHAR sbrMode; /**< USAC SBR mode */
406 SBR_PS_SIGNALING sbrSignaling; /**< 0: implicit signaling, 1: backwards
407 compatible explicit signaling, 2:
408 hierarcical explicit signaling */
409
410 UCHAR rawConfig[64]; /**< raw codec specific config as bit stream */
411 int rawConfigBits; /**< Size of rawConfig in bits */
412
413 UCHAR sbrPresent;
414 UCHAR psPresent;
415 } CODER_CONFIG;
416
417 #define USAC_ID_BIT 16 /** USAC element IDs start at USAC_ID_BIT */
418
419 /** MP4 Element IDs. */
420 typedef enum {
421 /* mp4 element IDs */
422 ID_NONE = -1, /**< Invalid Element helper ID. */
423 ID_SCE = 0, /**< Single Channel Element. */
424 ID_CPE = 1, /**< Channel Pair Element. */
425 ID_CCE = 2, /**< Coupling Channel Element. */
426 ID_LFE = 3, /**< LFE Channel Element. */
427 ID_DSE = 4, /**< Currently one Data Stream Element for ancillary data is
428 supported. */
429 ID_PCE = 5, /**< Program Config Element. */
430 ID_FIL = 6, /**< Fill Element. */
431 ID_END = 7, /**< Arnie (End Element = Terminator). */
432 ID_EXT = 8, /**< Extension Payload (ER only). */
433 ID_SCAL = 9, /**< AAC scalable element (ER only). */
434 /* USAC element IDs */
435 ID_USAC_SCE = 0 + USAC_ID_BIT, /**< Single Channel Element. */
436 ID_USAC_CPE = 1 + USAC_ID_BIT, /**< Channel Pair Element. */
437 ID_USAC_LFE = 2 + USAC_ID_BIT, /**< LFE Channel Element. */
438 ID_USAC_EXT = 3 + USAC_ID_BIT, /**< Extension Element. */
439 ID_USAC_END = 4 + USAC_ID_BIT, /**< Arnie (End Element = Terminator). */
440 ID_LAST
441 } MP4_ELEMENT_ID;
442
443 /* usacConfigExtType q.v. ISO/IEC DIS 23008-3 Table 52 and ISO/IEC FDIS
444 * 23003-3:2011(E) Table 74*/
445 typedef enum {
446 /* USAC and RSVD60 3DA */
447 ID_CONFIG_EXT_FILL = 0,
448 /* RSVD60 3DA */
449 ID_CONFIG_EXT_DOWNMIX = 1,
450 ID_CONFIG_EXT_LOUDNESS_INFO = 2,
451 ID_CONFIG_EXT_AUDIOSCENE_INFO = 3,
452 ID_CONFIG_EXT_HOA_MATRIX = 4,
453 ID_CONFIG_EXT_SIG_GROUP_INFO = 6
454 /* 5-127 => reserved for ISO use */
455 /* > 128 => reserved for use outside of ISO scope */
456 } CONFIG_EXT_ID;
457
458 #define IS_CHANNEL_ELEMENT(elementId) \
459 ((elementId) == ID_SCE || (elementId) == ID_CPE || (elementId) == ID_LFE || \
460 (elementId) == ID_USAC_SCE || (elementId) == ID_USAC_CPE || \
461 (elementId) == ID_USAC_LFE)
462
463 #define IS_MP4_CHANNEL_ELEMENT(elementId) \
464 ((elementId) == ID_SCE || (elementId) == ID_CPE || (elementId) == ID_LFE)
465
466 #define EXT_ID_BITS 4 /**< Size in bits of extension payload type tags. */
467
468 /** Extension payload types. */
469 typedef enum {
470 EXT_FIL = 0x00,
471 EXT_FILL_DATA = 0x01,
472 EXT_DATA_ELEMENT = 0x02,
473 EXT_DATA_LENGTH = 0x03,
474 EXT_UNI_DRC = 0x04,
475 EXT_LDSAC_DATA = 0x09,
476 EXT_SAOC_DATA = 0x0a,
477 EXT_DYNAMIC_RANGE = 0x0b,
478 EXT_SAC_DATA = 0x0c,
479 EXT_SBR_DATA = 0x0d,
480 EXT_SBR_DATA_CRC = 0x0e
481 } EXT_PAYLOAD_TYPE;
482
483 #define IS_USAC_CHANNEL_ELEMENT(elementId) \
484 ((elementId) == ID_USAC_SCE || (elementId) == ID_USAC_CPE || \
485 (elementId) == ID_USAC_LFE)
486
487 /** MPEG-D USAC & RSVD60 3D audio Extension Element Types. */
488 typedef enum {
489 /* usac */
490 ID_EXT_ELE_FILL = 0x00,
491 ID_EXT_ELE_MPEGS = 0x01,
492 ID_EXT_ELE_SAOC = 0x02,
493 ID_EXT_ELE_AUDIOPREROLL = 0x03,
494 ID_EXT_ELE_UNI_DRC = 0x04,
495 /* rsv603da */
496 ID_EXT_ELE_OBJ_METADATA = 0x05,
497 ID_EXT_ELE_SAOC_3D = 0x06,
498 ID_EXT_ELE_HOA = 0x07,
499 ID_EXT_ELE_FMT_CNVRTR = 0x08,
500 ID_EXT_ELE_MCT = 0x09,
501 ID_EXT_ELE_ENHANCED_OBJ_METADATA = 0x0d,
502 /* reserved for use outside of ISO scope */
503 ID_EXT_ELE_VR_METADATA = 0x81,
504 ID_EXT_ELE_UNKNOWN = 0xFF
505 } USAC_EXT_ELEMENT_TYPE;
506
507 /**
508 * Proprietary raw packet file configuration data type identifier.
509 */
510 typedef enum {
511 TC_NOTHING = 0, /* No configuration available -> in-band configuration. */
512 TC_RAW_ADTS = 2, /* Transfer type is ADTS. */
513 TC_RAW_LATM_MCP1 = 6, /* Transfer type is LATM with SMC present. */
514 TC_RAW_SDC = 21 /* Configuration data field is Drm SDC. */
515
516 } TP_CONFIG_TYPE;
517
518 /*
519 * ##############################################################################################
520 * Library identification and error handling
521 * ##############################################################################################
522 */
523 /* \cond */
524
525 typedef enum {
526 FDK_NONE = 0,
527 FDK_TOOLS = 1,
528 FDK_SYSLIB = 2,
529 FDK_AACDEC = 3,
530 FDK_AACENC = 4,
531 FDK_SBRDEC = 5,
532 FDK_SBRENC = 6,
533 FDK_TPDEC = 7,
534 FDK_TPENC = 8,
535 FDK_MPSDEC = 9,
536 FDK_MPEGFILEREAD = 10,
537 FDK_MPEGFILEWRITE = 11,
538 FDK_PCMDMX = 31,
539 FDK_MPSENC = 34,
540 FDK_TDLIMIT = 35,
541 FDK_UNIDRCDEC = 38,
542
543 FDK_MODULE_LAST
544
545 } FDK_MODULE_ID;
546
547 /* AAC capability flags */
548 #define CAPF_AAC_LC 0x00000001 /**< Support flag for AAC Low Complexity. */
549 #define CAPF_ER_AAC_LD \
550 0x00000002 /**< Support flag for AAC Low Delay with Error Resilience tools. \
551 */
552 #define CAPF_ER_AAC_SCAL 0x00000004 /**< Support flag for AAC Scalable. */
553 #define CAPF_ER_AAC_LC \
554 0x00000008 /**< Support flag for AAC Low Complexity with Error Resilience \
555 tools. */
556 #define CAPF_AAC_480 \
557 0x00000010 /**< Support flag for AAC with 480 framelength. */
558 #define CAPF_AAC_512 \
559 0x00000020 /**< Support flag for AAC with 512 framelength. */
560 #define CAPF_AAC_960 \
561 0x00000040 /**< Support flag for AAC with 960 framelength. */
562 #define CAPF_AAC_1024 \
563 0x00000080 /**< Support flag for AAC with 1024 framelength. */
564 #define CAPF_AAC_HCR \
565 0x00000100 /**< Support flag for AAC with Huffman Codeword Reordering. */
566 #define CAPF_AAC_VCB11 \
567 0x00000200 /**< Support flag for AAC Virtual Codebook 11. */
568 #define CAPF_AAC_RVLC \
569 0x00000400 /**< Support flag for AAC Reversible Variable Length Coding. */
570 #define CAPF_AAC_MPEG4 0x00000800 /**< Support flag for MPEG file format. */
571 #define CAPF_AAC_DRC \
572 0x00001000 /**< Support flag for AAC Dynamic Range Control. */
573 #define CAPF_AAC_CONCEALMENT \
574 0x00002000 /**< Support flag for AAC concealment. */
575 #define CAPF_AAC_DRM_BSFORMAT \
576 0x00004000 /**< Support flag for AAC DRM bistream format. */
577 #define CAPF_ER_AAC_ELD \
578 0x00008000 /**< Support flag for AAC Enhanced Low Delay with Error \
579 Resilience tools. */
580 #define CAPF_ER_AAC_BSAC \
581 0x00010000 /**< Support flag for AAC BSAC. */
582 #define CAPF_AAC_ELD_DOWNSCALE \
583 0x00040000 /**< Support flag for AAC-ELD Downscaling */
584 #define CAPF_AAC_USAC_LP \
585 0x00100000 /**< Support flag for USAC low power mode. */
586 #define CAPF_AAC_USAC \
587 0x00200000 /**< Support flag for Unified Speech and Audio Coding (USAC). */
588 #define CAPF_ER_AAC_ELDV2 \
589 0x00800000 /**< Support flag for AAC Enhanced Low Delay with MPS 212. */
590 #define CAPF_AAC_UNIDRC \
591 0x01000000 /**< Support flag for MPEG-D Dynamic Range Control (uniDrc). */
592
593 /* Transport capability flags */
594 #define CAPF_ADTS \
595 0x00000001 /**< Support flag for ADTS transport format. */
596 #define CAPF_ADIF \
597 0x00000002 /**< Support flag for ADIF transport format. */
598 #define CAPF_LATM \
599 0x00000004 /**< Support flag for LATM transport format. */
600 #define CAPF_LOAS \
601 0x00000008 /**< Support flag for LOAS transport format. */
602 #define CAPF_RAWPACKETS \
603 0x00000010 /**< Support flag for RAW PACKETS transport format. */
604 #define CAPF_DRM \
605 0x00000020 /**< Support flag for DRM/DRM+ transport format. */
606 #define CAPF_RSVD50 \
607 0x00000040 /**< Support flag for RSVD50 transport format */
608
609 /* SBR capability flags */
610 #define CAPF_SBR_LP \
611 0x00000001 /**< Support flag for SBR Low Power mode. */
612 #define CAPF_SBR_HQ \
613 0x00000002 /**< Support flag for SBR High Quality mode. */
614 #define CAPF_SBR_DRM_BS \
615 0x00000004 /**< Support flag for */
616 #define CAPF_SBR_CONCEALMENT \
617 0x00000008 /**< Support flag for SBR concealment. */
618 #define CAPF_SBR_DRC \
619 0x00000010 /**< Support flag for SBR Dynamic Range Control. */
620 #define CAPF_SBR_PS_MPEG \
621 0x00000020 /**< Support flag for MPEG Parametric Stereo. */
622 #define CAPF_SBR_PS_DRM \
623 0x00000040 /**< Support flag for DRM Parametric Stereo. */
624 #define CAPF_SBR_ELD_DOWNSCALE \
625 0x00000080 /**< Support flag for ELD reduced delay mode */
626 #define CAPF_SBR_HBEHQ \
627 0x00000100 /**< Support flag for HQ HBE */
628
629 /* PCM utils capability flags */
630 #define CAPF_DMX_BLIND \
631 0x00000001 /**< Support flag for blind downmixing. */
632 #define CAPF_DMX_PCE \
633 0x00000002 /**< Support flag for guided downmix with data from MPEG-2/4 \
634 Program Config Elements (PCE). */
635 #define CAPF_DMX_ARIB \
636 0x00000004 /**< Support flag for PCE guided downmix with slightly different \
637 equations and levels to fulfill ARIB standard. */
638 #define CAPF_DMX_DVB \
639 0x00000008 /**< Support flag for guided downmix with data from DVB ancillary \
640 data fields. */
641 #define CAPF_DMX_CH_EXP \
642 0x00000010 /**< Support flag for simple upmixing by dublicating channels or \
643 adding zero channels. */
644 #define CAPF_DMX_6_CH \
645 0x00000020 /**< Support flag for 5.1 channel configuration (input and \
646 output). */
647 #define CAPF_DMX_8_CH \
648 0x00000040 /**< Support flag for 6 and 7.1 channel configurations (input and \
649 output). */
650 #define CAPF_DMX_24_CH \
651 0x00000080 /**< Support flag for 22.2 channel configuration (input and \
652 output). */
653 #define CAPF_LIMITER \
654 0x00002000 /**< Support flag for signal level limiting. \
655 */
656
657 /* MPEG Surround capability flags */
658 #define CAPF_MPS_STD \
659 0x00000001 /**< Support flag for MPEG Surround. */
660 #define CAPF_MPS_LD \
661 0x00000002 /**< Support flag for Low Delay MPEG Surround. \
662 */
663 #define CAPF_MPS_USAC \
664 0x00000004 /**< Support flag for USAC MPEG Surround. */
665 #define CAPF_MPS_HQ \
666 0x00000010 /**< Support flag indicating if high quality processing is \
667 supported */
668 #define CAPF_MPS_LP \
669 0x00000020 /**< Support flag indicating if partially complex (low power) \
670 processing is supported */
671 #define CAPF_MPS_BLIND \
672 0x00000040 /**< Support flag indicating if blind processing is supported */
673 #define CAPF_MPS_BINAURAL \
674 0x00000080 /**< Support flag indicating if binaural output is possible */
675 #define CAPF_MPS_2CH_OUT \
676 0x00000100 /**< Support flag indicating if 2ch output is possible */
677 #define CAPF_MPS_6CH_OUT \
678 0x00000200 /**< Support flag indicating if 6ch output is possible */
679 #define CAPF_MPS_8CH_OUT \
680 0x00000400 /**< Support flag indicating if 8ch output is possible */
681 #define CAPF_MPS_1CH_IN \
682 0x00001000 /**< Support flag indicating if 1ch dmx input is possible */
683 #define CAPF_MPS_2CH_IN \
684 0x00002000 /**< Support flag indicating if 2ch dmx input is possible */
685 #define CAPF_MPS_6CH_IN \
686 0x00004000 /**< Support flag indicating if 5ch dmx input is possible */
687
688 /* \endcond */
689
690 /*
691 * ##############################################################################################
692 * Library versioning
693 * ##############################################################################################
694 */
695
696 /**
697 * Convert each member of version numbers to one single numeric version
698 * representation.
699 * \param lev0 1st level of version number.
700 * \param lev1 2nd level of version number.
701 * \param lev2 3rd level of version number.
702 */
703 #define LIB_VERSION(lev0, lev1, lev2) \
704 ((lev0 << 24 & 0xff000000) | (lev1 << 16 & 0x00ff0000) | \
705 (lev2 << 8 & 0x0000ff00))
706
707 /**
708 * Build text string of version.
709 */
710 #define LIB_VERSION_STRING(info) \
711 FDKsprintf((info)->versionStr, "%d.%d.%d", (((info)->version >> 24) & 0xff), \
712 (((info)->version >> 16) & 0xff), \
713 (((info)->version >> 8) & 0xff))
714
715 /**
716 * Library information.
717 */
718 typedef struct LIB_INFO {
719 const char* title;
720 const char* build_date;
721 const char* build_time;
722 FDK_MODULE_ID module_id;
723 INT version;
724 UINT flags;
725 char versionStr[32];
726 } LIB_INFO;
727
728 #ifdef __cplusplus
729 #define FDK_AUDIO_INLINE inline
730 #else
731 #define FDK_AUDIO_INLINE
732 #endif
733
734 /** Initialize library info. */
FDKinitLibInfo(LIB_INFO * info)735 static FDK_AUDIO_INLINE void FDKinitLibInfo(LIB_INFO* info) {
736 int i;
737
738 for (i = 0; i < FDK_MODULE_LAST; i++) {
739 info[i].module_id = FDK_NONE;
740 }
741 }
742
743 /** Aquire supported features of library. */
744 static FDK_AUDIO_INLINE UINT
FDKlibInfo_getCapabilities(const LIB_INFO * info,FDK_MODULE_ID module_id)745 FDKlibInfo_getCapabilities(const LIB_INFO* info, FDK_MODULE_ID module_id) {
746 int i;
747
748 for (i = 0; i < FDK_MODULE_LAST; i++) {
749 if (info[i].module_id == module_id) {
750 return info[i].flags;
751 }
752 }
753 return 0;
754 }
755
756 /** Search for next free tab. */
FDKlibInfo_lookup(const LIB_INFO * info,FDK_MODULE_ID module_id)757 static FDK_AUDIO_INLINE INT FDKlibInfo_lookup(const LIB_INFO* info,
758 FDK_MODULE_ID module_id) {
759 int i = -1;
760
761 for (i = 0; i < FDK_MODULE_LAST; i++) {
762 if (info[i].module_id == module_id) return -1;
763 if (info[i].module_id == FDK_NONE) break;
764 }
765 if (i == FDK_MODULE_LAST) return -1;
766
767 return i;
768 }
769
770 /*
771 * ##############################################################################################
772 * Buffer description
773 * ##############################################################################################
774 */
775
776 /**
777 * I/O buffer descriptor.
778 */
779 typedef struct FDK_bufDescr {
780 void** ppBase; /*!< Pointer to an array containing buffer base addresses.
781 Set to NULL for buffer requirement info. */
782 UINT* pBufSize; /*!< Pointer to an array containing the number of elements
783 that can be placed in the specific buffer. */
784 UINT* pEleSize; /*!< Pointer to an array containing the element size for each
785 buffer in bytes. That is mostly the number returned by the
786 sizeof() operator for the data type used for the specific
787 buffer. */
788 UINT*
789 pBufType; /*!< Pointer to an array of bit fields containing a description
790 for each buffer. See XXX below for more details. */
791 UINT numBufs; /*!< Total number of buffers. */
792
793 } FDK_bufDescr;
794
795 /**
796 * Buffer type description field.
797 */
798 #define FDK_BUF_TYPE_MASK_IO ((UINT)0x03 << 30)
799 #define FDK_BUF_TYPE_MASK_DESCR ((UINT)0x3F << 16)
800 #define FDK_BUF_TYPE_MASK_ID ((UINT)0xFF)
801
802 #define FDK_BUF_TYPE_INPUT ((UINT)0x1 << 30)
803 #define FDK_BUF_TYPE_OUTPUT ((UINT)0x2 << 30)
804
805 #define FDK_BUF_TYPE_PCM_DATA ((UINT)0x1 << 16)
806 #define FDK_BUF_TYPE_ANC_DATA ((UINT)0x2 << 16)
807 #define FDK_BUF_TYPE_BS_DATA ((UINT)0x4 << 16)
808
809 #ifdef __cplusplus
810 }
811 #endif
812
813 #endif /* FDK_AUDIO_H */
814