]> git.sesse.net Git - vlc/blobdiff - modules/audio_filter/param_eq.c
Revert "deinterlace: add basic support for YUY2 and NV12 (fixes #2206)"
[vlc] / modules / audio_filter / param_eq.c
index 57cbc5489c1ccf90d52d02ddea44a25830b215ed..9b984bec87c895908d999374ced8e552ef925865 100644 (file)
@@ -1,25 +1,25 @@
 /*****************************************************************************
  * param_eq.c:
  *****************************************************************************
- * Copyright © 2006 the VideoLAN team
+ * Copyright © 2006 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Antti Huovilainen
  *          Sigmund A. Helberg <dnumgis@videolan.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -55,26 +55,26 @@ vlc_module_begin ()
     set_category( CAT_AUDIO )
     set_subcategory( SUBCAT_AUDIO_AFILTER )
 
-    add_float( "param-eq-lowf", 100, NULL, N_("Low freq (Hz)"),NULL, false )
-    add_float_with_range( "param-eq-lowgain", 0, -20.0, 20.0, NULL,
+    add_float( "param-eq-lowf", 100, N_("Low freq (Hz)"),NULL, false )
+    add_float_with_range( "param-eq-lowgain", 0, -20.0, 20.0,
                           N_("Low freq gain (dB)"), NULL,false )
-    add_float( "param-eq-highf", 10000, NULL, N_("High freq (Hz)"),NULL, false )
-    add_float_with_range( "param-eq-highgain", 0, -20.0, 20.0, NULL,
+    add_float( "param-eq-highf", 10000, N_("High freq (Hz)"),NULL, false )
+    add_float_with_range( "param-eq-highgain", 0, -20.0, 20.0,
                           N_("High freq gain (dB)"),NULL,false )
-    add_float( "param-eq-f1", 300, NULL, N_("Freq 1 (Hz)"),NULL, false )
-    add_float_with_range( "param-eq-gain1", 0, -20.0, 20.0, NULL,
+    add_float( "param-eq-f1", 300, N_("Freq 1 (Hz)"),NULL, false )
+    add_float_with_range( "param-eq-gain1", 0, -20.0, 20.0,
                           N_("Freq 1 gain (dB)"), NULL,false )
-    add_float_with_range( "param-eq-q1", 3, 0.1, 100.0, NULL,
+    add_float_with_range( "param-eq-q1", 3, 0.1, 100.0,
                           N_("Freq 1 Q"), NULL,false )
-    add_float( "param-eq-f2", 1000, NULL, N_("Freq 2 (Hz)"),NULL, false )
-    add_float_with_range( "param-eq-gain2", 0, -20.0, 20.0, NULL,
+    add_float( "param-eq-f2", 1000, N_("Freq 2 (Hz)"),NULL, false )
+    add_float_with_range( "param-eq-gain2", 0, -20.0, 20.0,
                           N_("Freq 2 gain (dB)"),NULL,false )
-    add_float_with_range( "param-eq-q2", 3, 0.1, 100.0, NULL,
+    add_float_with_range( "param-eq-q2", 3, 0.1, 100.0,
                           N_("Freq 2 Q"),NULL,false )
-    add_float( "param-eq-f3", 3000, NULL, N_("Freq 3 (Hz)"),NULL, false )
-    add_float_with_range( "param-eq-gain3", 0, -20.0, 20.0, NULL,
+    add_float( "param-eq-f3", 3000, N_("Freq 3 (Hz)"),NULL, false )
+    add_float_with_range( "param-eq-gain3", 0, -20.0, 20.0,
                           N_("Freq 3 gain (dB)"),NULL,false )
-    add_float_with_range( "param-eq-q3", 3, 0.1, 100.0, NULL,
+    add_float_with_range( "param-eq-q3", 3, 0.1, 100.0,
                           N_("Freq 3 Q"),NULL,false )
 
     set_callbacks( Open, Close )
@@ -106,36 +106,15 @@ struct filter_sys_t
 static int Open( vlc_object_t *p_this )
 {
     filter_t     *p_filter = (filter_t *)p_this;
-    filter_sys_t *p_sys;
-    bool         b_fit = true;
     unsigned     i_samplerate;
 
-    if( p_filter->fmt_in.audio.i_format != VLC_CODEC_FL32 ||
-        p_filter->fmt_out.audio.i_format != VLC_CODEC_FL32 )
-    {
-        b_fit = false;
-        p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32;
-        p_filter->fmt_out.audio.i_format = VLC_CODEC_FL32;
-        msg_Warn( p_filter, "bad input or output format" );
-    }
-    if ( !AOUT_FMTS_SIMILAR( &p_filter->fmt_in.audio, &p_filter->fmt_out.audio ) )
-    {
-        b_fit = false;
-        memcpy( &p_filter->fmt_out.audio, &p_filter->fmt_in.audio,
-                sizeof(audio_sample_format_t) );
-        msg_Warn( p_filter, "input and output formats are not similar" );
-    }
-
-    if ( ! b_fit )
-    {
-        return VLC_EGENERIC;
-    }
-
     /* Allocate structure */
-    p_sys = p_filter->p_sys = malloc( sizeof( *p_sys ) );
+    filter_sys_t *p_sys = p_filter->p_sys = malloc( sizeof( *p_sys ) );
     if( !p_sys )
         return VLC_EGENERIC;
 
+    p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32;
+    p_filter->fmt_out.audio = p_filter->fmt_in.audio;
     p_filter->pf_audio_filter = DoWork;
 
     p_sys->f_lowf = var_InheritFloat( p_this, "param-eq-lowf");
@@ -221,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
@@ -265,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;