Source file: /~heha/hs/puh.zip/util.h

/*      lame utility library include file
 *      Copyright (c) 1999 Albert L Faber
 *      Copyright (c) 2008 Robert Hegemann
 */

#pragma once

#include "l3side.h"
#include "id3tag.h"
#include "lame_global_flags.h"
#include "quantize_pvt.h"	//calc_noise_data

/***********************************************************************
*
*  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         CRC16_POLYNOMIAL        0x8005

#define MAX_BITS_PER_CHANNEL 4095
#define MAX_BITS_PER_GRANULE 7680

/* "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


    struct replaygain_data;
#ifndef replaygain_data_defined
#define replaygain_data_defined
    typedef struct replaygain_data replaygain_t;
#endif
    struct plotting_data;
#ifndef plotting_data_defined
#define plotting_data_defined
    typedef struct plotting_data plotting_data;
#endif

/***********************************************************************
*
*  Global Type Definitions
*
***********************************************************************/

struct aligned_pointer_t {
  void*aligned;     /* pointer to ie. 128 bit aligned memory */
  void*pointer;     /* to use with malloc/free */
  aligned_pointer_t(unsigned,unsigned);
  ~aligned_pointer_t();
};

    /* "bit_stream.h" Type Definitions */

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) */
};

struct VBR_seek_info_t{
  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 */
  unsigned int nVbrNumFrames;
  unsigned long nBytesWritten;
        /* VBR tag data */
  unsigned int TotalFrameSize;
};


    /**
     *  ATH related stuff, if something new ATH related has to be added,
     *  please plugg it here into the ATH_t struct
     */
struct ATH_t{
  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_factor; /* 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_l[CBANDS]; /* ATH for long block convolution bands */
  FLOAT   cb_s[CBANDS]; /* ATH for short block convolution bands */
  FLOAT   eql_w[BLKSIZE / 2]; /* equal loudness weights (based on ATH) */
};

    /**
     *  PSY Model related stuff
     */

struct PsyConst_CB2SB_t{
  FLOAT   masking_lower[CBANDS];
  FLOAT   minval[CBANDS];
  FLOAT   rnumlines[CBANDS];
  FLOAT   mld_cb[CBANDS];
  FLOAT   mld[Max(SBMAX_l,SBMAX_s)];
  FLOAT   bo_weight[Max(SBMAX_l,SBMAX_s)]; /* band weight long scalefactor bands, at transition */
  FLOAT   attack_threshold; /* short block tuning */
  int     s3ind[CBANDS][2];
  int     numlines[CBANDS];
  int     bm[Max(SBMAX_l,SBMAX_s)];
  int     bo[Max(SBMAX_l,SBMAX_s)];
  int     npart;
  int     n_sb; /* SBMAX_l or SBMAX_s */
  FLOAT  *s3;
};


    /**
     *  global data constants
     */
struct PsyConst_t{
  FLOAT window[BLKSIZE], window_s[BLKSIZE_s / 2];
  PsyConst_CB2SB_t l;
  PsyConst_CB2SB_t s;
  PsyConst_CB2SB_t l_to_s;
  FLOAT   attack_threshold[4];
  FLOAT   decay;
  int     force_short_block_calc;
};


struct PsyStateVar_t{
  FLOAT   nb_l1[4][CBANDS], nb_l2[4][CBANDS];
  FLOAT   nb_s1[4][CBANDS], nb_s2[4][CBANDS];
  III_psy_xmin thm[4];
  III_psy_xmin en[4];
        /* loudness calculation (for adaptive threshold of hearing) */
  FLOAT   loudness_sq_save[2]; /* account for granule delay of L3psycho_anal */
  FLOAT   tot_ener[4];
  FLOAT   last_en_subshort[4][9];
  int     last_attacks[4];
  int     blocktype_old[2];
};

struct PsyResult_t{
        /* loudness calculation (for adaptive threshold of hearing) */
  FLOAT   loudness_sq[2][2]; /* loudness^2 approx. per granule and channel */
};


    /* variables used by encoder.c */
struct EncStateVar_t{
        /* variables for newmdct.c */
  FLOAT   sb_sample[2][2][18][SBLIMIT];
  FLOAT   amp_filter[32];

