• 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 /**************************** AAC encoder library ******************************
96 
97    Author(s):   M. Werner
98 
99    Description: Quantizing & coding data
100 
101 *******************************************************************************/
102 
103 #ifndef QC_DATA_H
104 #define QC_DATA_H
105 
106 #include "aacenc.h"
107 #include "psy_const.h"
108 #include "dyn_bits.h"
109 #include "adj_thr_data.h"
110 #include "line_pe.h"
111 #include "FDK_audio.h"
112 #include "interface.h"
113 
114 typedef enum {
115   QCDATA_BR_MODE_INVALID = -1,
116   QCDATA_BR_MODE_CBR = 0,   /* Constant bit rate, given average bitrate */
117   QCDATA_BR_MODE_VBR_1 = 1, /* Variable bit rate, very low */
118   QCDATA_BR_MODE_VBR_2 = 2, /* Variable bit rate, low */
119   QCDATA_BR_MODE_VBR_3 = 3, /* Variable bit rate, medium */
120   QCDATA_BR_MODE_VBR_4 = 4, /* Variable bit rate, high */
121   QCDATA_BR_MODE_VBR_5 = 5, /* Variable bit rate, very high */
122   QCDATA_BR_MODE_FF = 6,    /* Fixed frame mode. */
123   QCDATA_BR_MODE_SFR = 7    /* Superframe mode. */
124 
125 } QCDATA_BR_MODE;
126 
127 typedef struct {
128   MP4_ELEMENT_ID elType;
129   INT instanceTag;
130   INT nChannelsInEl;
131   INT ChannelIndex[2];
132   FIXP_DBL relativeBits;
133 } ELEMENT_INFO;
134 
135 typedef struct {
136   CHANNEL_MODE encMode;
137   INT nChannels;
138   INT nChannelsEff;
139   INT nElements;
140   ELEMENT_INFO elInfo[((8))];
141 } CHANNEL_MAPPING;
142 
143 typedef struct {
144   INT paddingRest;
145 } PADDING;
146 
147 /* Quantizing & coding stage */
148 
149 struct QC_INIT {
150   CHANNEL_MAPPING *channelMapping;
151   INT sceCpe;      /* not used yet                         */
152   INT maxBits;     /* maximum number of bits in reservoir  */
153   INT averageBits; /* average number of bits we should use */
154   INT bitRes;
155   INT sampleRate; /* output sample rate                   */
156   INT isLowDelay; /* if set, calc bits2PE factor depending on samplerate */
157   INT staticBits; /* Bits per frame consumed by transport layers. */
158   QCDATA_BR_MODE bitrateMode;
159   INT meanPe;
160   INT chBitrate; /* Bitrate/channel */
161   INT invQuant;
162   INT maxIterations; /* Maximum number of allowed iterations before
163                         FDKaacEnc_crashRecovery() is applied. */
164   FIXP_DBL maxBitFac;
165   INT bitrate;
166   INT nSubFrames;                /* helper variable */
167   INT minBits;                   /* minimal number of bits in one frame*/
168   AACENC_BITRES_MODE bitResMode; /* 0: full bitreservoir, 1: reduced
169                                     bitreservoir, 2: disabled bitreservoir */
170   INT bitDistributionMode; /* Configure element-wise execution or execution over
171                               all elements for the pe-dependent
172                               threshold-adaption */
173 
174   PADDING padding;
175 };
176 
177 typedef struct {
178   FIXP_DBL mdctSpectrum[(1024)];
179 
180   SHORT quantSpec[(1024)];
181 
182   UINT maxValueInSfb[MAX_GROUPED_SFB];
183   INT scf[MAX_GROUPED_SFB];
184   INT globalGain;
185   SECTION_DATA sectionData;
186 
187   FIXP_DBL sfbFormFactorLdData[MAX_GROUPED_SFB];
188 
189   FIXP_DBL sfbThresholdLdData[MAX_GROUPED_SFB];
190   FIXP_DBL sfbMinSnrLdData[MAX_GROUPED_SFB];
191   FIXP_DBL sfbEnergyLdData[MAX_GROUPED_SFB];
192   FIXP_DBL sfbEnergy[MAX_GROUPED_SFB];
193   FIXP_DBL sfbWeightedEnergyLdData[MAX_GROUPED_SFB];
194 
195   FIXP_DBL sfbEnFacLd[MAX_GROUPED_SFB];
196 
197   FIXP_DBL sfbSpreadEnergy[MAX_GROUPED_SFB];
198 
199 } QC_OUT_CHANNEL;
200 
201 typedef struct {
202   EXT_PAYLOAD_TYPE type; /* type of the extension payload */
203   INT nPayloadBits;      /* size of the payload */
204   UCHAR *pPayload;       /* pointer to payload */
205 
206 } QC_OUT_EXTENSION;
207 
208 typedef struct {
209   INT staticBitsUsed; /* for verification purposes */
210   INT dynBitsUsed;    /* for verification purposes */
211 
212   INT extBitsUsed; /* bit consumption of extended fill elements */
213   INT nExtensions; /* number of extension payloads for this element */
214   QC_OUT_EXTENSION extension[(1)]; /* reffering extension payload */
215 
216   INT grantedDynBits;
217 
218   INT grantedPe;
219   INT grantedPeCorr;
220 
221   PE_DATA peData;
222 
223   QC_OUT_CHANNEL *qcOutChannel[(2)];
224 
225   UCHAR
226   *dynMem_Ah_Flag; /* pointer to dynamic buffer used by AhFlag in function
227                       FDKaacEnc_adaptThresholdsToPe() */
228   UCHAR
229   *dynMem_Thr_Exp; /* pointer to dynamic buffer used by ThrExp in function
230                       FDKaacEnc_adaptThresholdsToPe() */
231   UCHAR *dynMem_SfbNActiveLinesLdData; /* pointer to dynamic buffer used by
232                                           sfbNActiveLinesLdData in function
233                                           FDKaacEnc_correctThresh() */
234 
235 } QC_OUT_ELEMENT;
236 
237 typedef struct {
238   QC_OUT_ELEMENT *qcElement[((8))];
239   QC_OUT_CHANNEL *pQcOutChannels[(8)];
240   QC_OUT_EXTENSION extension[(2 + 2)]; /* global extension payload */
241   INT nExtensions;    /* number of extension payloads for this AU */
242   INT maxDynBits;     /* maximal allowed dynamic bits in frame */
243   INT grantedDynBits; /* granted dynamic bits in frame */
244   INT totFillBits;    /* fill bits */
245   INT elementExtBits; /* element associated extension payload bits, e.g. sbr,
246                          drc ... */
247   INT globalExtBits;  /* frame/au associated extension payload bits (anc data
248                          ...) */
249   INT staticBits;     /* aac side info bits */
250 
251   INT totalNoRedPe;
252   INT totalGrantedPeCorr;
253 
254   INT usedDynBits; /* number of dynamic bits in use */
255   INT alignBits;   /* AU alignment bits */
256   INT totalBits;   /* sum of static, dyn, sbr, fill, align and dse bits */
257 
258 } QC_OUT;
259 
260 typedef struct {
261   INT chBitrateEl;         /* channel bitrate in element
262                               (totalbitrate*el_relativeBits/el_channels) */
263   INT maxBitsEl;           /* used in crash recovery */
264   INT bitResLevelEl;       /* update bitreservoir level in each call of
265                               FDKaacEnc_QCMain */
266   INT maxBitResBitsEl;     /* nEffChannels*6144 - averageBitsInFrame */
267   FIXP_DBL relativeBitsEl; /* Bits relative to total Bits*/
268 } ELEMENT_BITS;
269 
270 typedef struct {
271   /* this is basically struct QC_INIT */
272 
273   INT globHdrBits;
274   INT maxBitsPerFrame; /* maximal allowed bits per frame, 6144*nChannelsEff */
275   INT minBitsPerFrame; /* minimal allowd bits per fram, superframing - DRM */
276   INT nElements;
277   QCDATA_BR_MODE bitrateMode;
278   AACENC_BITRES_MODE bitResMode; /* 0: full bitreservoir, 1: reduced
279                                     bitreservoir, 2: disabled bitreservoir */
280   INT bitResTot;
281   INT bitResTotMax;
282   INT maxIterations; /* Maximum number of allowed iterations before
283                         FDKaacEnc_crashRecovery() is applied. */
284   INT invQuant;
285 
286   FIXP_DBL vbrQualFactor;
287   FIXP_DBL maxBitFac;
288 
289   PADDING padding;
290 
291   ELEMENT_BITS *elementBits[((8))];
292   BITCNTR_STATE *hBitCounter;
293   ADJ_THR_STATE *hAdjThr;
294 
295   INT dZoneQuantEnable; /* enable dead zone quantizer */
296 
297 } QC_STATE;
298 
299 #endif /* QC_DATA_H */
300