Commit 145903d0 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

HAVE_FPU: make constant

Currently, we do not have any architecture where this would not be
a build-time constant. Constancy helps fixing a few issues in the audio
path.
parent fefa53d2
......@@ -58,12 +58,27 @@
# define CPU_CAPABILITY_NEON (0)
# endif
/** Are floating point oeprations fast?
VLC_EXPORT( unsigned, vlc_CPU, ( void ) );
/** Are floating point operations fast?
* If this bit is not set, you should try to use fixed-point instead.
*/
# define CPU_CAPABILITY_FPU (1<<31)
# if defined (__i386__) || defined (__x86_64__)
# define HAVE_FPU 1
VLC_EXPORT( unsigned, vlc_CPU, ( void ) );
# elif defined (__powerpc__) || defined (__ppc__) || defined (__pc64__)
# define HAVE_FPU 1
# elif defined (__arm__)
# define HAVE_FPU 0 /* revisit later? */
# elif defined (__sparc__)
# define HAVE_FPU 1
# else
# define HAVE_FPU 0
# endif
typedef void *(*vlc_memcpy_t) (void *tgt, const void *src, size_t n);
typedef void *(*vlc_memset_t) (void *tgt, int c, size_t n);
......
......@@ -261,10 +261,7 @@ static int OpenFilter( vlc_object_t *p_this )
mad_synth_init( &p_sys->mad_synth );
mad_stream_options( &p_sys->mad_stream, MAD_OPTION_IGNORECRC );
if( vlc_CPU() & CPU_CAPABILITY_FPU )
p_filter->fmt_out.i_codec = VLC_CODEC_FL32;
else
p_filter->fmt_out.i_codec = VLC_CODEC_FI32;
p_filter->fmt_out.i_codec = HAVE_FPU ? VLC_CODEC_FL32 : VLC_CODEC_FI32;
p_filter->fmt_out.audio.i_format = p_filter->fmt_out.i_codec;
p_filter->fmt_out.audio.i_bitspersample =
aout_BitsPerSample( p_filter->fmt_out.i_codec );
......
......@@ -359,7 +359,7 @@ static int Open( vlc_object_t *p_this )
/* Choose the linear PCM format (read the comment above about FPU
and float32) */
if( vlc_CPU() & CPU_CAPABILITY_FPU )
if( HAVE_FPU )
{
i_vlc_pcm_format = VLC_CODEC_FL32;
i_snd_pcm_format = SND_PCM_FORMAT_FLOAT;
......
......@@ -169,7 +169,7 @@ static int Open ( vlc_object_t *p_this )
msg_Dbg(p_aout, "%d audio channels", ss.channels);
ss.rate = p_aout->output.output.i_rate;
if (vlc_CPU() & CPU_CAPABILITY_FPU)
if (HAVE_FPU)
{
ss.format = PA_SAMPLE_FLOAT32NE;
p_aout->output.output.i_format = VLC_CODEC_FL32;
......
......@@ -138,7 +138,7 @@ static int Open( vlc_object_t *p_this )
date_Set( &p_sys->date, 0 );
p_dec->fmt_out.i_cat = AUDIO_ES;
if (vlc_CPU() & CPU_CAPABILITY_FPU)
if (HAVE_FPU)
p_dec->fmt_out.i_codec = VLC_CODEC_FL32;
else
p_dec->fmt_out.i_codec = VLC_CODEC_S16N;
......@@ -177,7 +177,7 @@ static int Open( vlc_object_t *p_this )
/* Set the faad config */
cfg = faacDecGetCurrentConfiguration( p_sys->hfaad );
if (vlc_CPU() & CPU_CAPABILITY_FPU)
if (HAVE_FPU)
cfg->outputFormat = FAAD_FMT_FLOAT;
else
cfg->outputFormat = FAAD_FMT_16BIT;
......@@ -483,7 +483,7 @@ static void DoReordering( uint32_t *p_out, uint32_t *p_in, int i_samples,
}
/* Do the actual reordering */
if( vlc_CPU() & CPU_CAPABILITY_FPU )
if( HAVE_FPU )
for( i = 0; i < i_samples; i++ )
for( j = 0; j < i_nb_channels; j++ )
p_out[i * i_nb_channels + pi_chan_table[j]] =
......
......@@ -109,7 +109,7 @@ static int Open (vlc_object_t *p_this)
p_dec->fmt_out.audio.i_original_channels =
p_dec->fmt_out.audio.i_physical_channels =
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
if (vlc_CPU () & CPU_CAPABILITY_FPU)
if (HAVE_FPU)
{
p_dec->fmt_out.i_codec = VLC_CODEC_FL32;
p_dec->fmt_out.audio.i_bitspersample = 32;
......
......@@ -177,8 +177,7 @@ int aout_OutputNew( aout_instance_t * p_aout,
{
/* Non-S/PDIF mixer only deals with float32 or fixed32. */
p_aout->mixer_format.i_format
= (vlc_CPU() & CPU_CAPABILITY_FPU) ?
VLC_CODEC_FL32 : VLC_CODEC_FI32;
= HAVE_FPU ? VLC_CODEC_FL32 : VLC_CODEC_FI32;
aout_FormatPrepare( &p_aout->mixer_format );
}
else
......
......@@ -1011,11 +1011,6 @@ static const char *const ppsz_clock_descriptions[] =
"These options allow you to enable special CPU optimizations. " \
"You should always leave all these enabled." )
#define FPU_TEXT N_("Enable FPU support")
#define FPU_LONGTEXT N_( \
"If your processor has a floating point calculation unit, VLC can take " \
"advantage of it.")
#define MMX_TEXT N_("Enable CPU MMX support")
#define MMX_LONGTEXT N_( \
"If your processor supports the MMX instructions set, VLC can take " \
......@@ -1959,8 +1954,7 @@ vlc_module_begin ()
set_category( CAT_ADVANCED )
set_subcategory( SUBCAT_ADVANCED_CPU )
add_category_hint( N_("CPU"), CPU_CAT_LONGTEXT, true )
add_bool( "fpu", 1, NULL, FPU_TEXT, FPU_LONGTEXT, true )
change_need_restart ()
add_obsolete_bool( "fpu" )
#if defined( __i386__ ) || defined( __x86_64__ )
add_bool( "mmx", 1, NULL, MMX_TEXT, MMX_LONGTEXT, true )
change_need_restart ()
......
......@@ -727,9 +727,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
if( priv->b_color )
priv->b_color = config_GetInt( p_libvlc, "color" ) > 0;
if( !config_GetInt( p_libvlc, "fpu" ) )
cpu_flags &= ~CPU_CAPABILITY_FPU;
char p_capabilities[200];
#define PRINT_CAPABILITY( capability, string ) \
if( vlc_CPU() & capability ) \
......@@ -772,7 +769,12 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
#endif
PRINT_CAPABILITY( CPU_CAPABILITY_FPU, "FPU" );
#if HAVE_FPU
strncat( p_capabilities, "FPU ",
sizeof(p_capabilities) - strlen( p_capabilities) );
p_capabilities[sizeof(p_capabilities) - 1] = '\0';
#endif
msg_Dbg( p_libvlc, "CPU has capabilities %s", p_capabilities );
/*
......
......@@ -113,8 +113,6 @@ uint32_t CPUCapabilities( void )
: "cc" );
# endif
i_capabilities |= CPU_CAPABILITY_FPU;
# if defined (__i386__) && !defined (__i486__) && !defined (__i586__) \
&& !defined (__i686__) && !defined (__pentium4__) \
&& !defined (__k6__) && !defined (__athlon__) && !defined (__k8__)
......@@ -252,9 +250,6 @@ uint32_t CPUCapabilities( void )
out:
#elif defined( __arm__ )
# if defined( __ARM_EABI__ ) && !defined( __SOFTFP__ )
// i_capabilities |= CPU_CAPABILITY_FPU;
# endif
# if defined( __ARM_NEON__ )
i_capabilities |= CPU_CAPABILITY_NEON;
# endif
......@@ -262,8 +257,6 @@ out:
#elif defined( __powerpc__ ) || defined( __ppc__ ) || defined( __powerpc64__ ) \
|| defined( __ppc64__ )
i_capabilities |= CPU_CAPABILITY_FPU;
# if defined(__APPLE__)
int selectors[2] = { CTL_HW, HW_VECTORUNIT };
int i_has_altivec = 0;
......@@ -289,12 +282,6 @@ out:
# endif
#elif defined( __sparc__ )
i_capabilities |= CPU_CAPABILITY_FPU;
#elif defined( _MSC_VER ) && !defined( UNDER_CE )
i_capabilities |= CPU_CAPABILITY_FPU;
#endif
return i_capabilities;
}
......
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