Blame libmp3lame/quantize_pvt.h

Packit 47f805
/*
Packit 47f805
 *	quantize_pvt include file
Packit 47f805
 *
Packit 47f805
 *	Copyright (c) 1999 Takehiro TOMINAGA
Packit 47f805
 *
Packit 47f805
 * This library is free software; you can redistribute it and/or
Packit 47f805
 * modify it under the terms of the GNU Library General Public
Packit 47f805
 * License as published by the Free Software Foundation; either
Packit 47f805
 * version 2 of the License, or (at your option) any later version.
Packit 47f805
 *
Packit 47f805
 * This library is distributed in the hope that it will be useful,
Packit 47f805
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 47f805
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
Packit 47f805
 * Library General Public License for more details.
Packit 47f805
 *
Packit 47f805
 * You should have received a copy of the GNU Library General Public
Packit 47f805
 * License along with this library; if not, write to the
Packit 47f805
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit 47f805
 * Boston, MA 02111-1307, USA.
Packit 47f805
 */
Packit 47f805
Packit 47f805
#ifndef LAME_QUANTIZE_PVT_H
Packit 47f805
#define LAME_QUANTIZE_PVT_H
Packit 47f805
Packit 47f805
#define IXMAX_VAL 8206  /* ix always <= 8191+15.    see count_bits() */
Packit 47f805
Packit 47f805
/* buggy Winamp decoder cannot handle values > 8191 */
Packit 47f805
/* #define IXMAX_VAL 8191 */
Packit 47f805
Packit 47f805
#define PRECALC_SIZE (IXMAX_VAL+2)
Packit 47f805
Packit 47f805
Packit 47f805
extern const int nr_of_sfb_block[6][3][4];
Packit 47f805
extern const int pretab[SBMAX_l];
Packit 47f805
extern const int slen1_tab[16];
Packit 47f805
extern const int slen2_tab[16];
Packit 47f805
Packit 47f805
extern const scalefac_struct sfBandIndex[9];
Packit 47f805
Packit 47f805
extern FLOAT pow43[PRECALC_SIZE];
Packit 47f805
#ifdef TAKEHIRO_IEEE754_HACK
Packit 47f805
extern FLOAT adj43asm[PRECALC_SIZE];
Packit 47f805
#else
Packit 47f805
extern FLOAT adj43[PRECALC_SIZE];
Packit 47f805
#endif
Packit 47f805
Packit 47f805
#define Q_MAX (256+1)
Packit 47f805
#define Q_MAX2 116      /* minimum possible number of
Packit 47f805
                           -cod_info->global_gain
Packit 47f805
                           + ((scalefac[] + (cod_info->preflag ? pretab[sfb] : 0))
Packit 47f805
                           << (cod_info->scalefac_scale + 1))
Packit 47f805
                           + cod_info->subblock_gain[cod_info->window[sfb]] * 8;
Packit 47f805
Packit 47f805
                           for long block, 0+((15+3)<<2) = 18*4 = 72
Packit 47f805
                           for short block, 0+(15<<2)+7*8 = 15*4+56 = 116
Packit 47f805
                         */
Packit 47f805
Packit 47f805
extern FLOAT pow20[Q_MAX + Q_MAX2 + 1];
Packit 47f805
extern FLOAT ipow20[Q_MAX];
Packit 47f805
Packit 47f805
typedef struct calc_noise_result_t {
Packit 47f805
    FLOAT   over_noise;      /* sum of quantization noise > masking */
Packit 47f805
    FLOAT   tot_noise;       /* sum of all quantization noise */
Packit 47f805
    FLOAT   max_noise;       /* max quantization noise */
Packit 47f805
    int     over_count;      /* number of quantization noise > masking */
Packit 47f805
    int     over_SSD;        /* SSD-like cost of distorted bands */
Packit 47f805
    int     bits;
Packit 47f805
} calc_noise_result;
Packit 47f805
Packit 47f805
Packit 47f805
/**
Packit 47f805
* allows re-use of previously
Packit 47f805
* computed noise values
Packit 47f805
*/
Packit 47f805
typedef struct calc_noise_data_t {
Packit 47f805
    int     global_gain;
Packit 47f805
    int     sfb_count1;
Packit 47f805
    int     step[39];
Packit 47f805
    FLOAT   noise[39];
Packit 47f805
    FLOAT   noise_log[39];
Packit 47f805
} calc_noise_data;
Packit 47f805
Packit 47f805
Packit 47f805
int     on_pe(lame_internal_flags * gfc, const FLOAT pe[2][2],
Packit 47f805
              int targ_bits[2], int mean_bits, int gr, int cbr);
Packit 47f805
Packit 47f805
void    reduce_side(int targ_bits[2], FLOAT ms_ener_ratio, int mean_bits, int max_bits);
Packit 47f805
Packit 47f805
Packit 47f805
void    iteration_init(lame_internal_flags * gfc);
Packit 47f805
Packit 47f805
Packit 47f805
int     calc_xmin(lame_internal_flags const *gfc,
Packit 47f805
                  III_psy_ratio const *const ratio, gr_info * const cod_info, FLOAT * l3_xmin);
Packit 47f805
Packit 47f805
int     calc_noise(const gr_info * const cod_info,
Packit 47f805
                   const FLOAT * l3_xmin,
Packit 47f805
                   FLOAT * distort, calc_noise_result * const res, calc_noise_data * prev_noise);
Packit 47f805
Packit 47f805
void    set_frame_pinfo(lame_internal_flags * gfc, const III_psy_ratio ratio[2][2]);
Packit 47f805
Packit 47f805
Packit 47f805
Packit 47f805
Packit 47f805
/* takehiro.c */
Packit 47f805
Packit 47f805
int     count_bits(lame_internal_flags const *const gfc, const FLOAT * const xr,
Packit 47f805
                   gr_info * const cod_info, calc_noise_data * prev_noise);
Packit 47f805
int     noquant_count_bits(lame_internal_flags const *const gfc,
Packit 47f805
                           gr_info * const cod_info, calc_noise_data * prev_noise);
Packit 47f805
Packit 47f805
Packit 47f805
void    best_huffman_divide(const lame_internal_flags * const gfc, gr_info * const cod_info);
Packit 47f805
Packit 47f805
void    best_scalefac_store(const lame_internal_flags * gfc, const int gr, const int ch,
Packit 47f805
                            III_side_info_t * const l3_side);
Packit 47f805
Packit 47f805
int     scale_bitcount(const lame_internal_flags * gfc, gr_info * cod_info);
Packit 47f805
Packit 47f805
void    huffman_init(lame_internal_flags * const gfc);
Packit 47f805
Packit 47f805
void    init_xrpow_core_init(lame_internal_flags * const gfc);
Packit 47f805
Packit 47f805
FLOAT   athAdjust(FLOAT a, FLOAT x, FLOAT athFloor, float ATHfixpoint);
Packit 47f805
Packit 47f805
#define LARGE_BITS 100000
Packit 47f805
Packit 47f805
#endif /* LAME_QUANTIZE_PVT_H */