[vlc-commits] Check for 3D Now! at build time

Rémi Denis-Courmont git at videolan.org
Sat Aug 4 16:02:09 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Aug  4 16:50:03 2012 +0300| [b1a0789432b6d70e3eb5e0aa45dd9d18eaae3a63] | committer: Rémi Denis-Courmont

Check for 3D Now! at build time

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b1a0789432b6d70e3eb5e0aa45dd9d18eaae3a63
---

 include/vlc_cpu.h                              |    8 +++++++-
 modules/codec/avcodec/avcodec.c                |    2 +-
 modules/codec/avcodec/encoder.c                |    2 +-
 modules/codec/libmpeg2.c                       |    2 +-
 modules/stream_out/switcher.c                  |    6 ++----
 modules/video_filter/deinterlace/deinterlace.c |    2 +-
 modules/video_filter/postproc.c                |    2 +-
 modules/video_filter/swscale.c                 |    2 +-
 src/misc/cpu.c                                 |   11 ++---------
 src/posix/linux_cpu.c                          |   11 +----------
 10 files changed, 18 insertions(+), 30 deletions(-)

diff --git a/include/vlc_cpu.h b/include/vlc_cpu.h
index a87589d..83a85be 100644
--- a/include/vlc_cpu.h
+++ b/include/vlc_cpu.h
@@ -31,7 +31,7 @@ VLC_API unsigned vlc_CPU(void);
 # if defined (__i386__) || defined (__x86_64__)
 #  define HAVE_FPU 1
 #  define VLC_CPU_MMX    8
-#  define CPU_CAPABILITY_3DNOW   (1<<4)
+#  define VLC_CPU_3dNOW  16
 #  define VLC_CPU_MMXEXT 32
 #  define VLC_CPU_SSE    64
 #  define VLC_CPU_SSE2   128
@@ -103,6 +103,12 @@ VLC_API unsigned vlc_CPU(void);
 #  define vlc_CPU_SSE4A() ((vlc_CPU() & VLC_CPU_SSE4A) != 0)
 # endif
 
+# ifdef __3dNOW__
+#  define vlc_CPU_3dNOW() (1)
+# else
+#  define vlc_CPU_3dNOW() ((vlc_CPU() & VLC_CPU_3dNOW) != 0)
+# endif
+
 # elif defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__)
 #  define HAVE_FPU 1
 #  define VLC_CPU_ALTIVEC 2
diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index 4159cc0..d79d6b0 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -335,7 +335,7 @@ static int OpenDecoder( vlc_object_t *p_this )
         p_context->dsp_mask |= AV_CPU_FLAG_MMX;
     if( !vlc_CPU_MMXEXT() )
         p_context->dsp_mask |= AV_CPU_FLAG_MMX2;
-    if( !(vlc_CPU() & CPU_CAPABILITY_3DNOW) )
+    if( !vlc_CPU_3dNOW() )
         p_context->dsp_mask |= AV_CPU_FLAG_3DNOW;
     if( !vlc_CPU_SSE() )
         p_context->dsp_mask |= AV_CPU_FLAG_SSE;
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 02888ef..018ca3c 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -329,7 +329,7 @@ int OpenEncoder( vlc_object_t *p_this )
         p_context->dsp_mask |= AV_CPU_FLAG_MMX;
     if( !vlc_CPU_MMXEXT() )
         p_context->dsp_mask |= AV_CPU_FLAG_MMX2;
-    if( !(vlc_CPU() & CPU_CAPABILITY_3DNOW) )
+    if( !vlc_CPU_3dNOW() )
         p_context->dsp_mask |= AV_CPU_FLAG_3DNOW;
     if( !vlc_CPU_SSE() )
         p_context->dsp_mask |= AV_CPU_FLAG_SSE;
diff --git a/modules/codec/libmpeg2.c b/modules/codec/libmpeg2.c
index deed283..4059b78 100644
--- a/modules/codec/libmpeg2.c
+++ b/modules/codec/libmpeg2.c
@@ -195,7 +195,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     unsigned cpu = vlc_CPU();
     if( vlc_CPU_MMX() )
         i_accel |= MPEG2_ACCEL_X86_MMX;
