Newer
Older
monitord / lame-3.97 / libmp3lame / .svn / text-base / quantize_pvt.h.svn-base
  1. /*
  2. * quantize_pvt include file
  3. *
  4. * Copyright (c) 1999 Takehiro TOMINAGA
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Library General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Library General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this library; if not, write to the
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21.  
  22. #ifndef LAME_QUANTIZE_PVT_H
  23. #define LAME_QUANTIZE_PVT_H
  24.  
  25. #include "l3side.h"
  26. #define IXMAX_VAL 8206 /* ix always <= 8191+15. see count_bits() */
  27.  
  28. /* buggy Winamp decoder cannot handle values > 8191 */
  29. /* #define IXMAX_VAL 8191 */
  30.  
  31. #define PRECALC_SIZE (IXMAX_VAL+2)
  32.  
  33.  
  34. extern const int nr_of_sfb_block[6][3][4];
  35. extern const int pretab[SBMAX_l];
  36. extern const int slen1_tab[16];
  37. extern const int slen2_tab[16];
  38.  
  39. extern const scalefac_struct sfBandIndex[9];
  40.  
  41. extern FLOAT pow43[PRECALC_SIZE];
  42. #ifdef TAKEHIRO_IEEE754_HACK
  43. extern FLOAT adj43asm[PRECALC_SIZE];
  44. #else
  45. extern FLOAT adj43[PRECALC_SIZE];
  46. #endif
  47.  
  48. #define Q_MAX (256+1)
  49. #define Q_MAX2 116 /* minimum possible number of
  50. -cod_info->global_gain
  51. + ((scalefac[] + (cod_info->preflag ? pretab[sfb] : 0))
  52. << (cod_info->scalefac_scale + 1))
  53. + cod_info->subblock_gain[cod_info->window[sfb]] * 8;
  54.  
  55. for long block, 0+((15+3)<<2) = 18*4 = 72
  56. for short block, 0+(15<<2)+7*8 = 15*4+56 = 116
  57. */
  58.  
  59. extern FLOAT pow20[Q_MAX+Q_MAX2+1];
  60. extern FLOAT ipow20[Q_MAX];
  61. extern FLOAT iipow20[Q_MAX2+1];
  62.  
  63. typedef struct calc_noise_result_t {
  64. FLOAT over_noise; /* sum of quantization noise > masking */
  65. FLOAT tot_noise; /* sum of all quantization noise */
  66. FLOAT max_noise; /* max quantization noise */
  67. int over_count; /* number of quantization noise > masking */
  68. int over_SSD; /* SSD-like cost of distorted bands */
  69. int bits;
  70. } calc_noise_result;
  71.  
  72.  
  73. /**
  74. * allows re-use of previously
  75. * computed noise values
  76. */
  77. typedef struct calc_noise_data_t {
  78. int global_gain;
  79. int sfb_count1;
  80. int step[39];
  81. FLOAT noise[39];
  82. FLOAT noise_log[39];
  83. } calc_noise_data;
  84.  
  85.  
  86. int on_pe (lame_global_flags *gfp, FLOAT pe[2][2], III_side_info_t * l3_side,
  87. int targ_bits[2], int mean_bits, int gr, int cbr);
  88.  
  89. void reduce_side (int targ_bits[2], FLOAT ms_ener_ratio, int mean_bits,
  90. int max_bits);
  91.  
  92.  
  93. int bin_search_StepSize (lame_internal_flags * const gfc, gr_info * const cod_info,
  94. int desired_rate, const int ch,
  95. const FLOAT xrpow[576]);
  96.  
  97. void iteration_init (lame_global_flags *gfp);
  98.  
  99.  
  100. int calc_xmin (lame_global_flags *gfp,
  101. const III_psy_ratio * const ratio,
  102. gr_info * const cod_info,
  103. FLOAT * l3_xmin);
  104.  
  105. int calc_noise (const lame_internal_flags * const gfc,
  106. const gr_info * const cod_info,
  107. const FLOAT * l3_xmin,
  108. FLOAT * distort,
  109. calc_noise_result * const res,
  110. calc_noise_data * prev_noise);
  111.  
  112. #if defined(HAVE_GTK)
  113. void set_frame_pinfo (lame_global_flags *gfp,
  114. III_psy_ratio ratio[2][2]);
  115. #endif
  116.  
  117.  
  118.  
  119.  
  120. /* takehiro.c */
  121.  
  122. int count_bits (lame_internal_flags * const gfc, const FLOAT * const xr,
  123. gr_info * const cod_info, calc_noise_data* prev_noise);
  124. int noquant_count_bits (lame_internal_flags * const gfc,
  125. gr_info * const cod_info, calc_noise_data* prev_noise);
  126.  
  127.  
  128. void best_huffman_divide (const lame_internal_flags * const gfc,
  129. gr_info * const cod_info);
  130.  
  131. void best_scalefac_store (const lame_internal_flags * gfc, const int gr, const int ch,
  132. III_side_info_t * const l3_side);
  133.  
  134. int scale_bitcount (gr_info * const cod_info);
  135. int scale_bitcount_lsf (const lame_internal_flags *gfp,
  136. gr_info * const cod_info);
  137.  
  138. void huffman_init (lame_internal_flags * const gfc);
  139.  
  140. void quantize_init (lame_internal_flags * const gfc);
  141.  
  142. void init_xrpow_core_init (lame_internal_flags * const gfc);
  143.  
  144. FLOAT athAdjust( FLOAT a, FLOAT x, FLOAT athFloor );
  145.  
  146. #define LARGE_BITS 100000
  147.  
  148. #endif /* LAME_QUANTIZE_PVT_H */
  149.