On Mon, 24 May 1999, Gabriel Bouvigne wrote:
> quantizerstepsize is double, isn't it? So how will you build a table for
> those powers?
Uhm.. the type is double, but the values are always integer. I have built
a table for quantizerstepsizes between 255 to -255 that seems to work, but
I'm not sure if the stepsize never exceeds those values, and I didn't
notice any change in speed either, so haven't bothered to investigate it
any further (yet).
> If it was integer, this power should have been optimizable using several bit
> shifting, 1 case, 1 addition and 1 division to compute the whole formula.
There is a division by 4 in the pow() call. (or multiplication by 0.25)
Using a shift-right by 2 bits would then shift out needed bits :/ Maybe
there are better ways to do it than using i table. The function is this:
pow(2, quantizerstepsize * 0.25) where the stepsize seems to have a
integer value between 210 to -210. I solved this with a table from 0 to
256 and using the formula a^-n = 1/a^n..
> Perhaps it would be faster doing the optimized calculus for the integer part
> and multiplying the result by the "standard" calculs for the floating part
> of quantizerstepsize.
>
> Does the "standard" calculus of the power of 2 of the floating part of
> quantizerstepsize needs less operations than the power of 2 of the whole
> quantizerstepsize? I don't know. Perhaps someone could answer...
>
> Just changing a double to int won't speed up the program on a PII, as the
> fpu is nearly as fast as the integer unit.
All CPU's are not PII:s :)
That's also a reason to maybe investigate if double is really needed
everywhere. (Calculate what precision is really needed. I recall reading
in a paper somewhere that 24bit floats was enough for mp3-encoding.)
...
Regards,
Jan Peman (still wanting a compile option for compiling the code to a DSP)
:)
--
MP3 ENCODER mailing list