        /* variables used by util.c */
        /* BPC = maximum number of filter convolution windows to precompute */
#define BPC 320
  double  itime[2]; /* float precision seems to be not enough */
  sample_t *inbuf_old[2];
  sample_t *blackfilt[2 * BPC + 1];
  FLOAT   pefirbuf[19];
        /* used for padding */
  int     frac_SpF;
  int     slot_lag;
        /* variables for bitstream.c */
        /* mpeg1: buffer=511 bytes  smallest frame: 96-38(sideinfo)=58
         * max number of frames in reservoir:  8
         * mpeg2: buffer=255 bytes.  smallest frame: 24-23bytes=1
         * with VBR, if you are encoding all silence, it is possible to
         * have 8kbs/24khz frames with 1byte of data each, which means we need
         * to buffer up to 255 headers! */
        /* also, max_header_buf has to be a power of two */
#define MAX_HEADER_BUF 256
#define MAX_HEADER_LEN 40    /* max size of header is 38 */
  struct {
    int     write_timing;
    int     ptr;
    char    buf[MAX_HEADER_LEN];
  } header[MAX_HEADER_BUF];
  int     h_ptr;
  int     w_ptr;
  int     ancillary_flag;
        /* variables for reservoir.c */
  int     ResvSize;    /* in bits */
  int     ResvMax;     /* in bits */
  int     in_buffer_nsamples;
  sample_t *in_buffer_0;
  sample_t *in_buffer_1;
#ifndef  MFSIZE
# define MFSIZE  ( 3*1152 + ENCDELAY - MDCTDELAY )
#endif
  sample_t mfbuf[2][MFSIZE];
  int     mf_samples_to_encode;
  int     mf_size;
};


struct EncResult_t{
        /* simple statistics */
  int     bitrate_channelmode_hist[16][4 + 1];
  int     bitrate_blocktype_hist[16][4 + 1 + 1]; /*norm/start/short/stop/mixed(short)/sum */
  int     bitrate_index;
  int     frame_number; /* number of frames encoded             */
  int     padding;     /* padding for the current frame? */
  int     mode_ext;
  int     encoder_delay;
  int     encoder_padding; /* number of samples of padding appended to input */
};


    /* variables used by quantize.c */
struct QntStateVar_t{
        /* variables for nspsytune */
  FLOAT   longfact[SBMAX_l];
  FLOAT   shortfact[SBMAX_s];
  FLOAT   masking_lower;
  FLOAT   mask_adjust; /* the dbQ stuff */
  FLOAT   mask_adjust_short; /* the dbQ stuff */
  int     OldValue[2];
  int     CurrentStep[2];
  int     pseudohalf[SFBMAX];
  int     sfb21_extra; /* will be set in lame_init_params */
  int     substep_shaping; /* 0 = no substep
                                    1 = use substep shaping at last step(VBR only)
                                    (not implemented yet)
                                    2 = use substep inside loop
                                    3 = use substep inside loop and last step
                                  */
  char    bv_scf[576];
};

struct RpgStateVar_t{
  replaygain_t *rgdata;
        /* ReplayGain */
};

struct RpgResult_t{
  FLOAT   noclipScale; /* user-specified scale factor required for preventing clipping */
  sample_t PeakSample;
  int     RadioGain;
  int     noclipGainChange; /* gain change required for preventing clipping */
};

