📄 common.h
字号:
// that a bitstream frame contains either N or N+1 slots,
// depending on the value of the padding bit. The bitrate_index
// is an index to a table. The bitrate_index indicates the
// total bitrate irrespective of the mode (stereo, joint_stereo,
// dual_channel, single_channel).
//sampling_frequency:
// Indicates the sampling frequency.
//padding_bit:
// If this bit equals '1', the bitstream frame contains an
// additional slot to adjust the mean bitrate to the sampling
// frequency, otherwise this bit will be '0'. Padding is necessary
// with sampling frequencies of 11.025 kHz, 22.05 kHz and 44.1 kHz.
// Padding may also be required in free format.
//private_bit:
// Bit for private use. This bit will not be used in the future
// by ISO/IEC.
//mode -- Indicates the mode according to Table 10. The joint stereo mode
// is intensity_stereo and/or ms_stereo.
//mode_extension:
// These bits are used in joint_stereo mode. They indicate which
// type of joint stereo coding method is applied. The frequency
// ranges, over which the intensity_stereo and ms_stereo modes are
// applied, are implicit in the algorithm.
//copyright:
// If this bit equals '0', there is no copyright on the Layer3 bitstream,
// '1' means copyright protected.
//original/copy:
// This bit equals '0' if the bitstream is a copy and '1' if it is an
// original.
//emphasis:
// Indicates the type of de-emphasis that shall be used.
//================================================================
typedef struct {
int IDex; //Add by SinceLuo 2002/3/18
int version;
int lay;
int error_protection;
int bitrate_index;
int sampling_frequency;
int padding;
int extension;
int mode; //Indicate Channal Mode
int mode_ext;
int copyright;
int original;
int emphasis;
} layer, *the_layer;
/* 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 */
al_table *alloc; /* bit allocation table read in */
int tab_num; /* number of table as loaded */
int VoiceChannelNum; /* 1 for mono, 2 for stereo */
int jsbound; /* first band of joint stereo coding */
int sblimit; /* total number of sub bands */
} frame_params;
/* Double and SANE Floating Point Type Definitions */
typedef struct IEEE_DBL_struct {
unsigned long hi;
unsigned long lo;
} IEEE_DBL;
typedef struct SANE_EXT_struct {
unsigned long l1;
unsigned long l2;
unsigned short s1;
} SANE_EXT;
/* "bit_stream.h" Type Definitions */
typedef struct bit_stream_struc {
FILE *pt; /* pointer to bit stream device */
unsigned char *buf; /* bit stream buffer */
int buf_size; /* size of buffer (in number of bytes) */
long totbit; /* bit counter of bit stream */
int buf_byte_idx; /* pointer to top byte in buffer */
int buf_bit_idx; /* pointer to top bit of top byte in buffer */
int mode; /* bit stream open in read or write mode */
int eob; /* end of buffer index */
int eobs; /* end of bit stream flag */
char format;
/* format of file in rd mode (BINARY/ASCII) */
} Bit_stream_struc;
/* Layer III side information. */
typedef struct {
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;
} my_gr_info ;
typedef struct
{
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;
}gr_info_s;
typedef struct {
unsigned main_data_begin;
unsigned private_bits;
struct {
unsigned scfsi[4];
gr_info_s gr[2];
} ch[2];
} III_side_info_t;
/* Layer III scale factors. */
typedef struct {
int l[23]; /* [cb] */
int s[3][13]; /* [window][cb] */
} III_scalefac_t[2]; /* [ch] */
/***********************************************************************
*
* Global Variable External Declarations
*
***********************************************************************/
extern char *layer_names[3];
extern char *version_names[2];
extern double s_freq[3][4];
extern int bitrate[2][3][15];
extern double multiple[64];
/***********************************************************************
*
* Global Function Prototype Declarations
*
***********************************************************************/
/* The following functions are in the file "common.c" */
extern FILE *OpenTableFile(char*);
extern int read_bit_alloc(int, al_table*);
extern int pick_table(frame_params*);
extern int js_bound(int, int);
extern void hdr_to_frps(frame_params*);
extern void WriteMP3Header(frame_params*, FILE*);
extern void WriteBitAlloc(unsigned int[2][SBLIMIT], frame_params*,
FILE*);
extern void WriteScale(unsigned int[2][SBLIMIT],
unsigned int[2][SBLIMIT], unsigned int[2][3][SBLIMIT],
frame_params*, FILE*);
extern void WriteSamples(int, unsigned int [SBLIMIT],
unsigned int[SBLIMIT], frame_params*, FILE*);
extern int NumericQ(char*);
extern int BitrateIndex(int, int, int);
extern int SmpFrqIndex(long, int*);
extern int memcheck(char*, int, int);
extern void *mem_alloc(unsigned long);
extern void mem_free(void**);
extern void double_to_extended(double*, char[10]);
extern void extended_to_double(char[10], double*);
extern void refill_buffer(Bit_stream_struc*);
extern void empty_buffer(Bit_stream_struc*, int);
extern void open_bit_stream_write(Bit_stream_struc*, char*, int);
extern BOOL open_bit_stream_read(Bit_stream_struc*, char*, int);
extern void close_bit_stream_read(Bit_stream_struc*);
extern void close_bit_stream_write(Bit_stream_struc*);
extern void alloc_buffer(Bit_stream_struc*, int);
extern void desalloc_buffer(Bit_stream_struc*);
extern void back_track_buffer(Bit_stream_struc*, int);
extern unsigned int get1bit(Bit_stream_struc*);
extern void put1bit(Bit_stream_struc*, int);
extern unsigned long look_ahead(Bit_stream_struc*, int);
extern unsigned long getbits(Bit_stream_struc*, int);
extern void putbits(Bit_stream_struc*, unsigned int, int);
extern void byte_ali_putbits(Bit_stream_struc*, unsigned int, int);
extern unsigned long byte_ali_getbits(Bit_stream_struc*, int);
extern unsigned long sstell(Bit_stream_struc*);
extern int end_bs(Bit_stream_struc*);
extern int seek_sync(Bit_stream_struc*, long, int);
extern void I_CRC_calc(frame_params*, unsigned int[2][SBLIMIT],
unsigned int*);
extern void II_CRC_calc(frame_params*, unsigned int[2][SBLIMIT],
unsigned int[2][SBLIMIT], unsigned int*);
extern void update_CRC(unsigned int, unsigned int, unsigned int*);
extern void read_absthr(FLOAT*, int);
extern unsigned int hget1bit(); /* MI */
extern unsigned long hgetbits(int);
extern unsigned long hsstell();
extern void hputbuf(unsigned int,int);
extern void rewindNbytes( int );
enum byte_order DetermineByteOrder();
void SwapBytesInWords( short *loc, int words );
void rewindNbits(int N);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -