[vlc-devel] commit: Equalizer: convert to audio filter2 ( Rémi Denis-Courmont )

git version control git at videolan.org
Thu Nov 5 22:35:37 CET 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Nov  5 23:31:28 2009 +0200| [4073c82195ff4cdf1dccd81cd75ad5766a632b0f] | committer: Rémi Denis-Courmont 

Equalizer: convert to audio filter2

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

 modules/audio_filter/equalizer.c |   73 +++++++++++++++----------------------
 1 files changed, 30 insertions(+), 43 deletions(-)

diff --git a/modules/audio_filter/equalizer.c b/modules/audio_filter/equalizer.c
index 36a21ad..15dd08f 100644
--- a/modules/audio_filter/equalizer.c
+++ b/modules/audio_filter/equalizer.c
@@ -36,6 +36,7 @@
 #include <vlc_charset.h>
 
 #include <vlc_aout.h>
+#include <vlc_filter.h>
 
 #include "equalizer_presets.h"
 /* TODO:
@@ -73,7 +74,7 @@ static void Close( vlc_object_t * );
 vlc_module_begin ()
     set_description( N_("Equalizer with 10 bands") )
     set_shortname( N_("Equalizer" ) )
-    set_capability( "audio filter", 0 )
+    set_capability( "audio filter2", 0 )
     set_category( CAT_AUDIO )
     set_subcategory( SUBCAT_AUDIO_AFILTER )
 
@@ -93,7 +94,7 @@ vlc_module_end ()
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-struct aout_filter_sys_t
+struct filter_sys_t
 {
     /* Filter static config */
     int i_band;
@@ -121,14 +122,12 @@ struct aout_filter_sys_t
     vlc_mutex_t lock;
 };
 
-static void DoWork( aout_instance_t *, aout_filter_t *,
-                    aout_buffer_t *, aout_buffer_t * );
+static block_t *DoWork( filter_t *, block_t * );
 
 #define EQZ_IN_FACTOR (0.25)
-static int  EqzInit( aout_filter_t *, int );
-static void EqzFilter( aout_filter_t *, float *, float *,
-                        int, int );
-static void EqzClean( aout_filter_t * );
+static int  EqzInit( filter_t *, int );
+static void EqzFilter( filter_t *, float *, float *, int, int );
+static void EqzClean( filter_t * );
 
 static int PresetCallback ( vlc_object_t *, char const *, vlc_value_t,
                             vlc_value_t, void * );
@@ -146,36 +145,29 @@ static int TwoPassCallback( vlc_object_t *, char const *, vlc_value_t,
  *****************************************************************************/
 static int Open( vlc_object_t *p_this )
 {
-    aout_filter_t     *p_filter = (aout_filter_t *)p_this;
-    aout_filter_sys_t *p_sys;
-    bool         b_fit = true;
+    filter_t     *p_filter = (filter_t *)p_this;
+    filter_sys_t *p_sys;
 
     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" );
+        return VLC_EGENERIC;
     }
     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;
     }
 
-    p_filter->pf_do_work = DoWork;
-    p_filter->b_in_place = true;
+    p_filter->pf_audio_filter = DoWork;
 
     /* Allocate structure */
-    p_sys = p_filter->p_sys = malloc( sizeof( aout_filter_sys_t ) );
+    p_sys = p_filter->p_sys = malloc( sizeof( *p_sys ) );
     if( !p_sys )
         return VLC_ENOMEM;
 
