MP3 APIs
重要
The MP3 API v1.0 is the lastest stable MP3 APIs. It supports MPEG-1, MPEG-2 and MPEG-2.5 standard Layer3 decoding. All new applications should use MP3 API v1.0.
MP3 API Categories
- MP3 APIs:
MP3InitDecoder()
- allocate memory for platform-specific data and clear all the user-accessible fieldsMP3FreeDecoder()
- free platform-specific data allocated by InitMP3Decoder and zero out the contents of MP3DecInfo structMP3FindSyncWord()
- locate the next byte-alinged sync word in the raw mp3 streamMP3Decode()
- decode one frame of MP3 dataMP3GetLastFrameInfo()
- get info about last MP3 frame decoded (number of sampled decoded, sample rate, bitrate, etc.)MP3GetNextFrameInfo()
- parse MP3 frame header
API Reference
Header File
Functions
-
HMP3Decoder MP3InitDecoder(void)
Init the decoder of MP3.
This API init the mp3 decoder module:
allocate memory for platform-specific data
clear all the user-accessible fields
- 参数
None –
- 返回
None
-
void MP3FreeDecoder(HMP3Decoder hMP3Decoder)
Free the decoder of MP3.
This API free the mp3 decoder module:
free platform-specific data allocated by InitMP3Decoder
zero out the contents of MP3DecInfo struct
- 参数
HMP3Decoder – valid MP3 decoder instance pointer
- 返回
None
-
int MP3Decode(HMP3Decoder hMP3Decoder, unsigned char **inbuf, int *bytesLeft, short *outbuf, int useSize)
Decode one frame of MP3 data.
- 参数
hMP3Decoder – valid MP3 decoder instance pointer
inbuf – double pointer to buffer of MP3 data (containing headers + mainData)
bytesLeft – number of valid bytes remaining in inbuf
outbuf – pointer to outbuf, big enough to hold one frame of decoded PCM samples
useSize – flag indicating whether MP3 data is normal MPEG format (useSize = 0) or reformatted as “self-contained” frames (useSize = 1)
- 返回
error code, defined in mp3dec.h (0 means no error, < 0 means error)
-
void MP3GetLastFrameInfo(HMP3Decoder hMP3Decoder, MP3FrameInfo *mp3FrameInfo)
Get info about last MP3 frame decoded.
This API get the info about last mp3 decoded:
number of sampled decoded, sample rate, bitrate, etc.
- 参数
hMP3Decoder – valid MP3 decoder instance pointer
mp3FrameInfo – pointer to MP3FrameInfo struct
- 返回
None
-
int MP3GetNextFrameInfo(HMP3Decoder hMP3Decoder, MP3FrameInfo *mp3FrameInfo, unsigned char *buf)
Parse MP3 frame header.
- 参数
hMP3Decoder – valid MP3 decoder instance pointer
mp3FrameInfo – pointer to MP3FrameInfo struct
buf – pointer to buffer containing valid MP3 frame header
- 返回
error code, defined in mp3dec.h (0 means no error, < 0 means error)
-
int MP3FindSyncWord(unsigned char *buf, int nBytes)
locate the next byte-alinged sync word in the raw mp3 stream
- 参数
buf – buffer to search for sync word
nBytes – max number of bytes to search in buffer
- 返回
offset to first sync word (bytes from start of buf)
-1 if sync not found after searching nBytes
Structures
-
struct _MP3FrameInfo
Macros
-
MAINBUF_SIZE
-
MAX_NGRAN
-
MAX_NCHAN
-
MAX_NSAMP
Type Definitions
-
typedef void *HMP3Decoder
-
typedef struct _MP3FrameInfo MP3FrameInfo
Enumerations
-
enum err_mp3_t
Values:
-
enumerator ERR_MP3_NONE
-
enumerator ERR_MP3_INDATA_UNDERFLOW
-
enumerator ERR_MP3_MAINDATA_UNDERFLOW
-
enumerator ERR_MP3_FREE_BITRATE_SYNC
-
enumerator ERR_MP3_OUT_OF_MEMORY
-
enumerator ERR_MP3_NULL_POINTER
-
enumerator ERR_MP3_INVALID_FRAMEHEADER
-
enumerator ERR_MP3_INVALID_SIDEINFO
-
enumerator ERR_MP3_INVALID_SCALEFACT
-
enumerator ERR_MP3_INVALID_HUFFCODES
-
enumerator ERR_MP3_INVALID_DEQUANTIZE
-
enumerator ERR_MP3_INVALID_IMDCT
-
enumerator ERR_MP3_INVALID_SUBBAND
-
enumerator ERR_UNKNOWN
-
enumerator ERR_MP3_NONE