Commit 5288c382 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Check for MMX at build-time if possible

parent 83a11816
...@@ -30,7 +30,7 @@ VLC_API unsigned vlc_CPU(void); ...@@ -30,7 +30,7 @@ VLC_API unsigned vlc_CPU(void);
# if defined (__i386__) || defined (__x86_64__) # if defined (__i386__) || defined (__x86_64__)
# define HAVE_FPU 1 # define HAVE_FPU 1
# define CPU_CAPABILITY_MMX (1<<3) # define VLC_CPU_MMX 8
# define CPU_CAPABILITY_3DNOW (1<<4) # define CPU_CAPABILITY_3DNOW (1<<4)
# define CPU_CAPABILITY_MMXEXT (1<<5) # define CPU_CAPABILITY_MMXEXT (1<<5)
# define CPU_CAPABILITY_SSE (1<<6) # define CPU_CAPABILITY_SSE (1<<6)
...@@ -42,11 +42,15 @@ VLC_API unsigned vlc_CPU(void); ...@@ -42,11 +42,15 @@ VLC_API unsigned vlc_CPU(void);
# define CPU_CAPABILITY_SSE4A (1<<12) # define CPU_CAPABILITY_SSE4A (1<<12)
# if defined (__MMX__) # if defined (__MMX__)
# define vlc_CPU_MMX() (1)
# define VLC_MMX # define VLC_MMX
# elif VLC_GCC_VERSION(4, 4)
# define VLC_MMX __attribute__ ((__target__ ("mmx")))
# else # else
# define VLC_MMX VLC_MMX_is_not_implemented_on_this_compiler # define vlc_CPU_MMX() ((vlc_CPU() & VLC_CPU_MMX) != 0)
# if VLC_GCC_VERSION(4, 4)
# define VLC_MMX __attribute__ ((__target__ ("mmx")))
# else
# define VLC_MMX VLC_MMX_is_not_implemented_on_this_compiler
# endif
# endif # endif
# if defined (__SSE__) # if defined (__SSE__)
......
...@@ -332,7 +332,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -332,7 +332,7 @@ static int OpenDecoder( vlc_object_t *p_this )
p_context->dsp_mask = 0; p_context->dsp_mask = 0;
#if defined (__i386__) || defined (__x86_64__) #if defined (__i386__) || defined (__x86_64__)
unsigned i_cpu = vlc_CPU(); unsigned i_cpu = vlc_CPU();
if( !(i_cpu & CPU_CAPABILITY_MMX) ) if( !vlc_CPU_MMX() )
p_context->dsp_mask |= AV_CPU_FLAG_MMX; p_context->dsp_mask |= AV_CPU_FLAG_MMX;
if( !(i_cpu & CPU_CAPABILITY_MMXEXT) ) if( !(i_cpu & CPU_CAPABILITY_MMXEXT) )
p_context->dsp_mask |= AV_CPU_FLAG_MMX2; p_context->dsp_mask |= AV_CPU_FLAG_MMX2;
......
...@@ -326,7 +326,7 @@ int OpenEncoder( vlc_object_t *p_this ) ...@@ -326,7 +326,7 @@ int OpenEncoder( vlc_object_t *p_this )
p_context->dsp_mask = 0; p_context->dsp_mask = 0;
#if defined (__i386__) || defined (__x86_64__) #if defined (__i386__) || defined (__x86_64__)
unsigned i_cpu = vlc_CPU(); unsigned i_cpu = vlc_CPU();
if( !(i_cpu & CPU_CAPABILITY_MMX) ) if( !vlc_CPU_MMX() )
p_context->dsp_mask |= AV_CPU_FLAG_MMX; p_context->dsp_mask |= AV_CPU_FLAG_MMX;
if( !(i_cpu & CPU_CAPABILITY_MMXEXT) ) if( !(i_cpu & CPU_CAPABILITY_MMXEXT) )
p_context->dsp_mask |= AV_CPU_FLAG_MMX2; p_context->dsp_mask |= AV_CPU_FLAG_MMX2;
......
...@@ -193,7 +193,7 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -193,7 +193,7 @@ static int OpenDecoder( vlc_object_t *p_this )
#if defined( __i386__ ) || defined( __x86_64__ ) #if defined( __i386__ ) || defined( __x86_64__ )
unsigned cpu = vlc_CPU(); unsigned cpu = vlc_CPU();
if( cpu & CPU_CAPABILITY_MMX ) if( vlc_CPU_MMX() )
i_accel |= MPEG2_ACCEL_X86_MMX; i_accel |= MPEG2_ACCEL_X86_MMX;
if( cpu & CPU_CAPABILITY_3DNOW ) if( cpu & CPU_CAPABILITY_3DNOW )
i_accel |= MPEG2_ACCEL_X86_3DNOW; i_accel |= MPEG2_ACCEL_X86_3DNOW;
......
...@@ -1261,7 +1261,7 @@ static int Open ( vlc_object_t *p_this ) ...@@ -1261,7 +1261,7 @@ static int Open ( vlc_object_t *p_this )
#if defined (__i386__) || defined (__x86_64__) #if defined (__i386__) || defined (__x86_64__)
unsigned i_cpu = vlc_CPU(); unsigned i_cpu = vlc_CPU();
if( !(i_cpu & CPU_CAPABILITY_MMX) ) if( !vlc_CPU_MMX() )
p_sys->param.cpu &= ~X264_CPU_MMX; p_sys->param.cpu &= ~X264_CPU_MMX;
if( !(i_cpu & CPU_CAPABILITY_MMXEXT) ) if( !(i_cpu & CPU_CAPABILITY_MMXEXT) )
p_sys->param.cpu &= ~X264_CPU_MMXEXT; p_sys->param.cpu &= ~X264_CPU_MMXEXT;
......
...@@ -381,7 +381,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -381,7 +381,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->ff_enc_c->dsp_mask = 0; id->ff_enc_c->dsp_mask = 0;
#if defined (__i386__) || defined (__x86_64__) #if defined (__i386__) || defined (__x86_64__)
unsigned i_cpu = vlc_CPU(); unsigned i_cpu = vlc_CPU();
if( !(i_cpu & CPU_CAPABILITY_MMX) ) if( !vlc_CPU_MMX() )
id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_MMX; id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_MMX;
if( !(i_cpu & CPU_CAPABILITY_MMXEXT) ) if( !(i_cpu & CPU_CAPABILITY_MMXEXT) )
id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_MMX2; id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_MMX2;
...@@ -802,7 +802,7 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -802,7 +802,7 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
id->ff_enc_c->dsp_mask = 0; id->ff_enc_c->dsp_mask = 0;
#if defined (__i386__) || defined (__x86_64__) #if defined (__i386__) || defined (__x86_64__)
unsigned i_cpu = vlc_CPU(); unsigned i_cpu = vlc_CPU();
if( !(i_cpu & CPU_CAPABILITY_MMX) ) if( !vlc_CPU_MMX() )
id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_MMX; id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_MMX;
if( !(i_cpu & CPU_CAPABILITY_MMXEXT) ) if( !(i_cpu & CPU_CAPABILITY_MMXEXT) )
id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_MMX2; id->ff_enc_c->dsp_mask |= AV_CPU_FLAG_MMX2;
......
...@@ -84,17 +84,17 @@ vlc_module_begin () ...@@ -84,17 +84,17 @@ vlc_module_begin ()
set_description( N_("I420,IYUV,YV12 to " set_description( N_("I420,IYUV,YV12 to "
"RGB2,RV15,RV16,RV24,RV32 conversions") ) "RGB2,RV15,RV16,RV24,RV32 conversions") )
set_capability( "video filter2", 80 ) set_capability( "video filter2", 80 )
# define CPU_CAPABILITY 0 # define vlc_CPU_capable() (true)
#elif defined (MODULE_NAME_IS_i420_rgb_mmx) #elif defined (MODULE_NAME_IS_i420_rgb_mmx)
set_description( N_( "MMX I420,IYUV,YV12 to " set_description( N_( "MMX I420,IYUV,YV12 to "
"RV15,RV16,RV24,RV32 conversions") ) "RV15,RV16,RV24,RV32 conversions") )
set_capability( "video filter2", 100 ) set_capability( "video filter2", 100 )
# define CPU_CAPABILITY CPU_CAPABILITY_MMX # define vlc_CPU_capable() vlc_CPU_MMX()
#elif defined (MODULE_NAME_IS_i420_rgb_sse2) #elif defined (MODULE_NAME_IS_i420_rgb_sse2)
set_description( N_( "SSE2 I420,IYUV,YV12 to " set_description( N_( "SSE2 I420,IYUV,YV12 to "
"RV15,RV16,RV24,RV32 conversions") ) "RV15,RV16,RV24,RV32 conversions") )
set_capability( "video filter2", 120 ) set_capability( "video filter2", 120 )
# define CPU_CAPABILITY CPU_CAPABILITY_SSE2 # define vlc_CPU_capable() ((vlc_CPU() & CPU_CAPABILITY_SSE2) != 0)
#endif #endif
set_callbacks( Activate, Deactivate ) set_callbacks( Activate, Deactivate )
vlc_module_end () vlc_module_end ()
...@@ -111,10 +111,8 @@ static int Activate( vlc_object_t *p_this ) ...@@ -111,10 +111,8 @@ static int Activate( vlc_object_t *p_this )
size_t i_tables_size; size_t i_tables_size;
#endif #endif
#if CPU_CAPABILITY if( !vlc_CPU_capable() )
if( !(vlc_CPU() & CPU_CAPABILITY) )
return VLC_EGENERIC; return VLC_EGENERIC;
#endif
if( p_filter->fmt_out.video.i_width & 1 if( p_filter->fmt_out.video.i_width & 1
|| p_filter->fmt_out.video.i_height & 1 ) || p_filter->fmt_out.video.i_height & 1 )
{ {
......
...@@ -88,11 +88,11 @@ vlc_module_begin () ...@@ -88,11 +88,11 @@ vlc_module_begin ()
#if defined (MODULE_NAME_IS_i420_yuy2) #if defined (MODULE_NAME_IS_i420_yuy2)
set_description( N_("Conversions from " SRC_FOURCC " to " DEST_FOURCC) ) set_description( N_("Conversions from " SRC_FOURCC " to " DEST_FOURCC) )
set_capability( "video filter2", 80 ) set_capability( "video filter2", 80 )
# define vlc_CPU_capable() (1) # define vlc_CPU_capable() (true)
#elif defined (MODULE_NAME_IS_i420_yuy2_mmx) #elif defined (MODULE_NAME_IS_i420_yuy2_mmx)
set_description( N_("MMX conversions from " SRC_FOURCC " to " DEST_FOURCC) ) set_description( N_("MMX conversions from " SRC_FOURCC " to " DEST_FOURCC) )
set_capability( "video filter2", 160 ) set_capability( "video filter2", 160 )
# define vlc_CPU_capable() (vlc_CPU() & CPU_CAPABILITY_MMX) # define vlc_CPU_capable() vlc_CPU_MMX()
#elif defined (MODULE_NAME_IS_i420_yuy2_sse2) #elif defined (MODULE_NAME_IS_i420_yuy2_sse2)
set_description( N_("SSE2 conversions from " SRC_FOURCC " to " DEST_FOURCC) ) set_description( N_("SSE2 conversions from " SRC_FOURCC " to " DEST_FOURCC) )
set_capability( "video filter2", 250 ) set_capability( "video filter2", 250 )
......
...@@ -71,17 +71,17 @@ vlc_module_begin () ...@@ -71,17 +71,17 @@ vlc_module_begin ()
#if defined (MODULE_NAME_IS_i422_yuy2) #if defined (MODULE_NAME_IS_i422_yuy2)
set_description( N_("Conversions from " SRC_FOURCC " to " DEST_FOURCC) ) set_description( N_("Conversions from " SRC_FOURCC " to " DEST_FOURCC) )
set_capability( "video filter2", 80 ) set_capability( "video filter2", 80 )
# define CPU_CAPABILITY 0 # define vlc_CPU_capable() (true)
# define VLC_TARGET # define VLC_TARGET
#elif defined (MODULE_NAME_IS_i422_yuy2_mmx) #elif defined (MODULE_NAME_IS_i422_yuy2_mmx)
set_description( N_("MMX conversions from " SRC_FOURCC " to " DEST_FOURCC) ) set_description( N_("MMX conversions from " SRC_FOURCC " to " DEST_FOURCC) )
set_capability( "video filter2", 100 ) set_capability( "video filter2", 100 )
# define CPU_CAPABILITY CPU_CAPABILITY_MMX # define vlc_CPU_capable() vlc_CPU_MMX()
# define VLC_TARGET VLC_MMX # define VLC_TARGET VLC_MMX
#elif defined (MODULE_NAME_IS_i422_yuy2_sse2) #elif defined (MODULE_NAME_IS_i422_yuy2_sse2)
set_description( N_("SSE2 conversions from " SRC_FOURCC " to " DEST_FOURCC) ) set_description( N_("SSE2 conversions from " SRC_FOURCC " to " DEST_FOURCC) )
set_capability( "video filter2", 120 ) set_capability( "video filter2", 120 )
# define CPU_CAPABILITY CPU_CAPABILITY_SSE2 # define vlc_CPU_capable() ((vlc_CPU() & CPU_CAPABILITY_SSE2) != 0)
# define VLC_TARGET VLC_SSE # define VLC_TARGET VLC_SSE
#endif #endif
set_callbacks( Activate, NULL ) set_callbacks( Activate, NULL )
...@@ -96,10 +96,8 @@ static int Activate( vlc_object_t *p_this ) ...@@ -96,10 +96,8 @@ static int Activate( vlc_object_t *p_this )
{ {
filter_t *p_filter = (filter_t *)p_this; filter_t *p_filter = (filter_t *)p_this;
#if CPU_CAPABILITY if( !vlc_CPU_capable() )
if( !(vlc_CPU() & CPU_CAPABILITY) )
return VLC_EGENERIC; return VLC_EGENERIC;
#endif
if( p_filter->fmt_in.video.i_width & 1 if( p_filter->fmt_in.video.i_width & 1
|| p_filter->fmt_in.video.i_height & 1 ) || p_filter->fmt_in.video.i_height & 1 )
{ {
......
...@@ -110,7 +110,7 @@ int RenderYadif( filter_t *p_filter, picture_t *p_dst, picture_t *p_src, ...@@ -110,7 +110,7 @@ int RenderYadif( filter_t *p_filter, picture_t *p_dst, picture_t *p_src,
filter = yadif_filter_line_c; filter = yadif_filter_line_c;
#if defined(HAVE_YADIF_MMX) #if defined(HAVE_YADIF_MMX)
if( vlc_CPU() & CPU_CAPABILITY_MMX ) if( vlc_CPU_MMX() )
filter = yadif_filter_line_mmx; filter = yadif_filter_line_mmx;
#endif #endif
#if defined(HAVE_YADIF_SSE2) #if defined(HAVE_YADIF_SSE2)
......
...@@ -135,7 +135,7 @@ static int OpenPostproc( vlc_object_t *p_this ) ...@@ -135,7 +135,7 @@ static int OpenPostproc( vlc_object_t *p_this )
/* Set CPU capabilities */ /* Set CPU capabilities */
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
unsigned i_cpu = vlc_CPU(); unsigned i_cpu = vlc_CPU();
if( i_cpu & CPU_CAPABILITY_MMX ) if( vlc_CPU_MMX() )
i_flags |= PP_CPU_CAPS_MMX; i_flags |= PP_CPU_CAPS_MMX;
if( i_cpu & CPU_CAPABILITY_MMXEXT ) if( i_cpu & CPU_CAPABILITY_MMXEXT )
i_flags |= PP_CPU_CAPS_MMX2; i_flags |= PP_CPU_CAPS_MMX2;
......
...@@ -233,7 +233,7 @@ static int GetSwsCpuMask(void) ...@@ -233,7 +233,7 @@ static int GetSwsCpuMask(void)
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
const unsigned int i_cpu = vlc_CPU(); const unsigned int i_cpu = vlc_CPU();
if( i_cpu & CPU_CAPABILITY_MMX ) if( vlc_CPU_MMX() )
i_sws_cpu |= SWS_CPU_CAPS_MMX; i_sws_cpu |= SWS_CPU_CAPS_MMX;
#if (LIBSWSCALE_VERSION_INT >= ((0<<16)+(5<<8)+0)) #if (LIBSWSCALE_VERSION_INT >= ((0<<16)+(5<<8)+0))
if( i_cpu & CPU_CAPABILITY_MMXEXT ) if( i_cpu & CPU_CAPABILITY_MMXEXT )
......
...@@ -221,7 +221,7 @@ void vlc_CPU_init (void) ...@@ -221,7 +221,7 @@ void vlc_CPU_init (void)
if( ! (i_edx & 0x00800000) ) if( ! (i_edx & 0x00800000) )
goto out; goto out;
# endif # endif
i_capabilities |= CPU_CAPABILITY_MMX; i_capabilities |= VLC_CPU_MMX;
# if defined (__SSE__) # if defined (__SSE__)
i_capabilities |= CPU_CAPABILITY_MMXEXT | CPU_CAPABILITY_SSE; i_capabilities |= CPU_CAPABILITY_MMXEXT | CPU_CAPABILITY_SSE;
...@@ -352,7 +352,7 @@ void vlc_CPU_dump (vlc_object_t *obj) ...@@ -352,7 +352,7 @@ void vlc_CPU_dump (vlc_object_t *obj)
if (flags & (capability)) \ if (flags & (capability)) \
p += sprintf (p, "%s ", (string) ) p += sprintf (p, "%s ", (string) )
PRINT_CAPABILITY(CPU_CAPABILITY_MMX, "MMX"); if (vlc_CPU_MMX()) p += sprintf (p, "MMX ");
PRINT_CAPABILITY(CPU_CAPABILITY_3DNOW, "3DNow!"); PRINT_CAPABILITY(CPU_CAPABILITY_3DNOW, "3DNow!");
PRINT_CAPABILITY(CPU_CAPABILITY_MMXEXT, "MMXEXT"); PRINT_CAPABILITY(CPU_CAPABILITY_MMXEXT, "MMXEXT");
PRINT_CAPABILITY(CPU_CAPABILITY_SSE, "SSE"); PRINT_CAPABILITY(CPU_CAPABILITY_SSE, "SSE");
......
...@@ -67,10 +67,8 @@ static void vlc_CPU_init (void) ...@@ -67,10 +67,8 @@ static void vlc_CPU_init (void)
core_caps |= VLC_CPU_ARM_NEON; core_caps |= VLC_CPU_ARM_NEON;
#elif defined (__i386__) || defined (__x86_64__) #elif defined (__i386__) || defined (__x86_64__)
# ifndef __MMX__
if (!strcmp (cap, "mmx")) if (!strcmp (cap, "mmx"))
core_caps |= CPU_CAPABILITY_MMX; core_caps |= VLC_CPU_MMX;
# endif
# ifndef __SSE__ # ifndef __SSE__
if (!strcmp (cap, "sse")) if (!strcmp (cap, "sse"))
core_caps |= CPU_CAPABILITY_SSE | CPU_CAPABILITY_MMXEXT; core_caps |= CPU_CAPABILITY_SSE | CPU_CAPABILITY_MMXEXT;
...@@ -121,9 +119,6 @@ static void vlc_CPU_init (void) ...@@ -121,9 +119,6 @@ static void vlc_CPU_init (void)
/* Always enable capabilities that were forced during compilation */ /* Always enable capabilities that were forced during compilation */
#if defined (__i386__) || defined (__x86_64__) #if defined (__i386__) || defined (__x86_64__)
# ifdef __MMX__
all_caps |= CPU_CAPABILITY_MMX;
# endif
# ifdef __SSE__ # ifdef __SSE__
all_caps |= CPU_CAPABILITY_SSE | CPU_CAPABILITY_MMXEXT; all_caps |= CPU_CAPABILITY_SSE | CPU_CAPABILITY_MMXEXT;
# endif # endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment