[FFmpeg-devel] [PATCH] Move CPU detection to libavutil and cleanup

Stefano Sabatini stefano.sabatini-lala
Tue Sep 7 23:38:08 CEST 2010


On date Monday 2010-09-06 18:28:48 +0200, Stefano Sabatini encoded:
> On date Monday 2010-09-06 08:01:21 +0100, M?ns Rullg?rd encoded:
> > Ramiro Polla <ramiro.polla at gmail.com> writes:
> > 
> > > On Sun, Sep 5, 2010 at 9:29 PM, Stefano Sabatini
> > > <stefano.sabatini-lala at poste.it> wrote:
> > >> Check in attachment, *completely untested*.
> > >
> > > Why would you send a completely untested patch to the mailinglist?
> > > Don't you have access to Mans' ppc?
> > 
> > He does.
> >
> > > It needed a few adjustments and passed make fate.
> > >
> > > Index: libavcodec/ppc/dsputil_altivec.h
> > > ===================================================================
> > > --- libavcodec/ppc/dsputil_altivec.h	(revision 25047)
> > > +++ libavcodec/ppc/dsputil_altivec.h	(working copy)
> > > @@ -30,8 +30,6 @@
> > >  
> > >  void avg_pixels16_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h);
> > >  
> > > -int has_altivec(void);
> > > -
> > >  void fdct_altivec(int16_t *block);
> > >  void gmc1_altivec(uint8_t *dst, uint8_t *src, int stride, int h,
> > >                    int x16, int y16, int rounder);
> > > Index: libavcodec/ppc/dsputil_ppc.c
> > > ===================================================================
> > > --- libavcodec/ppc/dsputil_ppc.c	(revision 25047)
> > > +++ libavcodec/ppc/dsputil_ppc.c	(working copy)
> > > @@ -20,18 +20,72 @@
> > >   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> > >   */
> > >  
> > > +#ifdef __APPLE__
> > > +#undef _POSIX_C_SOURCE
> > > +#include <sys/sysctl.h>
> > > +#elif defined(__OpenBSD__)
> > > +#include <sys/param.h>
> > > +#include <sys/sysctl.h>
> > > +#include <machine/cpu.h>
> > > +#elif defined(__AMIGAOS4__)
> > > +#include <exec/exec.h>
> > > +#include <interfaces/exec.h>
> > > +#include <proto/exec.h>
> > > +#endif /* __APPLE__ */
> > > +
> > > +#include "config.h"
> > > +#include "dsputil_altivec.h"
> > >  #include "libavcodec/dsputil.h"
> > > -#include "dsputil_altivec.h"
> > >  
> > > +/**
> > > + * This function MAY rely on signal() or fork() in order to make sure AltiVec
> > > + * is present.
> > > + */
> > >  int mm_support(void)
> > >  {
> > > -    int result = 0;
> > >  #if HAVE_ALTIVEC
> > > -    if (has_altivec()) {
> > > -        result |= AV_CPU_FLAG_ALTIVEC;
> > > -    }
> > > -#endif /* result */
> > > -    return result;
> > > +#ifdef __AMIGAOS4__
> > > +    ULONG result = 0;
> > > +    extern struct ExecIFace *IExec;
> > > +
> > > +    IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE);
> > > +    if (result == VECTORTYPE_ALTIVEC)
> > > +        return AV_CPU_FLAG_ALTIVEC;
> > > +    return 0;
> > > +#elif defined(__APPLE__) || defined(__OpenBSD__)
> > 
> > The diff would be much smaller if you renamed has_altivec() to
> > mm_support() and deleted this mm_support(), which isn't even used
> > currently.
> 
> Done like that, regression test on PPC mans-box passed.
> 
> Regards.
> -- 
> FFmpeg = Fantastic Freak Mere Practical Ecumenical Gadget

> From 1676d7bd2441c47786a03b267d14eb577e5c784c Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Mon, 6 Sep 2010 17:12:49 +0200
> Subject: [PATCH 2/2] Merge has_altivec() function into mm_support(), remove it and use
>  mm_support() instead.
> 
> Reduce complexity and simplify pending move to libavutil.
> ---
>  libavcodec/ppc/check_altivec.c     |   15 ++++++++++-----
>  libavcodec/ppc/dsputil_altivec.h   |    2 --
>  libavcodec/ppc/dsputil_ppc.c       |   13 +------------
>  libavcodec/ppc/h264_altivec.c      |    4 ++--
>  libavcodec/ppc/mpegvideo_altivec.c |    2 +-
>  libavcodec/ppc/vp8dsp_altivec.c    |    2 +-
>  6 files changed, 15 insertions(+), 23 deletions(-)

Ping.
-- 
FFmpeg = Fanciful and Forgiving Mortal Pacific Earthshaking Guru



More information about the ffmpeg-devel mailing list