[vlc-devel] commit: HAVE_FPU: make constant ( Rémi Denis-Courmont )

git version control git at videolan.org
Mon Oct 19 21:15:50 CEST 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Oct 19 22:15:30 2009 +0300| [145903d05b94462eaa309575e46c3cbafb853a42] | committer: 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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=145903d05b94462eaa309575e46c3cbafb853a42
---

 include/vlc_cpu.h                              |   21 ++++++++++++++++++---
 modules/audio_filter/converter/mpgatofixed32.c |    5 +----
 modules/audio_output/alsa.c                    |    2 +-
 modules/audio_output/pulse.c                   |    2 +-
 modules/codec/faad.c                           |    6 +++---
 modules/codec/fluidsynth.c                     |    2 +-
 src/audio_output/output.c                      |    3 +--
 src/libvlc-module.c                            |    8 +-------
 src/libvlc.c                                   |   10 ++++++----
 src/misc/cpu.c                                 |   13 -------------
 10 files changed, 33 insertions(+), 39 deletions(-)

diff --git a/include/vlc_cpu.h b/include/vlc_cpu.h
index 7997770..b431238 100644
--- a/include/vlc_cpu.h
+++ b/include/vlc_cpu.h
@@ -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);
diff --git a/modules/audio_filter/converter/mpgatofixed32.c b/modules/audio_filter/converter/mpgatofixed32.c
index 74c64a1..243b1e4 100644
--- a/modules/audio_filter/converter/mpgatofixed32.c
+++ b/modules/audio_filter/converter/mpgatofixed32.c
@@ -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 );
diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index c8568a6..c479d3a 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -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;
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index a20db4f..c09b3f6 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -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;
diff --git a/modules/codec/faad.c b/modules/codec/faad.c
index 6dbd499..f53265c 100644
--- a/modules/codec/faad.c
+++ b/modules/codec/faad.c
@@ -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]] =
diff --git a/modules/codec/fluidsynth.c b/modules/codec/fluidsynth.c
index 34b4d15..8590de9 100644
--- a/modules/codec/fluidsynth.c
+++ b/modules/codec/fluidsynth.c
@@ -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;
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index dc6ea31..e8c9b6b 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -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
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 6945e00..41b841a 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -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 ()
diff --git a/src/libvlc.c b/src/libvlc.c
index c7c84de..4254781 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -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 );
 
     /*
diff --git a/src/misc/cpu.c b/src/misc/cpu.c
index 9ca2ab8..bb20617 100644
--- a/src/misc/cpu.c
+++ b/src/misc/cpu.c
@@ -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;
 }




More information about the vlc-devel mailing list