vbrquantize.c File Reference

#include <config.h>
#include "lame.h"
#include "machine.h"
#include "encoder.h"
#include "util.h"
#include "vbrquantize.h"
#include "quantize_pvt.h"

Include dependency graph for vbrquantize.c:

Go to the source code of this file.

Classes

struct  algo_s
struct  calc_noise_cache

Defines

#define VOLATILE
#define DOUBLEX   double
#define MAGIC_FLOAT_def   (65536*(128))
#define MAGIC_INT_def   0x4b000000
#define QUANTFAC(rx)   adj43[rx]
#define ROUNDFAC_def   0.4054f
#define XRPOW_FTOI(src, dest)   ((dest) = (int)(src))

Typedefs

typedef algo_s algo_t
typedef void(*) quantize_f (const algo_t *)
typedef uint8_t(*) find_f (const FLOAT *, const FLOAT *, FLOAT, unsigned int, uint8_t)
typedef int(*) alloc_sf_f (const algo_t *, int *, const int *, int)
union {
   float   f
   int   i
fi_union
typedef calc_noise_cache calc_noise_cache_t

Functions

static FLOAT max_x34 (const FLOAT *xr34, unsigned int bw)
static uint8_t find_lowest_scalefac (const FLOAT xr34)
static void k_34_4 (DOUBLEX x[4], int l3[4])
static void k_34_2 (DOUBLEX x[2], int l3[2])
static void k_iso_4 (DOUBLEX x[4], int l3[4])
static void k_iso_2 (DOUBLEX x[2], int l3[2])
static FLOAT calc_sfb_noise_x34 (const FLOAT *xr, const FLOAT *xr34, unsigned int bw, uint8_t sf)
static FLOAT calc_sfb_noise_ISO (const FLOAT *xr, const FLOAT *xr34, unsigned int bw, uint8_t sf)
static uint8_t tri_calc_sfb_noise_x34 (const FLOAT *xr, const FLOAT *xr34, FLOAT l3_xmin, unsigned int bw, uint8_t sf, calc_noise_cache_t *did_it)
static uint8_t tri_calc_sfb_noise_ISO (const FLOAT *xr, const FLOAT *xr34, FLOAT l3_xmin, unsigned int bw, uint8_t sf, calc_noise_cache_t *did_it)
static uint8_t find_scalefac_x34 (const FLOAT *xr, const FLOAT *xr34, FLOAT l3_xmin, unsigned int bw, uint8_t sf_min)
static uint8_t find_scalefac_ISO (const FLOAT *xr, const FLOAT *xr34, FLOAT l3_xmin, unsigned int bw, uint8_t sf_min)
static int block_sf (algo_t *that, const FLOAT l3_xmin[SFBMAX], int vbrsf[SFBMAX], int vbrsfmin[SFBMAX])
static void quantize_x34 (const algo_t *that)
static void quantize_ISO (const algo_t *that)
static void set_subblock_gain (gr_info *cod_info, const int mingain_s[3], int sf[])
static void set_scalefacs (gr_info *cod_info, const int *vbrsfmin, int sf[], const uint8_t *max_range)
static int checkScalefactor (const gr_info *cod_info, const int vbrsfmin[SFBMAX])
static int short_block_constrain (const algo_t *that, int vbrsf[SFBMAX], const int vbrsfmin[SFBMAX], int vbrmax)
static int long_block_constrain (const algo_t *that, int vbrsf[SFBMAX], const int vbrsfmin[SFBMAX], int vbrmax)
static int bitcount (const algo_t *that)
static int quantizeAndCountBits (const algo_t *that)
static int tryGlobalStepsize (const algo_t *that, const int sfwork[SFBMAX], const int vbrsfmin[SFBMAX], int delta)
static void searchGlobalStepsizeMax (const algo_t *that, const int sfwork[SFBMAX], const int vbrsfmin[SFBMAX], int target)
static void reduce_bit_usage (lame_internal_flags *gfc, int gr, int ch)
int VBR_encode_frame (lame_internal_flags *gfc, FLOAT const xr34orig[2][2][576], FLOAT const l3_xmin[2][2][SFBMAX], int const max_bits[2][2])

Variables

static int const MAGIC_INT = MAGIC_INT_def
static DOUBLEX const ROUNDFAC = ROUNDFAC_def
static DOUBLEX const MAGIC_FLOAT = MAGIC_FLOAT_def
static DOUBLEX const ROUNDFAC_plus_MAGIC_FLOAT = ROUNDFAC_def + MAGIC_FLOAT_def
static const uint8_t max_range_short [SBMAX_s *3]
static const uint8_t max_range_long [SBMAX_l]
static const uint8_t max_range_long_lsf_pretab [SBMAX_l]


Define Documentation

#define DOUBLEX   double

Definition at line 84 of file vbrquantize.c.

Referenced by calc_sfb_noise_ISO(), calc_sfb_noise_x34(), quantize_ISO(), and quantize_x34().

#define MAGIC_FLOAT_def   (65536*(128))

Definition at line 86 of file vbrquantize.c.

#define MAGIC_INT_def   0x4b000000

Definition at line 87 of file vbrquantize.c.

#define QUANTFAC ( rx   )     adj43[rx]

Definition at line 100 of file vbrquantize.c.

#define ROUNDFAC_def   0.4054f

Definition at line 101 of file vbrquantize.c.

#define VOLATILE

Definition at line 74 of file vbrquantize.c.

#define XRPOW_FTOI ( src,
dest   )     ((dest) = (int)(src))

Definition at line 102 of file vbrquantize.c.


Typedef Documentation

typedef struct algo_s algo_t

Definition at line 41 of file vbrquantize.c.

typedef int(*) alloc_sf_f(const algo_t *, int *, const int *, int)

Definition at line 47 of file vbrquantize.c.

typedef struct calc_noise_cache calc_noise_cache_t

Definition at line 390 of file vbrquantize.c.

typedef { ... } fi_union

typedef uint8_t(*) find_f(const FLOAT *, const FLOAT *, FLOAT, unsigned int, uint8_t)

Definition at line 45 of file vbrquantize.c.

typedef void(*) quantize_f(const algo_t *)

Definition at line 43 of file vbrquantize.c.


Function Documentation

static int bitcount ( const algo_t that  )  [static]

Definition at line 1144 of file vbrquantize.c.

References algo_s::cod_info, algo_s::gfc, lame_internal_flags::mode_gr, scale_bitcount(), and scale_bitcount_lsf().

Referenced by tryGlobalStepsize().

Here is the call graph for this function:

static int block_sf ( algo_t that,
const FLOAT  l3_xmin[SFBMAX],
int  vbrsf[SFBMAX],
int  vbrsfmin[SFBMAX] 
) [static]

Definition at line 547 of file vbrquantize.c.

References algo_s::cod_info, algo_s::find, find_lowest_scalefac(), i, gr_info::max_nonzero_coeff, max_x34(), algo_s::mingain_l, algo_s::mingain_s, gr_info::psymax, gr_info::width, gr_info::xr, and algo_s::xr34orig.

Here is the call graph for this function:

static FLOAT calc_sfb_noise_ISO ( const FLOAT xr,
const FLOAT xr34,
unsigned int  bw,
uint8_t  sf 
) [static]

Definition at line 341 of file vbrquantize.c.

References DOUBLEX, ipow20, k_iso_2(), k_iso_4(), pow20, pow43, and Q_MAX2.

Referenced by tri_calc_sfb_noise_ISO().

Here is the call graph for this function:

static FLOAT calc_sfb_noise_x34 ( const FLOAT xr,
const FLOAT xr34,
unsigned int  bw,
uint8_t  sf 
) [static]

Definition at line 297 of file vbrquantize.c.

References DOUBLEX, ipow20, k_34_2(), k_34_4(), pow20, pow43, and Q_MAX2.

Referenced by tri_calc_sfb_noise_x34().

Here is the call graph for this function:

static int checkScalefactor ( const gr_info cod_info,
const int  vbrsfmin[SFBMAX] 
) [static]

Definition at line 899 of file vbrquantize.c.

References gr_info::global_gain, gr_info::preflag, pretab, gr_info::psymax, gr_info::scalefac, gr_info::scalefac_scale, gr_info::subblock_gain, and gr_info::window.

static uint8_t find_lowest_scalefac ( const FLOAT  xr34  )  [static]

Definition at line 151 of file vbrquantize.c.

References i, ipow20, and IXMAX_VAL.