struct SessionConfig_t{
  int     version;     /* 0=MPEG-2/2.5  1=MPEG-1               */
  int     samplerate_index;
  int     sideinfo_len;
  int     noise_shaping; /* 0 = none
                                  1 = ISO AAC model
                                  2 = allow scalefac_select=1
                                */
  int     subblock_gain; /*  0 = no, 1 = yes */
  int     use_best_huffman; /* 0 = no.  1=outside loop  2=inside loop(slow) */
  int     noise_shaping_amp; /*  0 = ISO model: amplify all distorted bands
                                      1 = amplify within 50% of max (on db scale)
                                      2 = amplify only most distorted band
                                      3 = method 1 and refine with method 2
                                    */
  int     noise_shaping_stop; /* 0 = stop at over=0, all scalefacs amplified or
                                       a scalefac has reached max value
                                       1 = stop when all scalefacs amplified or
                                       a scalefac has reached max value
                                       2 = stop when all scalefacs amplified
                                     */
  int     full_outer_loop; /* 0 = stop early after 0 distortion found. 1 = full search */
  int     lowpassfreq;
  int     highpassfreq;
  int     samplerate_in; /* input_samp_rate in Hz. default=44.1 kHz     */
  int     samplerate_out; /* output_samp_rate. */
  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) */
  int     mode_gr;     /* granules per frame */
  int     force_ms;    /* force M/S mode.  requires mode=1            */
  int     quant_comp;
  int     quant_comp_short;
  int     use_temporal_masking_effect;
  int     use_safe_joint_stereo;
  int     preset;
  vbr_mode vbr;
  int     vbr_avg_bitrate_kbps;
  int     vbr_min_bitrate_index; /* min bitrate index */
  int     vbr_max_bitrate_index; /* max bitrate index */
  int     avg_bitrate;
  int     enforce_min_bitrate; /* strictly enforce VBR_min_bitrate normaly, it will be violated for analog silence */
  int     findReplayGain; /* find the RG value? default=0       */
  int     findPeakSample;
  int     decode_on_the_fly; /* decode on the fly? default=0                */
  int     analysis;
  int     disable_reservoir;
  int     buffer_constraint;  /* enforce ISO spec as much as possible   */
  int     free_format;
  int     write_lame_tag; /* add Xing VBR tag?                           */
  int     error_protection; /* use 2 bytes per frame for a CRC checksum. default=0 */
  int     copyright;   /* mark as copyright. default=0           */
  int     original;    /* mark as original. default=1            */
  int     extension;   /* the MP3 'private extension' bit. Meaningless */
  int     emphasis;    /* Input PCM is emphased PCM (for
                                instance from one of the rarely
                                emphased CDs), it is STRONGLY not
                                recommended to use this, because
                                psycho does not take it into account,
                                and last but not least many decoders
                                don't care about these bits          */
  MPEG_mode mode;
  short_block_t short_blocks;
  float   interChRatio;
  float   msfix;       /* Naoki's adjustment of Mid/Side maskings */
  float   ATH_offset_db;/* add to ATH this many db            */
  float   ATH_offset_factor;/* change ATH by this factor, derived from ATH_offset_db */
  float   ATHcurve;    /* change ATH formula 4 shape           */
  int     ATHtype;
  int     ATHonly;     /* only use ATH                         */
  int     ATHshort;    /* only use ATH for short blocks        */
  int     noATH;       /* disable ATH                          */
  float   ATHfixpoint;
  float   adjust_alto_db;
  float   adjust_bass_db;
  float   adjust_treble_db;
  float   adjust_sfb21_db;
  float   compression_ratio; /* sizeof(wav file)/sizeof(mp3 file)          */
        /* lowpass and highpass filter control */
  FLOAT   lowpass1, lowpass2; /* normalized frequency bounds of passband */
  FLOAT   highpass1, highpass2; /* normalized frequency bounds of passband */
        /* scale input by this amount before encoding at least not used for MP3 decoding */
  FLOAT   pcm_transform[2][2];
  FLOAT   minval;
  int  get_max_frame_buffer_size_by_constraint(int)const;
  int calcFrameLength(int, int)const;
};

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;

  bool lame_init_params_successful;
  bool lame_encode_frame_inited;
  bool iteration_init_init;
  bool fill_buffer_resample_inited;

  SessionConfig_t cfg;

        /* variables used by lame.c */
  Bit_stream_struc bs;
  III_side_info_t l3_side;
  scalefac_struct scalefac_band;
  PsyStateVar_t	sv_psy; /* DATA FROM PSYMODEL.C */
  PsyResult_t	ov_psy;
  EncStateVar_t	sv_enc; /* DATA FROM ENCODER.C */
  EncResult_t	ov_enc;
  QntStateVar_t sv_qnt; /* DATA FROM QUANTIZE.C */
  RpgStateVar_t sv_rpg;
  RpgResult_t	ov_rpg;
        /* optional ID3 tags, used in id3tag.c  */
  id3tag_spec	tag_spec;
  uint16_t nMusicCRC;
//  uint16_t _unused;

        /* CPU features */
  struct {
    unsigned MMX:1; /* Pentium MMX, Pentium II...IV, K6, K6-2,
                                   K6-III, Athlon */
    unsigned AMD_3DNow:1; /* K6-2, K6-III, Athlon      */
    unsigned SSE:1; /* Pentium III, Pentium 4    */
    unsigned SSE2:1; /* Pentium 4, K8             */
    unsigned _unused:28;
  } CPU_features;

  VBR_seek_info_t VBR_seek_table; /* used for Xing VBR header */
  ATH_t		*ATH;         /* all ATH related stuff */
  PsyConst_t	*cd_psy;
        /* used by the frame analyzer */
  plotting_data	*pinfo;
  hip_t		hip;

