[FFmpeg-devel] [PATCH] PPC runtime altivec detection via mfspr

Reimar Döffinger Reimar.Doeffinger
Thu Nov 15 11:51:01 CET 2007


Hello,
attached patch adds altivec detection via the mfspr.
Unfortunately, there is no way to detect if mfspr is available,
neither is there a configure flag to manually enable/disable runtime
cpudetection.
So as a (temporary) hack I made the code conditional on MPlayer's
RUNTIME_CPUDETECT.
I agree this is ugly, and for ffmpeg we could just as well put it under
#elif 0.
I just think it might be nice to have this code in because it seems e.g.
Debian could use it without any problems, whereas on my test system it
would always crash.
Of course, if someone wrote a proper ffmpeg configure part for it that
would be nice as well...
Opinions?

Greetings,
Reimar D?ffinger
-------------- next part --------------
diff --git a/libavcodec/ppc/check_altivec.c b/libavcodec/ppc/check_altivec.c
index b3778ca..cf55b9a 100644
--- a/libavcodec/ppc/check_altivec.c
+++ b/libavcodec/ppc/check_altivec.c
@@ -54,6 +54,18 @@ int has_altivec(void)
 
     if (err == 0) return (has_vu != 0);
     return 0;
+#elif defined(RUNTIME_CPUDETECT)
+    int proc_ver;
+    // support of mfspr PVR emulation added in Linux 2.6.17
+    asm volatile("mfspr %0, 287" : "=r" (proc_ver));
+    proc_ver >>= 16;
+    if (proc_ver  & 0x8000 ||
+        proc_ver == 0x000c ||
+        proc_ver == 0x0039 || proc_ver == 0x003c ||
+        proc_ver == 0x0044 || proc_ver == 0x0045 ||
+        proc_ver == 0x0070)
+        return 1;
+    return 0;
 #else
     // since we were compiled for altivec, just assume we have it
     // until someone comes up with a proper way (not involving signal hacks).



More information about the ffmpeg-devel mailing list