📄 mp2dec.h
字号:
#ifndef _MP2AUDIO_
#define _MP2AUDIO_
#define MP2_MAX_PCM_LENGTH 1152
#define MP2_MAX_BITS_REQUIRED 11520
#define MP2_NINFOBITS 32
#define FILE_MP2_MODE 0
#define DAB_MP2_MODE 1
#include "MP2DEC_instance.h"
/*
* Define the sample rate type.
*/
typedef enum tagMP2SampleRate
{
SR_11_025kHz,
SR_12kHz,
SR_8kHz,
SR_ReservedMPEG2_5,
SR_22_05kHz,
SR_24kHz,
SR_16kHz,
SR_ReservedLSF,
SR_44_1kHz,
SR_48kHz,
SR_32kHz,
SR_Reserved
} tMP2SampleRate ;
typedef struct tagMP2Bitstream tMP2Bitstream ;
typedef tMP2Bitstream *ptMP2Bitstream ;
struct tagMP2Bitstream
{
unsigned int *bufptr;
unsigned int bitidx;
} ;
typedef struct tagMP2Header tMP2Header ;
typedef tMP2Header *ptMP2Header ;
struct tagMP2Header
{
tMP2SampleRate sample_rate ;
unsigned int samplesperchannel;
unsigned int numchans;
unsigned int packed_info;
unsigned int bits_required;
unsigned int free_format;
} ;
typedef enum tagMP2Status
{
eNoErr,
eNoSyncword,
eCRCError,
eBrokenFrame,
eEndOfBitstream,
eDataOverflow,
eCantAllocateBuffer,
eUnsupportedLayer,
eFrameDiscarded,
eReservedSamplingFrequency,
eForbiddenBitRate,
eWrongMPEGBuild
} tMP2Status ;
/*
* InitMP2Audio
* ============
*
* Description
* -----------
* Initializes the MPEG audio decoder.
* Call this function before using any other decoder functions.
*
* Syntax
* ------
* void InitMP2Audio( tMP2Instance *inst, unsigned char *in )
*
* where:
*
* inst pointer to instance data for the decoder.
* in pointer to Input buffer
*/
void RKInitMP2Audio(tMP2Instance *inst , unsigned char *in);
/*
* MP2DECSearchForSyncword
* ====================
*
* Description
* -----------
* This function searches for the syncword and decodes a frame of samples from the MP2 stream.
*
* Syntax
* ------
* tMP2Status MP2DECSearchForSyncword(tMP2Bitstream *bs,tMP2Header *hdr, unsigned short ValidCount);
*
* where:
*
* bs pointer to the structure that points to the incoming bitstream.
* hdr pointer to the structure that points to the header information.
* ValidCount number of new valid bits
* UsedCount number of used bit in function (return value)
*
* Return Value
* ------------
*
* tMP2Status function's return status:
*
* eNoErr Frame decoded ok
* eNoSyncword No syncronization word
* eUnsupportedLayer Unsupported or illegal ('00') MPEG audio layer
* eReservedSamplingFrequency Undefined sampling frequency ('11')
* eForbiddenBitRate Illegal bit rate ('1111')
*/
tMP2Status RKMP2DECSearchForSyncword(tMP2Bitstream *bs, tMP2Header *hdr, unsigned short ValidCount, unsigned int *UsedCount);
/*
* MP2DecodeData
* =============
*
* Description
* -----------
* This function decodes a frame of samples from the MP3 stream.
*
* Syntax
* ------
* tMP2Status MP2DecodeData( short *left, short *right, tMP2Bitstream *bs, int mode ) ;
*
* where:
*
* left pointer to output buffer for left-channel PCM.
* right pointer to output buffer for right-channel PCM.
* bs pointer to the structure that points to the incoming bitstream.
* mode select scalefactor crc check mode
*
* Return Value
* ------------
*
* tMP2Status function's return status:
*
* eNoErr Frame decoded ok
* eCRCError CRC error failed
* eBrokenFrame Side information is inconsistent
* eFrameDiscarded Insufficient main data to decode the frame
*
*/
tMP2Status RKMP2DecodeData(short *left, short *right, tMP2Bitstream *bs, int mode);
tMP2Status RKMP2DecodeData_DAB(short *left, short *right, tMP2Bitstream *bs, int mode);
typedef void F_MP2DEC0(tMP2Instance *inst , unsigned char *in);
typedef tMP2Status F_MP2DEC1(tMP2Bitstream *bs, tMP2Header *hdr, unsigned short ValidCount, unsigned int *UsedCount);
//typedef tMP2Status F_MP2DEC2( short *left, short *right, tMP2Bitstream *bs, int mode) ;
typedef tMP2Status F_MP2DEC2(short *left, short *right, tMP2Bitstream *bs) ;
extern F_MP2DEC0 *InitMP2Aud; // = InitMP2Audio;
extern F_MP2DEC1 *MP2SyncHeader; // = MP2DECSearchForSyncword;
extern F_MP2DEC2 *MP2DecData; // = MP2DecodeData;
#endif /* _MPGAUDIO_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -