• 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 encoder library *************************
96 
97    Author(s):
98 
99    Description: Encoder Library Interface
100                 Bitstream Writer
101 
102 *******************************************************************************/
103 
104 #ifndef SACENC_BITSTREAM_H
105 #define SACENC_BITSTREAM_H
106 
107 /* Includes ******************************************************************/
108 #include "FDK_bitstream.h"
109 #include "FDK_matrixCalloc.h"
110 #include "sacenc_lib.h"
111 #include "sacenc_const.h"
112 
113 /* Defines *******************************************************************/
114 #define MAX_NUM_BINS 23
115 #define MAX_NUM_PARAMS 2
116 #define MAX_NUM_OUTPUTCHANNELS SACENC_MAX_OUTPUT_CHANNELS
117 #define MAX_TIME_SLOTS 32
118 
119 typedef enum {
120   TREE_212 = 7,
121   TREE_ESCAPE = 15
122 
123 } TREECONFIG;
124 
125 typedef enum {
126   FREQ_RES_40 = 0,
127   FREQ_RES_20 = 1,
128   FREQ_RES_10 = 2,
129   FREQ_RES_5 = 3
130 
131 } FREQ;
132 
133 typedef enum {
134   QUANTMODE_INVALID = -1,
135   QUANTMODE_FINE = 0,
136   QUANTMODE_EBQ1 = 1,
137   QUANTMODE_EBQ2 = 2
138 
139 } QUANTMODE;
140 
141 typedef enum {
142   TEMPSHAPE_OFF = 0
143 
144 } TEMPSHAPECONFIG;
145 
146 typedef enum {
147   FIXEDGAINDMX_INVALID = -1,
148   FIXEDGAINDMX_0 = 0,
149   FIXEDGAINDMX_1 = 1,
150   FIXEDGAINDMX_2 = 2,
151   FIXEDGAINDMX_3 = 3,
152   FIXEDGAINDMX_4 = 4,
153   FIXEDGAINDMX_5 = 5,
154   FIXEDGAINDMX_6 = 6,
155   FIXEDGAINDMX_7 = 7
156 
157 } FIXEDGAINDMXCONFIG;
158 
159 typedef enum {
160   DECORR_INVALID = -1,
161   DECORR_QMFSPLIT0 = 0, /* QMF splitfreq: 3, 15, 24, 65 */
162   DECORR_QMFSPLIT1 = 1, /* QMF splitfreq: 3, 50, 65, 65 */
163   DECORR_QMFSPLIT2 = 2  /* QMF splitfreq: 0, 15, 65, 65 */
164 
165 } DECORRCONFIG;
166 
167 typedef enum {
168   DEFAULT = 0,
169   KEEP = 1,
170   INTERPOLATE = 2,
171   FINECOARSE = 3
172 
173 } DATA_MODE;
174 
175 typedef enum {
176   READ_SPATIALFRAME = 0,
177   WRITE_SPATIALFRAME = 1
178 
179 } SPATIALFRAME_TYPE;
180 
181 /* Data Types ****************************************************************/
182 typedef struct {
183   INT numOttBoxes;
184   INT numInChan;
185   INT numOutChan;
186 
187 } TREEDESCRIPTION;
188 
189 typedef struct {
190   INT bsOttBands;
191 
192 } OTTCONFIG;
193 
194 typedef struct {
195   INT bsSamplingFrequency; /* for bsSamplingFrequencyIndex */
196   INT bsFrameLength;
197   INT numBands; /* for bsFreqRes */
198   TREECONFIG bsTreeConfig;
199   QUANTMODE bsQuantMode;
200   FIXEDGAINDMXCONFIG bsFixedGainDMX;
201   int bsEnvQuantMode;
202   DECORRCONFIG bsDecorrConfig;
203   TREEDESCRIPTION treeDescription;
204   OTTCONFIG ottConfig[SACENC_MAX_NUM_BOXES];
205 
206 } SPATIALSPECIFICCONFIG;
207 
208 typedef struct {
209   UCHAR bsFramingType;
210   UCHAR numParamSets;
211   UCHAR bsParamSlots[MAX_NUM_PARAMS];
212 
213 } FRAMINGINFO;
214 
215 typedef struct {
216   SCHAR cld[SACENC_MAX_NUM_BOXES][MAX_NUM_PARAMS][MAX_NUM_BINS];
217   SCHAR icc[SACENC_MAX_NUM_BOXES][MAX_NUM_PARAMS][MAX_NUM_BINS];
218 
219 } OTTDATA;
220 
221 typedef struct {
222   UCHAR bsSmoothMode[MAX_NUM_PARAMS];
223   UCHAR bsSmoothTime[MAX_NUM_PARAMS];
224   UCHAR bsFreqResStride[MAX_NUM_PARAMS];
225   UCHAR bsSmgData[MAX_NUM_PARAMS][MAX_NUM_BINS];
226 
227 } SMGDATA;
228 
229 typedef struct {
230   UCHAR bsEnvShapeChannel[MAX_NUM_OUTPUTCHANNELS];
231   UCHAR bsEnvShapeData[MAX_NUM_OUTPUTCHANNELS][MAX_TIME_SLOTS];
232 
233 } TEMPSHAPEDATA;
234 
235 typedef struct {
236   UCHAR bsXXXDataMode[SACENC_MAX_NUM_BOXES][MAX_NUM_PARAMS];
237   UCHAR bsDataPair[SACENC_MAX_NUM_BOXES][MAX_NUM_PARAMS];
238   UCHAR bsQuantCoarseXXX[SACENC_MAX_NUM_BOXES][MAX_NUM_PARAMS];
239   UCHAR bsFreqResStrideXXX[SACENC_MAX_NUM_BOXES][MAX_NUM_PARAMS];
240 
241 } LOSSLESSDATA;
242 
243 typedef struct {
244   FRAMINGINFO framingInfo;
245   UCHAR bsIndependencyFlag;
246   OTTDATA ottData;
247   SMGDATA smgData;
248   TEMPSHAPEDATA tempShapeData;
249   LOSSLESSDATA CLDLosslessData;
250   LOSSLESSDATA ICCLosslessData;
251   UCHAR bUseBBCues;
252 
253 } SPATIALFRAME;
254 
255 typedef struct BSF_INSTANCE *HANDLE_BSF_INSTANCE;
256 
257 /* Constants *****************************************************************/
258 
259 /* Function / Class Declarations *********************************************/
260 /* destroy encoder instance */
261 FDK_SACENC_ERROR fdk_sacenc_destroySpatialBitstreamEncoder(
262     HANDLE_BSF_INSTANCE *selfPtr);
263 
264 /* create encoder instance */
265 FDK_SACENC_ERROR fdk_sacenc_createSpatialBitstreamEncoder(
266     HANDLE_BSF_INSTANCE *selfPtr);
267 
268 FDK_SACENC_ERROR fdk_sacenc_initSpatialBitstreamEncoder(
269     HANDLE_BSF_INSTANCE selfPtr);
270 
271 /* get SpatialSpecificConfig struct */
272 SPATIALSPECIFICCONFIG *fdk_sacenc_getSpatialSpecificConfig(
273     HANDLE_BSF_INSTANCE selfPtr);
274 
275 /* write SpatialSpecificConfig to stream */
276 FDK_SACENC_ERROR fdk_sacenc_writeSpatialSpecificConfig(
277     SPATIALSPECIFICCONFIG *const spatialSpecificConfig,
278     UCHAR *const pOutputBuffer, const INT outputBufferSize,
279     INT *const pnOutputBits);
280 
281 /* get SpatialFrame struct */
282 SPATIALFRAME *fdk_sacenc_getSpatialFrame(HANDLE_BSF_INSTANCE selfPtr,
283                                          const SPATIALFRAME_TYPE frameType);
284 
285 /* write frame data to stream */
286 FDK_SACENC_ERROR fdk_sacenc_writeSpatialFrame(UCHAR *const pOutputBuffer,
287                                               const INT outputBufferSize,
288                                               INT *const pnOutputBits,
289                                               HANDLE_BSF_INSTANCE selfPtr);
290 
291 /* Copy/Save spatial frame data for one parameter set */
292 FDK_SACENC_ERROR fdk_sacenc_duplicateParameterSet(
293     const SPATIALFRAME *const hFrom, const INT setFrom, SPATIALFRAME *const hTo,
294     const INT setTo);
295 
296 #endif /* SACENC_BITSTREAM_H */
297