[Ffmpeg-devel] [PATCH] protect cmov asm sections with HAVE_CMOV

Guillaume POIRIER poirierg
Fri Oct 20 09:49:24 CEST 2006


Hi,
Now that configure script is able to "detect" if CMOV is supported, I
guess it's time to use it where appropriate, which is just what this
patch is supposed to do.

Note that with this patch, CMOV_IS_FAST == HAVE_CMOV, but since we
(can) know (after having done some benchmark) on which CPU CMOV is
actually fast (pretty much all of them except netburst processors), we
can make configure set CMOV_IS_FAST if HAVE_CMOV==1 && !CMPU=P4 or
smth like that.
Thoughts?

Guillaume
-- 
With DADVSI (http://en.wikipedia.org/wiki/DADVSI), France finally has
a lead on USA on selling out individuals right to corporations!
Vive la France!
-------------- next part --------------
Index: libavutil/internal.h
===================================================================
--- libavutil/internal.h	(revision 6742)
+++ libavutil/internal.h	(working copy)
@@ -168,7 +168,7 @@
             level= (level^mask)-mask;
 #endif
 
-#if __CPU__ >= 686 && !defined(RUNTIME_CPUDETECT)
+#ifdef HAVE_CMOV
 #define COPY3_IF_LT(x,y,a,b,c,d)\
 asm volatile (\
     "cmpl %0, %3        \n\t"\
Index: libavutil/common.h
===================================================================
--- libavutil/common.h	(revision 6742)
+++ libavutil/common.h	(working copy)
@@ -238,7 +238,7 @@
 /* median of 3 */
 static inline int mid_pred(int a, int b, int c)
 {
-#if (defined(ARCH_X86) && __CPU__ >= 686 || defined(ARCH_X86_64)) && !defined(RUNTIME_CPUDETECT)
+#if HAVE_CMOV
     int i=b;
     asm volatile(
         "cmp    %2, %1 \n\t"
Index: libavcodec/cabac.h
===================================================================
--- libavcodec/cabac.h	(revision 6742)
+++ libavcodec/cabac.h	(working copy)
@@ -32,7 +32,9 @@
 #define CABAC_BITS 16
 #define CABAC_MASK ((1<<CABAC_BITS)-1)
 #define BRANCHLESS_CABAC_DECODER 1
+#ifdef HAVE_CMOV
 #define CMOV_IS_FAST 1
+#endif
 //#define ARCH_X86_DISABLED 1
 
 typedef struct CABACContext{
@@ -454,7 +456,7 @@
 #else /* BRANCHLESS_CABAC_DECODER */
 
 
-#if (defined CMOV_IS_FAST  && __CPU__ >= 686)
+#if defined CMOV_IS_FAST
 #define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\
         "mov    "tmp"       , %%ecx                                     \n\t"\
         "shl    $17         , "tmp"                                     \n\t"\



More information about the ffmpeg-devel mailing list