Commit 7b0773e6 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use a vlc_CPU() wrapper instead of (ab)using libvlc_global

parent ce6766b6
...@@ -1162,6 +1162,7 @@ VLC_EXPORT( int, __vlc_execve, ( vlc_object_t *p_object, int i_argc, char *const ...@@ -1162,6 +1162,7 @@ VLC_EXPORT( int, __vlc_execve, ( vlc_object_t *p_object, int i_argc, char *const
#define CPU_CAPABILITY_SSE2 (1<<7) #define CPU_CAPABILITY_SSE2 (1<<7)
#define CPU_CAPABILITY_ALTIVEC (1<<16) #define CPU_CAPABILITY_ALTIVEC (1<<16)
#define CPU_CAPABILITY_FPU (1<<31) #define CPU_CAPABILITY_FPU (1<<31)
VLC_EXPORT( unsigned, vlc_CPU, ( void ) );
/***************************************************************************** /*****************************************************************************
* I18n stuff * I18n stuff
......
...@@ -313,7 +313,7 @@ static int OpenFilter( vlc_object_t *p_this ) ...@@ -313,7 +313,7 @@ static int OpenFilter( vlc_object_t *p_this )
mad_synth_init( &p_sys->mad_synth ); mad_synth_init( &p_sys->mad_synth );
mad_stream_options( &p_sys->mad_stream, MAD_OPTION_IGNORECRC ); mad_stream_options( &p_sys->mad_stream, MAD_OPTION_IGNORECRC );
if( p_this->p_libvlc_global->i_cpu & CPU_CAPABILITY_FPU ) if( vlc_CPU() & CPU_CAPABILITY_FPU )
p_filter->fmt_out.i_codec = VLC_FOURCC('f','l','3','2'); p_filter->fmt_out.i_codec = VLC_FOURCC('f','l','3','2');
else else
p_filter->fmt_out.i_codec = VLC_FOURCC('f','i','3','2'); p_filter->fmt_out.i_codec = VLC_FOURCC('f','i','3','2');
......
...@@ -357,7 +357,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -357,7 +357,7 @@ static int Open( vlc_object_t *p_this )
/* Choose the linear PCM format (read the comment above about FPU /* Choose the linear PCM format (read the comment above about FPU
and float32) */ and float32) */
if( p_aout->p_libvlc_global->i_cpu & CPU_CAPABILITY_FPU ) if( vlc_CPU() & CPU_CAPABILITY_FPU )
{ {
i_vlc_pcm_format = VLC_FOURCC('f','l','3','2'); i_vlc_pcm_format = VLC_FOURCC('f','l','3','2');
i_snd_pcm_format = SND_PCM_FORMAT_FLOAT; i_snd_pcm_format = SND_PCM_FORMAT_FLOAT;
......
...@@ -121,7 +121,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -121,7 +121,7 @@ static int Open( vlc_object_t *p_this )
aout_DateSet( &p_sys->date, 0 ); aout_DateSet( &p_sys->date, 0 );
p_dec->fmt_out.i_cat = AUDIO_ES; p_dec->fmt_out.i_cat = AUDIO_ES;
if (p_this->p_libvlc_global->i_cpu & CPU_CAPABILITY_FPU) if (vlc_CPU() & CPU_CAPABILITY_FPU)
p_dec->fmt_out.i_codec = VLC_FOURCC('f','l','3','2'); p_dec->fmt_out.i_codec = VLC_FOURCC('f','l','3','2');
else else
p_dec->fmt_out.i_codec = AOUT_FMT_S16_NE; p_dec->fmt_out.i_codec = AOUT_FMT_S16_NE;
...@@ -156,7 +156,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -156,7 +156,7 @@ static int Open( vlc_object_t *p_this )
/* Set the faad config */ /* Set the faad config */
cfg = faacDecGetCurrentConfiguration( p_sys->hfaad ); cfg = faacDecGetCurrentConfiguration( p_sys->hfaad );
if (p_this->p_libvlc_global->i_cpu & CPU_CAPABILITY_FPU) if (vlc_CPU() & CPU_CAPABILITY_FPU)
cfg->outputFormat = FAAD_FMT_FLOAT; cfg->outputFormat = FAAD_FMT_FLOAT;
else else
cfg->outputFormat = FAAD_FMT_16BIT; cfg->outputFormat = FAAD_FMT_16BIT;
...@@ -432,7 +432,7 @@ static void DoReordering( decoder_t *p_dec, ...@@ -432,7 +432,7 @@ static void DoReordering( decoder_t *p_dec,
} }
/* Do the actual reordering */ /* Do the actual reordering */
if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_FPU ) if( vlc_CPU() & CPU_CAPABILITY_FPU )
for( i = 0; i < i_samples; i++ ) for( i = 0; i < i_samples; i++ )
for( j = 0; j < i_nb_channels; j++ ) for( j = 0; j < i_nb_channels; j++ )
p_out[i * i_nb_channels + pi_chan_table[j]] = p_out[i * i_nb_channels + pi_chan_table[j]] =
......
...@@ -261,20 +261,21 @@ int E_(OpenEncoder)( vlc_object_t *p_this ) ...@@ -261,20 +261,21 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
p_context->opaque = (void *)p_this; p_context->opaque = (void *)p_this;
/* Set CPU capabilities */ /* Set CPU capabilities */
unsigned i_cpu = vlc_CPU();
p_context->dsp_mask = 0; p_context->dsp_mask = 0;
if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX) ) if( !(i_cpu & CPU_CAPABILITY_MMX) )
{ {
p_context->dsp_mask |= FF_MM_MMX; p_context->dsp_mask |= FF_MM_MMX;
} }
if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT) ) if( !(i_cpu & CPU_CAPABILITY_MMXEXT) )
{ {
p_context->dsp_mask |= FF_MM_MMXEXT; p_context->dsp_mask |= FF_MM_MMXEXT;
} }
if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW) ) if( !(i_cpu & CPU_CAPABILITY_3DNOW) )
{ {
p_context->dsp_mask |= FF_MM_3DNOW; p_context->dsp_mask |= FF_MM_3DNOW;
} }
if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE) ) if( !(i_cpu & CPU_CAPABILITY_SSE) )
{ {
p_context->dsp_mask |= FF_MM_SSE; p_context->dsp_mask |= FF_MM_SSE;
p_context->dsp_mask |= FF_MM_SSE2; p_context->dsp_mask |= FF_MM_SSE2;
......
...@@ -234,7 +234,8 @@ vlc_module_begin(); ...@@ -234,7 +234,8 @@ vlc_module_begin();
add_shortcut( "ffmpeg-deinterlace" ); add_shortcut( "ffmpeg-deinterlace" );
#endif #endif
var_Create( p_module->p_libvlc_global, "avcodec", VLC_VAR_MUTEX ); var_Create( (vlc_object_t *)p_module->p_libvlc_global, "avcodec",
VLC_VAR_MUTEX );
vlc_module_end(); vlc_module_end();
...@@ -284,24 +285,25 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -284,24 +285,25 @@ static int OpenDecoder( vlc_object_t *p_this )
p_context->opaque = (void *)p_this; p_context->opaque = (void *)p_this;
/* Set CPU capabilities */ /* Set CPU capabilities */
unsigned i_cpu = vlc_CPU();
p_context->dsp_mask = 0; p_context->dsp_mask = 0;
if( !(p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX) ) if( !(i_cpu & CPU_CAPABILITY_MMX) )
{ {
p_context->dsp_mask |= FF_MM_MMX; p_context->dsp_mask |= FF_MM_MMX;
} }
if( !(p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT) ) if( !(i_cpu & CPU_CAPABILITY_MMXEXT) )
{ {
p_context->dsp_mask |= FF_MM_MMXEXT; p_context->dsp_mask |= FF_MM_MMXEXT;
} }
if( !(p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW) ) if( !(i_cpu & CPU_CAPABILITY_3DNOW) )
{ {
p_context->dsp_mask |= FF_MM_3DNOW; p_context->dsp_mask |= FF_MM_3DNOW;
} }
if( !(p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE) ) if( !(i_cpu & CPU_CAPABILITY_SSE) )
{ {
p_context->dsp_mask |= FF_MM_SSE; p_context->dsp_mask |= FF_MM_SSE;
} }
if( !(p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE2) ) if( !(i_cpu & CPU_CAPABILITY_SSE2) )
{ {
p_context->dsp_mask |= FF_MM_SSE2; p_context->dsp_mask |= FF_MM_SSE2;
} }
...@@ -337,7 +339,7 @@ static void CloseDecoder( vlc_object_t *p_this ) ...@@ -337,7 +339,7 @@ static void CloseDecoder( vlc_object_t *p_this )
decoder_sys_t *p_sys = p_dec->p_sys; decoder_sys_t *p_sys = p_dec->p_sys;
vlc_value_t lockval; vlc_value_t lockval;
var_Get( p_dec->p_libvlc_global, "avcodec", &lockval ); var_Get( (vlc_object_t *)p_dec->p_libvlc_global, "avcodec", &lockval );
switch( p_sys->i_cat ) switch( p_sys->i_cat )
{ {
...@@ -426,7 +428,7 @@ void E_(InitLibavcodec)( vlc_object_t *p_object ) ...@@ -426,7 +428,7 @@ void E_(InitLibavcodec)( vlc_object_t *p_object )
static int b_ffmpeginit = 0; static int b_ffmpeginit = 0;
vlc_value_t lockval; vlc_value_t lockval;
var_Get( p_object->p_libvlc_global, "avcodec", &lockval ); var_Get( (vlc_object_t *)p_object->p_libvlc_global, "avcodec", &lockval );
vlc_mutex_lock( lockval.p_address ); vlc_mutex_lock( lockval.p_address );
/* *** init ffmpeg library (libavcodec) *** */ /* *** init ffmpeg library (libavcodec) *** */
......
...@@ -122,7 +122,7 @@ int E_(InitPostproc)( decoder_t *p_dec, void *p_data, ...@@ -122,7 +122,7 @@ int E_(InitPostproc)( decoder_t *p_dec, void *p_data,
int i_width, int i_height, int pix_fmt ) int i_width, int i_height, int pix_fmt )
{ {
video_postproc_sys_t *p_sys = (video_postproc_sys_t *)p_data; video_postproc_sys_t *p_sys = (video_postproc_sys_t *)p_data;
int32_t i_cpu = p_dec->p_libvlc_global->i_cpu; unsigned i_cpu = vlc_CPU();
int i_flags = 0; int i_flags = 0;
/* Set CPU capabilities */ /* Set CPU capabilities */
......
...@@ -115,20 +115,21 @@ int E_(OpenScaler)( vlc_object_t *p_this ) ...@@ -115,20 +115,21 @@ int E_(OpenScaler)( vlc_object_t *p_this )
swscale_fast_memcpy = p_filter->p_libvlc->pf_memcpy; swscale_fast_memcpy = p_filter->p_libvlc->pf_memcpy;
/* Set CPU capabilities */ /* Set CPU capabilities */
unsigned i_cpu = vlc_CPU();
p_sys->i_cpu_mask = 0; p_sys->i_cpu_mask = 0;
if( p_filter->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX ) if( i_cpu & CPU_CAPABILITY_MMX )
{ {
p_sys->i_cpu_mask |= SWS_CPU_CAPS_MMX; p_sys->i_cpu_mask |= SWS_CPU_CAPS_MMX;
} }
if( p_filter->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT ) if( i_cpu & CPU_CAPABILITY_MMXEXT )
{ {
p_sys->i_cpu_mask |= SWS_CPU_CAPS_MMX2; p_sys->i_cpu_mask |= SWS_CPU_CAPS_MMX2;
} }
if( p_filter->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW ) if( i_cpu & CPU_CAPABILITY_3DNOW )
{ {
p_sys->i_cpu_mask |= SWS_CPU_CAPS_3DNOW; p_sys->i_cpu_mask |= SWS_CPU_CAPS_3DNOW;
} }
if( p_filter->p_libvlc_global->i_cpu & CPU_CAPABILITY_ALTIVEC ) if( i_cpu & CPU_CAPABILITY_ALTIVEC )
{ {
p_sys->i_cpu_mask |= SWS_CPU_CAPS_ALTIVEC; p_sys->i_cpu_mask |= SWS_CPU_CAPS_ALTIVEC;
} }
......
...@@ -148,23 +148,23 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -148,23 +148,23 @@ static int OpenDecoder( vlc_object_t *p_this )
p_sys->b_preroll = VLC_FALSE; p_sys->b_preroll = VLC_FALSE;
#if defined( __i386__ ) || defined( __x86_64__ ) #if defined( __i386__ ) || defined( __x86_64__ )
if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX ) if( vlc_CPU() & CPU_CAPABILITY_MMX )
{ {
i_accel |= MPEG2_ACCEL_X86_MMX; i_accel |= MPEG2_ACCEL_X86_MMX;
} }
if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW ) if( vlc_CPU() & CPU_CAPABILITY_3DNOW )
{ {
i_accel |= MPEG2_ACCEL_X86_3DNOW; i_accel |= MPEG2_ACCEL_X86_3DNOW;
} }
if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT ) if( vlc_CPU() & CPU_CAPABILITY_MMXEXT )
{ {
i_accel |= MPEG2_ACCEL_X86_MMXEXT; i_accel |= MPEG2_ACCEL_X86_MMXEXT;
} }
#elif defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ ) #elif defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_ALTIVEC ) if( vlc_CPU() & CPU_CAPABILITY_ALTIVEC )
{ {
i_accel |= MPEG2_ACCEL_PPC_ALTIVEC; i_accel |= MPEG2_ACCEL_PPC_ALTIVEC;
} }
......
...@@ -1114,19 +1114,21 @@ static int Open ( vlc_object_t *p_this ) ...@@ -1114,19 +1114,21 @@ static int Open ( vlc_object_t *p_this )
p_sys->param.i_fps_num = p_enc->fmt_in.video.i_frame_rate; p_sys->param.i_fps_num = p_enc->fmt_in.video.i_frame_rate;
p_sys->param.i_fps_den = p_enc->fmt_in.video.i_frame_rate_base; p_sys->param.i_fps_den = p_enc->fmt_in.video.i_frame_rate_base;
} }
if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX) )
unsigned i_cpu = vlc_CPU();
if( !(i_cpu & CPU_CAPABILITY_MMX) )
{ {
p_sys->param.cpu &= ~X264_CPU_MMX; p_sys->param.cpu &= ~X264_CPU_MMX;
} }
if( !(p_enc->p_libvlc_global->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;
} }
if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE) ) if( !(i_cpu & CPU_CAPABILITY_SSE) )
{ {
p_sys->param.cpu &= ~X264_CPU_SSE; p_sys->param.cpu &= ~X264_CPU_SSE;
} }
if( !(p_enc->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE2) ) if( !(i_cpu & CPU_CAPABILITY_SSE2) )
{ {
p_sys->param.cpu &= ~X264_CPU_SSE2; p_sys->param.cpu &= ~X264_CPU_SSE2;
} }
......
...@@ -152,23 +152,23 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -152,23 +152,23 @@ static int OpenDecoder( vlc_object_t *p_this )
p_sys->b_skip = 0; p_sys->b_skip = 0;
#if defined( __i386__ ) #if defined( __i386__ )
if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX ) if( vlc_CPU() & CPU_CAPABILITY_MMX )
{ {
i_accel |= MPEG2_ACCEL_X86_MMX; i_accel |= MPEG2_ACCEL_X86_MMX;
} }
if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW ) if( vlc_CPU() & CPU_CAPABILITY_3DNOW )
{ {
i_accel |= MPEG2_ACCEL_X86_3DNOW; i_accel |= MPEG2_ACCEL_X86_3DNOW;
} }
if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT ) if( vlc_CPU() & CPU_CAPABILITY_MMXEXT )
{ {
i_accel |= MPEG2_ACCEL_X86_MMXEXT; i_accel |= MPEG2_ACCEL_X86_MMXEXT;
} }
#elif defined( __powerpc__ ) || defined( SYS_DARWIN ) #elif defined( __powerpc__ ) || defined( SYS_DARWIN )
if( p_dec->p_libvlc_global->i_cpu & CPU_CAPABILITY_ALTIVEC ) if( vlc_CPU() & CPU_CAPABILITY_ALTIVEC )
{ {
i_accel |= MPEG2_ACCEL_PPC_ALTIVEC; i_accel |= MPEG2_ACCEL_PPC_ALTIVEC;
} }
......
...@@ -352,20 +352,21 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -352,20 +352,21 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->ff_enc_c = avcodec_alloc_context(); id->ff_enc_c = avcodec_alloc_context();
/* Set CPU capabilities */ /* Set CPU capabilities */
unsigned i_cpu = vlc_CPU();
id->ff_enc_c->dsp_mask = 0; id->ff_enc_c->dsp_mask = 0;
if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX) ) if( !(i_cpu & CPU_CAPABILITY_MMX) )
{ {
id->ff_enc_c->dsp_mask |= FF_MM_MMX; id->ff_enc_c->dsp_mask |= FF_MM_MMX;
} }
if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT) ) if( !(i_cpu & CPU_CAPABILITY_MMXEXT) )
{ {
id->ff_enc_c->dsp_mask |= FF_MM_MMXEXT; id->ff_enc_c->dsp_mask |= FF_MM_MMXEXT;
} }
if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW) ) if( !(i_cpu & CPU_CAPABILITY_3DNOW) )
{ {
id->ff_enc_c->dsp_mask |= FF_MM_3DNOW; id->ff_enc_c->dsp_mask |= FF_MM_3DNOW;
} }
if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE) ) if( !(i_cpu & CPU_CAPABILITY_SSE) )
{ {
id->ff_enc_c->dsp_mask |= FF_MM_SSE; id->ff_enc_c->dsp_mask |= FF_MM_SSE;
id->ff_enc_c->dsp_mask |= FF_MM_SSE2; id->ff_enc_c->dsp_mask |= FF_MM_SSE2;
...@@ -725,20 +726,21 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -725,20 +726,21 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
id->ff_enc_c = avcodec_alloc_context(); id->ff_enc_c = avcodec_alloc_context();
/* Set CPU capabilities */ /* Set CPU capabilities */
unsigned i_cpu = vlc_CPU();
id->ff_enc_c->dsp_mask = 0; id->ff_enc_c->dsp_mask = 0;
if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMX) ) if( !(i_cpu & CPU_CAPABILITY_MMX) )
{ {
id->ff_enc_c->dsp_mask |= FF_MM_MMX; id->ff_enc_c->dsp_mask |= FF_MM_MMX;
} }
if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT) ) if( !(i_cpu & CPU_CAPABILITY_MMXEXT) )
{ {
id->ff_enc_c->dsp_mask |= FF_MM_MMXEXT; id->ff_enc_c->dsp_mask |= FF_MM_MMXEXT;
} }
if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW) ) if( !(i_cpu & CPU_CAPABILITY_3DNOW) )
{ {
id->ff_enc_c->dsp_mask |= FF_MM_3DNOW; id->ff_enc_c->dsp_mask |= FF_MM_3DNOW;
} }
if( !(p_stream->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE) ) if( !(i_cpu & CPU_CAPABILITY_SSE) )
{ {
id->ff_enc_c->dsp_mask |= FF_MM_SSE; id->ff_enc_c->dsp_mask |= FF_MM_SSE;
id->ff_enc_c->dsp_mask |= FF_MM_SSE2; id->ff_enc_c->dsp_mask |= FF_MM_SSE2;
......
...@@ -207,7 +207,7 @@ static int Create( vlc_object_t *p_this ) ...@@ -207,7 +207,7 @@ static int Create( vlc_object_t *p_this )
vlc_mutex_init( p_vout, &p_vout->p_sys->filter_lock ); vlc_mutex_init( p_vout, &p_vout->p_sys->filter_lock );
#if defined(CAN_COMPILE_C_ALTIVEC) #if defined(CAN_COMPILE_C_ALTIVEC)
if( p_vout->p_libvlc_global->i_cpu & CPU_CAPABILITY_ALTIVEC ) if( vlc_CPU() & CPU_CAPABILITY_ALTIVEC )
{ {
p_vout->p_sys->pf_merge = MergeAltivec; p_vout->p_sys->pf_merge = MergeAltivec;
p_vout->p_sys->pf_end_merge = NULL; p_vout->p_sys->pf_end_merge = NULL;
...@@ -215,7 +215,7 @@ static int Create( vlc_object_t *p_this ) ...@@ -215,7 +215,7 @@ static int Create( vlc_object_t *p_this )
else else
#endif #endif
#if defined(CAN_COMPILE_SSE) #if defined(CAN_COMPILE_SSE)
if( p_vout->p_libvlc_global->i_cpu & CPU_CAPABILITY_SSE2 ) if( vlc_CPU() & CPU_CAPABILITY_SSE2 )
{ {
p_vout->p_sys->pf_merge = MergeSSE2; p_vout->p_sys->pf_merge = MergeSSE2;
p_vout->p_sys->pf_end_merge = EndMMX; p_vout->p_sys->pf_end_merge = EndMMX;
...@@ -223,7 +223,7 @@ static int Create( vlc_object_t *p_this ) ...@@ -223,7 +223,7 @@ static int Create( vlc_object_t *p_this )
else else
#endif #endif
#if defined(CAN_COMPILE_MMXEXT) #if defined(CAN_COMPILE_MMXEXT)
if( p_vout->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT ) if( vlc_CPU() & CPU_CAPABILITY_MMXEXT )
{ {
p_vout->p_sys->pf_merge = MergeMMXEXT; p_vout->p_sys->pf_merge = MergeMMXEXT;
p_vout->p_sys->pf_end_merge = EndMMX; p_vout->p_sys->pf_end_merge = EndMMX;
...@@ -231,7 +231,7 @@ static int Create( vlc_object_t *p_this ) ...@@ -231,7 +231,7 @@ static int Create( vlc_object_t *p_this )
else else
#endif #endif
#if defined(CAN_COMPILE_3DNOW) #if defined(CAN_COMPILE_3DNOW)
if( p_vout->p_libvlc_global->i_cpu & CPU_CAPABILITY_3DNOW ) if( vlc_CPU() & CPU_CAPABILITY_3DNOW )
{ {
p_vout->p_sys->pf_merge = Merge3DNow; p_vout->p_sys->pf_merge = Merge3DNow;
p_vout->p_sys->pf_end_merge = End3DNow; p_vout->p_sys->pf_end_merge = End3DNow;
...@@ -1965,7 +1965,7 @@ static void RenderX( vout_thread_t *p_vout, ...@@ -1965,7 +1965,7 @@ static void RenderX( vout_thread_t *p_vout,
uint8_t *src = &p_pic->p[i_plane].p_pixels[8*y*i_src]; uint8_t *src = &p_pic->p[i_plane].p_pixels[8*y*i_src];
#ifdef CAN_COMPILE_MMXEXT #ifdef CAN_COMPILE_MMXEXT
if( p_vout->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT ) if( vlc_CPU & CPU_CAPABILITY_MMXEXT )
XDeintBand8x8MMXEXT( dst, i_dst, src, i_src, i_mbx, i_modx ); XDeintBand8x8MMXEXT( dst, i_dst, src, i_src, i_mbx, i_modx );
else else
#endif #endif
...@@ -1992,7 +1992,7 @@ static void RenderX( vout_thread_t *p_vout, ...@@ -1992,7 +1992,7 @@ static void RenderX( vout_thread_t *p_vout,
} }
#ifdef CAN_COMPILE_MMXEXT #ifdef CAN_COMPILE_MMXEXT
if( p_vout->p_libvlc_global->i_cpu & CPU_CAPABILITY_MMXEXT ) if( vlc_CPU & CPU_CAPABILITY_MMXEXT )
emms(); emms();
#endif #endif
} }
......
...@@ -173,7 +173,7 @@ libvlc_int_t * libvlc_InternalCreate( void ) ...@@ -173,7 +173,7 @@ libvlc_int_t * libvlc_InternalCreate( void )
if( !libvlc_global.b_ready ) if( !libvlc_global.b_ready )
{ {
/* Guess what CPU we have */ /* Guess what CPU we have */
libvlc_global.i_cpu = CPUCapabilities(); cpu_flags = CPUCapabilities();
/* The module bank will be initialized later */ /* The module bank will be initialized later */
libvlc_global.p_module_bank = NULL; libvlc_global.p_module_bank = NULL;
...@@ -728,27 +728,27 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] ) ...@@ -728,27 +728,27 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
msg_Flush( p_libvlc ); msg_Flush( p_libvlc );
if( !config_GetInt( p_libvlc, "fpu" ) ) if( !config_GetInt( p_libvlc, "fpu" ) )
libvlc_global.i_cpu &= ~CPU_CAPABILITY_FPU; cpu_flags &= ~CPU_CAPABILITY_FPU;
#if defined( __i386__ ) || defined( __x86_64__ ) #if defined( __i386__ ) || defined( __x86_64__ )
if( !config_GetInt( p_libvlc, "mmx" ) ) if( !config_GetInt( p_libvlc, "mmx" ) )
libvlc_global.i_cpu &= ~CPU_CAPABILITY_MMX; cpu_flags &= ~CPU_CAPABILITY_MMX;
if( !config_GetInt( p_libvlc, "3dn" ) ) if( !config_GetInt( p_libvlc, "3dn" ) )
libvlc_global.i_cpu &= ~CPU_CAPABILITY_3DNOW; cpu_flags &= ~CPU_CAPABILITY_3DNOW;
if( !config_GetInt( p_libvlc, "mmxext" ) ) if( !config_GetInt( p_libvlc, "mmxext" ) )
libvlc_global.i_cpu &= ~CPU_CAPABILITY_MMXEXT; cpu_flags &= ~CPU_CAPABILITY_MMXEXT;
if( !config_GetInt( p_libvlc, "sse" ) ) if( !config_GetInt( p_libvlc, "sse" ) )
libvlc_global.i_cpu &= ~CPU_CAPABILITY_SSE; cpu_flags &= ~CPU_CAPABILITY_SSE;
if( !config_GetInt( p_libvlc, "sse2" ) ) if( !config_GetInt( p_libvlc, "sse2" ) )
libvlc_global.i_cpu &= ~CPU_CAPABILITY_SSE2; cpu_flags &= ~CPU_CAPABILITY_SSE2;
#endif #endif
#if defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ ) #if defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
if( !config_GetInt( p_libvlc, "altivec" ) ) if( !config_GetInt( p_libvlc, "altivec" ) )
libvlc_global.i_cpu &= ~CPU_CAPABILITY_ALTIVEC; cpu_flags &= ~CPU_CAPABILITY_ALTIVEC;
#endif #endif
#define PRINT_CAPABILITY( capability, string ) \ #define PRINT_CAPABILITY( capability, string ) \
if( libvlc_global.i_cpu & capability ) \ if( vlc_CPU() & capability ) \
{ \ { \
strncat( p_capabilities, string " ", \ strncat( p_capabilities, string " ", \
sizeof(p_capabilities) - strlen(p_capabilities) ); \ sizeof(p_capabilities) - strlen(p_capabilities) ); \
......
...@@ -51,7 +51,7 @@ static void SigHandler ( int ); ...@@ -51,7 +51,7 @@ static void SigHandler ( int );
static jmp_buf env; static jmp_buf env;
static int i_illegal; static int i_illegal;
#if defined( __i386__ ) || defined( __x86_64__ ) #if defined( __i386__ ) || defined( __x86_64__ )
static char *psz_capability; static const char *psz_capability;
#endif #endif
#endif #endif
...@@ -60,7 +60,7 @@ static char *psz_capability; ...@@ -60,7 +60,7 @@ static char *psz_capability;
***************************************************************************** *****************************************************************************
* This function is called to list extensions the CPU may have. * This function is called to list extensions the CPU may have.
*****************************************************************************/ *****************************************************************************/
uint32_t CPUCapabilities( void ) static uint32_t CPUCapabilities( void )
{ {
volatile uint32_t i_capabilities = CPU_CAPABILITY_NONE; volatile uint32_t i_capabilities = CPU_CAPABILITY_NONE;
...@@ -338,3 +338,15 @@ static void SigHandler( int i_signal ) ...@@ -338,3 +338,15 @@ static void SigHandler( int i_signal )
} }
#endif #endif
extern uint32_t cpu_flags = 0;
/*****************************************************************************
* vlc_CPU: get pre-computed CPU capability flags
****************************************************************************/
unsigned vlc_CPU (void)
{
return cpu_flags;
}
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