/* functions to replace with CPU feature optimized versions in takehiro.c */
  int     (*choose_table) (const int *, const int *const, int &);
  void    (*fft_fht) (FLOAT *, int);
  void    (*init_xrpow_core) (gr_info & cod_info, FLOAT xrpow[576], int upper,
                                    FLOAT * sum);
  lame_report_function report_all[3];
  enum reptype{
    report_msg,report_dbg,report_err
  };
  void free_id3tag();
  lame_internal_flags();
  ~lame_internal_flags();
  void fill_buffer(sample_t *const mfbuf[2],
	sample_t const *const in_buffer[2],
	int nsamples, int&n_in, int&n_out);
  int  fill_buffer_resample(
	sample_t * outbuf, int desired_len,
	sample_t const *inbuf, int len,
	int &num_used, int ch);
//lame.cpp
  int lame_encode_buffer_sample_t(
	int nsamples, unsigned char*mp3buf, int mp3buf_size);
  void lame_copy_inbuffer(
	void const* l, void const* r, int nsamples,
	enum PCMSampleType pcm_type, int jump, FLOAT s);
  bool is_valid() const;
//encoder.cpp
  int lame_encode_mp3_frame(
	sample_t const *inbuf_l,
	sample_t const *inbuf_r,
	unsigned char *mp3buf,
	int mp3buf_size);
private:
  void lame_encode_frame_init(const sample_t *const inbuf[2]);
  void updateStats();

//newmdct.cpp
public:
  void mdct_sub48(const sample_t * w0, const sample_t * w1); 
//fft.cpp
  void fft_long(FLOAT x_real[BLKSIZE], int chn, const sample_t *const data[2]) const;
  void fft_short(FLOAT x_real[3][BLKSIZE_s], int chn, const sample_t *const data[2]) const;
  void init_fft(); 
//reservoir.cpp
  int  ResvFrameBegin(int *mean_bits);
  void ResvMaxBits(int mean_bits, int &targ_bits, int &max_bits, int cbr);
  void ResvAdjust(gr_info const & gi);
  void ResvFrameEnd(int mean_bits);
//vbrquantize.cpp
  int  VBR_encode_frame(const FLOAT xr34orig[2][2][576],const FLOAT l3_xmin[2][2][SFBMAX],const int maxbits[2][2]); 
