]> git.sesse.net Git - vlc/commitdiff
Check for AltiVec at build-time if possible (untested)
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 1 Aug 2012 21:33:06 +0000 (00:33 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 1 Aug 2012 21:34:25 +0000 (00:34 +0300)
include/vlc_cpu.h
modules/codec/libmpeg2.c
modules/video_chroma/i420_yuy2.c
modules/video_filter/deinterlace/deinterlace.c
modules/video_filter/postproc.c
modules/video_filter/swscale.c
src/misc/cpu.c
src/posix/linux_cpu.c

index bc0b1c16ea86d181a86fda55a1de2d784b7292a3..1d0bf9a9c0ed051ce1b49e3e2e8a02b43789aaf9 100644 (file)
@@ -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__)
index 4fac95248e0b41846c74033c1738caffca946975..e2301a710c2629156bc6f1d20c4a337cd6a53046 100644 (file)
@@ -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__)
index 1d36b06f36a6930524d8f074a1ab2d80e4e6c519..301bf627b759b2415541ee4d55d83f99d62f20c4 100644 (file)
@@ -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 )
     {
index 1995afcd6e321d10d471d8eefc40b854850c9b6d..b03987ad0da40e599efc072d57f59d2a9b1da31e 100644 (file)
@@ -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;
index e58a02577f44a7f73f491a1fb61deecc9e02a535..5c21235566177459667bc2dc2aebd09af00a6de6 100644 (file)
@@ -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
 
index 04fbe7e50cec2dff3e51b6b82f6acfaad9cfc60b..9500d0ec6b51a5ce9a91fce922df4f54524029d2 100644 (file)
@@ -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
 
index 748456293e52eed9ed513dd2ab4c3ec987701fbc..1acd0462ee09668239bee176f2d456eeaf7e2643 100644 (file)
@@ -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 ");
index 1b7f5d60a84f00ee9266f127c61f3d33345ed3b1..83bbc4cc41d74042695ec235b4c37ea73e764c66 100644 (file)
@@ -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
         }