www.pudn.com > mp3decoder.rar > COMMON.H


/*********************************************** 
copyright by Haia Tech 
www.haia2004.com 
************************************************/ 
 
 
 
#ifndef	_COMMON_H_ 
#define	_COMMON_H_ 
 
//#include  
 
/* MPEG Header Definitions - Mode Values */ 
#define	MPG_MD_STEREO           0 
#define	MPG_MD_JOINT_STEREO     1 
#define	MPG_MD_DUAL_CHANNEL     2 
#define	MPG_MD_MONO             3  
 
#define	SYNC_WORD			0xfff 
#define	SYNC_WORD_LENGTH	12 
 
#define	ALIGNING			8 
 
#define	MINIMUM				4    /* Minimum size of the buffer in bytes */ 
#define	MAX_LENGTH			32	/* Maximum length of word written or read from bit stream */ 
 
#define	BINARY				0	/*Binary input file*/ 
#define	READ_MODE			0	/*Decode mode only*/ 
 
#define	FALSE				0 
#define	TRUE				1 
 
#define	MIN(A, B)			((A) < (B) ? (A) : (B)) 
 
#define	SBLIMIT				32 
#define	SSLIMIT				18 
#define	HAN_SIZE			512 
#define	SCALE				32768 
 
#define	PI					3.14159265358979 
#define	PI64				PI/64 
#define	PI4					PI/4 
 
#define bitsPerSlot         8 
 
/*mp3比特流的缓冲*/ 
#define	BUFFER_SIZE			4096 
/*part2_3区的缓冲*/ 
#define	BITSTREAM_BUFSIZE	2048 
#define	ETHER_SIZE			512 
 
 
 
 
/* Header Information Structure */ 
typedef struct { 
    int version; 
    int lay; 
    int error_protection; 
    int bitrate_index; 
    int sampling_frequency; 
    int padding; 
    int extension; 
    int mode; 
    int mode_ext; 
    int copyright; 
    int original; 
    int emphasis; 
} layer;  
 
typedef double SS[SBLIMIT][SSLIMIT]; 
 
 
/* Parent Structure Interpreting some Frame Parameters in Header */ 
typedef struct { 
    layer       *header;        /* raw header information */ 
    int         actual_mode;    /* when writing IS, may forget if 0 chs */ 
    int         stereo;         /* 1 for mono, 2 for stereo */ 
    int         jsbound;        /* first band of joint stereo coding */ 
    int         sblimit;        /* total number of sub bands */ 
} frame_params; 
 
typedef struct { 
    unsigned short *buf;         /* bit stream buffer */ 
    unsigned long           totbit;         /* bit counter of bit stream */ 
    unsigned int            read_ptr;      /* pointer to top byte in buffer */ 
    unsigned int            bit_len;      /* pointer to top bit of top byte in buffer */ 
    unsigned int            write_ptr;   /* pointer to write byte in buffer */ 
    unsigned int            eof;            /* end of buffer index */ 
    unsigned int            eobs;           /* end of bit stream flag */ 
} Bit_stream_struc; 
 
/* Layer III side information. */ 
 
struct Granule { 
			unsigned part2_3_length; 
			unsigned big_values; 
			unsigned global_gain; 
			unsigned scalefac_compress; 
			unsigned window_switching_flag; 
			unsigned block_type;  
			unsigned mixed_block_flag; 
			unsigned table_select[3];  
			unsigned subblock_gain[3]; 
			unsigned region0_count; 
			unsigned region1_count; 
			unsigned preflag; 
			unsigned scalefac_scale; 
			unsigned count1table_select; 
}; 
 
typedef struct { 
	unsigned main_data_begin; 
	unsigned private_bits; 
	unsigned scfsi[2][4]; 
} III_side_info_t; 
 
typedef struct { 
	int l[23];			/* [cb] */ 
	int s[3][13];		/* [window][cb] */ 
} III_scalefac_t[2];	/* [ch] */ 
 
 
 
 
struct BandIndex{ 
	int l[23]; 
	int s[14]; 
}; 
 
void mp3(); 
 
void open_bit_stream_r(); 
 
unsigned int getbit(int N); 
int seek_sync( unsigned int sync); 
 
int js_bound(int lay, int m_ext); 
void hdr_to_frps(); 
void quest_stream(unsigned int *ptr); 
 
void hputbuf(unsigned int val); 
unsigned int hgetbits(int N); 
void rewindNbits(int N); 
void rewindNbytes(int N); 
 
 
#endif	/*_COMMON_H_*/