[FFmpeg-devel] [PATCH] swscale: have --enable-runtime-cpudetect actually detect cpu capabilities at runtime

Måns Rullgård mans
Sat Mar 5 13:38:21 CET 2011


Darren Horrocks <killallthehumans at gmail.com> writes:

> Hi,
>
> used av_get_cpu_flags to get all cpu capabilities, then checked for
> mmx2 mmx and 3dnow.
>
> if the cpu supports any of these, it gets added to the flags for use later.
>
> Regards,
> Darren Horrocks
>
> diff --git a/libswscale/swscale.c b/libswscale/swscale.c
> index 375171f..246a9d2 100644
> --- a/libswscale/swscale.c
> +++ b/libswscale/swscale.c
> @@ -62,6 +62,7 @@ untested special converters
>  #include "rgb2rgb.h"
>  #include "libavutil/intreadwrite.h"
>  #include "libavutil/x86_cpu.h"
> +#include "libavutil/cpu.h"
>  #include "libavutil/avutil.h"
>  #include "libavutil/mathematics.h"
>  #include "libavutil/bswap.h"
> @@ -1260,6 +1261,12 @@ SwsFunc ff_getSwsFunc(SwsContext *c)
>  #if CONFIG_RUNTIME_CPUDETECT
>      int flags = c->flags;
>
> +    int cpuflags = av_get_cpu_flags();
> +
> +    flags |= (cpuflags & AV_CPU_FLAG_MMX ? SWS_CPU_CAPS_MMX : 0);
> +    flags |= (cpuflags & AV_CPU_FLAG_MMX2 ? SWS_CPU_CAPS_MMX2 : 0);
> +    flags |= (cpuflags & AV_CPU_FLAG_3DNOW ? SWS_CPU_CAPS_3DNOW : 0);

libswscale should be changed to use the AV_CPU flags instead.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list