[FFmpeg-cvslog] Fix runtime CPU detection in libswscale.

tateu git at videolan.org
Wed Apr 27 01:52:53 CEST 2011


ffmpeg | branch: master | tateu <qtmb at tateuDOTnet> | Wed Apr 27 01:50:50 2011 +0200| [93c28a55fd84280d97c3c0dd7b0d546043242c34] | committer: Carl Eugen Hoyos

Fix runtime CPU detection in libswscale.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=93c28a55fd84280d97c3c0dd7b0d546043242c34
---

 libswscale/rgb2rgb.c |    2 +-
 libswscale/swscale.c |    7 -------
 libswscale/utils.c   |    8 ++++++++
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c
index a5cebcf..adc5d59 100644
--- a/libswscale/rgb2rgb.c
+++ b/libswscale/rgb2rgb.c
@@ -199,7 +199,7 @@ DECLARE_ASM_CONST(8, uint64_t, blue_15mask)  = 0x0000001f0000001fULL;
 
 void sws_rgb2rgb_init(int flags)
 {
-#if HAVE_MMX2 || HAVE_AMD3DNOW || HAVE_MMX
+#if HAVE_SSE2 || HAVE_MMX2 || HAVE_AMD3DNOW || HAVE_MMX
     if (flags & SWS_CPU_CAPS_SSE2)
         rgb2rgb_init_SSE2();
     else if (flags & SWS_CPU_CAPS_MMX2)
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index c0e4db3..bf41180 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -62,7 +62,6 @@ 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"
@@ -1314,12 +1313,6 @@ 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);
-
 #if ARCH_X86
     // ordered per speed fastest first
     if (flags & SWS_CPU_CAPS_MMX2) {
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 1f4a6c4..2080742 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -41,6 +41,7 @@
 #include "rgb2rgb.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/x86_cpu.h"
+#include "libavutil/cpu.h"
 #include "libavutil/avutil.h"
 #include "libavutil/bswap.h"
 #include "libavutil/opt.h"
@@ -742,6 +743,13 @@ static int update_flags_cpu(int flags)
                |SWS_CPU_CAPS_ALTIVEC
                |SWS_CPU_CAPS_BFIN);
     flags |= ff_hardcodedcpuflags();
+#else /* !CONFIG_RUNTIME_CPUDETECT */
+    int cpuflags = av_get_cpu_flags();
+
+    flags |= (cpuflags & AV_CPU_FLAG_SSE2 ? SWS_CPU_CAPS_SSE2 : 0);
+    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);
 #endif /* CONFIG_RUNTIME_CPUDETECT */
     return flags;
 }



More information about the ffmpeg-cvslog mailing list