2 * quantize_pvt include file
4 * Copyright (c) 1999 Takehiro TOMINAGA
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.
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.
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.
22 #ifndef LAME_QUANTIZE_PVT_H
23 #define LAME_QUANTIZE_PVT_H
26 #define IXMAX_VAL 8206 /* ix always <= 8191+15. see count_bits() */
28 /* buggy Winamp decoder cannot handle values > 8191 */
29 /* #define IXMAX_VAL 8191 */
31 #define PRECALC_SIZE (IXMAX_VAL+2)
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];
39 extern const scalefac_struct sfBandIndex
[9];
41 extern FLOAT8 pow43
[PRECALC_SIZE
];
42 extern FLOAT8 adj43
[PRECALC_SIZE
];
43 extern FLOAT8 adj43asm
[PRECALC_SIZE
];
47 extern FLOAT8 pow20
[Q_MAX
];
48 extern FLOAT8 ipow20
[Q_MAX
];
49 extern FLOAT8
*iipow20_
;
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 */
59 void compute_ath (lame_global_flags
* gfp
, FLOAT8 ATH_l
[SBPSY_l
],
60 FLOAT8 ATH_s
[SBPSY_l
]);
62 void ms_convert (FLOAT8 xr
[2][576], FLOAT8 xr_org
[2][576]);
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
);
67 void reduce_side (int targ_bits
[2], FLOAT8 ms_ener_ratio
, int mean_bits
,
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]);
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]);
78 void iteration_init (lame_global_flags
*gfp
);
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
);
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
);
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]);
96 void quantize_xrpow (const FLOAT8
*xr
, int *ix
, FLOAT8 istep
);
98 void quantize_xrpow_ISO (const FLOAT8
*xr
, int *ix
, FLOAT8 istep
);
104 int count_bits (lame_internal_flags
* const gfc
, int * const ix
, const FLOAT8
* const xr
,
105 gr_info
* const cod_info
);
108 void best_huffman_divide (const lame_internal_flags
* const gfc
,
109 gr_info
* const cod_info
, int * const ix
);
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]);
115 int scale_bitcount (III_scalefac_t
* const scalefac
, gr_info
* const cod_info
);
117 int scale_bitcount_lsf (const lame_internal_flags
*gfp
, const III_scalefac_t
* const scalefac
,
118 gr_info
* const cod_info
);
120 void huffman_init (lame_internal_flags
* const gfc
);
122 #define LARGE_BITS 100000
124 #endif /* LAME_QUANTIZE_PVT_H */