Referenced by block_sf().

static uint8_t find_scalefac_ISO ( const FLOAT xr,
const FLOAT xr34,
FLOAT  l3_xmin,
unsigned int  bw,
uint8_t  sf_min 
) [static]

Definition at line 506 of file vbrquantize.c.

References i, and tri_calc_sfb_noise_ISO().

Referenced by VBR_encode_frame().

Here is the call graph for this function:

static uint8_t find_scalefac_x34 ( const FLOAT xr,
const FLOAT xr34,
FLOAT  l3_xmin,
unsigned int  bw,
uint8_t  sf_min 
) [static]

Definition at line 476 of file vbrquantize.c.

References i, and tri_calc_sfb_noise_x34().

Referenced by VBR_encode_frame().

Here is the call graph for this function:

static void k_34_2 ( DOUBLEX  x[2],
int  l3[2] 
) [static]

Definition at line 215 of file vbrquantize.c.

References IXMAX_VAL, MAGIC_FLOAT, MAGIC_INT, QUANTFAC, and XRPOW_FTOI.

Referenced by calc_sfb_noise_x34(), and quantize_x34().

static void k_34_4 ( DOUBLEX  x[4],
int  l3[4] 
) [static]

Definition at line 173 of file vbrquantize.c.

References IXMAX_VAL, MAGIC_FLOAT, MAGIC_INT, QUANTFAC, and XRPOW_FTOI.

Referenced by calc_sfb_noise_x34(), and quantize_x34().

static void k_iso_2 ( DOUBLEX  x[2],
int  l3[2] 
) [static]

Definition at line 272 of file vbrquantize.c.

References IXMAX_VAL, MAGIC_INT, ROUNDFAC, and ROUNDFAC_plus_MAGIC_FLOAT.

Referenced by calc_sfb_noise_ISO(), and quantize_ISO().

static void k_iso_4 ( DOUBLEX  x[4],
int  l3[4] 
) [static]

Definition at line 243 of file vbrquantize.c.

References IXMAX_VAL, MAGIC_INT, ROUNDFAC, and ROUNDFAC_plus_MAGIC_FLOAT.

Referenced by calc_sfb_noise_ISO(), and quantize_ISO().

static int long_block_constrain ( const algo_t that,
int  vbrsf[SFBMAX],
const int  vbrsfmin[SFBMAX],
int  vbrmax 
) [static]

Definition at line 1011 of file vbrquantize.c.

References algo_s::cod_info, algo_s::gfc, gfc, max_range_long, max_range_long_lsf_pretab, algo_s::mingain_l, lame_internal_flags::mode_gr, lame_internal_flags::noise_shaping, pretab, and gr_info::psymax.

Referenced by VBR_encode_frame().

static FLOAT max_x34 ( const FLOAT xr34,
unsigned int  bw 
) [static]

Definition at line 116 of file vbrquantize.c.

Referenced by block_sf().

static void quantize_ISO ( const algo_t that  )  [static]

Definition at line 684 of file vbrquantize.c.

References algo_s::cod_info, DOUBLEX, gr_info::global_gain, ipow20, k_iso_2(), k_iso_4(), gr_info::l3_enc, gr_info::max_nonzero_coeff, gr_info::preflag, pretab, gr_info::scalefac, gr_info::scalefac_scale, gr_info::subblock_gain, gr_info::width, gr_info::window, and algo_s::xr34orig.

Referenced by VBR_encode_frame().

Here is the call graph for this function:

static void quantize_x34 ( const algo_t that  )  [static]

Definition at line 623 of file vbrquantize.c.

References algo_s::cod_info, DOUBLEX, gr_info::global_gain, ipow20, k_34_2(), k_34_4(), gr_info::l3_enc, gr_info::max_nonzero_coeff, gr_info::preflag, pretab, gr_info::scalefac, gr_info::scalefac_scale, gr_info::subblock_gain, gr_info::width, gr_info::window, and algo_s::xr34orig.

Referenced by VBR_encode_frame().

Here is the call graph for this function:

static int quantizeAndCountBits ( const algo_t that  )  [static]

Definition at line 1157 of file vbrquantize.c.

References algo_s::cod_info, algo_s::gfc, noquant_count_bits(), gr_info::part2_3_length, and algo_s::quantize.

Referenced by tryGlobalStepsize().

Here is the call graph for this function:

static void reduce_bit_usage ( lame_internal_flags gfc,
int  gr,
int  ch 
) [static]

Definition at line 1364 of file vbrquantize.c.

References best_huffman_divide(), best_scalefac_store(), gfc, lame_internal_flags::l3_side, gr_info::part2_3_length, gr_info::part2_length, lame_internal_flags::substep_shaping, trancate_smallspectrums(), III_side_info_t::tt, and lame_internal_flags::use_best_huffman.

Here is the call graph for this function:

static void searchGlobalStepsizeMax ( const algo_t that,
const int  sfwork[SFBMAX],
const int  vbrsfmin[SFBMAX],
int  target 
) [static]

Definition at line 1330 of file vbrquantize.c.

References algo_s::cod_info, gr_info::global_gain, LARGE_BITS, gr_info::part2_length, and tryGlobalStepsize().

Here is the call graph for this function:

static void set_scalefacs ( gr_info cod_info,
const int *  vbrsfmin,
int  sf[],
const uint8_t *  max_range 
) [static]

Definition at line 855 of file vbrquantize.c.

References gr_info::global_gain, gr_info::preflag, pretab, gr_info::scalefac, gr_info::scalefac_scale, SFBMAX, gr_info::sfbmax, gr_info::subblock_gain, gr_info::window, and window.

static void set_subblock_gain ( gr_info cod_info,
const int  mingain_s[3],
int  sf[] 
) [static]

Definition at line 772 of file vbrquantize.c.

References gr_info::global_gain, i, Max, gr_info::psymax, gr_info::scalefac_scale, SFBMAX, and gr_info::subblock_gain.

static int short_block_constrain ( const algo_t that,
int  vbrsf[SFBMAX],
const int  vbrsfmin[SFBMAX],
int  vbrmax 
) [static]

Definition at line 936 of file vbrquantize.c.

References algo_s::cod_info, algo_s::gfc, gfc, max_range_short, Min, algo_s::mingain_l, lame_internal_flags::noise_shaping, and gr_info::psymax.

Referenced by VBR_encode_frame().

static uint8_t tri_calc_sfb_noise_ISO ( const FLOAT xr,
const FLOAT xr34,
FLOAT  l3_xmin,
unsigned int  bw,
uint8_t  sf,
calc_noise_cache_t did_it 
) [static]

Definition at line 429 of file vbrquantize.c.

References calc_sfb_noise_ISO(), calc_noise_cache::valid, and calc_noise_cache::value.

Referenced by find_scalefac_ISO().

Here is the call graph for this function:

static uint8_t tri_calc_sfb_noise_x34 ( const FLOAT xr,
const FLOAT xr34,
FLOAT  l3_xmin,
unsigned int  bw,
uint8_t  sf,
calc_noise_cache_t did_it 
) [static]

Definition at line 394 of file vbrquantize.c.

References calc_sfb_noise_x34(), calc_noise_cache::valid, and calc_noise_cache::value.

Referenced by find_scalefac_x34().

Here is the call graph for this function:

static int tryGlobalStepsize ( const algo_t that,
const int  sfwork[SFBMAX],
const int  vbrsfmin[SFBMAX],
int  delta 
) [static]

Definition at line 1299 of file vbrquantize.c.

References algo_s::alloc, bitcount(), algo_s::cod_info, LARGE_BITS, quantizeAndCountBits(), and gr_info::xrpow_max.

Referenced by searchGlobalStepsizeMax().

Here is the call graph for this function:

int VBR_encode_frame ( lame_internal_flags gfc,
FLOAT const   xr34orig[2][2][576],
FLOAT const   l3_xmin[2][2][SFBMAX],
int const  max_bits[2][2] 
)

Definition at line 1481 of file vbrquantize.c.

References algo_s::alloc, lame_internal_flags::channels_out, algo_s::cod_info, algo_s::find, find_scalefac_ISO(), find_scalefac_x34(), gfc, algo_s::gfc, lame_internal_flags::l3_side, long_block_constrain(), lame_internal_flags::mode_gr, lame_internal_flags::quantization, algo_s::quantize, quantize_ISO(), quantize_x34(), short_block_constrain(), SHORT_TYPE, III_side_info_t::tt, and algo_s::xr34orig.

Referenced by VBR_new_iteration_loop().

Here is the call graph for this function:


Variable Documentation

float f

Definition at line 78 of file vbrquantize.c.

Referenced by apply_preset(), calc_xmin(), compute_ffts(), ConvertFromIeeeExtended(), init_s3_values(), iteration_init(), L3psycho_anal(), L3psycho_anal_ns(), mask_add(), ns_msfix(), and parse_args_from_string().

int i

Definition at line 79 of file vbrquantize.c.

Referenced by add_dummy_byte(), addVbr(), all_scalefactors_not_negative(), analyzeResult(), AnalyzeSamples(), best_huffman_divide(), best_scalefac_store(), BitrateIndex(), block_sf(), check_vbr_header(), compute_ath(), compute_masking_s(), copy_buffer(), CRC_update(), CRC_writeheader(), decodeMP3_clipchoice(), display_bitrate(), do_layer1(), do_layer2(), drain_into_ancillary(), fft_long(), fft_short(), fht(), fill_buffer(), fill_buffer_resample(), find_lowest_scalefac(), find_scalefac_ISO(), find_scalefac_x34(), FindNearestBitrate(), findpixmap(), format_bitstream(), free_id3tag(), freegfc(), get_audio_common(), get_framebits(), GetTitleGain(), gpk_bargraph_draw(), gpk_graph_draw(), gpk_rectangle_draw(), huffman_coder_count1(), huffman_init(), I_step_one(), I_step_two(), id3tag_genre_list(), id3tag_set_genre(), II_step_one(), II_step_two(), init_fft(), init_layer2(), init_layer3(), init_numline(), init_s3_values(), init_xrpow(), init_xrpow_core_c(), iteration_init(), L3psycho_anal(), L3psycho_anal_ns(), lame_bitrate_block_type_hist(), lame_bitrate_hist(), lame_bitrate_kbps(), lame_bitrate_stereo_mode_hist(), lame_block_type_hist(), lame_decoder(), lame_encode_buffer(), lame_encode_buffer_float(), lame_encode_buffer_int(), lame_encode_buffer_interleaved(), lame_encode_buffer_long(), lame_encode_buffer_long2(), lame_encode_buffer_sample_t(), lame_encode_frame_init(), lame_init_params(), lame_stereo_mode_hist(), LongHuffmancodebits(), main(), make_decode_tables(), mask_add(), maxvalue(), ms_convert(), noquant_count_bits(), parse_args(), plot_frame(), psycho_loudness_approx(), psymodel_init(), ResetSampleFrequency(), scale_bitcount_lsf(), scfsi_calc(), set_pinfo(), set_subblock_gain(), sync_buffer(), unpack_read_samples(), window_subband(), writeMainData(), and Xing_seek_table().

DOUBLEX const MAGIC_FLOAT = MAGIC_FLOAT_def [static]

Definition at line 109 of file vbrquantize.c.

Referenced by k_34_2(), and k_34_4().

int const MAGIC_INT = MAGIC_INT_def [static]

Definition at line 105 of file vbrquantize.c.

Referenced by k_34_2(), k_34_4(), k_iso_2(), and k_iso_4().

const uint8_t max_range_long[SBMAX_l] [static]

Initial value:

 {
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0
}

Definition at line 751 of file vbrquantize.c.

Referenced by long_block_constrain().

const uint8_t max_range_long_lsf_pretab[SBMAX_l] [static]

Initial value:

 {
    7, 7, 7, 7, 7, 7, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}

Definition at line 755 of file vbrquantize.c.

Referenced by long_block_constrain().

const uint8_t max_range_short[SBMAX_s *3] [static]

Initial value:

 {
    15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
    0, 0, 0
}

Definition at line 745 of file vbrquantize.c.

Referenced by short_block_constrain().

DOUBLEX const ROUNDFAC = ROUNDFAC_def [static]

Definition at line 107 of file vbrquantize.c.

DOUBLEX const ROUNDFAC_plus_MAGIC_FLOAT = ROUNDFAC_def + MAGIC_FLOAT_def [static]

Definition at line 110 of file vbrquantize.c.

Referenced by k_iso_2(), and k_iso_4().


Generated on Sun Dec 2 11:37:11 2007 for LAME by  doxygen 1.5.2