blob: d6e01d2610a12113459b579b29c7c5e76244ae71
1 | /* |
2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
3 | ** Copyright (C) 2003-2005 M. Bakker, Nero 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 | ** 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" |
24 | ** |
25 | ** Commercial non-GPL licensing of this software is possible. |
26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
27 | ** |
28 | ** $Id: neaacdec.h,v 1.13 2009/01/26 23:51:15 menno Exp $ |
29 | **/ |
30 | |
31 | #ifndef __NEAACDEC_H__ |
32 | #define __NEAACDEC_H__ |
33 | |
34 | #ifdef __cplusplus |
35 | extern "C" { |
36 | #endif /* __cplusplus */ |
37 | |
38 | |
39 | #if 1 |
40 | /* MACROS FOR BACKWARDS COMPATIBILITY */ |
41 | /* structs */ |
42 | #define faacDecHandle NeAACDecHandle |
43 | #define faacDecConfiguration NeAACDecConfiguration |
44 | #define faacDecConfigurationPtr NeAACDecConfigurationPtr |
45 | #define faacDecFrameInfo NeAACDecFrameInfo |
46 | /* functions */ |
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 |
58 | #endif |
59 | |
60 | |
61 | #ifdef _WIN32 |
62 | #pragma pack(push, 8) |
63 | #ifndef NEAACDECAPI |
64 | #define NEAACDECAPI __cdecl |
65 | #endif |
66 | #else |
67 | #ifndef NEAACDECAPI |
68 | #define NEAACDECAPI |
69 | #endif |
70 | #endif |
71 | |
72 | #define FAAD2_VERSION "2.7" |
73 | |
74 | /* object types for AAC */ |
75 | #define MAIN 1 |
76 | #define LC 2 |
77 | #define SSR 3 |
78 | #define LTP 4 |
79 | #define HE_AAC 5 |
80 | #define ER_LC 17 |
81 | #define ER_LTP 19 |
82 | #define LD 23 |
83 | #define DRM_ER_LC 27 /* special object type for DRM */ |
84 | |
85 | /* header types */ |
86 | #define RAW 0 |
87 | #define ADIF 1 |
88 | #define ADTS 2 |
89 | #define LATM 3 |
90 | |
91 | /* SBR signalling */ |
92 | #define NO_SBR 0 |
93 | #define SBR_UPSAMPLED 1 |
94 | #define SBR_DOWNSAMPLED 2 |
95 | #define NO_SBR_UPSAMPLED 3 |
96 | |
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 |
104 | |
105 | /* Capabilities */ |
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 */ |
112 | |
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) |
124 | |
125 | /* DRM channel definitions */ |
126 | #define DRMCH_MONO 1 |
127 | #define DRMCH_STEREO 2 |
128 | #define DRMCH_SBR_MONO 3 |
129 | #define DRMCH_SBR_STEREO 4 |
130 | #define DRMCH_SBR_PS_STEREO 5 |
131 | |
132 | |
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 */ |
136 | |
137 | |
138 | typedef void *NeAACDecHandle; |
139 | |
140 | typedef struct mp4AudioSpecificConfig { |
141 | /* Audio Specific Info */ |
142 | unsigned char objectTypeIndex; |
143 | unsigned char samplingFrequencyIndex; |
144 | unsigned long samplingFrequency; |
145 | unsigned char channelsConfiguration; |
146 | |
147 | /* GA Specific Info */ |
148 | unsigned char frameLengthFlag; |
149 | unsigned char dependsOnCoreCoder; |
150 | unsigned short coreCoderDelay; |
151 | unsigned char extensionFlag; |
152 | unsigned char aacSectionDataResilienceFlag; |
153 | unsigned char aacScalefactorDataResilienceFlag; |
154 | unsigned char aacSpectralDataResilienceFlag; |
155 | unsigned char epConfig; |
156 | |
157 | char sbr_present_flag; |
158 | char forceUpSampling; |
159 | char downSampledSBR; |
160 | } mp4AudioSpecificConfig; |
161 | |
162 | typedef struct NeAACDecConfiguration { |
163 | unsigned char defObjectType; |
164 | unsigned long defSampleRate; |
165 | unsigned char outputFormat; |
166 | unsigned char downMatrix; |
167 | unsigned char useOldADTSFormat; |
168 | unsigned char dontUpSampleImplicitSBR; |
169 | } NeAACDecConfiguration, *NeAACDecConfigurationPtr; |
170 | |
171 | typedef struct NeAACDecFrameInfo { |
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 | |
194 | /* PS: 0: off, 1: on */ |
195 | unsigned char ps; |
196 | } NeAACDecFrameInfo; |
197 | |
198 | char* NEAACDECAPI NeAACDecGetErrorMessage(unsigned char errcode); |
199 | |
200 | unsigned long NEAACDECAPI NeAACDecGetCapabilities(void); |
201 | |
202 | NeAACDecHandle NEAACDECAPI NeAACDecOpen(void); |
203 | |
204 | NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder); |
205 | |
206 | unsigned char NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder, |
207 | NeAACDecConfigurationPtr config); |
208 | |
209 | /* Init the library based on info from the AAC file (ADTS/ADIF) */ |
210 | long NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, |
211 | unsigned char *buffer, |
212 | unsigned long buffer_size, |
213 | unsigned long *samplerate, |
214 | unsigned char *channels, |
215 | int is_latm_external, |
216 | int *skipbytes); |
217 | |
218 | /* Init the library using a DecoderSpecificInfo */ |
219 | int NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, |
220 | unsigned char *pBuffer, |
221 | unsigned long SizeOfDecoderSpecificInfo, |
222 | unsigned long *samplerate, |
223 | unsigned char *channels); |
224 | |
225 | /* Init the library for DRM */ |
226 | char NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, unsigned long samplerate, |
227 | unsigned char channels); |
228 | |
229 | void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, long frame); |
230 | |
231 | void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder); |
232 | |
233 | void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder, |
234 | NeAACDecFrameInfo *hInfo, |
235 | unsigned char *buffer, |
236 | unsigned long buffer_size); |
237 | |
238 | void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder, |
239 | NeAACDecFrameInfo *hInfo, |
240 | unsigned char *buffer, |
241 | unsigned long buffer_size, |
242 | void **sample_buffer, |
243 | unsigned long sample_buffer_size); |
244 | |
245 | char NEAACDECAPI NeAACDecAudioSpecificConfig(unsigned char *pBuffer, |
246 | unsigned long buffer_size, |
247 | mp4AudioSpecificConfig *mp4ASC); |
248 | |
249 | #ifdef _WIN32 |
250 | #pragma pack(pop) |
251 | #endif |
252 | |
253 | #ifdef __cplusplus |
254 | } |
255 | #endif /* __cplusplus */ |
256 | |
257 | #endif |
258 |