CI130X SDK API手册  2.2.0
本手册用于描述CI130X SDK各个组件和驱动API
aaccommon.h
浏览该文件的文档.
1 /* ***** BEGIN LICENSE BLOCK *****
2  * Source last modified: $Id: aaccommon.h,v 1.1 2005/02/26 01:47:34 jrecker 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  * aaccommon.h - implementation-independent API's, datatypes, and definitions
44  **************************************************************************************/
45 
46 #ifndef _AACCOMMON_H
47 #define _AACCOMMON_H
48 
49 #include "aacdec.h"
50 #include "aacstatname.h"
51 
52 /* 12-bit syncword */
53 #define SYNCWORDH 0xff
54 #define SYNCWORDL 0xf0
55 
56 #define MAX_NCHANS_ELEM 2 /* max number of channels in any single bitstream element (SCE,CPE,CCE,LFE) */
57 
58 #define ADTS_HEADER_BYTES 7
59 #define NUM_SAMPLE_RATES 12
60 #define NUM_DEF_CHAN_MAPS 8
61 #define NUM_ELEMENTS 8
62 #define MAX_NUM_PCE_ADIF 16
63 
64 #define MAX_WIN_GROUPS 8
65 #define MAX_SFB_SHORT 15
66 #define MAX_SF_BANDS (MAX_SFB_SHORT*MAX_WIN_GROUPS) /* worst case = 15 sfb's * 8 windows for short block */
67 #define MAX_MS_MASK_BYTES ((MAX_SF_BANDS + 7) >> 3)
68 #define MAX_PRED_SFB 41
69 #define MAX_TNS_FILTERS 8
70 #define MAX_TNS_COEFS 60
71 #define MAX_TNS_ORDER 20
72 #define MAX_PULSES 4
73 #define MAX_GAIN_BANDS 3
74 #define MAX_GAIN_WIN 8
75 #define MAX_GAIN_ADJUST 7
76 
77 #define NSAMPS_LONG 1024
78 #define NSAMPS_SHORT 128
79 
80 #define NUM_SYN_ID_BITS 3
81 #define NUM_INST_TAG_BITS 4
82 
83 #define EXT_SBR_DATA 0x0d
84 #define EXT_SBR_DATA_CRC 0x0e
85 
86 #define IS_ADIF(p) ((p)[0] == 'A' && (p)[1] == 'D' && (p)[2] == 'I' && (p)[3] == 'F')
87 #define GET_ELE_ID(p) ((AACElementID)(*(p) >> (8-NUM_SYN_ID_BITS)))
88 
89 /* AAC file format */
90 enum {
91  AAC_FF_Unknown = 0, /* should be 0 on init */
92 
96 
97 };
98 
99 /* syntactic element type */
100 enum {
102 
111 };
112 
113 typedef struct _AACDecInfo {
114  /* pointers to platform-specific state information */
115  void *psInfoBase; /* baseline MPEG-4 LC decoding */
116  void *psInfoSBR; /* MPEG-4 SBR decoding */
117 
118  /* raw decoded data, before rounding to 16-bit PCM (for postprocessing such as SBR) */
122 
123  /* fill data (can be used for processing SBR or other extensions) */
124  unsigned char *fillBuf;
127 
128  /* block information */
134 
135  /* user-accessible info */
136  int bitRate;
137  int nChans;
138  int sampRate;
139  int profile;
140  int format;
142  int tnsUsed;
143  int pnsUsed;
145 
146 } AACDecInfo;
147 
148 /* decoder functions which must be implemented for each platform */
150 void FreeBuffers(AACDecInfo *aacDecInfo);
151 void ClearBuffers(AACDecInfo *aacDecInfo);
152 void ClearBuffer(void *buf, int nBytes);
153 
154 int UnpackADTSHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail);
155 int GetADTSChannelMapping(AACDecInfo *aacDecInfo, unsigned char *buf, int bitOffset, int bitsAvail);
156 int UnpackADIFHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail);
157 int SetRawBlockParams(AACDecInfo *aacDecInfo, int copyLast, int nChans, int sampRate, int profile);
158 int PrepareRawBlock(AACDecInfo *aacDecInfo);
159 int FlushCodec(AACDecInfo *aacDecInfo);
160 
161 int DecodeNextElement(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail);
162 int DecodeNoiselessData(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail, int ch);
163 
164 int Dequantize(AACDecInfo *aacDecInfo, int ch);
165 int StereoProcess(AACDecInfo *aacDecInfo);
166 int DeinterleaveShortBlocks(AACDecInfo *aacDecInfo, int ch);
167 int PNS(AACDecInfo *aacDecInfo, int ch);
168 int TNSFilter(AACDecInfo *aacDecInfo, int ch);
169 int IMDCT(AACDecInfo *aacDecInfo, int ch, int chBase, short *outbuf);
170 
171 /* SBR specific functions */
172 int InitSBR(AACDecInfo *aacDecInfo);
173 void FreeSBR(AACDecInfo *aacDecInfo);
174 int DecodeSBRBitstream(AACDecInfo *aacDecInfo, int chBase);
175 int DecodeSBRData(AACDecInfo *aacDecInfo, int chBase, short *outbuf);
176 int FlushCodecSBR(AACDecInfo *aacDecInfo);
177 
178 /* aactabs.c - global ROM tables */
179 extern const int sampRateTab[NUM_SAMPLE_RATES];
180 extern const int predSFBMax[NUM_SAMPLE_RATES];
181 extern const int channelMapTab[NUM_DEF_CHAN_MAPS];
182 extern const int elementNumChans[NUM_ELEMENTS];
183 extern const unsigned char sfBandTotalShort[NUM_SAMPLE_RATES];
184 extern const unsigned char sfBandTotalLong[NUM_SAMPLE_RATES];
185 extern const int sfBandTabShortOffset[NUM_SAMPLE_RATES];
186 extern const int sfBandTabShortTabSize[NUM_SAMPLE_RATES];
187 extern const short sfBandTabShort[76];
188 extern const int sfBandTabLongOffset[NUM_SAMPLE_RATES];
189 extern const int sfBandTabLongTabSize[NUM_SAMPLE_RATES];
190 extern const short sfBandTabLong[325];
191 extern const int tnsMaxBandsShortOffset[AAC_NUM_PROFILES];
192 extern const unsigned char tnsMaxBandsShort[2*NUM_SAMPLE_RATES];
193 extern const unsigned char tnsMaxOrderShort[AAC_NUM_PROFILES];
194 extern const int tnsMaxBandsLongOffset[AAC_NUM_PROFILES];
195 extern const unsigned char tnsMaxBandsLong[2*NUM_SAMPLE_RATES];
196 extern const unsigned char tnsMaxOrderLong[AAC_NUM_PROFILES];
197 
198 #endif /* _AACCOMMON_H */
int DecodeNextElement(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail)
Definition: aacdecelmnt.c:363
int UnpackADIFHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail)
Definition: aacfilefmt.c:306
int sbDeinterleaveReqd[2]
Definition: aaccommon.h:132
int frameCount
Definition: aaccommon.h:144
Definition: aaccommon.h:108
Definition: aaccommon.h:104
Definition: aaccommon.h:109
Definition: aaccommon.h:91
int DecodeSBRBitstream(AACDecInfo *aacDecInfo, int chBase)
Definition: aacsbr.c:176
const int sfBandTabLongOffset[NUM_SAMPLE_RATES]
Definition: aactabs.c:102
const int sfBandTabShortOffset[NUM_SAMPLE_RATES]
Definition: aactabs.c:81
int rawSampleBytes
Definition: aaccommon.h:120
const int sfBandTabShortTabSize[NUM_SAMPLE_RATES]
Definition: aactabs.c:83
int nChans
Definition: aaccommon.h:137
const int predSFBMax[NUM_SAMPLE_RATES]
Definition: aactabs.c:55
int fillCount
Definition: aaccommon.h:125
const unsigned char tnsMaxOrderLong[AAC_NUM_PROFILES]
Definition: aactabs.c:161
const unsigned char tnsMaxOrderShort[AAC_NUM_PROFILES]
Definition: aactabs.c:152
int DecodeSBRData(AACDecInfo *aacDecInfo, int chBase, short *outbuf)
Definition: aacsbr.c:252
int FlushCodec(AACDecInfo *aacDecInfo)
Definition: aacfilefmt.c:484
int PrepareRawBlock(AACDecInfo *aacDecInfo)
Definition: aacfilefmt.c:447
const int sampRateTab[NUM_SAMPLE_RATES]
Definition: aactabs.c:49
const short sfBandTabLong[325]
Definition: aactabs.c:106
const unsigned char tnsMaxBandsShort[2 *NUM_SAMPLE_RATES]
Definition: aactabs.c:147
#define AAC_MAX_NCHANS
Definition: aacdec.h:69
int FlushCodecSBR(AACDecInfo *aacDecInfo)
Definition: aacsbr.c:415
unsigned char * fillBuf
Definition: aaccommon.h:124
Definition: aaccommon.h:94
int IMDCT(AACDecInfo *aacDecInfo, int ch, int chOut, short *outbuf)
Definition: aacimdct.c:524
void FreeBuffers(AACDecInfo *aacDecInfo)
Definition: aacbuffers.c:131
void * psInfoSBR
Definition: aaccommon.h:116
int DecodeNoiselessData(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail, int ch)
Definition: aacnoiseless.c:452
int UnpackADTSHeader(AACDecInfo *aacDecInfo, unsigned char **buf, int *bitOffset, int *bitsAvail)
Definition: aacfilefmt.c:67
Definition: aaccommon.h:95
int TNSFilter(AACDecInfo *aacDecInfo, int ch)
Definition: aactns.c:180
int sbrEnabled
Definition: aaccommon.h:141
#define NUM_DEF_CHAN_MAPS
Definition: aaccommon.h:60
Definition: aaccommon.h:106
Definition: aaccommon.h:107
Definition: aaccommon.h:101
void * rawSampleBuf[2]
Definition: aaccommon.h:119
int Dequantize(AACDecInfo *aacDecInfo, int ch)
Definition: aacdequant.c:289
#define NUM_ELEMENTS
Definition: aaccommon.h:61
int SetRawBlockParams(AACDecInfo *aacDecInfo, int copyLast, int nChans, int sampRate, int profile)
Definition: aacfilefmt.c:404
int prevBlockID
Definition: aaccommon.h:129
int fillExtType
Definition: aaccommon.h:126
const int elementNumChans[NUM_ELEMENTS]
Definition: aactabs.c:67
Definition: aaccommon.h:113
int InitSBR(AACDecInfo *aacDecInfo)
Definition: aacsbr.c:99
void FreeSBR(AACDecInfo *aacDecInfo)
Definition: aacsbr.c:130
void ClearBuffer(void *buf, int nBytes)
Definition: aacbuffers.c:69
void * psInfoBase
Definition: aaccommon.h:115
const unsigned char sfBandTotalShort[NUM_SAMPLE_RATES]
Definition: aactabs.c:72
Definition: aaccommon.h:93
int PNS(AACDecInfo *aacDecInfo, int ch)
Definition: aacpns.c:270
int pnsUsed
Definition: aaccommon.h:143
int rawSampleFBits
Definition: aaccommon.h:121
AACDecInfo * AllocateBuffers(void)
Definition: aacbuffers.c:95
const unsigned char tnsMaxBandsLong[2 *NUM_SAMPLE_RATES]
Definition: aactabs.c:156
Definition: aaccommon.h:103
int sampRate
Definition: aaccommon.h:138
const int sfBandTabLongTabSize[NUM_SAMPLE_RATES]
Definition: aactabs.c:104
Definition: aaccommon.h:105
const unsigned char sfBandTotalLong[NUM_SAMPLE_RATES]
Definition: aactabs.c:76
const int tnsMaxBandsShortOffset[AAC_NUM_PROFILES]
Definition: aactabs.c:145
int profile
Definition: aaccommon.h:139
const int channelMapTab[NUM_DEF_CHAN_MAPS]
Definition: aactabs.c:60
void ClearBuffers(AACDecInfo *aacDecInfo)
Definition: aacbuffers.c:153
Definition: aaccommon.h:110
#define MAX_NCHANS_ELEM
Definition: aaccommon.h:56
int bitRate
Definition: aaccommon.h:136
const int tnsMaxBandsLongOffset[AAC_NUM_PROFILES]
Definition: aactabs.c:154
int currBlockID
Definition: aaccommon.h:130
int GetADTSChannelMapping(AACDecInfo *aacDecInfo, unsigned char *buf, int bitOffset, int bitsAvail)
Definition: aacfilefmt.c:169
int tnsUsed
Definition: aaccommon.h:142
#define AAC_NUM_PROFILES
Definition: aacdec.h:74
int StereoProcess(AACDecInfo *aacDecInfo)
Definition: aacstproc.c:187
int currInstTag
Definition: aaccommon.h:131
struct _AACDecInfo AACDecInfo
int DeinterleaveShortBlocks(AACDecInfo *aacDecInfo, int ch)
Definition: aacdequant.c:362
int adtsBlocksLeft
Definition: aaccommon.h:133
int format
Definition: aaccommon.h:140
#define NUM_SAMPLE_RATES
Definition: aaccommon.h:59
const short sfBandTabShort[76]
Definition: aactabs.c:85