[MPlayer-dev-eng] [PATCH] liba52/parse.c: avoid dirty hack on mingw32

Guillaume POIRIER poirierg at gmail.com
Wed Nov 8 09:20:12 CET 2006


Hi,

On 11/8/06, Zuxy Meng <zuxy.meng at gmail.com> wrote:
> Hi,
>
> 2006/11/1, Emanuele Giaquinta <e.giaquinta at glauco.it>:
> > > Since libavutil is now mandatory, we need this hack no more when
> > > MEMALIGN_HACK is defined.
> >
> > If I understand correctly, the problem is that memalign is bogus on
> > MINGW, but since memalign is present MEMALIGN_HACK is not defined so
> > your patch won't work. What about this one instead?
> >
> > --
> > Emanuele Giaquinta
> >
> >
> > Index: parse.c
> > ===================================================================
> > --- parse.c     (revision 20577)
> > +++ parse.c     (working copy)
> > @@ -37,6 +37,7 @@
> >  #include "bitstream.h"
> >  #include "tables.h"
> >  #include "mm_accel.h"
> > +#include "libavutil/avutil.h"
> >
> >  #ifdef HAVE_MEMALIGN
> >  /* some systems have memalign() but no declaration for it */
> > @@ -63,16 +64,10 @@
> >     if (state == NULL)
> >        return NULL;
> >
> > -    state->samples = memalign (16, 256 * 12 * sizeof (sample_t));
> >  #if defined(__MINGW32__) && defined(HAVE_SSE)
> > -    for(i=0;i<10;i++){
> > -      if((int)state->samples%16){
> > -        sample_t* samplestmp=malloc(256 * 12 * sizeof (sample_t));
> > -        free(state->samples);
> > -        state->samples = samplestmp;
> > -      }
> > -      else break;
> > -    }
> > +    state->samples = av_malloc(256 * 12 * sizeof (sample_t));
> > +#else
> > +    state->samples = memalign (16, 256 * 12 * sizeof (sample_t));
> >  #endif
> >     if(((int)state->samples%16) && (mm_accel&MM_ACCEL_X86_SSE)){
> >       mm_accel &=~MM_ACCEL_X86_SSE;
> > @@ -915,6 +910,10 @@
> >
> >  void a52_free (a52_state_t * state)
> >  {
> > -    free (state->samples);
> > +#if defined(__MINGW32__) && defined(HAVE_SSE)
> > +    av_free (state->samples);
> > +#else
> > +     free (state->samples);
> > +#endif
> >     free (state);
> >  }
>
> Anyone will review & apply this?

This patch indeed improves code readability, and seems to work
alright. Will apply tonite unless someone disagrees.

Guillaume
-- 
With DADVSI (http://en.wikipedia.org/wiki/DADVSI), France finally has
a lead on USA on selling out individuals right to corporations!
Vive la France!



More information about the MPlayer-dev-eng mailing list