2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
3 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 ** Any non-GPL usage of this software or parts of this software is strictly
22 ** The "appropriate copyright message" mentioned in section 2c of the GPLv2
23 ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com"
25 ** Commercial non-GPL licensing of this software is possible.
26 ** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
28 ** $Id: neaacdec.h,v 1.13 2009/01/26 23:51:15 menno Exp $
31 #ifndef __NEAACDEC_H__
32 #define __NEAACDEC_H__
36 #endif /* __cplusplus */
40 /* MACROS FOR BACKWARDS COMPATIBILITY */
42 #define faacDecHandle NeAACDecHandle
43 #define faacDecConfiguration NeAACDecConfiguration
44 #define faacDecConfigurationPtr NeAACDecConfigurationPtr
45 #define faacDecFrameInfo NeAACDecFrameInfo
47 #define faacDecGetErrorMessage NeAACDecGetErrorMessage
48 #define faacDecSetConfiguration NeAACDecSetConfiguration
49 #define faacDecGetCurrentConfiguration NeAACDecGetCurrentConfiguration
50 #define faacDecInit NeAACDecInit
51 #define faacDecInit2 NeAACDecInit2
52 #define faacDecInitDRM NeAACDecInitDRM
53 #define faacDecPostSeekReset NeAACDecPostSeekReset
54 #define faacDecOpen NeAACDecOpen
55 #define faacDecClose NeAACDecClose
56 #define faacDecDecode NeAACDecDecode
57 #define AudioSpecificConfig NeAACDecAudioSpecificConfig
64 #define NEAACDECAPI __cdecl
72 #define FAAD2_VERSION "2.7"
74 /* object types for AAC */
83 #define DRM_ER_LC 27 /* special object type for DRM */
93 #define SBR_UPSAMPLED 1
94 #define SBR_DOWNSAMPLED 2
95 #define NO_SBR_UPSAMPLED 3
97 /* library output formats */
98 #define FAAD_FMT_16BIT 1
99 #define FAAD_FMT_24BIT 2
100 #define FAAD_FMT_32BIT 3
101 #define FAAD_FMT_FLOAT 4
102 #define FAAD_FMT_FIXED FAAD_FMT_FLOAT
103 #define FAAD_FMT_DOUBLE 5
106 #define LC_DEC_CAP (1<<0) /* Can decode LC */
107 #define MAIN_DEC_CAP (1<<1) /* Can decode MAIN */
108 #define LTP_DEC_CAP (1<<2) /* Can decode LTP */
109 #define LD_DEC_CAP (1<<3) /* Can decode LD */
110 #define ERROR_RESILIENCE_CAP (1<<4) /* Can decode ER */
111 #define FIXED_POINT_CAP (1<<5) /* Fixed point */
113 /* Channel definitions */
114 #define FRONT_CHANNEL_CENTER (1)
115 #define FRONT_CHANNEL_LEFT (2)
116 #define FRONT_CHANNEL_RIGHT (3)
117 #define SIDE_CHANNEL_LEFT (4)
118 #define SIDE_CHANNEL_RIGHT (5)
119 #define BACK_CHANNEL_LEFT (6)
120 #define BACK_CHANNEL_RIGHT (7)
121 #define BACK_CHANNEL_CENTER (8)
122 #define LFE_CHANNEL (9)
123 #define UNKNOWN_CHANNEL (0)
125 /* DRM channel definitions */
127 #define DRMCH_STEREO 2
128 #define DRMCH_SBR_MONO 3
129 #define DRMCH_SBR_STEREO 4
130 #define DRMCH_SBR_PS_STEREO 5
133 /* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel,
134 so at least so much bytes per channel should be available in this stream */
135 #define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */
138 typedef void *NeAACDecHandle;
140 typedef struct mp4AudioSpecificConfig
142 /* Audio Specific Info */
143 unsigned char objectTypeIndex;
144 unsigned char samplingFrequencyIndex;
145 unsigned long samplingFrequency;
146 unsigned char channelsConfiguration;
148 /* GA Specific Info */
149 unsigned char frameLengthFlag;
150 unsigned char dependsOnCoreCoder;
151 unsigned short coreCoderDelay;
152 unsigned char extensionFlag;
153 unsigned char aacSectionDataResilienceFlag;
154 unsigned char aacScalefactorDataResilienceFlag;
155 unsigned char aacSpectralDataResilienceFlag;
156 unsigned char epConfig;
158 char sbr_present_flag;
159 char forceUpSampling;
161 } mp4AudioSpecificConfig;
163 typedef struct NeAACDecConfiguration
165 unsigned char defObjectType;
166 unsigned long defSampleRate;
167 unsigned char outputFormat;
168 unsigned char downMatrix;
169 unsigned char useOldADTSFormat;
170 unsigned char dontUpSampleImplicitSBR;
171 } NeAACDecConfiguration, *NeAACDecConfigurationPtr;
173 typedef struct NeAACDecFrameInfo
175 unsigned long bytesconsumed;
176 unsigned long samples;
177 unsigned char channels;
179 unsigned long samplerate;
181 /* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */
184 /* MPEG-4 ObjectType */
185 unsigned char object_type;
187 /* AAC header type; MP4 will be signalled as RAW also */
188 unsigned char header_type;
190 /* multichannel configuration */
191 unsigned char num_front_channels;
192 unsigned char num_side_channels;
193 unsigned char num_back_channels;
194 unsigned char num_lfe_channels;
195 unsigned char channel_position[64];
197 /* PS: 0: off, 1: on */
201 char* NEAACDECAPI NeAACDecGetErrorMessage(unsigned char errcode);
203 unsigned long NEAACDECAPI NeAACDecGetCapabilities(void);
205 NeAACDecHandle NEAACDECAPI NeAACDecOpen(void);
207 NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder);
209 unsigned char NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder,
210 NeAACDecConfigurationPtr config);
212 /* Init the library based on info from the AAC file (ADTS/ADIF) */
213 long NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder,
214 unsigned char *buffer,
215 unsigned long buffer_size,
216 unsigned long *samplerate,
217 unsigned char *channels);
219 /* Init the library using a DecoderSpecificInfo */
220 char NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder,
221 unsigned char *pBuffer,
222 unsigned long SizeOfDecoderSpecificInfo,
223 unsigned long *samplerate,
224 unsigned char *channels);
226 /* Init the library for DRM */
227 char NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, unsigned long samplerate,
228 unsigned char channels);
230 void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, long frame);
232 void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder);
234 void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
235 NeAACDecFrameInfo *hInfo,
236 unsigned char *buffer,
237 unsigned long buffer_size);
239 void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder,
240 NeAACDecFrameInfo *hInfo,
241 unsigned char *buffer,
242 unsigned long buffer_size,
243 void **sample_buffer,
244 unsigned long sample_buffer_size);
246 char NEAACDECAPI NeAACDecAudioSpecificConfig(unsigned char *pBuffer,
247 unsigned long buffer_size,
248 mp4AudioSpecificConfig *mp4ASC);
256 #endif /* __cplusplus */