[vlc-commits] Check for ARM NEON at build-time if possible
Rémi Denis-Courmont
git at videolan.org
Wed Aug 1 23:20:15 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Aug 2 00:19:24 2012 +0300| [b830aae4f0bb0f362299f67318a51e733f73c8c5] | committer: Rémi Denis-Courmont
Check for ARM NEON at build-time if possible
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b830aae4f0bb0f362299f67318a51e733f73c8c5
---
configure.ac | 1 -
include/vlc_cpu.h | 8 +++++++-
modules/arm_neon/audio_format.c | 2 +-
modules/arm_neon/chroma_yuv.c | 2 +-
modules/arm_neon/yuv_rgb.c | 2 +-
modules/codec/libmpeg2.c | 2 +-
modules/video_filter/deinterlace/deinterlace.c | 2 +-
src/misc/cpu.c | 25 ++++++++++--------------
src/posix/linux_cpu.c | 11 ++---------
9 files changed, 24 insertions(+), 31 deletions(-)
diff --git a/configure.ac b/configure.ac
index 702ae7d..7ac07e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1330,7 +1330,6 @@ asm volatile("ssat r0, #1, r0":::"r0"); /* assume ARMv6 */
VLC_RESTORE_FLAGS
AS_IF([test "$ac_cv_neon_inline" != "no"], [
NEON_CFLAGS="$ac_cv_neon_inline"
- AC_DEFINE([CAN_COMPILE_NEON], 1, [Define to 1 if NEON (and ARMv6) assembly is available with NEON_CFLAGS.])
])
], [
ac_cv_neon_inline="no"
diff --git a/include/vlc_cpu.h b/include/vlc_cpu.h
index befe49e..bc0b1c1 100644
--- a/include/vlc_cpu.h
+++ b/include/vlc_cpu.h
@@ -67,7 +67,13 @@ VLC_API unsigned vlc_CPU(void);
# else
# define HAVE_FPU 0
# endif
-# define CPU_CAPABILITY_NEON (1<<24)
+# define VLC_CPU_ARM_NEON 2
+
+# ifdef __ARM_NEON__
+# define vlc_CPU_ARM_NEON() (1)
+# else
+# define vlc_CPU_ARM_NEON() ((vlc_CPU() & VLC_CPU_ARM_NEON) != 0)
+# endif
# elif defined (__sparc__)
# define HAVE_FPU 1
diff --git a/modules/arm_neon/audio_format.c b/modules/arm_neon/audio_format.c
index 3a76f18..ec33161 100644
--- a/modules/arm_neon/audio_format.c
+++ b/modules/arm_neon/audio_format.c
@@ -45,7 +45,7 @@ static int Open (vlc_object_t *obj)
{
filter_t *filter = (filter_t *)obj;
- if (!(vlc_CPU() & CPU_CAPABILITY_NEON))
+ if (!vlc_CPU_ARM_NEON())
return VLC_EGENERIC;
if (!AOUT_FMTS_SIMILAR (&filter->fmt_in.audio, &filter->fmt_out.audio))
return VLC_EGENERIC;
diff --git a/modules/arm_neon/chroma_yuv.c b/modules/arm_neon/chroma_yuv.c
index be9ccb6..957d2fd 100644
--- a/modules/arm_neon/chroma_yuv.c
+++ b/modules/arm_neon/chroma_yuv.c
@@ -162,7 +162,7 @@ static int Open (vlc_object_t *obj)
{
filter_t *filter = (filter_t *)obj;
- if (!(vlc_CPU() & CPU_CAPABILITY_NEON))
+ if (!vlc_CPU_ARM_NEON())
return VLC_EGENERIC;
if ((filter->fmt_in.video.i_width != filter->fmt_out.video.i_width)
|| (filter->fmt_in.video.i_height != filter->fmt_out.video.i_height))
diff --git a/modules/arm_neon/yuv_rgb.c b/modules/arm_neon/yuv_rgb.c
index 8b458f4..91e24ae 100644
--- a/modules/arm_neon/yuv_rgb.c
+++ b/modules/arm_neon/yuv_rgb.c
@@ -125,7 +125,7 @@ static int Open (vlc_object_t *obj)
{
filter_t *filter = (filter_t *)obj;
- if (!(vlc_CPU() & CPU_CAPABILITY_NEON))
+ if (!vlc_CPU_ARM_NEON())
return VLC_EGENERIC;
if (((filter->fmt_in.video.i_width | filter->fmt_in.video.i_height) & 1)
diff --git a/modules/codec/libmpeg2.c b/modules/codec/libmpeg2.c
index 8365c15..4fac952 100644
--- a/modules/codec/libmpeg2.c
+++ b/modules/codec/libmpeg2.c
@@ -208,7 +208,7 @@ static int OpenDecoder( vlc_object_t *p_this )
i_accel |= MPEG2_ACCEL_ARM;
# endif
# ifdef MPEG2_ACCEL_ARM_NEON
- if( vlc_CPU() & CPU_CAPABILITY_NEON )
+ if( vlc_CPU_ARM_NEON() )
i_accel |= MPEG2_ACCEL_ARM_NEON;
# endif
diff --git a/modules/video_filter/deinterlace/deinterlace.c b/modules/video_filter/deinterlace/deinterlace.c
index 2762f04..1995afc 100644
--- a/modules/video_filter/deinterlace/deinterlace.c
+++ b/modules/video_filter/deinterlace/deinterlace.c
@@ -660,7 +660,7 @@ int Open( vlc_object_t *p_this )
else
#endif
#if defined __ARM_NEON__ // FIXME: runtime detect support
- if( chroma->pixel_size == 1 && (vlc_CPU() & CPU_CAPABILITY_NEON) )
+ if( chroma->pixel_size == 1 && vlc_CPU_ARM_NEON() )
{
p_sys->pf_merge = MergeNEON;
p_sys->pf_end_merge = NULL;
diff --git a/src/misc/cpu.c b/src/misc/cpu.c
index 089f891..7484562 100644
--- a/src/misc/cpu.c
+++ b/src/misc/cpu.c
@@ -317,14 +317,11 @@ out:
# endif
#elif defined ( __arm__)
- #ifdef __ARM_NEON__
- i_capabilities |= CPU_CAPABILITY_NEON;
- #elif defined (CAN_COMPILE_NEON)
- #ifdef __ANDROID__
- if (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON)
- i_capabilities |= CPU_CAPABILITY_NEON;
- #endif
- #endif
+# ifdef __ANDROID__
+ if (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON)
+ i_capabilities |= VLC_CPU_ARM_NEON;
+# endif
+
#endif
cpu_flags = i_capabilities;
@@ -347,14 +344,14 @@ unsigned vlc_CPU (void)
void vlc_CPU_dump (vlc_object_t *obj)
{
- const unsigned flags = vlc_CPU();
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 defined (__i386__) || defined (__x86_64__)
PRINT_CAPABILITY(CPU_CAPABILITY_MMX, "MMX");
PRINT_CAPABILITY(CPU_CAPABILITY_3DNOW, "3DNow!");
PRINT_CAPABILITY(CPU_CAPABILITY_MMXEXT, "MMXEXT");
@@ -367,13 +364,11 @@ void vlc_CPU_dump (vlc_object_t *obj)
PRINT_CAPABILITY(CPU_CAPABILITY_SSE4A, "SSE4A");
#elif defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__)
- PRINT_CAPABILITY(CPU_CAPABILITY_ALTIVEC, "AltiVec");
+ if (vlc_CPU() & CPU_CAPABILITY_ALTIVEC)
+ p += sprintf (p, "AltiVec");
#elif defined (__arm__)
- PRINT_CAPABILITY(CPU_CAPABILITY_NEON, "NEONv1");
-
-#else
- (void) flags;
+ if (vlc_CPU_ARM_NEON()) p += sprintf (p, "ARM_NEON ");
#endif
diff --git a/src/posix/linux_cpu.c b/src/posix/linux_cpu.c
index d243424..1b7f5d6 100644
--- a/src/posix/linux_cpu.c
+++ b/src/posix/linux_cpu.c
@@ -63,10 +63,8 @@ static void vlc_CPU_init (void)
while ((cap = strsep (&p, " ")) != NULL)
{
#if defined (__arm__)
-# ifndef __ARM_NEON__
if (!strcmp (cap, "neon"))
- core_caps |= CPU_CAPABILITY_NEON;
-# endif
+ core_caps |= VLC_CPU_ARM_NEON;
#elif defined (__i386__) || defined (__x86_64__)
# ifndef __MMX__
@@ -122,12 +120,7 @@ static void vlc_CPU_init (void)
all_caps = 0; /* Do not assume any capability! */
/* Always enable capabilities that were forced during compilation */
-#if defined (__arm__)
-# ifdef __ARM_NEON__
- all_caps |= CPU_CAPABILITY_NEON;
-# endif
-
-#elif defined (__i386__) || defined (__x86_64__)
+#if defined (__i386__) || defined (__x86_64__)
# ifdef __MMX__
all_caps |= CPU_CAPABILITY_MMX;
# endif
More information about the vlc-commits
mailing list