[FFmpeg-devel] [PATCH] Generic sine window init function
Benjamin Larsson
banan
Sun Jun 22 15:21:03 CEST 2008
Hello.
Robert Swain wrote:
> Hello,
>
> A few of the MDCT codecs (AAC, IMC, COOK, Nellymoser) use sine windows
> so it would make sense to share the sine window initialisation code
> between them as the . I have attached a patch for this. If there are
> other codecs that can use this that I've missed, let me know.
>
> It is probably noteworthy that the tables for functions that normalise
> the window coefficients may differ from the direct calculation due to
> loss of precision during intermediate stages. For example, in imc.c:
>
> + ff_sine_window_init(q->mdct_sine_window, 2*COEFFS);
You could add a scale argument and the scaling code in the codec(s)
could be removed.
> for(i = 0; i < COEFFS; i++)
> - q->mdct_sine_window[i] = sin((i + 0.5) / 512.0 * M_PI) * sqrt(2.0);
> + q->mdct_sine_window[i] *= sqrt(2.0);
>
> mdct_sine_window is a float array so the sin() part of the calculation
> is limited to float precision in ff_sine_window_init and is then
> normalised with the sqrt(2.0) after. Is this a problem or is the
> difference insignificant?
Insignificant.
> For the above case the maximum deviation was
> 0.00000011920928955078125.
>
> Also, off topic, should that sqrt(2.0) be switched for M_SQRT2?
Switch it.
>
> Rob
The IMC, Cook and Nellymoser parts can be applied.
MvH
Benjamin Larsson
More information about the ffmpeg-devel
mailing list