[Mplayer-cvslog] CVS: main Makefile,1.243,1.244 cpudetect.c,1.24,1.25 cpudetect.h,1.8,1.9 mencoder.c,1.200,1.201 mplayer.c,1.655,1.656

Arpi of Ize arpi at mplayerhq.hu
Sat Jan 18 20:29:48 CET 2003


Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv15719

Modified Files:
	Makefile cpudetect.c cpudetect.h mencoder.c mplayer.c 
Log Message:
AltiVec detection code ("borrowed" from FFmpeg and
    libmpeg2) & enough code to enable the AltiVec IMDCT
    in liba52 and the DCT64 in mp3lib.
patch by Romain Dolbeau <dolbeau at irisa.fr>


Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.243
retrieving revision 1.244
diff -u -r1.243 -r1.244
--- Makefile	11 Jan 2003 23:08:11 -0000	1.243
+++ Makefile	18 Jan 2003 19:29:45 -0000	1.244
@@ -40,6 +40,10 @@
 
 CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader -Ilibvo $(FREETYPE_INC) $(EXTRA_INC) $(CDPARANOIA_INC) $(SDL_INC) # -Wall
 
+ifeq ($(TARGET_ALTIVEC),yes)
+CFLAGS += -faltivec
+endif
+
 PARTS = libmpdemux libmpcodecs mp3lib liba52 libmpeg2 libavcodec libao2 drivers linux postproc input libvo libaf
 ifeq ($(VIDIX),yes)
 PARTS += libdha vidix

Index: cpudetect.c
===================================================================
RCS file: /cvsroot/mplayer/main/cpudetect.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- cpudetect.c	9 Jan 2003 18:39:09 -0000	1.24
+++ cpudetect.c	18 Jan 2003 19:29:45 -0000	1.25
@@ -429,6 +429,27 @@
 }
 #else /* ARCH_X86 */
 
+#ifdef SYS_DARWIN
+#include <sys/sysctl.h>
+#else
+#include <signal.h>
+#include <setjmp.h>
+
+static sigjmp_buf jmpbuf;
+static volatile sig_atomic_t canjump = 0;
+
+static void sigill_handler (int sig)
+{
+    if (!canjump) {
+        signal (sig, SIG_DFL);
+        raise (sig);
+    }
+    
+    canjump = 0;
+    siglongjmp (jmpbuf, 1);
+}
+#endif
+
 void GetCpuCaps( CpuCaps *caps)
 {
 	caps->cpuType=0;
@@ -440,5 +461,46 @@
 	caps->hasSSE=0;
 	caps->hasSSE2=0;
 	caps->isX86=0;
+	caps->hasAltiVec = 0;
+#ifdef HAVE_ALTIVEC   
+#ifdef SYS_DARWIN   
+/*
+  rip-off from ffmpeg altivec detection code.
+  this code also appears on Apple's AltiVec pages.
+ */
+        {
+                int sels[2] = {CTL_HW, HW_VECTORUNIT};
+                int has_vu = 0;
+                size_t len = sizeof(has_vu);
+                int err;
+
+                err = sysctl(sels, 2, &has_vu, &len, NULL, 0);   
+
+                if (err == 0)
+                        if (has_vu != 0)
+                                caps->hasAltiVec = 1;
+                mp_msg(MSGT_CPUDETECT,MSGL_INFO,"AltiVec %sfound\n", (caps->hasAltiVec ? "" : "not "));
+        }
+#else /* SYS_DARWIN */
+/* no Darwin, do it the brute-force way */
+/* this is borrowed from the libmpeg2 library */
+        {
+          signal (SIGILL, sigill_handler);
+          if (sigsetjmp (jmpbuf, 1)) {
+            signal (SIGILL, SIG_DFL);
+          } else {
+            canjump = 1;
+            
+            asm volatile ("mtspr 256, %0\n\t"
+                          "vand v0, v0, v0"
+                          :
+                          : "r" (-1));
+            
+            signal (SIGILL, SIG_DFL);
+            caps->hasAltiVec = 1;
+          }
+        }
+#endif /* SYS_DARWIN */
+#endif /* HAVE_ALTIVEC */
 }
 #endif /* !ARCH_X86 */

Index: cpudetect.h
===================================================================
RCS file: /cvsroot/mplayer/main/cpudetect.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- cpudetect.h	9 Jan 2003 18:39:09 -0000	1.8
+++ cpudetect.h	18 Jan 2003 19:29:45 -0000	1.9
@@ -17,6 +17,7 @@
 	int hasSSE2;
 	int isX86;
 	unsigned cl_size; /* size of cache line */
+        int hasAltiVec;
 } CpuCaps;
 
 extern CpuCaps gCpuCaps;

Index: mencoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/mencoder.c,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -r1.200 -r1.201
--- mencoder.c	16 Jan 2003 23:03:06 -0000	1.200
+++ mencoder.c	18 Jan 2003 19:29:45 -0000	1.201
@@ -367,8 +367,8 @@
   mp_msg(MSGT_CPLAYER,MSGL_INFO,"%s",banner_text);
 
   /* Test for cpu capabilities (and corresponding OS support) for optimizing */
-#ifdef ARCH_X86
   GetCpuCaps(&gCpuCaps);
+#ifdef ARCH_X86
   mp_msg(MSGT_CPLAYER,MSGL_INFO,"CPUflags: Type: %d MMX: %d MMX2: %d 3DNow: %d 3DNow2: %d SSE: %d SSE2: %d\n",
       gCpuCaps.cpuType,gCpuCaps.hasMMX,gCpuCaps.hasMMX2,
       gCpuCaps.has3DNow, gCpuCaps.has3DNowExt,

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.655
retrieving revision 1.656
diff -u -r1.655 -r1.656
--- mplayer.c	18 Jan 2003 19:08:42 -0000	1.655
+++ mplayer.c	18 Jan 2003 19:29:45 -0000	1.656
@@ -665,8 +665,8 @@
 
   mp_msg(MSGT_CPLAYER,MSGL_INFO,banner_text);
   /* Test for cpu capabilities (and corresponding OS support) for optimizing */
-#ifdef ARCH_X86
   GetCpuCaps(&gCpuCaps);
+#ifdef ARCH_X86
   mp_msg(MSGT_CPLAYER,MSGL_INFO,"CPUflags:  MMX: %d MMX2: %d 3DNow: %d 3DNow2: %d SSE: %d SSE2: %d\n",
       gCpuCaps.hasMMX,gCpuCaps.hasMMX2,
       gCpuCaps.has3DNow, gCpuCaps.has3DNowExt,



More information about the MPlayer-cvslog mailing list