[vlc-commits] Check for AltiVec at build-time if possible (untested)

Rémi Denis-Courmont git at videolan.org
Wed Aug 1 23:34:38 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Aug  2 00:33:06 2012 +0300| [7bdcbe8ac844cfbe03df61cf3c6f1877d0d716b9] | committer: Rémi Denis-Courmont

Check for AltiVec at build-time if possible (untested)

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

 include/vlc_cpu.h                              |    8 +++++++-
 modules/codec/libmpeg2.c                       |    2 +-
 modules/video_chroma/i420_yuy2.c               |   12 +++++-------
 modules/video_filter/deinterlace/deinterlace.c |    2 +-
 modules/video_filter/postproc.c                |    2 +-
 modules/video_filter/swscale.c                 |    2 +-
 src/misc/cpu.c                                 |    7 +++----
 src/posix/linux_cpu.c                          |    2 +-
 8 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/include/vlc_cpu.h b/include/vlc_cpu.h
index bc0b1c1..1d0bf9a 100644
--- a/include/vlc_cpu.h
+++ b/include/vlc_cpu.h
@@ -59,7 +59,13 @@ VLC_API unsigned vlc_CPU(void);
 
 # elif defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__)
 #  define HAVE_FPU 1
-#  define CPU_CAPABILITY_ALTIVEC (1<<16)
+#  define VLC_CPU_ALTIVEC 2
+
+#  ifdef ALTIVEC
+#   define vlc_CPU_ALTIVEC() (1)
+#  else
+#   define vlc_CPU_ALTIVEC() ((vlc_CPU() & VLC_CPU_ALTIVEC) != 0)
+#  endif
 
 # elif defined (__arm__)
 #  if defined (__VFP_FP__) && !defined (__SOFTFP__)
diff --git a/modules/codec/libmpeg2.c b/modules/codec/libmpeg2.c
index 4fac952..e2301a7 100644
--- a/modules/codec/libmpeg2.c
+++ b/modules/codec/libmpeg2.c
@@ -200,7 +200,7 @@ static int OpenDecoder( vlc_object_t *p_this )
     if( cpu & CPU_CAPABILITY_MMXEXT )
         i_accel |= MPEG2_ACCEL_X86_MMXEXT;
 #elif defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
-    if( vlc_CPU() & CPU_CAPABILITY_ALTIVEC )
+    if( vlc_CPU_ALTIVEC() )
         i_accel |= MPEG2_ACCEL_PPC_ALTIVEC;
 
 #elif defined(__arm__)
diff --git a/modules/video_chroma/i420_yuy2.c b/modules/video_chroma/i420_yuy2.c
index 1d36b06..301bf62 100644
--- a/modules/video_chroma/i420_yuy2.c
+++ b/modules/video_chroma/i420_yuy2.c
@@ -88,20 +88,20 @@ vlc_module_begin ()
 #if defined (MODULE_NAME_IS_i420_yuy2)
     set_description( N_("Conversions from " SRC_FOURCC " to " DEST_FOURCC) )
     set_capability( "video filter2", 80 )
-# define CPU_CAPABILITY 0
+# define vlc_CPU_capable() (1)
 #elif defined (MODULE_NAME_IS_i420_yuy2_mmx)
     set_description( N_("MMX conversions from " SRC_FOURCC " to " DEST_FOURCC) )
     set_capability( "video filter2", 160 )
-# define CPU_CAPABILITY CPU_CAPABILITY_MMX
+# define vlc_CPU_capable() (vlc_CPU() & CPU_CAPABILITY_MMX)
 #elif defined (MODULE_NAME_IS_i420_yuy2_sse2)
     set_description( N_("SSE2 conversions from " SRC_FOURCC " to " DEST_FOURCC) )
     set_capability( "video filter2", 250 )
-# define CPU_CAPABILITY CPU_CAPABILITY_SSE2
+# define vlc_CPU_capable() (vlc_CPU() & CPU_CAPABILITY_SSE2)
 #elif defined (MODULE_NAME_IS_i420_yuy2_altivec)
     set_description(
             _("AltiVec conversions from " SRC_FOURCC " to " DEST_FOURCC) );
     set_capability( "video filter2", 250 )
-# define CPU_CAPABILITY CPU_CAPABILITY_ALTIVEC
+# define vlc_CPU_capable() (vlc_CPU_ALTIVEC())
 #endif
     set_callbacks( Activate, NULL )
 vlc_module_end ()
@@ -115,10 +115,8 @@ static int Activate( vlc_object_t *p_this )
 {
     filter_t *p_filter = (filter_t *)p_this;
 
-#if CPU_CAPABILITY
-    if( !(vlc_CPU() & CPU_CAPABILITY) )
+    if( !vlc_CPU_capable() )
         return VLC_EGENERIC;
-#endif
     if( p_filter->fmt_in.video.i_width & 1
      || p_filter->fmt_in.video.i_height & 1 )
     {
diff --git a/modules/video_filter/deinterlace/deinterlace.c b/modules/video_filter/deinterlace/deinterlace.c
index 1995afc..b03987a 100644
--- a/modules/video_filter/deinterlace/deinterlace.c
+++ b/modules/video_filter/deinterlace/deinterlace.c
@@ -628,7 +628,7 @@ int Open( vlc_object_t *p_this )
     IVTCClearState( p_filter );
 
 #if defined(CAN_COMPILE_C_ALTIVEC)
-    if( chroma->pixel_size == 1 && (vlc_CPU() & CPU_CAPABILITY_ALTIVEC) )
+    if( chroma->pixel_size == 1 && vlc_CPU_ALTIVEC() )
     {
         p_sys->pf_merge = MergeAltivec;
         p_sys->pf_end_merge = NULL;
diff --git a/modules/video_filter/postproc.c b/modules/video_filter/postproc.c
index e58a025..5c21235 100644
--- a/modules/video_filter/postproc.c
+++ b/modules/video_filter/postproc.c
@@ -142,7 +142,7 @@ static int OpenPostproc( vlc_object_t *p_this )
     if( i_cpu & CPU_CAPABILITY_3DNOW )
         i_flags |= PP_CPU_CAPS_3DNOW;
 #elif defined(__ppc__) || defined(__ppc64__) || defined(__powerpc__)
-    if( vlc_CPU() & CPU_CAPABILITY_ALTIVEC )
+    if( vlc_CPU_ALTIVEC() )
         i_flags |= PP_CPU_CAPS_ALTIVEC;
 #endif
 
diff --git a/modules/video_filter/swscale.c b/modules/video_filter/swscale.c
index 04fbe7e..9500d0e 100644
--- a/modules/video_filter/swscale.c
+++ b/modules/video_filter/swscale.c
@@ -242,7 +242,7 @@ static int GetSwsCpuMask(void)
     if( i_cpu & CPU_CAPABILITY_3DNOW )
         i_sws_cpu |= SWS_CPU_CAPS_3DNOW;
 #elif defined(__ppc__) || defined(__ppc64__) || defined(__powerpc__)
-    if( vlc_CPU() & CPU_CAPABILITY_ALTIVEC )
+    if( vlc_CPU_ALTIVEC() )
         i_sws_cpu |= SWS_CPU_CAPS_ALTIVEC;
 #endif
 
diff --git a/src/misc/cpu.c b/src/misc/cpu.c
index 7484562..1acd046 100644
--- a/src/misc/cpu.c
+++ b/src/misc/cpu.c
@@ -308,11 +308,11 @@ out:
     int i_error = sysctl( selectors, 2, &i_has_altivec, &i_length, NULL, 0);
 
     if( i_error == 0 && i_has_altivec != 0 )
-        i_capabilities |= CPU_CAPABILITY_ALTIVEC;
+        i_capabilities |= VLC_CPU_ALTIVEC;
 
 #   elif defined( CAN_COMPILE_ALTIVEC )
     if (vlc_CPU_check ("Altivec", Altivec_test))
-        i_capabilities |= CPU_CAPABILITY_ALTIVEC;
+        i_capabilities |= VLC_CPU_ALTIVEC;
 
 #   endif
 
@@ -364,8 +364,7 @@ void vlc_CPU_dump (vlc_object_t *obj)
     PRINT_CAPABILITY(CPU_CAPABILITY_SSE4A,  "SSE4A");
 
 #elif defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__)
-    if (vlc_CPU() & CPU_CAPABILITY_ALTIVEC)
-        p += sprintf (p, "AltiVec");
+    if (vlc_CPU_ALTIVEC())  p += sprintf (p, "AltiVec");
 
 #elif defined (__arm__)
     if (vlc_CPU_ARM_NEON()) p += sprintf (p, "ARM_NEON ");
diff --git a/src/posix/linux_cpu.c b/src/posix/linux_cpu.c
index 1b7f5d6..83bbc4c 100644
--- a/src/posix/linux_cpu.c
+++ b/src/posix/linux_cpu.c
@@ -106,7 +106,7 @@ static void vlc_CPU_init (void)
 
 #elif defined (__powerpc__) || defined (__powerpc64__)
             if (!strcmp (cap, "altivec supported"))
-                core_caps |= CPU_CAPABILITY_ALTIVEC;
+                core_caps |= VLC_CPU_ALTIVEC;
 #endif
         }
 



More information about the vlc-commits mailing list