13453
|
1 /*
|
|
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
|
|
3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
|
|
4 **
|
|
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.
|
|
9 **
|
|
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.
|
|
14 **
|
|
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.
|
|
18 **
|
|
19 ** Any non-GPL usage of this software or parts of this software is strictly
|
|
20 ** forbidden.
|
|
21 **
|
|
22 ** Commercial non-GPL licensing of this software is possible.
|
|
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
|
|
24 **
|
|
25 ** Initially modified for use with MPlayer by Diego Biurrun on 2004/09/24
|
|
26 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
|
|
27 **/
|
|
28
|
|
29 #ifndef __NEAACDEC_H__
|
|
30 #define __NEAACDEC_H__
|
|
31
|
|
32 #ifdef __cplusplus
|
|
33 extern "C" {
|
|
34 #endif /* __cplusplus */
|
|
35
|
|
36
|
|
37 #if 1
|
|
38 /* MACROS FOR BACKWARDS COMPATIBILITY */
|
|
39 /* structs */
|
|
40 #define faacDecHandle NeAACDecHandle
|
|
41 #define faacDecConfiguration NeAACDecConfiguration
|
|
42 #define faacDecConfigurationPtr NeAACDecConfigurationPtr
|
|
43 #define faacDecFrameInfo NeAACDecFrameInfo
|
|
44 /* functions */
|
|
45 #define faacDecGetErrorMessage NeAACDecGetErrorMessage
|
|
46 #define faacDecSetConfiguration NeAACDecSetConfiguration
|
|
47 #define faacDecGetCurrentConfiguration NeAACDecGetCurrentConfiguration
|
|
48 #define faacDecInit NeAACDecInit
|
|
49 #define faacDecInit2 NeAACDecInit2
|
|
50 #define faacDecInitDRM NeAACDecInitDRM
|
|
51 #define faacDecPostSeekReset NeAACDecPostSeekReset
|
|
52 #define faacDecOpen NeAACDecOpen
|
|
53 #define faacDecClose NeAACDecClose
|
|
54 #define faacDecDecode NeAACDecDecode
|
|
55 #define AudioSpecificConfig NeAACDecAudioSpecificConfig
|
|
56 #endif
|
|
57
|
|
58
|
|
59 #ifdef _WIN32
|
|
60 #pragma pack(push, 8)
|
|
61 #ifndef NEAACDECAPI
|
|
62 #define NEAACDECAPI __cdecl
|
|
63 #endif
|
|
64 #else
|
|
65 #ifndef NEAACDECAPI
|
|
66 #define NEAACDECAPI
|
|
67 #endif
|
|
68 #endif
|
|
69
|
|
70 #define FAAD2_VERSION "2.1 beta"
|
|
71
|
|
72 /* object types for AAC */
|
|
73 #define MAIN 1
|
|
74 #define LC 2
|
|
75 #define SSR 3
|
|
76 #define LTP 4
|
|
77 #define HE_AAC 5
|
|
78 #define ER_LC 17
|
|
79 #define ER_LTP 19
|
|
80 #define LD 23
|
|
81 #define DRM_ER_LC 27 /* special object type for DRM */
|
|
82
|
|
83 /* header types */
|
|
84 #define RAW 0
|
|
85 #define ADIF 1
|
|
86 #define ADTS 2
|
|
87
|
|
88 /* SBR signalling */
|
|
89 #define NO_SBR 0
|
|
90 #define SBR_UPSAMPLED 1
|
|
91 #define SBR_DOWNSAMPLED 2
|
|
92 #define NO_SBR_UPSAMPLED 3
|
|
93
|
|
94 /* library output formats */
|
|
95 #define FAAD_FMT_16BIT 1
|
|
96 #define FAAD_FMT_24BIT 2
|
|
97 #define FAAD_FMT_32BIT 3
|
|
98 #define FAAD_FMT_FLOAT 4
|
|
99 #define FAAD_FMT_FIXED FAAD_FMT_FLOAT
|
|
100 #define FAAD_FMT_DOUBLE 5
|
|
101
|
|
102 /* Capabilities */
|
|
103 #define LC_DEC_CAP (1<<0) /* Can decode LC */
|
|
104 #define MAIN_DEC_CAP (1<<1) /* Can decode MAIN */
|
|
105 #define LTP_DEC_CAP (1<<2) /* Can decode LTP */
|
|
106 #define LD_DEC_CAP (1<<3) /* Can decode LD */
|
|
107 #define ERROR_RESILIENCE_CAP (1<<4) /* Can decode ER */
|
|
108 #define FIXED_POINT_CAP (1<<5) /* Fixed point */
|
|
109
|
|
110 /* Channel definitions */
|
|
111 #define FRONT_CHANNEL_CENTER (1)
|
|
112 #define FRONT_CHANNEL_LEFT (2)
|
|
113 #define FRONT_CHANNEL_RIGHT (3)
|
|
114 #define SIDE_CHANNEL_LEFT (4)
|
|
115 #define SIDE_CHANNEL_RIGHT (5)
|
|
116 #define BACK_CHANNEL_LEFT (6)
|
|
117 #define BACK_CHANNEL_RIGHT (7)
|
|
118 #define BACK_CHANNEL_CENTER (8)
|
|
119 #define LFE_CHANNEL (9)
|
|
120 #define UNKNOWN_CHANNEL (0)
|
|
121
|
|
122 /* DRM channel definitions */
|
|
123 #define DRMCH_MONO 1
|
|
124 #define DRMCH_STEREO 2
|
|
125 #define DRMCH_SBR_MONO 3
|
|
126 #define DRMCH_SBR_STEREO 4
|
|
127 #define DRMCH_SBR_PS_STEREO 5
|
|
128
|
|
129
|
|
130 /* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel,
|
|
131 so at least so much bytes per channel should be available in this stream */
|
|
132 #define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */
|
|
133
|
|
134
|
|
135 typedef void *NeAACDecHandle;
|
|
136
|
|
137 typedef struct mp4AudioSpecificConfig
|
|
138 {
|
|
139 /* Audio Specific Info */
|
|
140 unsigned char objectTypeIndex;
|
|
141 unsigned char samplingFrequencyIndex;
|
|
142 unsigned long samplingFrequency;
|
|
143 unsigned char channelsConfiguration;
|
|
144
|
|
145 /* GA Specific Info */
|
|
146 unsigned char frameLengthFlag;
|
|
147 unsigned char dependsOnCoreCoder;
|
|
148 unsigned short coreCoderDelay;
|
|
149 unsigned char extensionFlag;
|
|
150 unsigned char aacSectionDataResilienceFlag;
|
|
151 unsigned char aacScalefactorDataResilienceFlag;
|
|
152 unsigned char aacSpectralDataResilienceFlag;
|
|
153 unsigned char epConfig;
|
|
154
|
|
155 char sbr_present_flag;
|
|
156 char forceUpSampling;
|
|
157 char downSampledSBR;
|
|
158 } mp4AudioSpecificConfig;
|
|
159
|
|
160 typedef struct NeAACDecConfiguration
|
|
161 {
|
|
162 unsigned char defObjectType;
|
|
163 unsigned long defSampleRate;
|
|
164 unsigned char outputFormat;
|
|
165 unsigned char downMatrix;
|
|
166 unsigned char useOldADTSFormat;
|
|
167 unsigned char dontUpSampleImplicitSBR;
|
|
168 } NeAACDecConfiguration, *NeAACDecConfigurationPtr;
|
|
169
|
|
170 typedef struct NeAACDecFrameInfo
|
|
171 {
|
|
172 unsigned long bytesconsumed;
|
|
173 unsigned long samples;
|
|
174 unsigned char channels;
|
|
175 unsigned char error;
|
|
176 unsigned long samplerate;
|
|
177
|
|
178 /* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */
|
|
179 unsigned char sbr;
|
|
180
|
|
181 /* MPEG-4 ObjectType */
|
|
182 unsigned char object_type;
|
|
183
|
|
184 /* AAC header type; MP4 will be signalled as RAW also */
|
|
185 unsigned char header_type;
|
|
186
|
|
187 /* multichannel configuration */
|
|
188 unsigned char num_front_channels;
|
|
189 unsigned char num_side_channels;
|
|
190 unsigned char num_back_channels;
|
|
191 unsigned char num_lfe_channels;
|
|
192 unsigned char channel_position[64];
|
|
193 } NeAACDecFrameInfo;
|
|
194
|
|
195 char* NEAACDECAPI NeAACDecGetErrorMessage(unsigned char errcode);
|
|
196
|
|
197 unsigned long NEAACDECAPI NeAACDecGetCapabilities(void);
|
|
198
|
|
199 NeAACDecHandle NEAACDECAPI NeAACDecOpen(void);
|
|
200
|
|
201 NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder);
|
|
202
|
|
203 unsigned char NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder,
|
|
204 NeAACDecConfigurationPtr config);
|
|
205
|
|
206 /* Init the library based on info from the AAC file (ADTS/ADIF) */
|
|
207 long NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder,
|
|
208 unsigned char *buffer,
|
|
209 unsigned long buffer_size,
|
|
210 unsigned long *samplerate,
|
|
211 unsigned char *channels);
|
|
212
|
|
213 /* Init the library using a DecoderSpecificInfo */
|
|
214 char NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, unsigned char *pBuffer,
|
|
215 unsigned long SizeOfDecoderSpecificInfo,
|
|
216 unsigned long *samplerate, unsigned char *channels);
|
|
217
|
|
218 /* Init the library for DRM */
|
|
219 char NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, unsigned long samplerate,
|
|
220 unsigned char channels);
|
|
221
|
|
222 void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, long frame);
|
|
223
|
|
224 void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder);
|
|
225
|
|
226 void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
|
|
227 NeAACDecFrameInfo *hInfo,
|
|
228 unsigned char *buffer,
|
|
229 unsigned long buffer_size);
|
|
230
|
|
231 char NEAACDECAPI NeAACDecAudioSpecificConfig(unsigned char *pBuffer,
|
|
232 unsigned long buffer_size,
|
|
233 mp4AudioSpecificConfig *mp4ASC);
|
|
234
|
|
235 #ifdef _WIN32
|
|
236 #pragma pack(pop)
|
|
237 #endif
|
|
238
|
|
239 #ifdef __cplusplus
|
|
240 }
|
|
241 #endif /* __cplusplus */
|
|
242
|
|
243 #endif
|