Adafruit mp3
mp3common.h
1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: RCSL 1.0/RPSL 1.0
3  *
4  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
5  *
6  * The contents of this file, and the files included with this file, are
7  * subject to the current version of the RealNetworks Public Source License
8  * Version 1.0 (the "RPSL") available at
9  * http://www.helixcommunity.org/content/rpsl unless you have licensed
10  * the file under the RealNetworks Community Source License Version 1.0
11  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
12  * in which case the RCSL will apply. You may also obtain the license terms
13  * directly from RealNetworks. You may not use this file except in
14  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks
15  * applicable to this file, the RCSL. Please see the applicable RPSL or
16  * RCSL for the rights, obligations and limitations governing use of the
17  * contents of the file.
18  *
19  * This file is part of the Helix DNA Technology. RealNetworks is the
20  * developer of the Original Code and owns the copyrights in the portions
21  * it created.
22  *
23  * This file, and the files included with this file, is distributed and made
24  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
25  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
26  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
27  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
28  *
29  * Technology Compatibility Kit Test Suite(s) Location:
30  * http://www.helixcommunity.org/content/tck
31  *
32  * Contributor(s):
33  *
34  * ***** END LICENSE BLOCK ***** */
35 
36 /**************************************************************************************
37  * Fixed-point MP3 decoder
38  * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
39  * June 2003
40  *
41  * mp3common.h - implementation-independent API's, datatypes, and definitions
42  **************************************************************************************/
43 
44 #ifndef _MP3COMMON_H
45 #define _MP3COMMON_H
46 
47 #include "mp3dec.h"
48 #include "statname.h" /* do name-mangling for static linking */
49 
50 #define MAX_SCFBD 4 /* max scalefactor bands per channel */
51 #define NGRANS_MPEG1 2
52 #define NGRANS_MPEG2 1
53 
54 /* 11-bit syncword if MPEG 2.5 extensions are enabled */
55 #define SYNCWORDH 0xff
56 #define SYNCWORDL 0xe0
57 
58 /* 12-bit syncword if MPEG 1,2 only are supported
59  * #define SYNCWORDH 0xff
60  * #define SYNCWORDL 0xf0
61  */
62 
63 typedef struct _MP3DecInfo {
64  /* pointers to platform-specific data structures */
65  void *FrameHeaderPS;
66  void *SideInfoPS;
67  void *ScaleFactorInfoPS;
68  void *HuffmanInfoPS;
69  void *DequantInfoPS;
70  void *IMDCTInfoPS;
71  void *SubbandInfoPS;
72 
73  /* buffer which must be large enough to hold largest possible main_data section */
74  unsigned char mainBuf[MAINBUF_SIZE];
75 
76  /* special info for "free" bitrate files */
77  int freeBitrateFlag;
78  int freeBitrateSlots;
79 
80  /* user-accessible info */
81  int bitrate;
82  int nChans;
83  int samprate;
84  int nGrans; /* granules per frame */
85  int nGranSamps; /* samples per granule */
86  int nSlots;
87  int layer;
88  MPEGVersion version;
89 
90  int mainDataBegin;
91  int mainDataBytes;
92 
93  int part23Length[MAX_NGRAN][MAX_NCHAN];
94 
95 } MP3DecInfo;
96 
97 typedef struct _SFBandTable {
98  short l[23];
99  short s[14];
100 } SFBandTable;
101 
102 /* decoder functions which must be implemented for each platform */
103 MP3DecInfo *AllocateBuffers(void);
104 void FreeBuffers(MP3DecInfo *mp3DecInfo);
105 int CheckPadBit(MP3DecInfo *mp3DecInfo);
106 int UnpackFrameHeader(MP3DecInfo *mp3DecInfo, unsigned char *buf);
107 int UnpackSideInfo(MP3DecInfo *mp3DecInfo, unsigned char *buf);
108 int DecodeHuffman(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int huffBlockBits, int gr, int ch);
109 int Dequantize(MP3DecInfo *mp3DecInfo, int gr);
110 int IMDCT(MP3DecInfo *mp3DecInfo, int gr, int ch);
111 int UnpackScaleFactors(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int bitsAvail, int gr, int ch);
112 int Subband(MP3DecInfo *mp3DecInfo, short *pcmBuf);
113 
114 /* mp3tabs.c - global ROM tables */
115 extern const int samplerateTab[3][3];
116 extern const short bitrateTab[3][3][15];
117 extern const short samplesPerFrameTab[3][3];
118 extern const short bitsPerSlotTab[3];
119 extern const short sideBytesTab[3][2];
120 extern const short slotTab[3][3][15];
121 extern const SFBandTable sfBandTable[3][3];
122 
123 #endif /* _MP3COMMON_H */
Definition: mp3common.h:63
Definition: mp3common.h:97