• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 surround decoder library *************************
96 
97    Author(s):
98 
99    Description: SAC Decoder Library Interface
100 
101 *******************************************************************************/
102 
103 #ifndef SAC_DEC_INTERFACE_H
104 #define SAC_DEC_INTERFACE_H
105 
106 #include "common_fix.h"
107 #include "FDK_audio.h"
108 
109 #ifdef __cplusplus
110 extern "C" {
111 #endif
112 
113 #include "sac_dec_errorcodes.h"
114 #include "sac_dec_ssc_struct.h"
115 
116 /**
117  * \brief  Baseline MPEG-Surround profile Level 1-5.
118  */
119 typedef enum {
120   DECODER_LEVEL_0 = 0, /*!< Level 0: dummy level; 212 only */
121   DECODER_LEVEL_6 = 6  /*!< Level 6: no support */
122 } CFG_LEVEL;
123 
124 /*
125  * \brief  Number of output channels restriction.
126  */
127 typedef enum {
128   OUTPUT_CHANNELS_DEFAULT, /*!< Default configuration depending on Decoder Level
129                             */
130   OUTPUT_CHANNELS_2_0,     /*!< Limitation to stereo output */
131   OUTPUT_CHANNELS_5_1      /*!< Limitation to 5.1 output */
132 } CFG_RESTRICTION;
133 
134 /*
135  * \brief  Supported decoder mode.
136  */
137 typedef enum {
138   EXT_HQ_ONLY = 0,  /*!< High Quality processing only */
139   EXT_LP_ONLY = 1,  /*!< Low Power procesing only */
140   EXT_HQ_AND_LP = 2 /*!< Support both HQ and LP processing */
141 } CFG_EXTENT;
142 
143 /*
144  * \brief  Supported binaural mode.
145  */
146 typedef enum {
147   BINAURAL_NONE = -1 /*!< No binaural procesing supported */
148 } CFG_BINAURAL;
149 
150 /**
151  * \brief  Decoder configuration structure.
152  *
153  * These structure contains all parameters necessary for decoder open function.
154  * The configuration specifies the functional range of the decoder instance.
155  */
156 typedef struct {
157   CFG_LEVEL decoderLevel;
158   CFG_EXTENT decoderMode;
159   CFG_RESTRICTION maxNumOutputChannels;
160   CFG_BINAURAL binauralMode;
161 
162 } SPATIAL_DEC_CONFIG;
163 
164 typedef enum {
165   INPUTMODE_QMF = 1000,
166   INPUTMODE_QMF_SBR = 1001,
167   INPUTMODE_TIME = 1002
168 } SPATIALDEC_INPUT_MODE;
169 
170 /**
171  * \brief  MPEG Surround upmix type mode.
172  **/
173 typedef enum {
174   UPMIX_TYPE_BYPASS =
175       -1, /*!< Bypass the downmix channels from the core decoder.    */
176   UPMIX_TYPE_NORMAL = 0 /*!< Multi channel output. */
177 
178 } SPATIAL_DEC_UPMIX_TYPE;
179 
180 /**
181  * \brief  Dynamic decoder parameters.
182  */
183 typedef struct {
184   /* Basics */
185   UCHAR outputMode;
186   UCHAR blindEnable;
187   UCHAR bypassMode;
188 
189   /* Error concealment */
190   UCHAR concealMethod;
191   UINT concealNumKeepFrames;
192   UINT concealFadeOutSlopeLength;
193   UINT concealFadeInSlopeLength;
194   UINT concealNumReleaseFrames;
195 
196 } SPATIALDEC_PARAM;
197 
198 /**
199  * \brief Flags which control the initialization
200  **/
201 typedef enum {
202   MPEGS_INIT_NONE = 0x00000000, /*!< Indicates no initialization */
203 
204   MPEGS_INIT_CONFIG = 0x00000010, /*!< Indicates a configuration change due to
205                                      SSC value changes */
206 
207   MPEGS_INIT_STATES_ANA_QMF_FILTER =
208       0x00000100, /*!< Controls the initialization of the analysis qmf filter
209                      states */
210   MPEGS_INIT_STATES_SYN_QMF_FILTER =
211       0x00000200, /*!< Controls the initialization of the synthesis qmf filter
212                      states */
213   MPEGS_INIT_STATES_ANA_HYB_FILTER = 0x00000400, /*!< Controls the
214                                                     initialization of the
215                                                     analysis hybrid filter
216                                                     states */
217   MPEGS_INIT_STATES_DECORRELATOR =
218       0x00000800, /*!< Controls the initialization of the decorrelator states */
219   MPEGS_INIT_STATES_M1M2 = 0x00002000, /*!< Controls the initialization of the
220                                           history in m1 and m2 parameter
221                                           calculation */
222   MPEGS_INIT_STATES_GES = 0x00004000,  /*!< Controls the initialization of the
223                                           history in the ges calculation */
224   MPEGS_INIT_STATES_REVERB =
225       0x00008000, /*!< Controls the initialization of the reverb states */
226   MPEGS_INIT_STATES_PARAM =
227       0x00020000, /*!< Controls the initialization of the history of all other
228                      parameter */
229   MPEGS_INIT_STATES_ERROR_CONCEALMENT =
230       0x00080000, /*!< Controls the initialization of the error concealment
231                      module state */
232   MPEGS_INIT_PARAMS_ERROR_CONCEALMENT = 0x00200000 /*!< Controls the
233                                                       initialization of the
234                                                       whole error concealment
235                                                       parameter set */
236 
237 } MPEGS_INIT_CTRL_FLAGS;
238 
239 #define MASK_MPEGS_INIT_ALL_STATES (0x000FFF00)
240 #define MASK_MPEGS_INIT_ALL_PARAMS (0x00F00000)
241 
242 typedef struct spatialDec_struct spatialDec, *HANDLE_SPATIAL_DEC;
243 
244 typedef struct SPATIAL_BS_FRAME_struct SPATIAL_BS_FRAME;
245 
246 typedef struct {
247   UINT sizePersistent;     /* persistent memory */
248   UINT sizeFastPersistent; /* fast persistent memory */
249 
250 } MEM_REQUIREMENTS;
251 
252 #define PCM_MPS INT_PCM
253 #define PCM_MPSF FIXP_PCM
254 
255 #define FIXP_DBL2PCM_MPS(x) ((INT_PCM)FX_DBL2FX_PCM(x))
256 
257 /* exposed functions (library interface) */
258 
259 int FDK_SpatialDecCompareSpatialSpecificConfigHeader(
260     SPATIAL_SPECIFIC_CONFIG *pSsc1, SPATIAL_SPECIFIC_CONFIG *pSsc2);
261 
262 int FDK_SpatialDecInitDefaultSpatialSpecificConfig(
263     SPATIAL_SPECIFIC_CONFIG *pSpatialSpecificConfig,
264     AUDIO_OBJECT_TYPE coreCodec, int coreChannels, int samplingFreq,
265     int nTimeSlots, int decoderLevel, int isBlind);
266 
267 spatialDec *FDK_SpatialDecOpen(const SPATIAL_DEC_CONFIG *config,
268                                int stereoConfigIndex);
269 
270 /**
271  * \brief Initialize state variables of the MPS parser
272  */
273 void SpatialDecInitParserContext(spatialDec *self);
274 
275 /**
276  * \brief Initialize state of MPS decoder. This may happen after the first parse
277  * operation.
278  */
279 SACDEC_ERROR FDK_SpatialDecInit(spatialDec *self, SPATIAL_BS_FRAME *frame,
280                                 SPATIAL_SPECIFIC_CONFIG *pSpatialSpecificConfig,
281                                 int nQmfBands,
282                                 SPATIAL_DEC_UPMIX_TYPE const upmixType,
283                                 SPATIALDEC_PARAM *pUserParams,
284                                 UINT initFlags /* MPEGS_INIT_CTRL_FLAGS */
285 );
286 
287 /**
288  * \brief Apply decoded MPEG Surround parameters to time domain or QMF down mix
289  * data.
290  * \param self spatial decoder handle.
291  * \param inData Pointer to time domain input down mix data if any.
292  * \param qmfInDataReal Pointer array of QMF domain down mix input data (real
293  * part).
294  * \param qmfInDataImag Pointer array of QMF domain down mix input data
295  * (imaginary part).
296  * \param pcmOutBuf Pointer to a time domain buffer were the upmixed output data
297  * will be stored into.
298  * \param nSamples Amount of audio samples per channel of down mix input data
299  * (frame length).
300  * \param pControlFlags pointer to control flags field; input/output.
301  * \param numInputChannels amount of down mix input channels. Might not match
302  * the current tree config, useful for internal sanity checks and bypass mode.
303  * \param channelMapping array containing the desired output channel ordering to
304  * transform MPEG PCE style ordering to any other channel ordering. First
305  * dimension is the total channel count.
306  */
307 SACDEC_ERROR SpatialDecApplyFrame(
308     spatialDec *self, SPATIAL_BS_FRAME *frame, SPATIALDEC_INPUT_MODE inputMode,
309     PCM_MPS *inData,          /* Time domain input  */
310     FIXP_DBL **qmfInDataReal, /* interleaved l/r */
311     FIXP_DBL **qmfInDataImag, /* interleaved l/r */
312     PCM_MPS *pcmOutBuf, /* MAX_OUTPUT_CHANNELS*MAX_TIME_SLOTS*NUM_QMF_BANDS] */
313     UINT nSamples, UINT *pControlFlags, int numInputChannels,
314     const FDK_channelMapDescr *const mapDescr);
315 
316 /**
317  * \brief Fill given arrays with audio channel types and indices.
318  * \param self spatial decoder handle.
319  * \param channelType array where corresponding channel types fr each output
320  * channels are stored into.
321  * \param channelIndices array where corresponding channel type indices fr each
322  * output channels are stored into.
323  */
324 void SpatialDecChannelProperties(spatialDec *self,
325                                  AUDIO_CHANNEL_TYPE channelType[],
326                                  UCHAR channelIndices[],
327                                  const FDK_channelMapDescr *const mapDescr);
328 
329 void FDK_SpatialDecClose(spatialDec *self);
330 
331 #ifdef __cplusplus
332 }
333 #endif
334 
335 #endif /* SAC_DEC_INTERFACE_H */
336