-    if( cpu & CPU_CAPABILITY_3DNOW )
+    if( vlc_CPU_3dNOW() )
         i_accel |= MPEG2_ACCEL_X86_3DNOW;
     if( vlc_CPU_MMXEXT() )
         i_accel |= MPEG2_ACCEL_X86_MMXEXT;
diff --git a/modules/stream_out/switcher.c b/modules/stream_out/switcher.c
index bb0c1b3..ac7945f 100644
--- a/modules/stream_out/switcher.c
+++ b/modules/stream_out/switcher.c
@@ -380,12 +380,11 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
         /* Set CPU capabilities */
         id->ff_enc_c->dsp_mask = 0;
 #if defined (__i386__) || defined (__x86_64__)
-        unsigned i_cpu = vlc_CPU();
         if( !vlc_CPU_MMX() )
             id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_MMX;
         if( !vlc_CPU_MMXEXT() )
             id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_MMX2;
-        if( !(i_cpu & CPU_CAPABILITY_3DNOW) )
+        if( !vlc_CPU_3dNOW() )
             id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_3DNOW;
         if( !vlc_CPU_SSE() )
             id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_SSE;
@@ -801,12 +800,11 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
         /* Set CPU capabilities */
         id->ff_enc_c->dsp_mask = 0;
 #if defined (__i386__) || defined (__x86_64__)
-        unsigned i_cpu = vlc_CPU();
         if( !vlc_CPU_MMX() )
             id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_MMX;
         if( !vlc_CPU_MMXEXT() )
             id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_MMX2;
-        if( !(i_cpu & CPU_CAPABILITY_3DNOW) )
+        if( !vlc_CPU_3dNOW() )
             id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_3DNOW;
         if( !vlc_CPU_SSE() )
             id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_SSE;
diff --git a/modules/video_filter/deinterlace/deinterlace.c b/modules/video_filter/deinterlace/deinterlace.c
index ab02cbb..ac83dfc 100644
--- a/modules/video_filter/deinterlace/deinterlace.c
+++ b/modules/video_filter/deinterlace/deinterlace.c
@@ -649,7 +649,7 @@ int Open( vlc_object_t *p_this )
     else
 #endif
 #if defined(CAN_COMPILE_3DNOW)
