[vlc-commits] Check for SSE3 at build-time if possible
Rémi Denis-Courmont
git at videolan.org
Sat Aug 4 16:02:08 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Aug 4 16:28:22 2012 +0300| [6f7ffd31655d7ba7f0ba1b3e8f400a831f56e804] | committer: Rémi Denis-Courmont
Check for SSE3 at build-time if possible
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6f7ffd31655d7ba7f0ba1b3e8f400a831f56e804
---
include/vlc_cpu.h | 8 +++++++-
modules/codec/avcodec/avcodec.c | 2 +-
modules/codec/avcodec/encoder.c | 2 +-
modules/stream_out/switcher.c | 4 ++--
src/misc/cpu.c | 8 +++-----
src/posix/linux_cpu.c | 7 +------
6 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/include/vlc_cpu.h b/include/vlc_cpu.h
index f233b66..1c2090d 100644
--- a/include/vlc_cpu.h
+++ b/include/vlc_cpu.h
@@ -35,7 +35,7 @@ VLC_API unsigned vlc_CPU(void);
# define VLC_CPU_MMXEXT 32
# define VLC_CPU_SSE 64
# define VLC_CPU_SSE2 128
-# define CPU_CAPABILITY_SSE3 (1<<8)
+# define VLC_CPU_SSE3 256
# define CPU_CAPABILITY_SSSE3 (1<<9)
# define CPU_CAPABILITY_SSE4_1 (1<<10)
# define CPU_CAPABILITY_SSE4_2 (1<<11)
@@ -73,6 +73,12 @@ VLC_API unsigned vlc_CPU(void);
# define vlc_CPU_SSE2() ((vlc_CPU() & VLC_CPU_SSE2) != 0)
# endif
+# ifdef __SSE3__
+# define vlc_CPU_SSE3() (1)
+# else
+# define vlc_CPU_SSE3() ((vlc_CPU() & VLC_CPU_SSE3) != 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 3f606b6..2c1961c 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -343,7 +343,7 @@ static int OpenDecoder( vlc_object_t *p_this )
if( !vlc_CPU_SSE2() )
p_context->dsp_mask |= AV_CPU_FLAG_SSE2;
# ifdef AV_CPU_FLAG_SSE3
- if( !(i_cpu & CPU_CAPABILITY_SSE3) )
+ if( !vlc_CPU_SSE3() )
p_context->dsp_mask |= AV_CPU_FLAG_SSE3;
# endif
# ifdef AV_CPU_FLAG_SSSE3
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 537a445..70f98ad 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -337,7 +337,7 @@ int OpenEncoder( vlc_object_t *p_this )
if( !vlc_CPU_SSE2() )
p_context->dsp_mask |= AV_CPU_FLAG_SSE2;
# ifdef AV_CPU_FLAG_SSE3
- if( !(i_cpu & CPU_CAPABILITY_SSE3) )
+ if( !vlc_CPU_SSE3() )
p_context->dsp_mask |= AV_CPU_FLAG_SSE3;
# endif
# ifdef AV_CPU_FLAG_SSSE3
diff --git a/modules/stream_out/switcher.c b/modules/stream_out/switcher.c
index 8c28541..a52dbc7 100644
--- a/modules/stream_out/switcher.c
+++ b/modules/stream_out/switcher.c
@@ -392,7 +392,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
if( !vlc_cpu_SSE2() )
id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_SSE2;
# ifdef AV_CPU_FLAG_SSE3
- if( !(i_cpu & CPU_CAPABILITY_SSE3) )
+ if( !vlc_CPU_SSE3() )
id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_SSE3;
# endif
# ifdef AV_CPU_FLAG_SSSE3
@@ -813,7 +813,7 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
if( !vlc_CPU_SSE2() )
id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_SSE2;
# ifdef AV_CPU_FLAG_SSE3
- if( !(i_cpu & CPU_CAPABILITY_SSE3) )
+ if( !vlc_CPU_SSE3() )
id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_SSE3;
# endif
# ifdef AV_CPU_FLAG_SSSE3
diff --git a/src/misc/cpu.c b/src/misc/cpu.c
index fb193fc..c258e94 100644
--- a/src/misc/cpu.c
+++ b/src/misc/cpu.c
@@ -237,11 +237,9 @@ void vlc_CPU_init (void)
i_capabilities |= VLC_CPU_SSE2;
# endif
-# if defined (__SSE3__)
- i_capabilities |= CPU_CAPABILITY_SSE3;
-# elif defined (CAN_COMPILE_SSE3)
+# if defined (CAN_COMPILE_SSE3)
if ((i_ecx & 0x00000001) && vlc_CPU_check ("SSE3", SSE3_test))
- i_capabilities |= CPU_CAPABILITY_SSE3;
+ i_capabilities |= VLC_CPU_SSE3;
# endif
# if defined (__SSSE3__)
@@ -347,7 +345,7 @@ void vlc_CPU_dump (vlc_object_t *obj)
if (vlc_CPU_MMXEXT()) p += sprintf (p, "MMXEXT ");
if (vlc_CPU_SSE()) p += sprintf (p, "SSE ");;
if (vlc_CPU_SSE2()) p += sprintf (p, "SSE2 ");;
- PRINT_CAPABILITY(CPU_CAPABILITY_SSE3, "SSE3");
+ if (vlc_CPU_SSE3()) p += sprintf (p, "SSE2 ");;
PRINT_CAPABILITY(CPU_CAPABILITY_SSSE3, "SSSE3");
PRINT_CAPABILITY(CPU_CAPABILITY_SSE4_1, "SSE4.1");
PRINT_CAPABILITY(CPU_CAPABILITY_SSE4_2, "SSE4.2");
diff --git a/src/posix/linux_cpu.c b/src/posix/linux_cpu.c
index 57b4326..5b6ffa3 100644
--- a/src/posix/linux_cpu.c
+++ b/src/posix/linux_cpu.c
@@ -75,10 +75,8 @@ static void vlc_CPU_init (void)
core_caps |= VLC_CPU_MMXEXT;
if (!strcmp (cap, "sse2"))
core_caps |= VLC_CPU_SSE2;
-# ifndef __SSE3__
if (!strcmp (cap, "pni"))
- core_caps |= CPU_CAPABILITY_SSE3;
-# endif
+ core_caps |= VLC_CPU_SSE3;
# ifndef __SSSE3__
if (!strcmp (cap, "ssse3"))
core_caps |= CPU_CAPABILITY_SSSE3;
@@ -115,9 +113,6 @@ static void vlc_CPU_init (void)
/* Always enable capabilities that were forced during compilation */
#if defined (__i386__) || defined (__x86_64__)
-# ifdef __SSE3__
- all_caps |= CPU_CAPABILITY_SSE3;
-# endif
# ifdef __SSSE3__
all_caps |= CPU_CAPABILITY_SSSE3;
# endif
More information about the vlc-commits
mailing list