[vlc-commits] param_eq: single precision math

Rémi Denis-Courmont git at videolan.org
Wed Aug 13 22:23:09 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Aug 13 23:10:36 2014 +0300| [6f7b2c432982f61ad2b68485bfd7ad999c4bff0b] | committer: Rémi Denis-Courmont

param_eq: single precision math

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

 modules/audio_filter/param_eq.c |   38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/modules/audio_filter/param_eq.c b/modules/audio_filter/param_eq.c
index 9ad5568..9b984be 100644
--- a/modules/audio_filter/param_eq.c
+++ b/modules/audio_filter/param_eq.c
@@ -200,15 +200,15 @@ static void CalcPeakEQCoeffs( float f0, float Q, float gainDB, float Fs,
     if (gainDB < -40) gainDB = -40;
     if (gainDB > 40) gainDB = 40;
  
-    A = pow(10, gainDB/40);
-    w0 = 2*3.141593f*f0/Fs;
-    alpha = sin(w0)/(2*Q);
+    A = powf(10, gainDB/40);
+    w0 = 2*((float)M_PI)*f0/Fs;
+    alpha = sinf(w0)/(2*Q);
  
     b0 = 1 + alpha*A;
-    b1 = -2*cos(w0);
+    b1 = -2*cosf(w0);
     b2 = 1 - alpha*A;
     a0 = 1 + alpha/A;
-    a1 = -2*cos(w0);
+    a1 = -2*cosf(w0);
     a2 = 1 - alpha/A;
  
     // Store values to coeffs and normalize by 1/a0
@@ -244,27 +244,27 @@ static void CalcShelfEQCoeffs( float f0, float slope, float gainDB, int high,
     if (gainDB < -40) gainDB = -40;
     if (gainDB > 40) gainDB = 40;
 
-    A = pow(10, gainDB/40);
+    A = powf(10, gainDB/40);
     w0 = 2*3.141593f*f0/Fs;
-    alpha = sin(w0)/2 * sqrt( (A + 1/A)*(1/slope - 1) + 2 );
+    alpha = sinf(w0)/2 * sqrtf( (A + 1/A)*(1/slope - 1) + 2 );
 
     if (high)
     {
-        b0 =    A*( (A+1) + (A-1)*cos(w0) + 2*sqrt(A)*alpha );
-        b1 = -2*A*( (A-1) + (A+1)*cos(w0) );
-        b2 =    A*( (A+1) + (A-1)*cos(w0) - 2*sqrt(A)*alpha );
-        a0 =        (A+1) - (A-1)*cos(w0) + 2*sqrt(A)*alpha;
-        a1 =    2*( (A-1) - (A+1)*cos(w0) );
-        a2 =        (A+1) - (A-1)*cos(w0) - 2*sqrt(A)*alpha;
+        b0 =    A*( (A+1) + (A-1)*cosf(w0) + 2*sqrtf(A)*alpha );
+        b1 = -2*A*( (A-1) + (A+1)*cosf(w0) );
+        b2 =    A*( (A+1) + (A-1)*cosf(w0) - 2*sqrtf(A)*alpha );
+        a0 =        (A+1) - (A-1)*cosf(w0) + 2*sqrtf(A)*alpha;
+        a1 =    2*( (A-1) - (A+1)*cosf(w0) );
+        a2 =        (A+1) - (A-1)*cosf(w0) - 2*sqrtf(A)*alpha;
     }
     else
     {
-        b0 =    A*( (A+1) - (A-1)*cos(w0) + 2*sqrt(A)*alpha );
-        b1 =  2*A*( (A-1) - (A+1)*cos(w0));
-        b2 =    A*( (A+1) - (A-1)*cos(w0) - 2*sqrt(A)*alpha );
-        a0 =        (A+1) + (A-1)*cos(w0) + 2*sqrt(A)*alpha;
-        a1 =   -2*( (A-1) + (A+1)*cos(w0));
-        a2 =        (A+1) + (A-1)*cos(w0) - 2*sqrt(A)*alpha;
+        b0 =    A*( (A+1) - (A-1)*cosf(w0) + 2*sqrtf(A)*alpha );
+        b1 =  2*A*( (A-1) - (A+1)*cosf(w0));
+        b2 =    A*( (A+1) - (A-1)*cosf(w0) - 2*sqrtf(A)*alpha );
+        a0 =        (A+1) + (A-1)*cosf(w0) + 2*sqrtf(A)*alpha;
+        a1 =   -2*( (A-1) + (A+1)*cosf(w0));
+        a2 =        (A+1) + (A-1)*cosf(w0) - 2*sqrtf(A)*alpha;
     }
     // Store values to coeffs and normalize by 1/a0
     coeffs[0] = b0/a0;



More information about the vlc-commits mailing list