summaryrefslogtreecommitdiff
path: root/audio_codec/libraac/aacdec.h (plain)
blob: f73020913075c831c064e5551a552f2f8651510e
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
80extern "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 2 /* 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 * AAC_MAINBUF_SIZE * AAC_MAX_NCHANS) /* pick something big enough to hold a bunch of frames */
101
102 /* define these to enable decoder features */
103#ifdef __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
145 ERR_UNKNOWN = -9999
146 };
147
148 typedef struct _AACIOBuf {
149 int bytesLeft;
150 unsigned char *readPtr;
151 unsigned char readBuf[AAC_INPUTBUF_SIZE];
152 short outBuf[AAC_MAX_NCHANS * AAC_MAX_NSAMPS * SBR_MUL];
153 } AACIOBuf;
154
155 typedef struct _AACFrameInfo { // should keep same as _audio_codec_config_aacdec_t in audio_codec_aac.h
156 int bitRate;
157 int nChans;
158 int sampRateCore;
159 int sampRateOut;
160 int bitsPerSample;
161 int outputSamps;
162 int profile;
163 int tnsUsed;
164 int pnsUsed;
165 int format;
166 unsigned total_byte_parsed;
167 unsigned total_sample_decoded;
168 unsigned audio_send_by_frame;
169 //#ifndef PRE_APOLLO
170 unsigned char *extra_data;
171 unsigned extradata_len;
172 //#endif
173 } AACFrameInfo;
174
175 typedef void *HAACDecoder;
176 typedef void *HAACIOBuf;
177
178 /* public C API */
179 HAACDecoder AACInitDecoder(int);
180 void AACFreeDecoder(HAACDecoder hAACDecoder);
181 int AACDecode(HAACDecoder hAACDecoder, unsigned char **inbuf, int *bytesLeft, short *outbuf);
182
183 int AACFindSyncWord(unsigned char *buf, int nBytes);
184 void AACGetLastFrameInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo);
185 void AACGetDecoderInfo(HAACDecoder hAACDecoder, AACFrameInfo *aacFrameInfo);
186 int AACSetRawBlockParams(HAACDecoder hAACDecoder, int copyLast, AACFrameInfo *aacFrameInfo);
187 int AACFlushCodec(HAACDecoder hAACDecoder);
188
189#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT
190 int AACInitTrigtabsFloat(void);
191 void AACFreeTrigtabsFloat(void);
192#endif
193
194 extern int AACDataSource;
195
196#ifdef __cplusplus
197}
198#endif
199
200#endif /* _AACDEC_H */
201