changeset 109:a2ef0ea8643b libavutil

asm implementation of mid_pred. 20% faster huffyuv decoding, 4% faster ffv1.
author lorenm
date Fri, 15 Sep 2006 00:36:49 +0000
parents 11be8e0d1344
children 813b7366ac3f
files common.h
diffstat 1 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/common.h	Sun Sep 10 14:02:42 2006 +0000
+++ b/common.h	Fri Sep 15 00:36:49 2006 +0000
@@ -235,7 +235,22 @@
 /* median of 3 */
 static inline int mid_pred(int a, int b, int c)
 {
-#if 0
+#if (defined(ARCH_X86) && __CPU__ >= 686 || defined(ARCH_X86_64)) && !defined(RUNTIME_CPUDETECT)
+    int i=a, j=a;
+    asm volatile(
+        "cmp    %4, %2 \n\t"
+        "cmovg  %4, %0 \n\t"
+        "cmovl  %4, %1 \n\t"
+        "cmp    %4, %3 \n\t"
+        "cmovg  %3, %0 \n\t"
+        "cmovl  %3, %1 \n\t"
+        "cmp    %3, %2 \n\t"
+        "cmovl  %1, %0 \n\t"
+        :"+&r"(i), "+&r"(j)
+        :"r"(a), "r"(b), "r"(c)
+    );
+    return i;
+#elif 0
     int t= (a-b)&((a-b)>>31);
     a-=t;
     b+=t;