-    if( chroma->pixel_size == 1 && (vlc_CPU() & CPU_CAPABILITY_3DNOW) )
+    if( chroma->pixel_size == 1 && vlc_CPU_3dNOW() )
     {
         p_sys->pf_merge = Merge3DNow;
         p_sys->pf_end_merge = End3DNow;
diff --git a/modules/video_filter/postproc.c b/modules/video_filter/postproc.c
index 5fb5127..db2bbe1 100644
--- a/modules/video_filter/postproc.c
+++ b/modules/video_filter/postproc.c
@@ -138,7 +138,7 @@ static int OpenPostproc( vlc_object_t *p_this )
         i_flags |= PP_CPU_CAPS_MMX;
     if( vlc_CPU_MMXEXT() )
         i_flags |= PP_CPU_CAPS_MMX2;
-    if( vlc_CPU() & CPU_CAPABILITY_3DNOW )
+    if( vlc_CPU_3dNOW() )
         i_flags |= PP_CPU_CAPS_3DNOW;
 #elif defined(__ppc__) || defined(__ppc64__) || defined(__powerpc__)
     if( vlc_CPU_ALTIVEC() )
diff --git a/modules/video_filter/swscale.c b/modules/video_filter/swscale.c
index 9a5bfda..632a04a 100644
--- a/modules/video_filter/swscale.c
+++ b/modules/video_filter/swscale.c
@@ -238,7 +238,7 @@ static int GetSwsCpuMask(void)
     if( vlc_CPU_MMXEXT() )
         i_sws_cpu |= SWS_CPU_CAPS_MMX2;
 #endif
-    if( vlc_CPU() & CPU_CAPABILITY_3DNOW )
+    if( vlc_CPU_3dNOW() )
         i_sws_cpu |= SWS_CPU_CAPS_3DNOW;
 #elif defined(__ppc__) || defined(__ppc64__) || defined(__powerpc__)
     if( vlc_CPU_ALTIVEC() )
diff --git a/src/misc/cpu.c b/src/misc/cpu.c
index f7e9bfe..6b284a8 100644
--- a/src/misc/cpu.c
+++ b/src/misc/cpu.c
@@ -266,9 +266,7 @@ void vlc_CPU_init (void)
     /* list these additional capabilities */
     cpuid( 0x80000001 );
 
-# if defined (__3dNOW__)
-    i_capabilities |= CPU_CAPABILITY_3DNOW;
-# elif defined (CAN_COMPILE_3DNOW)
+# if defined (CAN_COMPILE_3DNOW)
     if ((i_edx & 0x80000000) && vlc_CPU_check ("3D Now!", ThreeD_Now_test))
         i_capabilities |= CPU_CAPABILITY_3DNOW;
 # endif
@@ -330,11 +328,6 @@ void vlc_CPU_dump (vlc_object_t *obj)
     char buf[200], *p = buf;
 
 #if defined (__i386__) || defined (__x86_64__)
-    const unsigned flags = vlc_CPU();
-#define PRINT_CAPABILITY( capability, string ) \
-    if (flags & (capability)) \
-        p += sprintf (p, "%s ", (string) )
-
     if (vlc_CPU_MMX()) p += sprintf (p, "MMX ");
     if (vlc_CPU_MMXEXT()) p += sprintf (p, "MMXEXT ");
     if (vlc_CPU_SSE()) p += sprintf (p, "SSE ");;
@@ -344,7 +337,7 @@ void vlc_CPU_dump (vlc_object_t *obj)
     if (vlc_CPU_SSE4_1()) p += sprintf (p, "SSE4.1 ");;
     if (vlc_CPU_SSE4_2()) p += sprintf (p, "SSE4.2 ");;
     if (vlc_CPU_SSE4A()) p += sprintf (p, "SSE4A ");;
-    PRINT_CAPABILITY(CPU_CAPABILITY_3DNOW, "3DNow!");
+    if (vlc_CPU_3dNOW()) p += sprintf (p, "3DNow! ");;
 
 #elif defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__)
     if (vlc_CPU_ALTIVEC())  p += sprintf (p, "AltiVec");
diff --git a/src/posix/linux_cpu.c b/src/posix/linux_cpu.c
index edb4f24..cc33db2 100644
--- a/src/posix/linux_cpu.c
+++ b/src/posix/linux_cpu.c
@@ -85,10 +85,8 @@ static void vlc_CPU_init (void)
                 core_caps |= VLC_CPU_SSE4_1;
             if (!strcmp (cap, "sse4a"))
                 core_caps |= VLC_CPU_SSE4A;
-# ifndef __3dNOW__
             if (!strcmp (cap, "3dnow"))
-                core_caps |= CPU_CAPABILITY_3DNOW;
-# endif
+                core_caps |= VLC_CPU_3dNOW;
 
 #elif defined (__powerpc__) || defined (__powerpc64__)
             if (!strcmp (cap, "altivec supported"))
@@ -105,13 +103,6 @@ static void vlc_CPU_init (void)
     if (all_caps == 0xFFFFFFFF) /* Error parsing of cpuinfo? */
         all_caps = 0; /* Do not assume any capability! */
 
-    /* Always enable capabilities that were forced during compilation */
-#if defined (__i386__) || defined (__x86_64__)
-# ifdef __3dNOW__
-    all_caps |= CPU_CAPABILITY_3DNOW;
-# endif
-
-#endif
     cpu_flags = all_caps;
 }
 



More information about the vlc-commits mailing list