removed more 'context'.

lame now segfaults.
This commit is contained in:
markt
2000-11-01 18:22:18 +00:00
parent 9e12167e04
commit 90d8eed82d
9 changed files with 76 additions and 84 deletions
+1 -2
View File
@@ -710,8 +710,7 @@ INLINE static void mdct_long(FLOAT8 *out, FLOAT8 *in)
}
void mdct_sub48( context *gfc, sample_t *w0, sample_t *w1,
void mdct_sub48( lame_internal_flags *gfc, sample_t *w0, sample_t *w1,
FLOAT8 mdct_freq[2][2][576] )
{
int gr, k, ch;
+4 -4
View File
@@ -41,7 +41,7 @@
#define NSFIRLEN 21
int L3para_read( context * const gfc,
int L3para_read( lame_internal_flags * const gfc,
FLOAT8 sfreq, int numlines[CBANDS],int numlines_s[CBANDS],
FLOAT8 minval[CBANDS],
FLOAT8 s3_l[CBANDS][CBANDS],
@@ -54,7 +54,7 @@ int L3para_read( context * const gfc,
int *, int *, int *, int *);
/* addition of simultaneous masking Naoki Shibata 2000/7 */
INLINE FLOAT8 mask_add(FLOAT8 m1,FLOAT8 m2,int k,int b, context * const gfc)
INLINE FLOAT8 mask_add(FLOAT8 m1,FLOAT8 m2,int k,int b, lame_internal_flags * const gfc)
{
static const FLOAT8 table1[] = {
3.3246 *3.3246 ,3.23837*3.23837,3.15437*3.15437,3.00412*3.00412,2.86103*2.86103,2.65407*2.65407,2.46209*2.46209,2.284 *2.284 ,
@@ -107,7 +107,7 @@ INLINE FLOAT8 mask_add(FLOAT8 m1,FLOAT8 m2,int k,int b, context * const gfc)
return (m1+m2)*table1[i];
}
int L3psycho_anal( context * const gfc,
int L3psycho_anal( lame_internal_flags * const gfc,
sample_t *buffer[2],int gr_out ,
FLOAT8 *ms_ratio,
FLOAT8 *ms_ratio_next,
@@ -1285,7 +1285,7 @@ int L3psycho_anal( context * const gfc,
int L3para_read(context * const gfc, FLOAT8 sfreq, int *numlines_l,int *numlines_s,
int L3para_read(lame_internal_flags * const gfc, FLOAT8 sfreq, int *numlines_l,int *numlines_s,
FLOAT8 *minval,
FLOAT8 s3_l[CBANDS][CBANDS], FLOAT8 s3_s[CBANDS][CBANDS],
FLOAT8 *SNR,
+35 -35
View File
@@ -49,7 +49,7 @@
************************************************************************/
static int
init_outer_loop (
init_outer_loop(
gr_info * const cod_info,
III_scalefac_t * const scalefac,
const FLOAT8 xr [576],
@@ -99,7 +99,7 @@ init_outer_loop (
/* fresh scalefactors are all zero
*/
memset (scalefac, 0, sizeof(III_scalefac_t));
memset(scalefac,0,sizeof(III_scalefac_t));
/* check if there is some energy we have to quantize
* and calculate xrpow matching our fresh scalefactors
@@ -134,8 +134,8 @@ typedef enum {
} binsearchDirection_t;
int
bin_search_StepSize (
context * const gfc,
bin_search_StepSize(
lame_internal_flags * const gfc,
gr_info * const cod_info,
const int desired_rate,
const int start,
@@ -153,7 +153,7 @@ bin_search_StepSize (
do {
cod_info->global_gain = StepSize;
nBits = count_bits (gfc, l3enc, xrpow, cod_info);
nBits = count_bits(gfc,l3enc,xrpow,cod_info);
if (CurrentStep == 1) break; /* nothing to adjust anymore */
@@ -203,8 +203,8 @@ bin_search_StepSize (
***************************************************************************/
int
inner_loop (
context * const gfc,
inner_loop(
lame_internal_flags * const gfc,
gr_info * const cod_info,
const int max_bits,
const FLOAT8 xrpow [576],
@@ -212,11 +212,11 @@ inner_loop (
{
int bits;
assert (max_bits >= 0);
assert(max_bits >= 0);
/* scalefactors may have changed, so count bits
*/
bits = count_bits (gfc, l3enc, xrpow, cod_info);
bits=count_bits(gfc,l3enc,xrpow,cod_info);
/* increase quantizer stepsize until needed bits are below maximum
*/
@@ -243,7 +243,7 @@ inner_loop (
INLINE
static int
loop_break (
loop_break(
const gr_info * const cod_info,
const III_scalefac_t * const scalefac )
{
@@ -276,7 +276,7 @@ loop_break (
INLINE
static int
quant_compare (
quant_compare(
const int experimentalX,
const calc_noise_result * const best,
const calc_noise_result * const calc )
@@ -365,8 +365,8 @@ quant_compare (
*************************************************************************/
static void
amp_scalefac_bands (
const context * const gfc,
amp_scalefac_bands(
const lame_internal_flags * const gfc,
const gr_info * const cod_info,
III_scalefac_t * const scalefac,
FLOAT8 distort [4][SBMAX_l],
@@ -376,7 +376,7 @@ amp_scalefac_bands (
int start, end, l,i,j,sfb;
FLOAT8 ifqstep34,distort_thresh;
if ( cod_info->scalefac_scale == 0 ) {
if (cod_info->scalefac_scale == 0) {
ifqstep34 = 1.29683955465100964055; /* 2**(.75*.5)*/
} else {
ifqstep34 = 1.68179283050742922612; /* 2**(.75*1) */
@@ -386,12 +386,12 @@ amp_scalefac_bands (
* In that case, just amplify bands with distortion
* within 95% of largest distortion/masking ratio */
distort_thresh = -900;
for ( sfb = 0; sfb < cod_info->sfb_lmax; sfb++ ) {
for (sfb = 0; sfb < cod_info->sfb_lmax; sfb++) {
distort_thresh = Max(distort[0][sfb],distort_thresh);
}
for ( sfb = cod_info->sfb_smin; sfb < 12; sfb++ ) {
for ( i = 0; i < 3; i++ ) {
for (sfb = cod_info->sfb_smin; sfb < 12; sfb++) {
for (i = 0; i < 3; i++ ) {
distort_thresh = Max(distort[i+1][sfb],distort_thresh);
}
}
@@ -404,11 +404,11 @@ amp_scalefac_bands (
int asfb = -1,ablk=0,astart=0,aend=0;
FLOAT8 max_dist = 0;
for ( sfb = 0; sfb < cod_info->sfb_lmax; sfb++ ) {
for (sfb = 0; sfb < cod_info->sfb_lmax; sfb++ ) {
start = gfc->scalefac_band.l[sfb];
end = gfc->scalefac_band.l[sfb+1];
if ( distort[0][sfb]>distort_thresh ) {
if (distort[0][sfb]>distort_thresh ) {
if (distort[0][sfb]-distort_thresh > max_dist) {
max_dist = distort[0][sfb]-distort_thresh;
asfb = sfb;
@@ -426,10 +426,10 @@ amp_scalefac_bands (
max_dist = 0;
asfb = -1;
for ( j=0,sfb = cod_info->sfb_smin; sfb < 12; sfb++ ) {
for (j=0,sfb = cod_info->sfb_smin; sfb < 12; sfb++ ) {
start = gfc->scalefac_band.s[sfb];
end = gfc->scalefac_band.s[sfb+1];
for ( i = 0; i < 3; i++ ) {
for (i = 0; i < 3; i++ ) {
if ( distort[i+1][sfb]>distort_thresh) {
if (distort[i+1][sfb]>max_dist) {
max_dist = distort[i+1][sfb];
@@ -581,7 +581,7 @@ amp_scalefac_bands (
static void
inc_scalefac_scale (
const context * const gfc,
const lame_internal_flags * const gfc,
gr_info * const cod_info,
III_scalefac_t * const scalefac,
FLOAT8 xrpow[576] )
@@ -634,7 +634,7 @@ inc_scalefac_scale (
static int
inc_subblock_gain (
const context * const gfc,
const lame_internal_flags * const gfc,
gr_info * const cod_info,
III_scalefac_t * const scalefac,
FLOAT8 xrpow[576] )
@@ -712,7 +712,7 @@ inc_subblock_gain (
INLINE
static int
balance_noise (
const context * const gfc,
const lame_internal_flags * const gfc,
gr_info * const cod_info,
III_scalefac_t * const scalefac,
FLOAT8 distort[4][SBMAX_l],
@@ -792,7 +792,7 @@ balance_noise (
static int
outer_loop (
context * const gfc,
lame_internal_flags * const gfc,
gr_info * const cod_info,
const FLOAT8 xr[576], /* magnitudes of spectral values */
const III_psy_xmin * const l3_xmin, /* allowed distortion of the scalefactor */
@@ -1000,7 +1000,7 @@ outer_loop (
static void
iteration_finish (
context * const gfc,
lame_internal_flags * const gfc,
FLOAT8 xr [2][2][576],
int l3_enc [2][2][576],
III_psy_ratio ratio [2][2],
@@ -1063,7 +1063,7 @@ iteration_finish (
static int
VBR_prepare (
context * const gfc,
lame_internal_flags * const gfc,
FLOAT8 pe [2][2],
FLOAT8 ms_ener_ratio [2],
FLOAT8 xr [2][2][576],
@@ -1118,7 +1118,7 @@ VBR_prepare (
static void
VBR_encode_granule (
context * const gfc,
lame_internal_flags * const gfc,
gr_info * const cod_info,
FLOAT8 xr[576], /* magnitudes of spectral values */
const III_psy_xmin * const l3_xmin, /* allowed distortion of the scalefactor */
@@ -1219,7 +1219,7 @@ VBR_encode_granule (
static void
get_framebits (
context * const gfc,
lame_internal_flags * const gfc,
int * const analog_mean_bits,
int * const min_mean_bits,
int frameBits[15] )
@@ -1261,7 +1261,7 @@ get_framebits (
INLINE
static int
calc_min_bits (
const context * const gfc,
const lame_internal_flags * const gfc,
const gr_info * const cod_info,
const int pe,
const FLOAT8 ms_ener_ratio,
@@ -1324,7 +1324,7 @@ calc_min_bits (
INLINE
static int
calc_max_bits (
const context * const gfc,
const lame_internal_flags * const gfc,
const int frameBits[15],
const int min_bits )
{
@@ -1357,7 +1357,7 @@ calc_max_bits (
void
VBR_iteration_loop (
context * const gfc,
lame_internal_flags * const gfc,
FLOAT8 pe [2][2],
FLOAT8 ms_ener_ratio[2],
FLOAT8 xr [2][2][576],
@@ -1542,7 +1542,7 @@ VBR_iteration_loop (
static void
calc_target_bits (
context * const gfc,
lame_internal_flags * const gfc,
FLOAT8 pe [2][2],
FLOAT8 ms_ener_ratio [2],
int targ_bits [2][2],
@@ -1644,7 +1644,7 @@ calc_target_bits (
void ABR_iteration_loop
(
context * const gfc,
lame_internal_flags * const gfc,
FLOAT8 pe [2][2],
FLOAT8 ms_ener_ratio[2],
FLOAT8 xr [2][2][576],
@@ -1735,7 +1735,7 @@ void ABR_iteration_loop
void iteration_loop
(
context * const gfc,
lame_internal_flags * const gfc,
FLOAT8 pe [2][2],
FLOAT8 ms_ener_ratio[2],
FLOAT8 xr [2][2][576],
+6 -6
View File
@@ -156,7 +156,7 @@ FLOAT8 adj43[PRECALC_SIZE];
/* initialization for iteration_loop */
/************************************************************************/
void
iteration_init( context * const gfc )
iteration_init( lame_internal_flags * const gfc )
{
III_side_info_t * const l3_side = &gfc->l3_side;
int i;
@@ -342,7 +342,7 @@ void ms_convert(FLOAT8 xr[2][576],FLOAT8 xr_org[2][576])
* allocate bits among 2 channels based on PE
* mt 6/99
************************************************************************/
int on_pe(context *gfc,FLOAT8 pe[2][2],III_side_info_t *l3_side,
int on_pe(lame_internal_flags *gfc,FLOAT8 pe[2][2],III_side_info_t *l3_side,
int targ_bits[2],int mean_bits, int gr)
{
gr_info *cod_info;
@@ -452,7 +452,7 @@ void reduce_side(int targ_bits[2],FLOAT8 ms_ener_ratio,int mean_bits,int max_bit
returns number of sfb's with energy > ATH
*/
int calc_xmin(
const context * const gfc,
const lame_internal_flags * const gfc,
const FLOAT8 xr [576],
const III_psy_ratio * const ratio,
const gr_info * const cod_info,
@@ -552,7 +552,7 @@ int calc_xmin(
/*************************************************************************/
/* mt 5/99: Function: Improved calc_noise for a single channel */
int calc_noise(
const context * const gfc,
const lame_internal_flags * const gfc,
const FLOAT8 xr [576],
const int ix [576],
const gr_info * const cod_info,
@@ -719,7 +719,7 @@ int calc_noise(
static
void set_pinfo (
const context * const gfc,
const lame_internal_flags * const gfc,
const gr_info * const cod_info,
const III_psy_ratio * const ratio,
const III_scalefac_t * const scalefac,
@@ -911,7 +911,7 @@ void set_pinfo (
************************************************************************/
void set_frame_pinfo(
context * const gfc,
lame_internal_flags * const gfc,
FLOAT8 xr [2][2][576],
III_psy_ratio ratio [2][2],
int l3_enc [2][2][576],
+4 -4
View File
@@ -36,7 +36,7 @@
was set properly by the formatter
*/
int
ResvFrameBegin(context *gfc,III_side_info_t *l3_side, int mean_bits, int frameLength )
ResvFrameBegin(lame_internal_flags *gfc,III_side_info_t *l3_side, int mean_bits, int frameLength )
{
int fullFrameBits;
int resvLimit;
@@ -82,7 +82,7 @@ ResvFrameBegin(context *gfc,III_side_info_t *l3_side, int mean_bits, int frameLe
extra_bits: amount extra available from reservoir
Mark Taylor 4/99
*/
void ResvMaxBits(context *gfc, int mean_bits, int *targ_bits, int *extra_bits)
void ResvMaxBits(lame_internal_flags *gfc, int mean_bits, int *targ_bits, int *extra_bits)
{
int add_bits,full_fac;
*targ_bits = mean_bits ;
@@ -120,7 +120,7 @@ void ResvMaxBits(context *gfc, int mean_bits, int *targ_bits, int *extra_bits)
the reservoir to reflect the granule's usage.
*/
void
ResvAdjust(context *gfc,gr_info *gi, III_side_info_t *l3_side, int mean_bits )
ResvAdjust(lame_internal_flags *gfc,gr_info *gi, III_side_info_t *l3_side, int mean_bits )
{
gfc->ResvSize += (mean_bits / gfc->stereo) - gi->part2_3_length;
#if 0
@@ -138,7 +138,7 @@ mean_bits/gfc->stereo-gi->part2_3_length,gfc->ResvSize);
bits.
*/
void
ResvFrameEnd(context *gfc, III_side_info_t *l3_side, int mean_bits)
ResvFrameEnd(lame_internal_flags *gfc, III_side_info_t *l3_side, int mean_bits)
{
int stuffingBits;
int over_bits;
+4 -4
View File
@@ -22,9 +22,9 @@
#ifndef LAME_RESERVOIR_H
#define LAME_RESERVOIR_H
int ResvFrameBegin( context *gfc,III_side_info_t *l3_side, int mean_bits, int frameLength );
void ResvMaxBits(context *gfc, int mean_bits, int *targ_bits, int *max_bits);
void ResvAdjust(context *gfc,gr_info *gi, III_side_info_t *l3_side, int mean_bits );
void ResvFrameEnd(context *gfc,III_side_info_t *l3_side, int mean_bits );
int ResvFrameBegin(lame_internal_flags *gfc,III_side_info_t *l3_side, int mean_bits, int frameLength );
void ResvMaxBits(lame_internal_flags *gfc, int mean_bits, int *targ_bits, int *max_bits);
void ResvAdjust(lame_internal_flags *gfc,gr_info *gi, III_side_info_t *l3_side, int mean_bits );
void ResvFrameEnd(lame_internal_flags *gfc,III_side_info_t *l3_side, int mean_bits );
#endif /* LAME_RESERVOIR_H */
+7 -7
View File
@@ -313,7 +313,7 @@ static int choose_table_nonMMX(
*/
int count_bits_long(context * const gfc, const int ix[576], gr_info * const gi)
int count_bits_long(lame_internal_flags * const gfc, const int ix[576], gr_info * const gi)
{
int i, a1, a2;
int bits = 0;
@@ -399,7 +399,7 @@ int count_bits_long(context * const gfc, const int ix[576], gr_info * const gi)
int count_bits(
context * const gfc,
lame_internal_flags * const gfc,
int * const ix,
const FLOAT8 * const xr,
gr_info * const cod_info)
@@ -430,7 +430,7 @@ int count_bits(
INLINE void
recalc_divide_init(
const context * const gfc,
const lame_internal_flags * const gfc,
gr_info cod_info,
int * const ix,
int r01_bits[],
@@ -472,7 +472,7 @@ recalc_divide_init(
INLINE void
recalc_divide_sub(
const context * const gfc,
const lame_internal_flags * const gfc,
const gr_info cod_info2,
gr_info * const gi,
const int * const ix,
@@ -512,7 +512,7 @@ recalc_divide_sub(
void best_huffman_divide(
const context * const gfc,
const lame_internal_flags * const gfc,
const int gr,
const int ch,
gr_info * const gi,
@@ -657,7 +657,7 @@ Only call this routine after final scalefactors have been
chosen and the channel/granule will not be re-encoded.
*/
void best_scalefac_store(
const context * const gfc,
const lame_internal_flags * const gfc,
const int gr,
const int ch,
int l3_enc[2][2][576],
@@ -966,7 +966,7 @@ int scale_bitcount_lsf(
void huffman_init(context * const gfc)
void huffman_init(lame_internal_flags * const gfc)
{
int i;
+5 -5
View File
@@ -41,7 +41,7 @@
*
***********************************************************************/
/*empty and close mallocs in gfc */
void freegfc(context *gfc) /* bit stream structure */
void freegfc(lame_internal_flags *gfc) /* bit stream structure */
{
int i;
for (i=0 ; i<2*BPC+1 ; ++i)
@@ -157,7 +157,7 @@ FLOAT8 freq2cbw(FLOAT8 freq)
/***********************************************************************
* compute bitsperframe and mean_bits for a layer III frame
**********************************************************************/
void getframebits(context *const gfc, int *bitsPerFrame, int *mean_bits)
void getframebits(lame_internal_flags *const gfc, int *bitsPerFrame, int *mean_bits)
{
int whole_SpF; /* integral number of Slots per Frame without padding */
int bit_rate;
@@ -338,7 +338,7 @@ int gcd ( int i, int j )
int fill_buffer_resample (
context * const gfc,
lame_internal_flags * const gfc,
sample_t* const outbuf,
const int desired_len,
const sample_t* inbuf,
@@ -563,7 +563,7 @@ int has_SIMD (void)
*
***********************************************************************/
void updateStats( context * const gfc )
void updateStats( lame_internal_flags * const gfc )
{
assert ( gfc->bitrate_index < 16u );
assert ( gfc->mode_ext < 4u );
@@ -646,7 +646,7 @@ scalar_t scalar20;
scalar_t scalar64;
scalarn_t scalar;
void init_scalar_functions ( const context * const gfc )
void init_scalar_functions ( lame_internal_flags *gfc )
{
scalar4 = std_scalar4;
scalar8 = std_scalar8;
+10 -17
View File
@@ -536,7 +536,7 @@ compute_scalefacs_long(int sf[SBPSY_l],gr_info *cod_info,int scalefac[SBPSY_l])
static int
VBR_quantize_granule(
context * const gfc,
lame_internal_flags * const gfc,
FLOAT8 xr34[576],
int l3_enc[576],
const III_psy_ratio * const ratio,
@@ -588,7 +588,7 @@ static const int MAX_SF_DELTA = 4;
static int
short_block_vbr_sf (
const context * const gfc,
const lame_internal_flags * const gfc,
const III_psy_xmin * const l3_xmin,
const FLOAT8 xr34_orig[576],
const FLOAT8 xr34 [576],
@@ -627,7 +627,7 @@ short_block_vbr_sf (
static int
long_block_vbr_sf (
const context * const gfc,
const lame_internal_flags * const gfc,
const III_psy_xmin * const l3_xmin,
const FLOAT8 xr34_orig[576],
const FLOAT8 xr34 [576],
@@ -667,7 +667,7 @@ long_block_vbr_sf (
static void
short_block_scalefacs (
const context * const gfc,
const lame_internal_flags * const gfc,
gr_info * const cod_info,
III_scalefac_t * const scalefac,
III_scalefac_t * const vbrsf,
@@ -758,7 +758,7 @@ short_block_scalefacs (
static void
long_block_scalefacs (
const context * const gfc,
const lame_internal_flags * const gfc,
gr_info * const cod_info,
III_scalefac_t * const scalefac,
III_scalefac_t * const vbrsf,
@@ -788,17 +788,10 @@ long_block_scalefacs (
maxover0 = v0;
if (maxover1 < v1)
maxover1 = v1;
#if 1 /* I think this was intended, RH */
if (maxover0p < v0p)
maxover0p = v0p;
if (maxover1p < v1p)
maxover1p = v1p;
#else /* but keep compatible for now */
if (maxover0 < v0p)
maxover0p = v0p; else maxover0p = maxover0;
if (maxover1 < v1p)
maxover1p = v1p; else maxover1p = maxover1;
#endif
}
mover = Min (maxover0, maxover0p);
@@ -886,7 +879,7 @@ static FLOAT8 calc_fac ( const int ifac )
static void
short_block_xr34 (
const context * const gfc,
const lame_internal_flags * const gfc,
const gr_info * const cod_info,
const III_scalefac_t * const scalefac,
const FLOAT8 xr34_orig[576],
@@ -918,7 +911,7 @@ short_block_xr34 (
static void
long_block_xr34 (
const context * const gfc,
const lame_internal_flags * const gfc,
const gr_info * const cod_info,
const III_scalefac_t * const scalefac,
const FLOAT8 xr34_orig[576],
@@ -974,7 +967,7 @@ long_block_xr34 (
************************************************************************/
static int
VBR_noise_shaping (
context * const gfc,
lame_internal_flags * const gfc,
FLOAT8 xr [576],
FLOAT8 xr34orig [576],
III_psy_ratio *ratio,
@@ -1065,7 +1058,7 @@ VBR_noise_shaping (
int
VBR_noise_shaping2 (
context * const gfc,
lame_internal_flags * const gfc,
FLOAT8 xr [576],
FLOAT8 xr34orig [576],
III_psy_ratio * const ratio,
@@ -1145,7 +1138,7 @@ VBR_noise_shaping2 (
void
VBR_quantize(context * const gfc,
VBR_quantize(lame_internal_flags * const gfc,
FLOAT8 pe[2][2], FLOAT8 ms_ener_ratio[2],
FLOAT8 xr[2][2][576], III_psy_ratio ratio[2][2],
int l3_enc[2][2][576],