diff x86/mathops.h @ 8627:d6bab465b82c libavcodec

moves mid_pred() into mathops.h (with arch specific code split by directory)
author aurel
date Sun, 18 Jan 2009 22:57:40 +0000
parents 7768bdfd4f7b
children 4cea2f47219a
line wrap: on
line diff
--- a/x86/mathops.h	Sun Jan 18 20:43:11 2009 +0000
+++ b/x86/mathops.h	Sun Jan 18 22:57:40 2009 +0000
@@ -22,6 +22,9 @@
 #ifndef AVCODEC_X86_MATHOPS_H
 #define AVCODEC_X86_MATHOPS_H
 
+#include "config.h"
+#include "libavutil/common.h"
+
 #define MULL(ra, rb, shift) \
         ({ int rt, dummy; __asm__ (\
             "imull %3               \n\t"\
@@ -40,4 +43,25 @@
      __asm__ ("imull %2\n\t" : "=A"(rt) : "a" ((int)ra), "g" ((int)rb));\
      rt; })
 
+#if HAVE_CMOV
+/* median of 3 */
+#define mid_pred mid_pred
+static inline av_const int mid_pred(int a, int b, int c)
+{
+    int i=b;
+    __asm__ volatile(
+        "cmp    %2, %1 \n\t"
+        "cmovg  %1, %0 \n\t"
+        "cmovg  %2, %1 \n\t"
+        "cmp    %3, %1 \n\t"
+        "cmovl  %3, %1 \n\t"
+        "cmp    %1, %0 \n\t"
+        "cmovg  %1, %0 \n\t"
+        :"+&r"(i), "+&r"(a)
+        :"r"(b), "r"(c)
+    );
+    return i;
+}
+#endif
+
 #endif /* AVCODEC_X86_MATHOPS_H */