@@ -195,8 +187,8 @@ static int Open( vlc_object_t *p_this )
  *****************************************************************************/
 static void Close( vlc_object_t *p_this )
 {
-    aout_filter_t     *p_filter = (aout_filter_t *)p_this;
-    aout_filter_sys_t *p_sys = p_filter->p_sys;
+    filter_t     *p_filter = (filter_t *)p_this;
+    filter_sys_t *p_sys = p_filter->p_sys;
 
     EqzClean( p_filter );
     vlc_mutex_destroy( &p_sys->lock );
@@ -208,16 +200,12 @@ static void Close( vlc_object_t *p_this )
  *****************************************************************************
  *
  *****************************************************************************/
-static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
-                    aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf )
+static block_t * DoWork( filter_t * p_filter, block_t * p_in_buf )
 {
-    VLC_UNUSED(p_aout);
-    p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
-    p_out_buf->i_buffer = p_in_buf->i_buffer;
-
-    EqzFilter( p_filter, (float*)p_out_buf->p_buffer,
+    EqzFilter( p_filter, (float*)p_in_buf->p_buffer,
                (float*)p_in_buf->p_buffer, p_in_buf->i_nb_samples,
                aout_FormatNbChannels( &p_filter->fmt_in.audio ) );
+    return p_in_buf;
 }
 
 /*****************************************************************************
@@ -288,13 +276,13 @@ static inline float EqzConvertdB( float db )
     return EQZ_IN_FACTOR * ( pow( 10, db / 20.0 ) - 1.0 );
 }
 
-static int EqzInit( aout_filter_t *p_filter, int i_rate )
+static int EqzInit( filter_t *p_filter, int i_rate )
 {
-    aout_filter_sys_t *p_sys = p_filter->p_sys;
+    filter_sys_t *p_sys = p_filter->p_sys;
     const eqz_config_t *p_cfg;
     int i, ch;
     vlc_value_t val1, val2, val3;
-    aout_instance_t *p_aout = (aout_instance_t *)p_filter->p_parent;
+    vlc_object_t *p_aout = p_filter->p_parent;
     int i_ret = VLC_ENOMEM;
 
     /* Select the config */
@@ -420,10 +408,10 @@ error:
     return i_ret;
 }
 
-static void EqzFilter( aout_filter_t *p_filter, float *out, float *in,
+static void EqzFilter( filter_t *p_filter, float *out, float *in,
                        int i_samples, int i_channels )
 {
-    aout_filter_sys_t *p_sys = p_filter->p_sys;
+    filter_sys_t *p_sys = p_filter->p_sys;
     int i, ch, j;
 
     vlc_mutex_lock( &p_sys->lock );
@@ -483,10 +471,10 @@ static void EqzFilter( aout_filter_t *p_filter, float *out, float *in,
     vlc_mutex_unlock( &p_sys->lock );
 }
 
-static void EqzClean( aout_filter_t *p_filter )
+static void EqzClean( filter_t *p_filter )
 {
-    aout_filter_sys_t *p_sys = p_filter->p_sys;
-    aout_instance_t *p_aout = (aout_instance_t *)p_filter->p_parent;
+    filter_sys_t *p_sys = p_filter->p_sys;
+    vlc_object_t *p_aout = p_filter->p_parent;
 
     var_DelCallback( p_aout, "equalizer-bands", BandsCallback, p_sys );
     var_DelCallback( p_aout, "equalizer-preset", PresetCallback, p_sys );
@@ -502,12 +490,11 @@ static void EqzClean( aout_filter_t *p_filter )
 }
 
 
-static int PresetCallback( vlc_object_t *p_this, char const *psz_cmd,
+static int PresetCallback( vlc_object_t *p_aout, char const *psz_cmd,
                          vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
     VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
-    aout_filter_sys_t *p_sys = (aout_filter_sys_t *)p_data;
-    aout_instance_t *p_aout = (aout_instance_t *)p_this;
+    filter_sys_t *p_sys = p_data;
 
     const char *psz_preset = newval.psz_string;
 
@@ -572,7 +559,7 @@ static int PreampCallback( vlc_object_t *p_this, char const *psz_cmd,
                          vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
     VLC_UNUSED(p_this); VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
-    aout_filter_sys_t *p_sys = (aout_filter_sys_t *)p_data;
+    filter_sys_t *p_sys = p_data;
 
     if( newval.f_float < -20.0 )
         newval.f_float = -20.0;
@@ -590,7 +577,7 @@ static int BandsCallback( vlc_object_t *p_this, char const *psz_cmd,
                          vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
     VLC_UNUSED(p_this); VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
-    aout_filter_sys_t *p_sys = (aout_filter_sys_t *)p_data;
+    filter_sys_t *p_sys = p_data;
     const char *psz_bands = newval.psz_string;
     const char *p = psz_bands;
     char *psz_next;
@@ -623,7 +610,7 @@ static int TwoPassCallback( vlc_object_t *p_this, char const *psz_cmd,
                             vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
     VLC_UNUSED(p_this); VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
-    aout_filter_sys_t *p_sys = (aout_filter_sys_t *)p_data;
+    filter_sys_t *p_sys = p_data;
 
     vlc_mutex_lock( &p_sys->lock );
     p_sys->b_2eqz = newval.b_bool;




More information about the vlc-devel mailing list