[FFmpeg-devel] [PATCH] Move CPU detection to libavutil and cleanup
Måns Rullgård
mans
Mon Sep 6 09:01:21 CEST 2010
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.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list