blob: 6d22a9ed426983f98c736c7cb57dce8be1318a22
1 | /* ***** BEGIN LICENSE BLOCK ***** |
2 | * Source last modified: $Id: aacdec.h,v 1.8 2005/11/10 00:15:08 margotm Exp $ |
3 | * |
4 | * Portions Copyright (c) 1995-2005 RealNetworks, Inc. All Rights Reserved. |
5 | * |
6 | * The contents of this file, and the files included with this file, |
7 | * are subject to the current version of the RealNetworks Public |
8 | * Source License (the "RPSL") available at |
9 | * http://www.helixcommunity.org/content/rpsl unless you have licensed |
10 | * the file under the current version of the RealNetworks Community |
11 | * Source License (the "RCSL") available at |
12 | * http://www.helixcommunity.org/content/rcsl, in which case the RCSL |
13 | * will apply. You may also obtain the license terms directly from |
14 | * RealNetworks. You may not use this file except in compliance with |
15 | * the RPSL or, if you have a valid RCSL with RealNetworks applicable |
16 | * to this file, the RCSL. Please see the applicable RPSL or RCSL for |
17 | * the rights, obligations and limitations governing use of the |
18 | * contents of the file. |
19 | * |
20 | * This file is part of the Helix DNA Technology. RealNetworks is the |
21 | * developer of the Original Code and owns the copyrights in the |
22 | * portions it created. |
23 | * |
24 | * This file, and the files included with this file, is distributed |
25 | * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY |
26 | * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS |
27 | * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES |
28 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET |
29 | * ENJOYMENT OR NON-INFRINGEMENT. |
30 | * |
31 | * Technology Compatibility Kit Test Suite(s) Location: |
32 | * http://www.helixcommunity.org/content/tck |
33 | * |
34 | * Contributor(s): |
35 | * |
36 | * ***** END LICENSE BLOCK ***** */ |
37 | |
38 | /************************************************************************************** |
39 | * Fixed-point HE-AAC decoder |
40 | * Jon Recker (jrecker@real.com) |
41 | * February 2005 |
42 | * |
43 | * aacdec.h - public C API for AAC decoder |
44 | **************************************************************************************/ |
45 | |
46 | #ifndef _AACDEC_H |
47 | #define _AACDEC_H |
48 | |
49 | #define _ARC32 |
50 | |
51 | #if defined(_WIN32) && !defined(_WIN32_WCE) |
52 | # |
53 | #elif defined(_WIN32) && defined(_WIN32_WCE) && defined(ARM) |
54 | # |
55 | #elif defined(_WIN32) && defined(WINCE_EMULATOR) |
56 | # |
57 | #elif defined (__arm) && defined (__ARMCC_VERSION) |
58 | # |
59 | #elif defined(_SYMBIAN) && defined(__WINS__) |
60 | # |
61 | #elif defined(__GNUC__) && defined(__arm__) |
62 | # |
63 | #elif defined(__GNUC__) && defined(__i386__) |
64 | # |
65 | #elif defined(__GNUC__) && defined(__amd64__) |
66 | # |
67 | #elif defined(__GNUC__) && (defined(__powerpc__) || defined(__POWERPC__)) |
68 | # |
69 | #elif defined(_OPENWAVE_SIMULATOR) || defined(_OPENWAVE_ARMULATOR) |
70 | # |
71 | #elif defined(_SOLARIS) && !defined(__GNUC__) |
72 | # |
73 | #elif defined(_ARC32) |
74 | #define __inline _Inline |
75 | #else |
76 | #error No platform defined. See valid options in aacdec.h |
77 | #endif |
78 | |
79 | #ifdef __cplusplus |
80 | extern "C" { |
81 | #endif |
82 | |
83 | /* according to spec (13818-7 section 8.2.2, 14496-3 section 4.5.3) |
84 | * max size of input buffer = |
85 | * 6144 bits = 768 bytes per SCE or CCE-I |
86 | * 12288 bits = 1536 bytes per CPE |
87 | * 0 bits = 0 bytes per CCE-D (uses bits from the SCE/CPE/CCE-I it is coupled to) |
88 | */ |
89 | #ifndef AAC_MAX_NCHANS /* if max channels isn't set in makefile, */ |
90 | #define AAC_MAX_NCHANS 6 /* set to default max number of channels */ |
91 | #endif |
92 | #define AAC_MAX_NSAMPS 1024 |
93 | #define AAC_MAINBUF_SIZE (768 * AAC_MAX_NCHANS) |
94 | |
95 | #define AAC_NUM_PROFILES 3 |
96 | #define AAC_PROFILE_MP 0 |
97 | #define AAC_PROFILE_LC 1 |
98 | #define AAC_PROFILE_SSR 2 |
99 | |
100 | #define AAC_INPUTBUF_SIZE (2 * 768 * 4) /* pick something big enough to hold a bunch of frames */ |
101 | |
102 | /* define these to enable decoder features */ |
103 | #ifndef __ARC600__ |
104 | #define HELIX_FEATURE_AUDIO_CODEC_AAC_SBR |
105 | #endif /* __ARC600__ */ |
106 | #if defined(HELIX_FEATURE_AUDIO_CODEC_AAC_SBR) |
107 | #define AAC_ENABLE_SBR |
108 | #endif // HELIX_FEATURE_AUDIO_CODEC_AAC_SBR. |
109 | #define AAC_ENABLE_MPEG4 |
110 | |
111 | #ifdef AAC_ENABLE_SBR |
112 | #define SBR_MUL 2 |
113 | #else |
114 | #define SBR_MUL 1 |
115 | #endif |
116 | |
117 | enum { |
118 | ERR_AAC_NONE = 0, |
119 | ERR_AAC_INDATA_UNDERFLOW = -1, |
120 | ERR_AAC_NULL_POINTER = -2, |
121 | ERR_AAC_INVALID_ADTS_HEADER = -3, |
122 | ERR_AAC_INVALID_ADIF_HEADER = -4, |
123 | ERR_AAC_INVALID_FRAME = -5, |
124 | ERR_AAC_MPEG4_UNSUPPORTED = -6, |
125 | ERR_AAC_CHANNEL_MAP = -7, |
126 | ERR_AAC_SYNTAX_ELEMENT = -8, |
127 | |
128 | ERR_AAC_DEQUANT = -9, |
129 | ERR_AAC_STEREO_PROCESS = -10, |
130 | ERR_AAC_PNS = -11, |
131 | ERR_AAC_SHORT_BLOCK_DEINT = -12, |
132 | ERR_AAC_TNS = -13, |
133 | ERR_AAC_IMDCT = -14, |
134 | ERR_AAC_NCHANS_TOO_HIGH = -15, |
135 | |
136 | ERR_AAC_SBR_INIT = -16, |
137 | ERR_AAC_SBR_BITSTREAM = -17, |
138 | ERR_AAC_SBR_DATA = -18, |
139 | ERR_AAC_SBR_PCM_FORMAT = -19, |
140 | ERR_AAC_SBR_NCHANS_TOO_HIGH = -20, |
141 | ERR_AAC_SBR_SINGLERATE_UNSUPPORTED = -21, |
142 | |
143 | ERR_AAC_RAWBLOCK_PARAMS = -22, |
144 | ERR_AAC_COFF_EXCEED_RANGE = -23, |
145 | ERR_AAC_HUFFMAN_DECODING = -24, |
146 | ERR_AAC_SPEC_NOT_MATCH = -25, |
147 | ERR_AAC_INVALID_ADTS_SYNCWORD = -26, |
148 | ERR_AAC_SSR_GAIN_NOT_ADDED = -27, |
149 | ERR_AAC_EXIT_DECODE = -28, |
150 | |
151 | ERR_UNKNOWN = -9999 |
152 | }; |
153 | |
154 | typedef struct _AACIOBuf { |
155 | int bytesLeft; |
156 | unsigned char *readPtr; |
157 | unsigned char readBuf[AAC_INPUTBUF_SIZE]; |
158 | short outBuf[AAC_MAX_NCHANS * AAC_MAX_NSAMPS * SBR_MUL]; |
159 | } AACIOBuf; |
160 | |
161 | typedef struct _AACFrameInfo { // should keep same as _audio_codec_config_aacdec_t in audio_codec_aac.h |
162 | int bitRate; |
163 | int nChans; |
164 | int sampRateCore; |
165 | int sampRateOut; |
166 | int bitsPerSample; |
167 | int outputSamps; |
168 | int profile; |
169 | int tnsUsed; |
170 | int pnsUsed; |
171 | int format; |
172 | unsigned total_byte_parsed; |
173 | unsigned total_sample_decoded; |
174 | unsigned audio_send_by_frame; |
175 | //#ifndef PRE_APOLLO |
176 | unsigned char *extra_data; |
177 | unsigned extradata_len; |
178 | //#endif |
179 | } AACFrameInfo; |
180 | |
181 | typedef void *HAACDecoder; |
182 | typedef void *HAACIOBuf; |
183 | |
184 | /* public C API */ |
185 | HAACDecoder AACInitDecoder(); |
186 | void AACFreeDecoder(HAACDecoder hAACDecoder); |
187 | int AACDecode(HAACDecoder hAACDecoder, unsigned char **inbuf, int *bytesLeft, short *outbuf); |
188 | |
189 | int AACFindSyncWord(unsigned char *buf, int nBytes); |
190 | void AACGetLastFrameInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo); |
191 | void AACGetDecoderInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo); |
192 | int AACSetRawBlockParams(HAACDecoder hAACDecoder, int copyLast, AACFrameInfo *aacFrameInfo); |
193 | int AACFlushCodec(HAACDecoder hAACDecoder); |
194 | |
195 | #ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT |
196 | int AACInitTrigtabsFloat(void); |
197 | void AACFreeTrigtabsFloat(void); |
198 | #endif |
199 | |
200 | extern int AACDataSource; |
201 | |
202 | #ifdef __cplusplus |
203 | } |
204 | #endif |
205 | |
206 | #endif /* _AACDEC_H */ |
207 |