> From: Segher Boessenkool <[EMAIL PROTECTED]>
> Date: Mon, 29 Nov 1999 12:44:30 +0100 (CET)
>
> > Segher, shouldn't the formula be:
> >
> > > if (x > (0.5 * (pow(i, 4.0/3.0) + pow(i+1, 4.0/3.0))
> > > i++;
> >
> >
> > Mark
>
> No, if you use 4/3, you optimize for sample amplitude; but we'd like
> the sample _energy_ to be optimal, so 8/3.
>
> Ciao,
>
> Segher
>
hmm, I'm not so sure about this. The noise measure used in LAME
is based *not* on the error in the energy
fabs(i^8/3 - x^2)
but instead on the energy of the error:
( i^4/3 -x ) ^2
Since LAME picks scalefactors to try to minimize the second quantity,
I think we should use a quantization consistant with this error measure?
As for the speed, i think it was slow mostly because of the C implimentation
of the two (int) casts. The new asm code gets the speed almost back
to what it used to be. Here is the latest version:
#if defined(__GNUC__) && defined(__i386__)
# define QUANTFAC(rx) adj43asm[rx]
# define XRPOW_FTOI(src, dest) \
asm ("fistpl %0 " : "=m"(dest) : "t"(src) : "st")
#elif defined (_MSC_VER)
# define QUANTFAC(rx) adj43asm[rx]
# define XRPOW_FTOI(src, dest) do { \
FLOAT8 src_ = (src); \
int dest_; \
{ \
__asm fld src_ \
__asm fistp dest_ \
} \
(dest) = dest_; \
} while (0)
#else
# define QUANTFAC(rx) adj43[rx]
# define XRPOW_FTOI(src,dest) ((dest) = (int)(src))
#endif
/*********************************************************************
* nonlinear quantization of xr
* More accurate formula than the ISO formula. Takes into account
* the fact that we are quantizing xr -> ix, but we want ix^4/3 to be
* as close as possible to x^4/3. (taking the nearest int would mean
* ix is as close as possible to xr, which is different.)
* From Segher Boessenkool <[EMAIL PROTECTED]> 11/1999
* ASM optimization from Mathew Hendry <[EMAIL PROTECTED]> 11/1999
* and Takehiro Tominaga <[EMAIL PROTECTED]>
*********************************************************************/
void quantize_xrpow( FLOAT8 xr[576], int ix[576], gr_info *cod_info )
{
/* quantize on xr^(3/4) instead of xr */
register int j;
int rx;
FLOAT8 x,quantizerStepSize;
FLOAT8 istep_l,istep0,istep1,istep2;
quantizerStepSize = cod_info->quantizerStepSize;
istep_l = pow ( 2.0, quantizerStepSize * -0.1875 );
if ((cod_info->block_type==SHORT_TYPE))
{
istep0 = istep_l * pow(2.0,1.5* (FLOAT8) cod_info->subblock_gain[0]);
istep1 = istep_l * pow(2.0,1.5* (FLOAT8) cod_info->subblock_gain[1]);
istep2 = istep_l * pow(2.0,1.5* (FLOAT8) cod_info->subblock_gain[2]);
for (j=192;j>0;j--)
{
x = istep0 * *xr++;
/* *(ix++) = (int)( x + adj43[(int)x]); */
XRPOW_FTOI(x-.5, rx);
XRPOW_FTOI(x + QUANTFAC(rx), *(ix++));
x = istep1 * *xr++;
/* *(ix++) = (int)( x + adj43[(int)x]); */
XRPOW_FTOI(x-.5, rx);
XRPOW_FTOI(x + QUANTFAC(rx), *(ix++));
x = istep2 * *xr++;
/* *(ix++) = (int)( x + adj43[(int)x]); */
XRPOW_FTOI(x-.5, rx);
XRPOW_FTOI(x + QUANTFAC(rx), *(ix++));
}
}
else
{
for (j=576;j>0;j--) {
x = istep_l * *xr++;
/* *(ix++) = (int)( x + adj43[(int)x]); */
XRPOW_FTOI(x-.5, rx);
XRPOW_FTOI(x + QUANTFAC(rx), *(ix++));
}
}
}
--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )