• 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 /******************* Library for basic calculation routines ********************
96 
97    Author(s):   Oliver Moser
98 
99    Description: ROM tables used by FDK tools
100 
101 *******************************************************************************/
102 
103 #ifndef FDK_TOOLS_ROM_H
104 #define FDK_TOOLS_ROM_H
105 
106 #include "common_fix.h"
107 #include "FDK_audio.h"
108 
109 /* sinetables */
110 
111 /* None radix2 rotation vectors */
112 extern RAM_ALIGN const FIXP_STB RotVectorReal60[60];
113 extern RAM_ALIGN const FIXP_STB RotVectorImag60[60];
114 extern RAM_ALIGN const FIXP_STB RotVectorReal192[192];
115 extern RAM_ALIGN const FIXP_STB RotVectorImag192[192];
116 extern RAM_ALIGN const FIXP_STB RotVectorReal240[210];
117 extern RAM_ALIGN const FIXP_STB RotVectorImag240[210];
118 extern RAM_ALIGN const FIXP_STB RotVectorReal480[480];
119 extern RAM_ALIGN const FIXP_STB RotVectorImag480[480];
120 extern RAM_ALIGN const FIXP_STB RotVectorReal6[6];
121 extern RAM_ALIGN const FIXP_STB RotVectorImag6[6];
122 extern RAM_ALIGN const FIXP_STB RotVectorReal12[12];
123 extern RAM_ALIGN const FIXP_STB RotVectorImag12[12];
124 extern RAM_ALIGN const FIXP_STB RotVectorReal24[24];
125 extern RAM_ALIGN const FIXP_STB RotVectorImag24[24];
126 extern RAM_ALIGN const FIXP_STB RotVectorReal48[48];
127 extern RAM_ALIGN const FIXP_STB RotVectorImag48[48];
128 extern RAM_ALIGN const FIXP_STB RotVectorReal80[80];
129 extern RAM_ALIGN const FIXP_STB RotVectorImag80[80];
130 extern RAM_ALIGN const FIXP_STB RotVectorReal96[96];
131 extern RAM_ALIGN const FIXP_STB RotVectorImag96[96];
132 extern RAM_ALIGN const FIXP_STB RotVectorReal384[384];
133 extern RAM_ALIGN const FIXP_STB RotVectorImag384[384];
134 extern RAM_ALIGN const FIXP_STB RotVectorReal20[20];
135 extern RAM_ALIGN const FIXP_STB RotVectorImag20[20];
136 extern RAM_ALIGN const FIXP_STB RotVectorReal120[120];
137 extern RAM_ALIGN const FIXP_STB RotVectorImag120[120];
138 
139 /* Regular sine tables */
140 extern RAM_ALIGN const FIXP_STP SineTable1024[];
141 extern RAM_ALIGN const FIXP_STP SineTable512[];
142 extern RAM_ALIGN const FIXP_STP SineTable480[];
143 extern RAM_ALIGN const FIXP_STP SineTable384[];
144 extern RAM_ALIGN const FIXP_STP SineTable80[];
145 #ifdef INCLUDE_SineTable10
146 extern RAM_ALIGN const FIXP_STP SineTable10[];
147 #endif
148 
149 /* AAC-LC windows */
150 extern RAM_ALIGN const FIXP_WTP SineWindow1024[];
151 extern RAM_ALIGN const FIXP_WTP KBDWindow1024[];
152 extern RAM_ALIGN const FIXP_WTP SineWindow128[];
153 extern RAM_ALIGN const FIXP_WTP KBDWindow128[];
154 
155 extern RAM_ALIGN const FIXP_WTP SineWindow960[];
156 extern RAM_ALIGN const FIXP_WTP KBDWindow960[];
157 extern RAM_ALIGN const FIXP_WTP SineWindow120[];
158 extern RAM_ALIGN const FIXP_WTP KBDWindow120[];
159 
160 /* AAC-LD windows */
161 extern RAM_ALIGN const FIXP_WTP SineWindow512[];
162 #define LowOverlapWindow512 SineWindow128
163 extern RAM_ALIGN const FIXP_WTP SineWindow480[];
164 #define LowOverlapWindow480 SineWindow120
165 
166 /* USAC TCX Window */
167 extern RAM_ALIGN const FIXP_WTP SineWindow256[256];
168 extern RAM_ALIGN const FIXP_WTP SineWindow192[];
169 
170 /* USAC 8/3 windows */
171 extern RAM_ALIGN const FIXP_WTP SineWindow768[];
172 extern RAM_ALIGN const FIXP_WTP KBDWindow768[];
173 extern RAM_ALIGN const FIXP_WTP SineWindow96[];
174 extern RAM_ALIGN const FIXP_WTP KBDWindow96[];
175 
176 /* DCT and others */
177 extern RAM_ALIGN const FIXP_WTP SineWindow64[];
178 extern RAM_ALIGN const FIXP_WTP SineWindow48[];
179 extern RAM_ALIGN const FIXP_WTP SineWindow32[];
180 extern RAM_ALIGN const FIXP_WTP SineWindow24[];
181 extern RAM_ALIGN const FIXP_WTP SineWindow16[];
182 extern RAM_ALIGN const FIXP_WTP SineWindow8[];
183 
184 /**
185  * \brief Helper table for window slope mapping. You should prefer the usage of
186  * the function FDKgetWindowSlope(), this table is only made public for some
187  * optimized access inside dct.cpp.
188  */
189 extern const FIXP_WTP *const windowSlopes[2][4][9];
190 
191 /**
192  * \brief Window slope access helper. Obtain a window of given length and shape.
193  * \param length Length of the window slope.
194  * \param shape Shape index of the window slope. 0: sine window, 1:
195  * Kaiser-Bessel. Any other value is applied a mask of 1 to, mapping it to
196  * either 0 or 1.
197  * \param Pointer to window slope or NULL if the requested window slope is not
198  * available.
199  */
200 const FIXP_WTP *FDKgetWindowSlope(int length, int shape);
201 
202 extern const FIXP_WTP sin_twiddle_L64[];
203 
204 /*
205  * Filter coefficient type definition
206  */
207 
208 #if defined(ARCH_PREFER_MULT_16x16) || defined(ARCH_PREFER_MULT_32x16)
209 #define QMF_COEFF_16BIT
210 #endif
211 
212 #define QMF_FILTER_PROTOTYPE_SIZE 640
213 #define QMF_NO_POLY 5
214 
215 #ifdef QMF_COEFF_16BIT
216 #define FIXP_PFT FIXP_SGL
217 #define FIXP_QTW FIXP_SGL
218 #define FX_DBL2FX_QTW(x) FX_DBL2FX_SGL(x)
219 #else
220 #define FIXP_PFT FIXP_DBL
221 #define FIXP_QTW FIXP_DBL
222 
223 #define FX_DBL2FX_QTW(x) (x)
224 
225 #endif
226 
227 #define QMF640_PFT_TABLE_SIZE (640 / 2 + QMF_NO_POLY)
228 
229 /* Resampling twiddles for QMF */
230 
231 /* Not resampling twiddles */
232 extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos32[32];
233 extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin32[32];
234 /* Adapted analysis post-twiddles for down-sampled HQ SBR */
235 extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos_downsamp32[32];
236 extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin_downsamp32[32];
237 extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos64[64];
238 extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin64[64];
239 extern RAM_ALIGN const FIXP_PFT
240     qmf_pfilt640[QMF640_PFT_TABLE_SIZE + QMF_NO_POLY];
241 extern RAM_ALIGN const FIXP_PFT qmf_pfilt640_vector[640];
242 
243 extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos40[40];
244 extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin40[40];
245 extern RAM_ALIGN const FIXP_PFT qmf_pfilt400[];
246 extern RAM_ALIGN const FIXP_PFT qmf_pfilt200[];
247 extern RAM_ALIGN const FIXP_PFT qmf_pfilt120[];
248 
249 extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos24[24];
250 extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin24[24];
251 extern RAM_ALIGN const FIXP_PFT qmf_pfilt240[];
252 
253 extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos16[16];
254 extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin16[16];
255 
256 #define QMF640_CLDFB_PFT_TABLE_SIZE (640)
257 #define QMF320_CLDFB_PFT_TABLE_SIZE (320)
258 #define QMF_CLDFB_PFT_SCALE 1
259 
260 extern const FIXP_QTW qmf_phaseshift_cos32_cldfb_ana[32];
261 extern const FIXP_QTW qmf_phaseshift_cos32_cldfb_syn[32];
262 extern const FIXP_QTW qmf_phaseshift_sin32_cldfb[32];
263 
264 extern const FIXP_QTW qmf_phaseshift_cos16_cldfb_ana[16];
265 extern const FIXP_QTW qmf_phaseshift_cos16_cldfb_syn[16];
266 extern const FIXP_QTW qmf_phaseshift_sin16_cldfb[16];
267 
268 extern const FIXP_QTW qmf_phaseshift_cos8_cldfb_ana[8];
269 extern const FIXP_QTW qmf_phaseshift_cos8_cldfb_syn[8];
270 extern const FIXP_QTW qmf_phaseshift_sin8_cldfb[8];
271 
272 extern const FIXP_QTW qmf_phaseshift_cos64_cldfb[64];
273 extern const FIXP_QTW qmf_phaseshift_sin64_cldfb[64];
274 
275 extern RAM_ALIGN const FIXP_PFT qmf_cldfb_640[QMF640_CLDFB_PFT_TABLE_SIZE];
276 extern RAM_ALIGN const FIXP_PFT qmf_cldfb_320[QMF320_CLDFB_PFT_TABLE_SIZE];
277 #define QMF160_CLDFB_PFT_TABLE_SIZE (160)
278 extern RAM_ALIGN const FIXP_PFT qmf_cldfb_160[QMF160_CLDFB_PFT_TABLE_SIZE];
279 #define QMF80_CLDFB_PFT_TABLE_SIZE (80)
280 extern RAM_ALIGN const FIXP_PFT qmf_cldfb_80[QMF80_CLDFB_PFT_TABLE_SIZE];
281 
282 #define QMF320_MPSLDFB_PFT_TABLE_SIZE (320)
283 #define QMF640_MPSLDFB_PFT_TABLE_SIZE (640)
284 #define QMF_MPSLDFB_PFT_SCALE 1
285 
286 extern const FIXP_PFT qmf_mpsldfb_320[QMF320_MPSLDFB_PFT_TABLE_SIZE];
287 extern RAM_ALIGN const FIXP_PFT qmf_mpsldfb_640[QMF640_MPSLDFB_PFT_TABLE_SIZE];
288 
289 /**
290  * Audio bitstream element specific syntax flags:
291  */
292 #define AC_EL_GA_CCE 0x00000001 /*!< GA AAC coupling channel element (CCE) */
293 
294 /*
295  * Raw Data Block list items.
296  */
297 typedef enum {
298   element_instance_tag,
299   common_window, /* -> decision for link_sequence */
300   global_gain,
301   ics_info, /* ics_reserved_bit, window_sequence, window_shape, max_sfb,
302                scale_factor_grouping, predictor_data_present, ltp_data_present,
303                ltp_data */
304   max_sfb,
305   ms,                         /* ms_mask_present, ms_used */
306   /*predictor_data_present,*/ /* part of ics_info */
307   ltp_data_present,
308   ltp_data,
309   section_data,
310   scale_factor_data,
311   pulse, /* pulse_data_present, pulse_data  */
312   tns_data_present,
313   tns_data,
314   gain_control_data_present,
315   gain_control_data,
316   esc1_hcr,
317   esc2_rvlc,
318   spectral_data,
319 
320   scale_factor_data_usac,
321   core_mode, /* -> decision for link_sequence */
322   common_tw,
323   lpd_channel_stream,
324   tw_data,
325   noise,
326   ac_spectral_data,
327   fac_data,
328   tns_active, /* introduced in MPEG-D usac CD */
329   tns_data_present_usac,
330   common_max_sfb,
331 
332   coupled_elements,   /* only for CCE parsing */
333   gain_element_lists, /* only for CCE parsing */
334 
335   /* Non data list items */
336   adtscrc_start_reg1,
337   adtscrc_start_reg2,
338   adtscrc_end_reg1,
339   adtscrc_end_reg2,
340   drmcrc_start_reg,
341   drmcrc_end_reg,
342   next_channel,
343   next_channel_loop,
344   link_sequence,
345   end_of_sequence
346 } rbd_id_t;
347 
348 struct element_list {
349   const rbd_id_t *id;
350   const struct element_list *next[2];
351 };
352 
353 typedef struct element_list element_list_t;
354 /**
355  * \brief get elementary stream pieces list for given parameters.
356  * \param aot audio object type
357  * \param epConfig the epConfig value from the current Audio Specific Config
358  * \param nChannels amount of channels contained in the current element.
359  * \param layer the layer of the current element.
360  * \param elFlags element specific flags.
361  * \return element_list_t parser guidance structure.
362  */
363 const element_list_t *getBitstreamElementList(AUDIO_OBJECT_TYPE aot,
364                                               SCHAR epConfig, UCHAR nChannels,
365                                               UCHAR layer, UINT elFlags);
366 
367 typedef enum {
368   /* n.a. */
369   FDK_FORMAT_1_0 = 1,     /* mono */
370   FDK_FORMAT_2_0 = 2,     /* stereo */
371   FDK_FORMAT_3_0_FC = 3,  /* 3/0.0 */
372   FDK_FORMAT_3_1_0 = 4,   /* 3/1.0 */
373   FDK_FORMAT_5_0 = 5,     /* 3/2.0 */
374   FDK_FORMAT_5_1 = 6,     /* 5.1 */
375   FDK_FORMAT_7_1_ALT = 7, /* 5/2.1 ALT */
376   /* 8 n.a.*/
377   FDK_FORMAT_3_0_RC = 9, /* 2/1.0 */
378   FDK_FORMAT_2_2_0 = 10, /* 2/2.0 */
379   FDK_FORMAT_6_1 = 11,   /* 3/3.1 */
380   FDK_FORMAT_7_1 = 12,   /* 3/4.1 */
381   FDK_FORMAT_22_2 = 13,  /* 22.2 */
382   FDK_FORMAT_5_2_1 = 14, /* 5/2.1*/
383   FDK_FORMAT_5_5_2 = 15, /* 5/5.2 */
384   FDK_FORMAT_9_1 = 16,   /* 5/4.1 */
385   FDK_FORMAT_6_5_1 = 17, /* 6/5.1 */
386   FDK_FORMAT_6_7_1 = 18, /* 6/7.1 */
387   FDK_FORMAT_5_6_1 = 19, /* 5/6.1 */
388   FDK_FORMAT_7_6_1 = 20, /* 7/6.1 */
389   FDK_FORMAT_IN_LISTOFCHANNELS = 21,
390   FDK_FORMAT_OUT_LISTOFCHANNELS = 22,
391   /* 20 formats + In & Out list of channels */
392   FDK_NFORMATS = 23,
393   FDK_FORMAT_FAIL = -1
394 } FDK_converter_formatid_t;
395 
396 extern const INT format_nchan[FDK_NFORMATS + 9 - 2];
397 
398 #endif
399