//quantize.cpp
  void CBR_iteration_loop(
	const FLOAT pe[2][2],const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
  void VBR_old_iteration_loop(
	const FLOAT pe[2][2],const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
  void VBR_new_iteration_loop(
	const FLOAT pe[2][2],const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
  void ABR_iteration_loop(
	const FLOAT pe[2][2],const FLOAT ms_ratio[2], const III_psy_ratio ratio[2][2]);
  void init_xrpow_core_init();
private:
  int VBR_old_prepare(const FLOAT pe[2][2], FLOAT const ms_ener_ratio[2],
                const III_psy_ratio ratio[2][2],
                FLOAT l3_xmin[2][2][SFBMAX],
                int frameBits[16], int min_bits[2][2], int max_bits[2][2], int bands[2][2]);
  void bitpressure_strategy(FLOAT l3_xmin[2][2][SFBMAX], const int min_bits[2][2], int max_bits[2][2])const;
  int VBR_new_prepare(
                const FLOAT pe[2][2], const III_psy_ratio ratio[2][2],
                FLOAT l3_xmin[2][2][SFBMAX], int frameBits[16], int max_bits[2][2],
                int* max_resv);
  void calc_target_bits(const FLOAT pe[2][2],FLOAT const*,int targ_bits[2][2], int*, int*);
  void init_outer_loop(gr_info&)const;
  int inc_subblock_gain(gr_info&, FLOAT xrpow[576])const;
  void amp_scalefac_bands(gr_info&, FLOAT const *, FLOAT xrpow[576], int);
  void iteration_finish_one(int,int);
  void get_framebits(int frameBits[15]);
  void VBR_encode_granule(gr_info&,const FLOAT*const,FLOAT xrpow[576],const int,int,int);
  int outer_loop(gr_info&,const FLOAT* const,FLOAT xrpow[576],const int,const int);
  int balance_noise(gr_info&,FLOAT const*,FLOAT xrpow[576],int);
  void trancate_smallspectrums(gr_info&,const FLOAT* const l3_xmin,FLOAT*const)const;
  void psfb21_analogsilence(gr_info&)const;
  int bin_search_StepSize(gr_info&,int, const int, const FLOAT xrpow[576]);
  int init_xrpow(gr_info&,FLOAT*);
//quantize_pvt.cpp
public:
  void iteration_init();
  int on_pe(const FLOAT pe[][2], int targ_bits[2], int mean_bits, int gr, int cbr);
  int calc_xmin(III_psy_ratio const *const ratio, gr_info & cod_info, FLOAT * pxmin) const;
  void set_frame_pinfo(const III_psy_ratio ratio[2][2]);
private:
  void compute_ath() const;
  void set_pinfo(gr_info & cod_info, const III_psy_ratio * const ratio, const int gr, const int ch) const;
//takehiro.cpp
public:
  void best_scalefac_store(const int gr, const int ch, III_side_info_t & l3_side) const;
/* takehiro.cpp */
  int  count_bits(const FLOAT * const xr, gr_info&, calc_noise_data*)const;
  int  noquant_count_bits(gr_info&, calc_noise_data*)const;
  void best_huffman_divide(gr_info&)const;
//void best_scalefac_store(int gr, int ch, III_side_info_t&)const;
  int  scale_bitcount(gr_info&)const;
  void huffman_init();
private:
  int mpeg1_scale_bitcount(gr_info &cod_info) const;
  int mpeg2_scale_bitcount(gr_info &cod_info) const;
  void recalc_divide_init(gr_info const &,int const *const, int*, int*, int*, int*)const;
  void recalc_divide_sub(const gr_info*,gr_info&,const int*const, const int*, const int*, const int*, const int*)const;
// bitstream.cpp
public:
  int  getframebits()const;
  int  format_bitstream();
  void flush_bitstream();
  void add_dummy_byte(unsigned char,unsigned);
  int  copy_buffer(unsigned char*,int,bool);
  void init_bit_stream_w();
  void CRC_writeheader(char*)const;
  int  compute_flushbits(int*)const;
private:
  void putheader_bits();
  void putbits2(int,int);
  void putbits_noheaders(int,int);
  void drain_into_ancillary(int);
  void writeheader(int,int);
  void encodeSideInfo2(int);
  int writeMainData();
  int huffman_coder_count1(gr_info const &);
  int Huffmancode(const unsigned,int,int,gr_info const&);
  int ShortHuffmancodebits(gr_info const&);
  int LongHuffmancodebits(gr_info const &);
  int do_gain_analysis(unsigned char*, int);
  int do_copy_buffer(unsigned char *, int);
  void AddVbrFrame();
//lame.cpp
public:
  void save_gain_values();
  int update_inbuffer_size(int);
//get_set
  int calc_maximum_input_samples_for_buffer_size(size_t)const;
//VbrTag.cpp
  void setLameTagFrameHeader(unsigned char*)const;
};

#ifndef lame_internal_flags_defined
#define lame_internal_flags_defined
    typedef struct lame_internal_flags lame_internal_flags;
#endif


/***********************************************************************
*
*  Global Function Prototype Declarations
*
***********************************************************************/
    extern int BitrateIndex(int, int, int);
    extern int FindNearestBitrate(int, int, int);
    extern int map2MP3Frequency(int freq);
    extern int SmpFrqIndex(int, int* =0);
    extern int nearestBitrateFullIndex(uint16_t brate);
    extern FLOAT ATHformula(SessionConfig_t const &, FLOAT freq);
    extern FLOAT freq2bark(FLOAT freq);
    void    disable_FPE(void);

/* log/log10 approximations */
    extern void init_log_table(void);
    extern ieee754_float32_t fast_log2(ieee754_float32_t x);

    bool isResamplingNecessary(SessionConfig_t const& cfg);


/* same as lame_decode1 (look in lame.h), but returns
   unclipped raw floating-point samples. It is declared
   here, not in lame.h, because it returns LAME's
   internal type sample_t. No more than 1152 samples
   per channel are allowed. */
    int     hip_decode1_unclipped(hip_t hip, unsigned char *mp3buf,
                                   size_t len, sample_t pcm_l[], sample_t pcm_r[]);


    extern int has_MMX(void);
    extern int has_3DNow(void);
    extern int has_SSE(void);
    extern int has_SSE2(void);



/***********************************************************************
*
*  Macros about Message Printing and Exit
*
***********************************************************************/

void lame_report_def(const char* format, va_list args);
void _cdecl lame_report_fnc(lame_report_function print_f, const char *, ...);
void _cdecl lame_errorf(const lame_internal_flags & gfc, const char *, ...);
void _cdecl lame_debugf(const lame_internal_flags & gfc, const char *, ...);
void _cdecl lame_msgf(const lame_internal_flags & gfc, const char *, ...);
#define DEBUGF  lame_debugf
#define ERRORF  lame_errorf
#define MSGF    lame_msgf

    
    extern void hip_set_pinfo(hip_t hip, plotting_data* pinfo);

Detected encoding: ASCII (7 bit)2