- #define _DEBUG_MP3
- #ifndef _COMMON_H_
- #define _COMMON_H_
- //#include <stdio.h>
- #include "Include.h"
- /* 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 SBLIMIT 32
- #define SSLIMIT 18
- #define PI 3.1415926
- #define bitsPerSlot 8
- /*mp3比特流的缓冲*/
- #define BUFFER_SIZE 4096
- /*part2_3区的缓冲*/
- #define BITSTREAM_BUFSIZE 4096
- /* 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 float 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 {
- S16 *buf; /* bit stream buffer */
- int totbit; /* bit counter of bit stream */
- int read_ptr; /* pointer to top byte in buffer */
- int bit_len; /* pointer to top bit of top byte in buffer */
- int write_ptr; /* pointer to write byte in buffer */
- int eof; /* end of buffer index */
- int eobs; /* end of bit stream flag */
- } Bit_stream_struc;
- /* Layer III side information. */
- struct Granule {
- int part2_3_length;
- int big_values;
- int global_gain;
- int scalefac_compress;
- int window_switching_flag;
- int block_type;
- int mixed_block_flag;
- int table_select[3];
- int subblock_gain[3];
- int region0_count;
- int region1_count;
- int preflag;
- int scalefac_scale;
- int count1table_select;
- };
- typedef struct {
- int main_data_begin;
- int private_bits;
- int 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];
- };
- /*============================================================================*/
- /*============================================================================*/
- extern U32 totpos;
- extern U8* mp3_src;
- extern U32 mp3_dat_size;
- extern frame_params fr_ps;
- extern Bit_stream_struc bs;
- extern float s_freq[4];
- extern U32 buf_byte_idx;
- extern struct Granule grle[2][2];
- extern const struct BandIndex sfBandIndex[3];
- extern S8 bs_buf[BITSTREAM_BUFSIZE];
- /*============================================================================*/
- /*============================================================================*/
- /*============================================================================*/
- //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_*/