📄 libmp3enc.h
字号:
/* CopyRight (C) Sigma Designs, Inc. 2003 - 2004 All Right Reserved. Purpose: MPEG-1 Layer III audio encoder, supports LFS encoding. Description: LIBHEADER File Date: Jan.30, 2004 Note: This code is based on ISO reference DIST 10, and heavily modified and optimized by David for running it on embedded processor without floating point co-processor. total complexity: 65 MIPS (estimated on Jasper II)*/#ifndef _LIBMP3ENC_H_#define _LIBMP3ENC_H_#ifdef __cplusplusextern "C" {#endif#define u8 unsigned char#define i8 char#define u32 unsigned int#define i32 int#define i16 short int#define u16 unsigned short int#ifdef WIN32#define i64 __int64#define u64 unsigned __int64#else#define i64 long long#define u64 unsigned long long#endif#define SBLIMIT 32#define HAN_SIZE 512/* 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#ifndef FALSE#define FALSE 0#endif#ifndef TRUE#define TRUE 1#endif/* General Definitions */#define NULL_CHAR '\0'#define MAX_U_32_NUM 0xFFFFFFFF#ifndef PI#define PI 3.14159265358979#endif#define PI4 PI/4#define PI64 PI/64#define LN_TO_LOG10 0.2302585093#define VOL_REF_NUM 0#define MPEG_AUDIO_ID 1#define MPEG_PHASE2_LSF 0 /* 1995-07-11 SHN */#define MAC_WINDOW_SIZE 24#define MONO 1#define STEREO 2#define BITS_IN_A_BYTE 8//#define SBLIMIT 32#define SSLIMIT 18#define FFT_SIZE 1024//#define HAN_SIZE 512#define SCALE_BLOCK 12#define SCALE_RANGE 64#define SCALE 32768#define CRC16_POLYNOMIAL 0x8005/* Mode Extention */#define MPG_MD_LR_LR 0#define MPG_MD_LR_I 1#define MPG_MD_MS_LR 2#define MPG_MD_MS_I 3/************************************************************************* Global Type Definitions************************************************************************/typedef struct{ i32 pos; u32 reg; u32 * buf; u32 * ptr;}BitWriter;/* Header Information Structure */typedef struct { i32 version; i32 lay; i32 error_protection; i32 bitrate_index; i32 sampling_frequency; i32 padding; i32 extension; i32 mode; i32 mode_ext; i32 copyright; i32 original; i32 emphasis;} layer, *the_layer;/* Parent Structure Interpreting some Frame Parameters in Header */typedef struct { layer header; /* raw header information */ i32 actual_mode; /* when writing IS, may forget if 0 chs */ i32 stereo; /* 1 for mono, 2 for stereo */ i32 jsbound; /* first band of joint stereo coding */ i32 sblimit; /* total number of sub bands */} frame_params;typedef struct { u32 part2_3_length; u32 big_values; u32 count1; u32 global_gain; u32 scalefac_compress; u32 window_switching_flag; u32 block_type; u32 mixed_block_flag; u32 table_select[3]; i32 subblock_gain[3]; u32 region0_count; u32 region1_count; u32 preflag; u32 scalefac_scale; u32 count1table_select; u32 part2_length; u32 sfb_lmax; u32 sfb_smax; u32 address1; u32 address2; u32 address3; i32 quantizerStepSize; /* added for LSF */ u32 *sfb_partition_table; u32 slen[4]; u32 StepSize;} gr_info;typedef struct { i32 main_data_begin; /* u32 -> i32 */ u32 private_bits; i32 resvDrain; // use them for quantization i32 prevQuant[2]; // for two channels i32 prevStep[2]; // for two channels u32 scfsi[2][4]; i32 xrmax[2][2]; struct { struct gr_info_s { gr_info tt; } ch[2]; } gr[2];} III_side_info_t;/* Layer III scale factors. */typedef struct { i32 l[2][2][22]; /* [cb] */ i32 s[2][2][13][3]; /* [window][cb] */ } III_scalefac_t; /* [gr][ch] */typedef struct{ i32 samplesPerFrame; i32 whole_SpF; i32 frac_SpF; i32 slot_lag; i16 buffer[2*1152]; i32 l3_sb_sample[2][3][18][SBLIMIT]; i32 xr[2][2][576]; i32 l3_enc[2][2][576]; i32 x[2][HAN_SIZE]; i32 y[64]; i32 en_tot[2][2]; /* ch,gr */ i32 en[2][2][21]; i32 xm[2][2][21]; i32 f[32]; i32 off[2]; frame_params fr_ps; III_side_info_t l3_side; III_scalefac_t scalefac; BitWriter bw; }MP3CODEC;/* Implementations */i32 init_MP3codec(MP3CODEC *mp3codec, layer *input);i32 MP3_encoding(u8 *f_buf, MP3CODEC *mp3codec);i32 deinit_MP3codec(MP3CODEC *mp3codec, u8 *buf);i32 SmpFrqIndex(i32 sRate, i32 *version); /* convert samp frq in Hz to index */i32 getBitRateIndex(i32 kay, i32 brate, i32 version);i8 * getVersionName(i32 version);i8 * getLayerName(i32 lay);i8 * getModeName(i32 mode);#ifdef __cplusplus}#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -