]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/ext/faad/neaacdec.h
wwww
[16.git] / src / lib / doslib / ext / faad / neaacdec.h
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 {
142     /* Audio Specific Info */
143     unsigned char objectTypeIndex;
144     unsigned char samplingFrequencyIndex;
145     unsigned long samplingFrequency;
146     unsigned char channelsConfiguration;
147
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;
157
158     char sbr_present_flag;
159     char forceUpSampling;
160     char downSampledSBR;
161 } mp4AudioSpecificConfig;
162
163 typedef struct NeAACDecConfiguration
164 {
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;
172
173 typedef struct NeAACDecFrameInfo
174 {
175     unsigned long bytesconsumed;
176     unsigned long samples;
177     unsigned char channels;
178     unsigned char error;
179     unsigned long samplerate;
180
181     /* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */
182     unsigned char sbr;
183
184     /* MPEG-4 ObjectType */
185     unsigned char object_type;
186
187     /* AAC header type; MP4 will be signalled as RAW also */
188     unsigned char header_type;
189
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];
196
197     /* PS: 0: off, 1: on */
198     unsigned char ps;
199 } NeAACDecFrameInfo;
200
201 char* NEAACDECAPI NeAACDecGetErrorMessage(unsigned char errcode);
202
203 unsigned long NEAACDECAPI NeAACDecGetCapabilities(void);
204
205 NeAACDecHandle NEAACDECAPI NeAACDecOpen(void);
206
207 NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder);
208
209 unsigned char NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder,
210                                                    NeAACDecConfigurationPtr config);
211
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);
218
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);
225
226 /* Init the library for DRM */
227 char NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, unsigned long samplerate,
228                                  unsigned char channels);
229
230 void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, long frame);
231
232 void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder);
233
234 void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder,
235                                  NeAACDecFrameInfo *hInfo,
236                                  unsigned char *buffer,
237                                  unsigned long buffer_size);
238
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);
245
246 char NEAACDECAPI NeAACDecAudioSpecificConfig(unsigned char *pBuffer,
247                                              unsigned long buffer_size,
248                                              mp4AudioSpecificConfig *mp4ASC);
249
250 #ifdef _WIN32
251   #pragma pack(pop)
252 #endif
253
254 #ifdef __cplusplus
255 }
256 #endif /* __cplusplus */
257
258 #endif