📄 common.h
字号:
/************************************************************************* Global Type Definitions************************************************************************//* Structure for Reading Layer II Allocation Tables from File */typedef struct { unsigned int steps; unsigned int bits; unsigned int group; unsigned int quant;} sb_alloc, *alloc_ptr;typedef sb_alloc al_table[SBLIMIT][16];/* 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; int center; /* center present */ int surround; /* surrounds present*/ int audio_mix; /* large listening room or not? */ int matrix; /* type of dematricing */ int lfe; /* low frequency effect channel*/ int multiling_ch; /* number of multilingual channels */ int multiling_fs; /* fs of ML channels is half fs of main channels */ int multiling_lay; /* Layer IIML or Layer II ML is used*/ int ext_bit_stream_present; /* extension bitstream present? */ int n_ad_bytes; /* if yes, how many bits anc.data for mpeg2 */ int mc_pred[8]; /* prediction bit*/ int tc_alloc[12]; /* transmission channel allocation in each sbgroup*/ int predsi[8][6]; /* predictor select information*/ int delay_comp[8][6]; int pred_coef[8][6][3]; int mc_prediction_on; int tc_sbgr_select; int tc_allocation; int dyn_cross_on; int dyn_cross_LR; /* center out of Lo or Ro*/ int dyn_cross[12]; int ext_length; int ext_sync; int ext_bit; int copy_ident_bit; int copy_ident_start; int dyn_second_stereo[12];#ifdef Augmentation_7ch int aug_mtx_proc; int aug_dyn_cross_on; int aug_future_ext; int aug_tc_alloc[12]; /* transmission channel allocation in each sbgroup */ int aug_dyn_cross[12];#endif} 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 */ al_table *alloc_mc; /* MC bit allocation table read in */ al_table *alloc_ml; /* ML bit allocation table read in */ int tab_num; /* number of table as loaded */ int tab_num_mc; /* number of MC table as loaded */ int tab_num_ml; /* number of ML table as loaded */ int stereo; /* 1 for mono, 2 for stereo */ int stereomc; int stereoaug; int lfe_pos; int jsbound; /* first band of joint stereo coding */ double mnr_min; /* mnr for dynamic bitallocation */ int sblimit; /* total number of sub bands */ int sblimit_mc; /* total number of MC sub bands */ int sblimit_ml; /* total number of ML sub bands */ int phantom_c; /* phantom coding of Center signal */ int config; /* config code: 320, 310, 300, 302, 220, 210, 200, 202, 100, 102 */} 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;/* AIFF Type Definitions */typedef char ID[4];typedef struct identifier_struct{ ID name; long ck_length;}identifier;typedef struct ChunkHeader_struct { ID ckID; long ckSize;} ChunkHeader;typedef struct Chunk_struct { ID ckID; long ckSize; ID formType;} Chunk;typedef struct CommonChunk_struct { ID ckID; long ckSize; short numChannels; unsigned long numSampleFrames; short sampleSize; char sampleRate[10];} CommonChunk;typedef struct SoundDataChunk_struct { ID ckID; long ckSize; unsigned long offset; unsigned long blockSize;} SoundDataChunk;typedef struct blockAlign_struct { unsigned long offset; unsigned long blockSize;} blockAlign;typedef struct IFF_AIFF_struct { short numChannels; unsigned long numSampleFrames; short sampleSize; double sampleRate; ID/*char**/ sampleType;/*must be allocated 21.6.93 SR*/ blockAlign blkAlgn;} IFF_AIFF;/* "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;/* JMZ 08/03/1995 begin SORT*/typedef struct { int tc_channel; int audio_channel; int subband; int sbgroup; int used; double mnr; int next;} channel_sort;/* JMZ 08/03/1995 end SORT*//************************************************************************* Global Variable External Declarations************************************************************************/extern char *mode_names[4];extern char *layer_names[3];extern double s_freq[4];extern int bitrate[3][16];extern double multiple[64];extern int sbgrp[32];extern int sb_groups[12];extern int n_pred_coef[16]; extern int no_channel[8][2];extern int T2[SBGRS], T3[SBGRS], T4[SBGRS]; #ifdef Augmentation_7chextern int T5[SBGRS], T6[SBGRS]; #endifextern int T2outof[12], T3outof[12], T4outof[12]; /* L0 or R0 */ extern int T2from[12], T3from[12], T4from[12]; extern int verbosity;/************************************************************************* Global Function Prototype Declarations************************************************************************//* The following functions are in the file "common.c" */#ifdef MACINTOSHextern void set_mac_file_attr(char[MAX_NAME_SIZE], short, OsType, OsType);#endifextern void program_information(void);extern FILE *OpenTableFile(char *name);extern int read_bit_alloc(int table, al_table (*alloc));extern int pick_table(frame_params *fr_ps);extern int js_bound(int lay, int m_ext);extern void hdr_to_frps(frame_params *fr_ps);extern int BitrateIndex(int layr, int bRate);extern int SmpFrqIndex(long int sRate);extern void *mem_alloc(long unsigned int block, char *item);extern void mem_free(void **ptr_addr);extern void double_to_extended(double *pd, char *ps);extern void extended_to_double(char *ps, double *pd);extern int aiff_read_headers(FILE *file_ptr, IFF_AIFF *aiff_ptr, int *byte_per_sample);extern int aiff_seek_to_sound_data(FILE *file_ptr);extern int aiff_write_headers(FILE *file_ptr, IFF_AIFF *aiff_ptr);extern int refill_buffer(Bit_stream_struc *bs);extern void empty_buffer(Bit_stream_struc *bs, int minimum);extern void open_bit_stream_w(Bit_stream_struc *bs, char *bs_filenam, int size);extern void open_bit_stream_r(Bit_stream_struc *bs, char *bs_filenam, int size);extern void close_bit_stream_r(Bit_stream_struc *bs);extern void close_bit_stream_w(Bit_stream_struc *bs);extern void alloc_buffer(Bit_stream_struc *bs, int size);extern void desalloc_buffer(Bit_stream_struc *bs);extern unsigned int get1bit(Bit_stream_struc *bs);extern void put1bit(Bit_stream_struc *bs, int bit);extern unsigned long getbits(Bit_stream_struc *bs, int N);extern void putbits(Bit_stream_struc *bs, unsigned int val, int N);extern unsigned long sstell (Bit_stream_struc *bs);extern int end_bs (Bit_stream_struc *bs);extern int transmission_channel (frame_params *fr_ps, int sbgr, int m);extern int dyn_ch (frame_params *fr_ps, int sbgr, int m);extern int dyn_bbal (int config, int center, int dynx, int m);extern int dyn_bbal_2ndst (int dynx, int m);#ifdef Augmentation_7chextern int dyn_bbal_aug (int aug_dynx, int m);#endifextern void init_mc_pred (frame_params *fr_ps);extern void set_mc_pred (frame_params *fr_ps);extern void I_CRC_calc (frame_params *fr_ps, unsigned int (*bit_alloc)[32], unsigned int *crc);extern void II_CRC_calc (frame_params *fr_ps, unsigned int (*bit_alloc)[32], unsigned int (*scfsi)[32], unsigned int *crc);extern void II_CRC_calc_mc (frame_params *fr_ps, unsigned int (*bit_alloc)[32], unsigned int lfe_alloc, unsigned int (*scfsi)[32], unsigned int *crc);#ifdef Augmentation_7chextern void II_CRC_calc_aug (frame_params *fr_ps, unsigned int (*bit_alloc)[32], unsigned int (*scfsi)[32], unsigned int *crc);#endifextern void II_CRC_calc_ext (frame_params *fr_ps, unsigned int *x, unsigned int *crc);extern void update_CRC (unsigned int data, unsigned int length, unsigned int *crc);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -