Nut/OS  4.10.3
API Reference
mp3dec.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  * mp3dec.h - public C API for MP3 decoder
00042  **************************************************************************************/
00043 
00044 #ifndef _MP3DEC_H
00045 #define _MP3DEC_H
00046 
00047 #if defined(_WIN32) && !defined(_WIN32_WCE)
00048 #
00049 #elif defined(_WIN32) && defined(_WIN32_WCE) && defined(ARM)
00050 #
00051 #elif defined(_WIN32) && defined(WINCE_EMULATOR)
00052 #
00053 #elif defined(ARM_ADS)
00054 #
00055 #elif defined(_SYMBIAN) && defined(__WINS__)    /* Symbian emulator for Ix86 */
00056 #
00057 #elif defined(__GNUC__) && defined(__arm__)
00058 #
00059 #elif defined(__GNUC__) && defined(__i386__)
00060 #
00061 #elif defined(_OPENWAVE_SIMULATOR) || defined(_OPENWAVE_ARMULATOR)
00062 #
00063 #else
00064 #error No platform defined. See valid options in mp3dec.h
00065 #endif
00066 
00067 #ifdef __cplusplus
00068 extern "C" {
00069 #endif
00070 
00071 /* determining MAINBUF_SIZE:
00072  *   max mainDataBegin = (2^9 - 1) bytes (since 9-bit offset) = 511
00073  *   max nSlots (concatenated with mainDataBegin bytes from before) = 1440 - 9 - 4 + 1 = 1428
00074  *   511 + 1428 = 1939, round up to 1940 (4-byte align)
00075  */
00076 #ifndef MAINBUF_SIZE
00077 #define MAINBUF_SIZE    1940
00078 #endif
00079 
00080 #define MAX_NGRAN               2               /* max granules */
00081 
00082 #ifndef MAX_NCHAN
00083 #define MAX_NCHAN               2               /* max channels */
00084 #endif
00085 
00086 #define MAX_NSAMP               576             /* max samples per channel, per granule */
00087 
00088 /* map to 0,1,2 to make table indexing easier */
00089 typedef enum {
00090         MPEG1 =  0,
00091         MPEG2 =  1,
00092         MPEG25 = 2
00093 } MPEGVersion;
00094 
00095 typedef void *HMP3Decoder;
00096 
00097 enum {
00098         ERR_MP3_NONE =                  0,
00099         ERR_MP3_INDATA_UNDERFLOW =     -1,
00100         ERR_MP3_MAINDATA_UNDERFLOW =   -2,
00101         ERR_MP3_FREE_BITRATE_SYNC =    -3,
00102         ERR_MP3_OUT_OF_MEMORY =        -4,
00103         ERR_MP3_NULL_POINTER =         -5,
00104         ERR_MP3_INVALID_FRAMEHEADER =  -6,
00105         ERR_MP3_INVALID_SIDEINFO =     -7,
00106         ERR_MP3_INVALID_SCALEFACT =    -8,
00107         ERR_MP3_INVALID_HUFFCODES =    -9,
00108 
00109         ERR_UNKNOWN =                  -9999
00110 };
00111 
00112 typedef struct _MP3FrameInfo {
00113         int bitrate;
00114         int nChans;
00115         int samprate;
00116         int bitsPerSample;
00117         int outputSamps;
00118         int layer;
00119         int version;
00120 } MP3FrameInfo;
00121 
00122 /* public API */
00123 HMP3Decoder MP3InitDecoder(void);
00124 void MP3FreeDecoder(HMP3Decoder hMP3Decoder);
00125 int MP3Decode(HMP3Decoder hMP3Decoder, unsigned char **inbuf, int *bytesLeft, short *outbuf, int useSize);
00126 
00127 void MP3GetLastFrameInfo(HMP3Decoder hMP3Decoder, MP3FrameInfo *mp3FrameInfo);
00128 int MP3GetNextFrameInfo(HMP3Decoder hMP3Decoder, MP3FrameInfo *mp3FrameInfo, unsigned char *buf);
00129 int MP3FindSyncWord(unsigned char *buf, int nBytes);
00130 
00131 #ifdef __cplusplus
00132 }
00133 #endif
00134 
00135 #endif  /* _MP3DEC_H */