[vlc-commits] equalizer: Enforce type correctness for M_PI as well

Ronald Wright git at videolan.org
Mon Apr 8 11:29:34 CEST 2013


vlc | branch: master | Ronald Wright <logiconcepts819 at gmail.com> | Sat Apr  6 15:26:17 2013 -0500| [fcdd5a13acdaf277178131d12d3be991acfd5c31] | committer: Jean-Baptiste Kempf

equalizer: Enforce type correctness for M_PI as well

It was my expectation that M_PI in the EqzCoeffs function is automatically cast
to a float during compile time, but my expectation turned out to be incorrect.
Specifically, I noticed in GCC's assembly output of equalizer.c that GCC was
doing the inverse by making the program convert all single-precision terms
(excluding 2.0f * M_PI) in the line containing M_PI to double-precision, and
then making it convert the double-precision result to single-precision before
the assignment to f_theta_1.  As a result, M_PI must be explicitly cast to a
float.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/audio_filter/equalizer.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/audio_filter/equalizer.c b/modules/audio_filter/equalizer.c
index 3402bb8..651b4a1 100644
--- a/modules/audio_filter/equalizer.c
+++ b/modules/audio_filter/equalizer.c
@@ -254,7 +254,7 @@ static void EqzCoeffs( int i_rate, float f_octave_percent,
 
         if( f_freq <= f_nyquist_freq )
         {
-            float f_theta_1 = ( 2.0f * M_PI * f_freq ) / f_rate;
+            float f_theta_1 = ( 2.0f * (float) M_PI * f_freq ) / f_rate;
             float f_theta_2 = f_theta_1 / f_octave_factor;
             float f_sin     = sinf( f_theta_2 );
             float f_sin_prd = sinf( f_theta_2 * f_octave_factor_1 )



More information about the vlc-commits mailing list