mp3common.h

Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK ***** 
00002  * Version: RCSL 1.0/RPSL 1.0 
00003  *  
00004  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 
00005  *      
00006  * The contents of this file, and the files included with this file, are 
00007  * subject to the current version of the RealNetworks Public Source License 
00008  * Version 1.0 (the "RPSL") available at 
00009  * http://www.helixcommunity.org/content/rpsl unless you have licensed 
00010  * the file under the RealNetworks Community Source License Version 1.0 
00011  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 
00012  * in which case the RCSL will apply. You may also obtain the license terms 
00013  * directly from RealNetworks.  You may not use this file except in 
00014  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 
00015  * applicable to this file, the RCSL.  Please see the applicable RPSL or 
00016  * RCSL for the rights, obligations and limitations governing use of the 
00017  * contents of the file.  
00018  *  
00019  * This file is part of the Helix DNA Technology. RealNetworks is the 
00020  * developer of the Original Code and owns the copyrights in the portions 
00021  * it created. 
00022  *  
00023  * This file, and the files included with this file, is distributed and made 
00024  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
00025  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
00026  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
00027  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
00028  * 
00029  * Technology Compatibility Kit Test Suite(s) Location: 
00030  *    http://www.helixcommunity.org/content/tck 
00031  * 
00032  * Contributor(s): 
00033  *  
00034  * ***** END LICENSE BLOCK ***** */ 
00035 
00036 /**************************************************************************************
00037  * Fixed-point MP3 decoder
00038  * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
00039  * June 2003
00040  *
00041  * mp3common.h - implementation-independent API's, datatypes, and definitions
00042  **************************************************************************************/
00043 
00044 #ifndef _MP3COMMON_H
00045 #define _MP3COMMON_H
00046 
00047 #include <contrib/hxmp3/mp3dec.h>
00048 #include <contrib/hxmp3/statname.h> /* do name-mangling for static linking */
00049 
00050 #define MAX_SCFBD       4       /* max scalefactor bands per channel */
00051 #define NGRANS_MPEG1    2
00052 #define NGRANS_MPEG2    1
00053 
00054 /* 11-bit syncword if MPEG 2.5 extensions are enabled */
00055 #define SYNCWORDH       0xff
00056 #define SYNCWORDL       0xe0
00057 
00058 /* 12-bit syncword if MPEG 1,2 only are supported  */
00059 //#define   SYNCWORDH       0xff
00060 //#define   SYNCWORDL       0xf0
00061 
00062 typedef struct _MP3DecInfo {
00063     /* pointers to platform-specific data structures */
00064     void *FrameHeaderPS;
00065     void *SideInfoPS;
00066     void *ScaleFactorInfoPS;
00067     void *HuffmanInfoPS;
00068     void *DequantInfoPS;
00069     void *IMDCTInfoPS;
00070     void *SubbandInfoPS;
00071 
00072     /* buffer which must be large enough to hold largest possible main_data section */
00073     unsigned char mainBuf[MAINBUF_SIZE];
00074 
00075     /* special info for "free" bitrate files */
00076     int freeBitrateFlag;
00077     int freeBitrateSlots;
00078 
00079     /* user-accessible info */
00080     int bitrate;
00081     int nChans;
00082     int samprate;
00083     int nGrans;             /* granules per frame */
00084     int nGranSamps;         /* samples per granule */
00085     int nSlots;
00086     int layer;
00087     MPEGVersion version;
00088 
00089     int mainDataBegin;
00090     int mainDataBytes;
00091 
00092     int part23Length[MAX_NGRAN][MAX_NCHAN];
00093 
00094 } MP3DecInfo;
00095 
00096 typedef struct _SFBandTable {
00097     short l[23];
00098     short s[14];
00099 } SFBandTable;
00100 
00101 /* decoder functions which must be implemented for each platform */
00102 MP3DecInfo *AllocateBuffers(void);
00103 void FreeBuffers(MP3DecInfo *mp3DecInfo);
00104 int CheckPadBit(MP3DecInfo *mp3DecInfo);
00105 int UnpackFrameHeader(MP3DecInfo *mp3DecInfo, unsigned char *buf);
00106 int UnpackSideInfo(MP3DecInfo *mp3DecInfo, unsigned char *buf);
00107 int DecodeHuffman(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int huffBlockBits, int gr, int ch);
00108 int Dequantize(MP3DecInfo *mp3DecInfo, int gr);
00109 int IMDCT(MP3DecInfo *mp3DecInfo, int gr, int ch);
00110 int UnpackScaleFactors(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int bitsAvail, int gr, int ch);
00111 int Subband(MP3DecInfo *mp3DecInfo, short *pcmBuf);
00112 
00113 /* mp3tabs.c - global ROM tables */
00114 extern const int samplerateTab[3][3];
00115 extern const short bitrateTab[3][3][15];
00116 extern const short samplesPerFrameTab[3][3];
00117 extern const short bitsPerSlotTab[3];
00118 extern const short sideBytesTab[3][2];
00119 extern const short slotTab[3][3][15];
00120 extern const SFBandTable sfBandTable[3][3];
00121 
00122 #endif  /* _MP3COMMON_H */

© 2000-2010 by contributors - visit http://www.ethernut.de/