[FFmpeg-devel] [PATCH] Generic sine window init function
Michael Niedermayer
michaelni
Sun Jun 22 16:37:10 CEST 2008
On Sun, Jun 22, 2008 at 01:15:22PM +0100, Robert Swain wrote:
> 2008/6/22 Michael Niedermayer <michaelni at gmx.at>:
[...]
> > [...]
> >> Index: libavcodec/imc.c
> >> ===================================================================
> >> --- libavcodec/imc.c (revision 13854)
> >> +++ libavcodec/imc.c (working copy)
> >> @@ -102,8 +102,9 @@
> >> q->old_floor[i] = 1.0;
> >>
> >> /* Build mdct window, a simple sine window normalized with sqrt(2) */
> >> + ff_sine_window_init(q->mdct_sine_window, COEFFS);
> >> 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);
> >> for(i = 0; i < COEFFS/2; i++){
> >> q->post_cos[i] = cos(i / 256.0 * M_PI);
> >> q->post_sin[i] = sin(i / 256.0 * M_PI);
> >> Index: libavcodec/cook.c
> >> ===================================================================
> >> --- libavcodec/cook.c (revision 13854)
> >> +++ libavcodec/cook.c (working copy)
> >> @@ -239,9 +239,9 @@
> >> return -1;
> >>
> >> /* Initialize the MLT window: simple sine window. */
> >> - alpha = M_PI / (2.0 * (float)mlt_size);
> >> + ff_sine_window_init(q->mlt_window, mlt_size);
> >> for(j=0 ; j<mlt_size ; j++)
> >> - q->mlt_window[j] = sin((j + 0.5) * alpha) * sqrt(2.0 / q->samples_per_channel);
> >> + q->mlt_window[j] *= sqrt(2.0 / q->samples_per_channel);
> >
> > The window should not be scaled by sqrt(2) there are plenty of other places
> > where the sqrt(2) could be applied.
> > and it should not be in the context but static and shared
> > (of course that is not really your job to do so the patch is ok if you dont
> > want to work on that)
>
> It's OK. I'll do it. I don't mind a bit of monkey work now and again. :)
>
> I actually have some improvements. As these normalisation factors are
> always that, how about adding another argument and multiplying by the
> normalisation factor within the init function? This could also be done
> for ff_kbd_window_init() as well which would solve that non-thread
> safe situation in aac.c. See attached.
I would like to share the tables between codecs!
If each codec puts its normalisation factors in the window
then they cannot be shared as they are not identical.
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080622/63e5a5e4/attachment.pgp>
More information about the ffmpeg-devel
mailing list