polygon intersector: added horizontal line reconstruction
[swftools.git] / lib / lame / quantize_pvt.h
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 char pretab[SBMAX_l];
36 extern const char slen1_tab[16];
37 extern const char slen2_tab[16];
38
39 extern const scalefac_struct sfBandIndex[9];
40
41 extern FLOAT8 pow43[PRECALC_SIZE];
42 extern FLOAT8 adj43[PRECALC_SIZE];
43 extern FLOAT8 adj43asm[PRECALC_SIZE];
44
45 #define Q_MAX 330
46
47 extern FLOAT8 pow20[Q_MAX];
48 extern FLOAT8 ipow20[Q_MAX];
49 extern FLOAT8 *iipow20_;
50
51 typedef struct calc_noise_result_t {
52     int     over_count;      /* number of quantization noise > masking */
53     FLOAT8  over_noise;      /* sum of quantization noise > masking */
54     FLOAT8  tot_noise;       /* sum of all quantization noise */
55     FLOAT8  max_noise;       /* max quantization noise */
56     float   klemm_noise;
57 } calc_noise_result;
58
59 void    compute_ath (lame_global_flags * gfp, FLOAT8 ATH_l[SBPSY_l],
60                      FLOAT8 ATH_s[SBPSY_l]);
61
62 void    ms_convert (FLOAT8 xr[2][576], FLOAT8 xr_org[2][576]);
63
64 int     on_pe (lame_global_flags *gfp, FLOAT8 pe[2][2], III_side_info_t * l3_side,
65                int targ_bits[2], int mean_bits, int gr);
66
67 void    reduce_side (int targ_bits[2], FLOAT8 ms_ener_ratio, int mean_bits,
68                      int max_bits);
69
70
71 int     bin_search_StepSize (lame_internal_flags * const gfc, gr_info * const cod_info,
72                              const int desired_rate, const int start,
73                              const FLOAT8 xrpow[576], int l3enc[576]);
74
75 int     inner_loop (lame_internal_flags * const gfc, gr_info * const cod_info, const int max_bits,
76                     const FLOAT8 xrpow[576], int l3enc[576]);
77
78 void    iteration_init (lame_global_flags *gfp);
79
80
81 int     calc_xmin (lame_global_flags *gfp, const FLOAT8 xr[576],
82                    const III_psy_ratio * const ratio, const gr_info * const cod_info,
83                    III_psy_xmin * const l3_xmin);
84
85 int     calc_noise (const lame_internal_flags * const gfc, const FLOAT8 xr[576],
86                     const int ix[576], const gr_info * const cod_info,
87                     const III_psy_xmin * const l3_xmin,
88                     const III_scalefac_t * const scalefac,
89                     III_psy_xmin * distort, calc_noise_result * const res);
90
91 void    set_frame_pinfo (lame_global_flags *gfp, FLOAT8 xr[2][2][576],
92                          III_psy_ratio ratio[2][2], int l3_enc[2][2][576],
93                          III_scalefac_t scalefac[2][2]);
94
95
96 void    quantize_xrpow (const FLOAT8 *xr, int *ix, FLOAT8 istep);
97
98 void    quantize_xrpow_ISO (const FLOAT8 *xr, int *ix, FLOAT8 istep);
99
100
101
102 /* takehiro.c */
103
104 int     count_bits (lame_internal_flags * const gfc, int * const ix, const FLOAT8 * const xr,
105                     gr_info * const cod_info);
106
107
108 void    best_huffman_divide (const lame_internal_flags * const gfc, 
109                              gr_info * const cod_info, int * const ix);
110
111 void    best_scalefac_store (const lame_internal_flags * gfc, const int gr, const int ch,
112                              int l3_enc[2][2][576], III_side_info_t * const l3_side,
113                              III_scalefac_t scalefac[2][2]);
114
115 int     scale_bitcount (III_scalefac_t * const scalefac, gr_info * const cod_info);
116
117 int     scale_bitcount_lsf (const lame_internal_flags *gfp, const III_scalefac_t * const scalefac,
118                             gr_info * const cod_info);
119
120 void    huffman_init (lame_internal_flags * const gfc);
121
122 #define LARGE_BITS 100000
123
124 #endif /* LAME_QUANTIZE_PVT_H */