2 /* -----------------------------------------------------------------------------------------------------------
3 Software License for The Fraunhofer FDK AAC Codec Library for Android
5 © Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
9 The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
10 the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
11 This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
13 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual
14 audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by
15 independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part
16 of the MPEG specifications.
18 Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer)
19 may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners
20 individually for the purpose of encoding or decoding bit streams in products that are compliant with
21 the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license
22 these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec
23 software may already be covered under those patent licenses when it is used for those licensed purposes only.
25 Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality,
26 are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional
27 applications information and documentation.
31 Redistribution and use in source and binary forms, with or without modification, are permitted without
32 payment of copyright license fees provided that you satisfy the following conditions:
34 You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
35 your modifications thereto in source code form.
37 You must retain the complete text of this software license in the documentation and/or other materials
38 provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
39 You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
40 modifications thereto to recipients of copies in binary form.
42 The name of Fraunhofer may not be used to endorse or promote products derived from this library without
43 prior written permission.
45 You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
46 software or your modifications thereto.
48 Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
49 and the date of any change. For modified versions of the FDK AAC Codec, the term
50 "Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
51 "Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
55 NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
56 ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
57 respect to this software.
59 You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
60 by appropriate patent licenses.
64 This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
65 "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
66 of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
67 CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
68 including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
69 or business interruption, however caused and on any theory of liability, whether in contract, strict
70 liability, or tort (including negligence), arising in any way out of the use of this software, even if
71 advised of the possibility of such damage.
73 5. CONTACT INFORMATION
75 Fraunhofer Institute for Integrated Circuits IIS
76 Attention: Audio and Multimedia Departments - FDK AAC LL
78 91058 Erlangen, Germany
80 www.iis.fraunhofer.de/amm
81 amm-info@iis.fraunhofer.de
82 ----------------------------------------------------------------------------------------------------------- */
84 /***************************** MPEG-4 AAC Decoder **************************
86 Author(s): Manuel Jander
87 Description: MPEG Transport data tables
89 ******************************************************************************/
94 #include "machine_type.h"
95 #include "FDK_audio.h"
96 #include "FDK_bitstream.h"
102 /* #define TP_CELP_ENABLE */
103 /* #define TP_HVXC_ENABLE */
104 /* #define TP_SLS_ENABLE */
105 #define TP_ELD_ENABLE
106 /* #define TP_USAC_ENABLE */
107 /* #define TP_RSVD50_ENABLE */
109 #if defined(TP_GA_ENABLE) || defined(TP_SLS_ENABLE)
110 #define TP_PCE_ENABLE /**< Enable full PCE support */
114 * ProgramConfig struct.
116 /* ISO/IEC 14496-3 4.4.1.1 Table 4.2 Program config element */
117 #define PC_FSB_CHANNELS_MAX 16 /* Front/Side/Back channels */
118 #define PC_LFE_CHANNELS_MAX 4
119 #define PC_ASSOCDATA_MAX 8
120 #define PC_CCEL_MAX 16 /* CC elements */
121 #define PC_COMMENTLENGTH 256
126 /* PCE bitstream elements: */
127 UCHAR ElementInstanceTag
;
129 UCHAR SamplingFrequencyIndex
;
130 UCHAR NumFrontChannelElements
;
131 UCHAR NumSideChannelElements
;
132 UCHAR NumBackChannelElements
;
133 UCHAR NumLfeChannelElements
;
134 UCHAR NumAssocDataElements
;
135 UCHAR NumValidCcElements
;
137 UCHAR MonoMixdownPresent
;
138 UCHAR MonoMixdownElementNumber
;
140 UCHAR StereoMixdownPresent
;
141 UCHAR StereoMixdownElementNumber
;
143 UCHAR MatrixMixdownIndexPresent
;
144 UCHAR MatrixMixdownIndex
;
145 UCHAR PseudoSurroundEnable
;
147 UCHAR FrontElementIsCpe
[PC_FSB_CHANNELS_MAX
];
148 UCHAR FrontElementTagSelect
[PC_FSB_CHANNELS_MAX
];
150 UCHAR SideElementIsCpe
[PC_FSB_CHANNELS_MAX
];
151 UCHAR SideElementTagSelect
[PC_FSB_CHANNELS_MAX
];
153 UCHAR BackElementIsCpe
[PC_FSB_CHANNELS_MAX
];
154 UCHAR BackElementTagSelect
[PC_FSB_CHANNELS_MAX
];
156 UCHAR LfeElementTagSelect
[PC_LFE_CHANNELS_MAX
];
158 UCHAR AssocDataElementTagSelect
[PC_ASSOCDATA_MAX
];
160 UCHAR CcElementIsIndSw
[PC_CCEL_MAX
];
161 UCHAR ValidCcElementTagSelect
[PC_CCEL_MAX
];
163 UCHAR CommentFieldBytes
;
164 UCHAR Comment
[PC_COMMENTLENGTH
];
165 #endif /* TP_PCE_ENABLE */
167 /* Helper variables for administration: */
168 UCHAR isValid
; /*!< Flag showing if PCE has been read successfully. */
169 UCHAR NumChannels
; /*!< Amount of audio channels summing all channel elements including LFEs */
170 UCHAR NumEffectiveChannels
; /*!< Amount of audio channels summing only SCEs and CPEs */
183 } TP_ASC_EXTENSION_ID
;
187 * GaSpecificConfig struct
190 UINT m_frameLengthFlag
;
191 UINT m_dependsOnCoreCoder
;
192 UINT m_coreCoderDelay
;
194 UINT m_extensionFlag
;
195 UINT m_extensionFlag3
;
198 UINT m_numOfSubFrame
;
201 } CSGaSpecificConfig
;
202 #endif /* TP_GA_ENABLE */
210 ELDEXT_TERM
= 0x0, /* Termination tag */
211 ELDEXT_SAOC
= 0x1, /* SAOC config */
212 ELDEXT_LDSAC
= 0x2 /* LD MPEG Surround config */
217 UCHAR m_frameLengthFlag
;
219 UCHAR m_sbrPresentFlag
;
220 UCHAR m_useLdQmfTimeAlign
; /* Use LD-MPS QMF in SBR to achive time alignment */
221 UCHAR m_sbrSamplingRate
;
224 } CSEldSpecificConfig
;
225 #endif /* TP_ELD_ENABLE */
231 * Audio configuration struct, suitable for encoder and decoder configuration.
235 /* XYZ Specific Data */
238 CSGaSpecificConfig m_gaSpecificConfig
; /**< General audio specific configuration. */
239 #endif /* TP_GA_ENABLE */
241 CSEldSpecificConfig m_eldSpecificConfig
; /**< ELD specific configuration. */
242 #endif /* TP_ELD_ENABLE */
245 /* Common ASC parameters */
247 CProgramConfig m_progrConfigElement
; /**< Program configuration. */
248 #endif /* TP_PCE_ENABLE */
250 AUDIO_OBJECT_TYPE m_aot
; /**< Audio Object Type. */
251 UINT m_samplingFrequency
; /**< Samplerate. */
252 UINT m_samplesPerFrame
; /**< Amount of samples per frame. */
253 UINT m_directMapping
; /**< Document this please !! */
255 AUDIO_OBJECT_TYPE m_extensionAudioObjectType
; /**< Audio object type */
256 UINT m_extensionSamplingFrequency
; /**< Samplerate */
258 SCHAR m_channelConfiguration
; /**< Channel configuration index */
260 SCHAR m_epConfig
; /**< Error protection index */
261 SCHAR m_vcb11Flag
; /**< aacSectionDataResilienceFlag */
262 SCHAR m_rvlcFlag
; /**< aacScalefactorDataResilienceFlag */
263 SCHAR m_hcrFlag
; /**< aacSpectralDataResilienceFlag */
265 SCHAR m_sbrPresentFlag
; /**< Flag indicating the presence of SBR data in the bitstream */
266 SCHAR m_psPresentFlag
; /**< Flag indicating the presence of parametric stereo data in the bitstream */
267 UCHAR m_samplingFrequencyIndex
; /**< Samplerate index */
268 UCHAR m_extensionSamplingFrequencyIndex
; /**< Samplerate index */
269 SCHAR m_extensionChannelConfiguration
; /**< Channel configuration index */
271 } CSAudioSpecificConfig
;
273 typedef INT (*cbUpdateConfig_t
)(void*, const CSAudioSpecificConfig
*);
274 typedef INT (*cbSsc_t
)(
275 void*, HANDLE_FDK_BITSTREAM
,
276 const AUDIO_OBJECT_TYPE coreCodec
,
277 const INT samplingFrequency
,
279 const INT configBytes
281 typedef INT (*cbSbr_t
)(
283 HANDLE_FDK_BITSTREAM hBs
,
284 const INT sampleRateIn
,
285 const INT sampleRateOut
,
286 const INT samplesPerFrame
,
287 const AUDIO_OBJECT_TYPE coreCodec
,
288 const MP4_ELEMENT_ID elementID
,
289 const INT elementIndex
293 cbUpdateConfig_t cbUpdateConfig
; /*!< Function pointer for Config change notify callback. */
294 void *cbUpdateConfigData
; /*!< User data pointer for Config change notify callback. */
295 cbSsc_t cbSsc
; /*!< Function pointer for SSC parser callback. */
296 void *cbSscData
; /*!< User data pointer for SSC parser callback. */
297 cbSbr_t cbSbr
; /*!< Function pointer for SBR header parser callback. */
298 void *cbSbrData
; /*!< User data pointer for SBR header parser callback. */
301 static const UINT SamplingRateTable
[] =
302 { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, 0, 0,
307 int getSamplingRateIndex( UINT samplingRate
)
309 UINT sf_index
, tableSize
=sizeof(SamplingRateTable
)/sizeof(UINT
);
311 for (sf_index
=0; sf_index
<tableSize
; sf_index
++) {
312 if( SamplingRateTable
[sf_index
] == samplingRate
) break;
315 if (sf_index
>tableSize
-1) {
323 * Get Channel count from channel configuration
325 static inline int getNumberOfTotalChannels(int channelConfig
)
327 if (channelConfig
> 0 && channelConfig
< 8)
328 return (channelConfig
== 7)?8:channelConfig
;
334 int getNumberOfEffectiveChannels(const int channelConfig
)
336 const int n
[] = {0,1,2,3,4,5,5,7};
337 return n
[channelConfig
];
340 #endif /* __TP_DATA_H__ */