[vlc-commits] Check for SSSE3 at build time if possible
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:35:19 2012 +0300| [58dd22531f1fa4aa858badb45bf5c63ae099b2a6] | committer: Rémi Denis-Courmont
Check for SSSE3 at build time if possible
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=58dd22531f1fa4aa858badb45bf5c63ae099b2a6
---
include/vlc_cpu.h | 8 +++++++-
modules/codec/avcodec/avcodec.c | 2 +-
modules/codec/avcodec/copy.c | 8 +++++++-
modules/codec/avcodec/encoder.c | 2 +-
modules/stream_out/switcher.c | 4 ++--
modules/video_filter/deinterlace/algo_yadif.c | 2 +-
modules/video_filter/gradfun.c | 2 +-
src/misc/cpu.c | 8 +++-----
src/posix/linux_cpu.c | 7 +------
9 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/include/vlc_cpu.h b/include/vlc_cpu.h
index 1c2090d..9753687 100644
--- a/include/vlc_cpu.h
+++ b/include/vlc_cpu.h
@@ -36,7 +36,7 @@ VLC_API unsigned vlc_CPU(void);
# define VLC_CPU_SSE 64
# define VLC_CPU_SSE2 128
# define VLC_CPU_SSE3 256
-# define CPU_CAPABILITY_SSSE3 (1<<9)
+# define VLC_CPU_SSSE3 512
# define CPU_CAPABILITY_SSE4_1 (1<<10)
# define CPU_CAPABILITY_SSE4_2 (1<<11)
# define CPU_CAPABILITY_SSE4A (1<<12)
@@ -79,6 +79,12 @@ VLC_API unsigned vlc_CPU(void);
# define vlc_CPU_SSE3() ((vlc_CPU() & VLC_CPU_SSE3) != 0)
# endif
+# ifdef __SSSE3__
+# define vlc_CPU_SSSE3() (1)
+# else
+# define vlc_CPU_SSSE3() ((vlc_CPU() & VLC_CPU_SSSE3) != 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 2c1961c..a4e3d82 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -347,7 +347,7 @@ static int OpenDecoder( vlc_object_t *p_this )
p_context->dsp_mask |= AV_CPU_FLAG_SSE3;
# endif
# ifdef AV_CPU_FLAG_SSSE3
- if( !(i_cpu & CPU_CAPABILITY_SSSE3) )
+ if( !vlc_CPU_SSE3() )
p_context->dsp_mask |= AV_CPU_FLAG_SSSE3;
# endif
# ifdef AV_CPU_FLAG_SSE4
diff --git a/modules/codec/avcodec/copy.c b/modules/codec/avcodec/copy.c
index 1573b93..71758ef 100644
--- a/modules/codec/avcodec/copy.c
+++ b/modules/codec/avcodec/copy.c
@@ -47,6 +47,11 @@
store " %%xmm4, 48(%[dst])\n" \
: : [dst]"r"(dstp), [src]"r"(srcp) : "memory")
+#ifndef __SSSE3__
+# undef vlc_CPU_SSSE3
+# define vlc_CPU_SSSE3() ((cpu & VLC_CPU_SSSE3) != 0)
+#endif
+
/* Execute the instruction op only if SSE2 is supported. */
#ifdef CAN_COMPILE_SSE2
# ifdef __SSE2__
@@ -180,7 +185,8 @@ static void SplitUV(uint8_t *dstu, size_t dstu_pitch,
"movhpd %%xmm3, 24(%[dst2])\n"
#ifdef CAN_COMPILE_SSSE3
- if (cpu & CPU_CAPABILITY_SSSE3) {
+ if (vlc_CPU_SSE3())
+ {
for (x = 0; x < (width & ~31); x += 32) {
asm volatile (
"movdqu (%[shuffle]), %%xmm7\n"
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 70f98ad..7101df1 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -341,7 +341,7 @@ int OpenEncoder( vlc_object_t *p_this )
p_context->dsp_mask |= AV_CPU_FLAG_SSE3;
# endif
# ifdef AV_CPU_FLAG_SSSE3
- if( !(i_cpu & CPU_CAPABILITY_SSSE3) )
+ if( !vlc_CPU_SSSE3() )
p_context->dsp_mask |= AV_CPU_FLAG_SSSE3;
# endif
# ifdef AV_CPU_FLAG_SSE4
diff --git a/modules/stream_out/switcher.c b/modules/stream_out/switcher.c
index a52dbc7..b6ebf52 100644
--- a/modules/stream_out/switcher.c
+++ b/modules/stream_out/switcher.c
@@ -396,7 +396,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_SSE3;
# endif
# ifdef AV_CPU_FLAG_SSSE3
- if( !(i_cpu & CPU_CAPABILITY_SSSE3) )
+ if( !vlc_CPU_SSSE3() )
id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_SSSE3;
# endif
# ifdef AV_CPU_FLAG_SSE4
@@ -817,7 +817,7 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_SSE3;
# endif
# ifdef AV_CPU_FLAG_SSSE3
- if( !(i_cpu & CPU_CAPABILITY_SSSE3) )
+ if( !vlc_CPU_SSSE3() )
id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_SSSE3;
# endif
# ifdef AV_CPU_FLAG_SSE4
diff --git a/modules/video_filter/deinterlace/algo_yadif.c b/modules/video_filter/deinterlace/algo_yadif.c
index 8345d3a..04b34fa 100644
--- a/modules/video_filter/deinterlace/algo_yadif.c
+++ b/modules/video_filter/deinterlace/algo_yadif.c
@@ -109,7 +109,7 @@ int RenderYadif( filter_t *p_filter, picture_t *p_dst, picture_t *p_src,
int w, int prefs, int mrefs, int parity, int mode);
#if defined(HAVE_YADIF_SSSE3)
- if( vlc_CPU() & CPU_CAPABILITY_SSSE3 )
+ if( vlc_CPU_SSSE3() )
filter = yadif_filter_line_ssse3;
else
#endif
diff --git a/modules/video_filter/gradfun.c b/modules/video_filter/gradfun.c
index 701a119..3249682 100644
--- a/modules/video_filter/gradfun.c
+++ b/modules/video_filter/gradfun.c
@@ -141,7 +141,7 @@ static int Open(vlc_object_t *object)
#endif
cfg->blur_line = blur_line_c;
#if HAVE_SSSE3
- if (vlc_CPU() & CPU_CAPABILITY_SSSE3)
+ if (vlc_CPU_SSSE3())
cfg->filter_line = filter_line_ssse3;
else
#endif
diff --git a/src/misc/cpu.c b/src/misc/cpu.c
index c258e94..e0ae7b9 100644
--- a/src/misc/cpu.c
+++ b/src/misc/cpu.c
@@ -242,11 +242,9 @@ void vlc_CPU_init (void)
i_capabilities |= VLC_CPU_SSE3;
# endif
-# if defined (__SSSE3__)
- i_capabilities |= CPU_CAPABILITY_SSSE3;
-# elif defined (CAN_COMPILE_SSSE3)
+# if defined (CAN_COMPILE_SSSE3)
if ((i_ecx & 0x00000200) && vlc_CPU_check ("SSSE3", SSSE3_test))
- i_capabilities |= CPU_CAPABILITY_SSSE3;
+ i_capabilities |= VLC_CPU_SSSE3;
# endif
# if defined (__SSE4_1__)
@@ -346,7 +344,7 @@ void vlc_CPU_dump (vlc_object_t *obj)
if (vlc_CPU_SSE()) p += sprintf (p, "SSE ");;
if (vlc_CPU_SSE2()) p += sprintf (p, "SSE2 ");;
if (vlc_CPU_SSE3()) p += sprintf (p, "SSE2 ");;
- PRINT_CAPABILITY(CPU_CAPABILITY_SSSE3, "SSSE3");
+ if (vlc_CPU_SSSE3()) p += sprintf (p, "SSSE3 ");;
PRINT_CAPABILITY(CPU_CAPABILITY_SSE4_1, "SSE4.1");
PRINT_CAPABILITY(CPU_CAPABILITY_SSE4_2, "SSE4.2");
PRINT_CAPABILITY(CPU_CAPABILITY_SSE4A, "SSE4A");
diff --git a/src/posix/linux_cpu.c b/src/posix/linux_cpu.c
index 5b6ffa3..f239d2c 100644
--- a/src/posix/linux_cpu.c
+++ b/src/posix/linux_cpu.c
@@ -77,10 +77,8 @@ static void vlc_CPU_init (void)
core_caps |= VLC_CPU_SSE2;
if (!strcmp (cap, "pni"))
core_caps |= VLC_CPU_SSE3;
-# ifndef __SSSE3__
if (!strcmp (cap, "ssse3"))
- core_caps |= CPU_CAPABILITY_SSSE3;
-# endif
+ core_caps |= VLC_CPU_SSSE3;
# ifndef __SSE4_1__
if (!strcmp (cap, "sse4_1"))
core_caps |= CPU_CAPABILITY_SSE4_1;
@@ -113,9 +111,6 @@ static void vlc_CPU_init (void)
/* Always enable capabilities that were forced during compilation */
#if defined (__i386__) || defined (__x86_64__)
-# ifdef __SSSE3__
- all_caps |= CPU_CAPABILITY_SSSE3;
-# endif
# ifdef __SSE4_1__
all_caps |= CPU_CAPABILITY_SSE4_1;
# endif
More information about the vlc-commits
mailing list