OK, here is finaly a patch, that solves the
problems not only with "Glockenspiel" gspi35_1.wav
but with "Glockenspiel" gspi35_2.wav too.
If a scalefactor band contains a peak Takehiro described
earlier, then the average distortion within such a
band will be much lower than the maximum distortion.
By now Lame ignores such peaks, as distortion
is defined as the average distortion over a scalefactor
band only, and the peak becomes audible.
With this patch Lame will define the distortion in such
a band as something inbetween the average and the maximum,
depending on the distance of them.
Robert
Lame A Mpeg-audio Experience
diff -c lame3.55/quantize.c lame3.55.w6/quantize.c
*** lame3.55/quantize.c Thu Nov 11 18:24:05 1999
--- lame3.55.w6/quantize.c Thu Nov 18 23:30:23 1999
***************
*** 1374,1379 ****
--- 1374,1380 ----
step = pow( 2.0, (cod_info->quantizerStepSize) * 0.25 );
for ( sfb = 0; sfb < cod_info->sfb_lmax; sfb++ )
{
+ FLOAT8 max_sfb_noise=0;
start = scalefac_band_long[ sfb ];
end = scalefac_band_long[ sfb+1 ];
bw = end - start;
***************
*** 1382,1390 ****
{
FLOAT8 temp;
temp = fabs(xr[l]) - pow43[ix[l]] * step;
! sum += temp * temp;
}
xfsf[0][sfb] = sum / bw;
/* max -30db noise below threshold */
noise = 10*log10(Max(.001,xfsf[0][sfb] / l3_xmin->l[gr][ch][sfb]));
distort[0][sfb] = noise;
--- 1383,1402 ----
{
FLOAT8 temp;
temp = fabs(xr[l]) - pow43[ix[l]] * step;
! temp*= temp;
! sum += temp;
! max_sfb_noise = Max(max_sfb_noise,temp);
}
xfsf[0][sfb] = sum / bw;
+ /* if there is a large gap between maximum distortion and
+ * average distortion within this scalefactor band,
+ * increase the distortion upto maximum. (rh 99-11-18)
+ */
+ if( (max_sfb_noise > 0) && (xfsf[0][sfb] < 1E-7 ) ) {
+ FLOAT8 diff = max_sfb_noise-xfsf[0][sfb];
+ FLOAT8 fac = pow(diff/max_sfb_noise,4);
+ xfsf[0][sfb] += diff*fac;
+ }
/* max -30db noise below threshold */
noise = 10*log10(Max(.001,xfsf[0][sfb] / l3_xmin->l[gr][ch][sfb]));
distort[0][sfb] = noise;
***************
*** 1408,1413 ****
--- 1420,1426 ----
for ( sfb = cod_info->sfb_smax; sfb < 12; sfb++ )
{
+ FLOAT8 max_sfb_noise=0;
start = scalefac_band_short[ sfb ];
end = scalefac_band_short[ sfb+1 ];
bw = end - start;
***************
*** 1416,1424 ****
{
FLOAT8 temp;
temp = fabs((*xr_s)[l][i]) - pow43[(*ix_s)[l][i]] * step;
! sum += temp * temp;
}
xfsf[i+1][sfb] = sum / bw;
/* max -30db noise below threshold */
noise = 10*log10(Max(.001,xfsf[i+1][sfb] / l3_xmin->s[gr][ch][sfb][i] ));
distort[i+1][sfb] = noise;
--- 1429,1448 ----
{
FLOAT8 temp;
temp = fabs((*xr_s)[l][i]) - pow43[(*ix_s)[l][i]] * step;
! temp*= temp;
! sum += temp;
! max_sfb_noise = Max(max_sfb_noise,temp);
}
xfsf[i+1][sfb] = sum / bw;
+ /* if there is a large gap between maximum distortion and
+ * average distortion within this scalefactor band,
+ * increase the distortion upto maximum. (rh 99-11-18)
+ */
+ if ( (max_sfb_noise > 0) && (xfsf[i+1][sfb] < 1E-7 ) ) {
+ FLOAT8 diff = max_sfb_noise-xfsf[i+1][sfb];
+ FLOAT8 fac = pow(diff/max_sfb_noise,4);
+ xfsf[i+1][sfb] += diff*fac;
+ }
/* max -30db noise below threshold */
noise = 10*log10(Max(.001,xfsf[i+1][sfb] / l3_xmin->s[gr][ch][sfb][i] ));
distort[i+1][sfb] = noise;
--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )