📄 util.h
字号:
/* * lame utility library include file * * Copyright (c) 1999 Albert L Faber * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */#ifndef LAME_UTIL_H#define LAME_UTIL_H/************************************************************************* Global Include Files************************************************************************/#include "machine.h"#include "encoder.h"#include "lame.h"#include "lame_global_flags.h"#include "lame-analysis.h"#include "id3tag.h"#include "gain_analysis.h"#if HAVE_INTTYPES_H# include <inttypes.h>#else# if HAVE_STDINT_H# include <stdint.h># endif#endif#ifdef __cplusplusextern "C" {#endif/************************************************************************* Global Definitions************************************************************************/#ifndef FALSE#define FALSE 0#endif#ifndef TRUE#define TRUE (!FALSE)#endif#ifdef UINT_MAX# define MAX_U_32_NUM UINT_MAX#else# define MAX_U_32_NUM 0xFFFFFFFF#endif#ifndef PI# ifdef M_PI# define PI M_PI# else# define PI 3.14159265358979323846# endif#endif#ifdef M_LN2# define LOG2 M_LN2#else# define LOG2 0.69314718055994530942#endif#ifdef M_LN10# define LOG10 M_LN10#else# define LOG10 2.30258509299404568402#endif#ifdef M_SQRT2# define SQRT2 M_SQRT2#else# define SQRT2 1.41421356237309504880#endif#define HAN_SIZE 512#define CRC16_POLYNOMIAL 0x8005#define MAX_BITS 4095/* "bit_stream.h" Definitions */#define BUFFER_SIZE LAME_MAXMP3BUFFER#define Min(A, B) ((A) < (B) ? (A) : (B))#define Max(A, B) ((A) > (B) ? (A) : (B))/* log/log10 approximations */#ifdef USE_FAST_LOG#define FAST_LOG10(x) (fast_log2(x)*(LOG2/LOG10))#define FAST_LOG(x) (fast_log2(x)*LOG2)#define FAST_LOG10_X(x,y) (fast_log2(x)*(LOG2/LOG10*(y)))#define FAST_LOG_X(x,y) (fast_log2(x)*(LOG2*(y)))#else#define FAST_LOG10(x) log10(x)#define FAST_LOG(x) log(x)#define FAST_LOG10_X(x,y) (log10(x)*(y))#define FAST_LOG_X(x,y) (log(x)*(y))#endif/************************************************************************* Global Type Definitions************************************************************************/ /* "bit_stream.h" Type Definitions */ typedef struct bit_stream_struc { unsigned char *buf; /* bit stream buffer */ int buf_size; /* size of buffer (in number of bytes) */ int 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 */ /* format of file in rd mode (BINARY/ASCII) */ } Bit_stream_struc;#include "l3side.h" /* variables used for --nspsytune */ typedef struct { /* variables for nspsytune */ FLOAT last_en_subshort[4][9]; int last_attacks[4]; FLOAT pefirbuf[19]; FLOAT longfact[SBMAX_l]; FLOAT shortfact[SBMAX_s]; /* short block tuning */ FLOAT attackthre; FLOAT attackthre_s; /* variables for nspsytune2 */ FILE *pass1fp; } nsPsy_t; typedef struct { int sum; /* what we have seen so far */ int seen; /* how many frames we have seen in this chunk */ int want; /* how many frames we want to collect into one chunk */ int pos; /* actual position in our bag */ int size; /* size of our bag */ int *bag; /* pointer to our bag */ } VBR_seek_info_t; /** * ATH related stuff, if something new ATH related has to be added, * please plugg it here into the ATH_t struct */ typedef struct { int use_adjust; /* method for the auto adjustment */ FLOAT aa_sensitivity_p; /* factor for tuning the (sample power) point below which adaptive threshold of hearing adjustment occurs */ FLOAT adjust; /* lowering based on peak volume, 1 = no lowering */ FLOAT adjust_limit; /* limit for dynamic ATH adjust */ FLOAT decay; /* determined to lower x dB each second */ FLOAT floor; /* lowest ATH value */ FLOAT l[SBMAX_l]; /* ATH for sfbs in long blocks */ FLOAT s[SBMAX_s]; /* ATH for sfbs in short blocks */ FLOAT psfb21[PSFB21]; /* ATH for partitionned sfb21 in long blocks */ FLOAT psfb12[PSFB12]; /* ATH for partitionned sfb12 in short blocks */ FLOAT cb[CBANDS]; /* ATH for convolution bands */ FLOAT eql_w[BLKSIZE / 2]; /* equal loudness weights (based on ATH) */ } ATH_t; /** * PSY Model related stuff */ typedef struct { FLOAT mask_adjust; /* the dbQ stuff */ FLOAT mask_adjust_short; /* the dbQ stuff */ int tonalityPatch; /* temporaly needed by VBR */ FLOAT cwlimit; FLOAT prvTonRed[CBANDS]; } PSY_t;#define MAX_CHANNELS 2 struct lame_internal_flags { /******************************************************************** * internal variables NOT set by calling program, and should not be * * modified by the calling program * ********************************************************************/ /* * Some remarks to the Class_ID field: * The Class ID is an Identifier for a pointer to this struct. * It is very unlikely that a pointer to lame_global_flags has the same 32 bits * in it's structure (large and other special properties, for instance prime). * * To test that the structure is right and initialized, use: * if ( gfc -> Class_ID == LAME_ID ) ... * Other remark: * If you set a flag to 0 for uninit data and 1 for init data, the right test * should be "if (flag == 1)" and NOT "if (flag)". Unintended modification * of this element will be otherwise misinterpreted as an init. */# define LAME_ID 0xFFF88E3B unsigned long Class_ID; int lame_encode_frame_init; int iteration_init_init; int fill_buffer_resample_init;#ifndef MFSIZE# define MFSIZE ( 3*1152 + ENCDELAY - MDCTDELAY )#endif sample_t mfbuf[2][MFSIZE]; struct { void (*msgf) (const char *format, va_list ap); void (*debugf) (const char *format, va_list ap); void (*errorf) (const char *format, va_list ap); } report; int mode_gr; /* granules per frame */ int channels_in; /* number of channels in the input data stream (PCM or decoded PCM) */ int channels_out; /* number of channels in the output data stream (not used for decoding) */ FLOAT resample_ratio; /* input_samp_rate/output_samp_rate */ int mf_samples_to_encode; int mf_size; int VBR_min_bitrate; /* min bitrate index */ int VBR_max_bitrate; /* max bitrate index */ int bitrate_index; int samplerate_index; int mode_ext; /* lowpass and highpass filter control */ FLOAT lowpass1, lowpass2; /* normalized frequency bounds of passband */ FLOAT highpass1, highpass2; /* normalized frequency bounds of passband */ int filter_type; /* 0=polyphase filter, 1= FIR filter 2=MDCT filter(bad) */ int quantization; /* 0 = ISO formual, 1=best amplitude */ int noise_shaping; /* 0 = none 1 = ISO AAC model 2 = allow scalefac_select=1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -