[MPlayer-dev-eng] [PATCH] Remove duplicated CPU detection in libmpeg2

jserv at linux2.cc.ntu.edu.tw jserv at linux2.cc.ntu.edu.tw
Thu Jun 15 11:49:49 CEST 2006


On Thu, Jun 15, 2006 at 11:29:40AM +0200, Michael Niedermayer wrote:
> Hi
> 
> On Thu, Jun 15, 2006 at 02:35:32PM +0800, jserv at linux2.cc.ntu.edu.tw wrote:
> [...]
> 
> 3DNOW is ignored by this patch

hi Michael,

  Thanks for remanding me of 3DNow! detection, and I have updated my
patch in attachment.

Sincerely,
Jim Huang (jserv)
http://jserv.sayya.org/
-------------- next part --------------
Index: libmpeg2/cpu_accel.c
===================================================================
--- libmpeg2/cpu_accel.c	(revision 18717)
+++ libmpeg2/cpu_accel.c	(working copy)
@@ -26,6 +26,7 @@
  */
 
 #include "config.h"
+#include "cpudetect.h"
 
 #include <inttypes.h>
 
@@ -37,6 +38,7 @@
 #if defined(ARCH_X86) || defined(ARCH_X86_64)
 static inline uint32_t arch_accel (void)
 {
+#if 0 /* MPlayer has its own CPU detection mechanisms */
     uint32_t eax, ebx, ecx, edx;
     int AMD;
     uint32_t caps;
@@ -109,6 +111,27 @@ static inline uint32_t arch_accel (void)
 	caps |= MPEG2_ACCEL_X86_MMXEXT;
 
     return caps;
+#else /* Use MPlayer's cpu capability property */
+
+#if defined(HAVE_SSE2)
+    if (gCpuCaps.hasSSE2) {
+	return MPEG2_ACCEL_X86_MMX | MPEG2_ACCEL_X86_MMXEXT | MPEG2_ACCEL_X86_SSE2;
+    }
+#endif
+#if defined(HAVE_MMX2) || defined(HAVE_SSE)
+    if (gCpuCaps.hasSSE || gCpuCaps.hasMMX2)
+	return MPEG2_ACCEL_X86_MMX | MPEG2_ACCEL_X86_MMXEXT;
+    }
+#endif
+#if defined(HAVE_MMX)
+    if (gCpuCaps.hasMMX || gCpuCaps.has3DNow || gCpuCaps.has3DNowExt)
+	return MPEG2_ACCEL_X86_MMX;
+    }
+#endif
+    /* No acceleration instructions */
+    return 0;
+
+#endif /* End of cpu detection */
 }
 #endif /* ARCH_X86 || ARCH_X86_64 */
 
Index: libmpeg2/mpeg2.h
===================================================================
--- libmpeg2/mpeg2.h	(revision 18717)
+++ libmpeg2/mpeg2.h	(working copy)
@@ -159,6 +159,7 @@ void mpeg2_custom_fbuf (mpeg2dec_t * mpe
 #define MPEG2_ACCEL_X86_MMX 1
 #define MPEG2_ACCEL_X86_3DNOW 2
 #define MPEG2_ACCEL_X86_MMXEXT 4
+#define MPEG2_ACCEL_X86_SSE2 8
 #define MPEG2_ACCEL_PPC_ALTIVEC 1
 #define MPEG2_ACCEL_ALPHA 1
 #define MPEG2_ACCEL_ALPHA_MVI 2


More information about the MPlayer-dev-eng mailing list