• 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 /**************************** SBR decoder library ******************************
96 
97    Author(s):
98 
99    Description:
100 
101 *******************************************************************************/
102 
103 /*!
104   \file
105   \brief  Low Power Profile Transposer
106 */
107 
108 #ifndef LPP_TRAN_H
109 #define LPP_TRAN_H
110 
111 #include "sbrdecoder.h"
112 #include "hbe.h"
113 #include "qmf.h"
114 
115 /*
116   Common
117 */
118 #define QMF_OUT_SCALE 8
119 
120 /*
121   Frequency scales
122 */
123 
124 /*
125   Env-Adjust
126 */
127 #define MAX_NOISE_ENVELOPES 2
128 #define MAX_NOISE_COEFFS 5
129 #define MAX_NUM_NOISE_VALUES (MAX_NOISE_ENVELOPES * MAX_NOISE_COEFFS)
130 #define MAX_NUM_LIMITERS 12
131 
132 /* Set MAX_ENVELOPES to the largest value of all supported BSFORMATs
133    by overriding MAX_ENVELOPES in the correct order: */
134 #define MAX_ENVELOPES_LEGACY 5
135 #define MAX_ENVELOPES_USAC 8
136 #define MAX_ENVELOPES MAX_ENVELOPES_USAC
137 
138 #define MAX_FREQ_COEFFS_DUAL_RATE 48
139 #define MAX_FREQ_COEFFS_QUAD_RATE 56
140 #define MAX_FREQ_COEFFS MAX_FREQ_COEFFS_QUAD_RATE
141 
142 #define MAX_FREQ_COEFFS_FS44100 35
143 #define MAX_FREQ_COEFFS_FS48000 32
144 
145 #define MAX_NUM_ENVELOPE_VALUES (MAX_ENVELOPES * MAX_FREQ_COEFFS)
146 
147 #define MAX_GAIN_EXP 34
148 /* Maximum gain will be sqrt(0.5 * 2^MAX_GAIN_EXP)
149    example: 34=99dB   */
150 #define MAX_GAIN_CONCEAL_EXP 1
151 /* Maximum gain will be sqrt(0.5 * 2^MAX_GAIN_CONCEAL_EXP) in concealment case
152  * (0dB) */
153 
154 /*
155   LPP Transposer
156 */
157 #define LPC_ORDER 2
158 
159 #define MAX_INVF_BANDS MAX_NOISE_COEFFS
160 
161 #define MAX_NUM_PATCHES 6
162 #define SHIFT_START_SB 1 /*!< lowest subband of source range */
163 
164 typedef enum {
165   INVF_OFF = 0,
166   INVF_LOW_LEVEL,
167   INVF_MID_LEVEL,
168   INVF_HIGH_LEVEL,
169   INVF_SWITCHED /* not a real choice but used here to control behaviour */
170 } INVF_MODE;
171 
172 /** parameter set for one single patch */
173 typedef struct {
174   UCHAR sourceStartBand; /*!< first band in lowbands where to take the samples
175                             from */
176   UCHAR
177   sourceStopBand;       /*!< first band in lowbands which is not included in the
178                            patch anymore */
179   UCHAR guardStartBand; /*!< first band in highbands to be filled with zeros in
180                            order to reduce interferences between patches */
181   UCHAR
182   targetStartBand;       /*!< first band in highbands to be filled with whitened
183                             lowband signal */
184   UCHAR targetBandOffs;  /*!< difference between 'startTargetBand' and
185                             'startSourceBand' */
186   UCHAR numBandsInPatch; /*!< number of consecutive bands in this one patch */
187 } PATCH_PARAM;
188 
189 /** whitening factors for different levels of whitening
190     need to be initialized corresponding to crossover frequency */
191 typedef struct {
192   FIXP_DBL off; /*!< bw factor for signal OFF */
193   FIXP_DBL transitionLevel;
194   FIXP_DBL lowLevel;  /*!< bw factor for signal LOW_LEVEL */
195   FIXP_DBL midLevel;  /*!< bw factor for signal MID_LEVEL */
196   FIXP_DBL highLevel; /*!< bw factor for signal HIGH_LEVEL */
197 } WHITENING_FACTORS;
198 
199 /*! The transposer settings are calculated on a header reset and are shared by
200  * both channels. */
201 typedef struct {
202   UCHAR nCols;           /*!< number subsamples of a codec frame */
203   UCHAR noOfPatches;     /*!< number of patches */
204   UCHAR lbStartPatching; /*!< first band of lowbands that will be patched */
205   UCHAR lbStopPatching;  /*!< first band that won't be patched anymore*/
206   UCHAR bwBorders[MAX_NUM_NOISE_VALUES]; /*!< spectral bands with different
207                                             inverse filtering levels */
208 
209   PATCH_PARAM
210   patchParam[MAX_NUM_PATCHES]; /*!< new parameter set for patching */
211   WHITENING_FACTORS
212   whFactors;     /*!< the pole moving factors for certain
213                     whitening levels as indicated     in the bitstream
214                     depending on the crossover frequency */
215   UCHAR overlap; /*!< Overlap size */
216 } TRANSPOSER_SETTINGS;
217 
218 typedef struct {
219   TRANSPOSER_SETTINGS *pSettings; /*!< Common settings for both channels */
220   FIXP_DBL
221   bwVectorOld[MAX_NUM_PATCHES]; /*!< pole moving factors of past frame */
222   FIXP_DBL lpcFilterStatesRealLegSBR[LPC_ORDER + (3 * (4))][(
223       32)]; /*!< pointer array to save filter states */
224 
225   FIXP_DBL lpcFilterStatesImagLegSBR[LPC_ORDER + (3 * (4))][(
226       32)]; /*!< pointer array to save filter states */
227 
228   FIXP_DBL lpcFilterStatesRealHBE[LPC_ORDER + (3 * (4))][(
229       64)]; /*!< pointer array to save filter states */
230   FIXP_DBL lpcFilterStatesImagHBE[LPC_ORDER + (3 * (4))][(
231       64)]; /*!< pointer array to save filter states */
232 } SBR_LPP_TRANS;
233 
234 typedef SBR_LPP_TRANS *HANDLE_SBR_LPP_TRANS;
235 
236 void lppTransposer(HANDLE_SBR_LPP_TRANS hLppTrans,
237                    QMF_SCALE_FACTOR *sbrScaleFactor, FIXP_DBL **qmfBufferReal,
238 
239                    FIXP_DBL *degreeAlias, FIXP_DBL **qmfBufferImag,
240                    const int useLP, const int fPreWhitening,
241                    const int v_k_master0, const int timeStep,
242                    const int firstSlotOffset, const int lastSlotOffset,
243                    const int nInvfBands, INVF_MODE *sbr_invf_mode,
244                    INVF_MODE *sbr_invf_mode_prev);
245 
246 void lppTransposerHBE(
247     HANDLE_SBR_LPP_TRANS hLppTrans, /*!< Handle of lpp transposer  */
248     HANDLE_HBE_TRANSPOSER hQmfTransposer,
249     QMF_SCALE_FACTOR *sbrScaleFactor, /*!< Scaling factors */
250     FIXP_DBL **qmfBufferReal, /*!< Pointer to pointer to real part of subband
251                                  samples (source) */
252     FIXP_DBL **qmfBufferImag, /*!< Pointer to pointer to imaginary part of
253                                  subband samples (source) */
254     const int timeStep,       /*!< Time step of envelope */
255     const int firstSlotOffs,  /*!< Start position in time */
256     const int lastSlotOffs,   /*!< Number of overlap-slots into next frame */
257     const int nInvfBands,     /*!< Number of bands for inverse filtering */
258     INVF_MODE *sbr_invf_mode, /*!< Current inverse filtering modes */
259     INVF_MODE *sbr_invf_mode_prev /*!< Previous inverse filtering modes */
260 );
261 
262 SBR_ERROR
263 createLppTransposer(HANDLE_SBR_LPP_TRANS hLppTrans,
264                     TRANSPOSER_SETTINGS *pSettings, const int highBandStartSb,
265                     UCHAR *v_k_master, const int numMaster, const int usb,
266                     const int timeSlots, const int nCols, UCHAR *noiseBandTable,
267                     const int noNoiseBands, UINT fs, const int chan,
268                     const int overlap);
269 
270 SBR_ERROR
271 resetLppTransposer(HANDLE_SBR_LPP_TRANS hLppTrans, UCHAR highBandStartSb,
272                    UCHAR *v_k_master, UCHAR numMaster, UCHAR *noiseBandTable,
273                    UCHAR noNoiseBands, UCHAR usb, UINT fs);
274 
275 #endif /* LPP_TRAN_H */
276