]> git.sesse.net Git - vlc/blobdiff - modules/audio_filter/equalizer.c
Fix memleak in audio equalizer.
[vlc] / modules / audio_filter / equalizer.c
index 0fdb011474d2320f12de43d09e600ae2cc6d16b0..a05c34a10217b825c40a884eb9388487e3e673b9 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * equalizer.c:
  *****************************************************************************
- * Copyright (C) 2004 VideoLAN
+ * Copyright (C) 2004, 2006 the VideoLAN team
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
  * 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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <math.h>
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 
-#include <vlc/aout.h>
-#include "aout_internal.h"
+#include "vlc_aout.h"
 
+#include "equalizer_presets.h"
 /* TODO:
  *  - add tables for other rates ( 22500, 11250, ...)
  *  - optimize a bit (you can hardly do slower ;)
@@ -49,41 +54,37 @@ static int  Open ( vlc_object_t * );
 static void Close( vlc_object_t * );
 
 #define PRESET_TEXT N_( "Equalizer preset" )
-#define PRESET_LONGTEXT PRESET_TEXT
+#define PRESET_LONGTEXT N_("Preset to use for the equalizer." )
 
 #define BANDS_TEXT N_( "Bands gain")
-#define BANDS_LONGTEXT N_( "Override preset bands gain in dB (-20 ... 20)" )
+#define BANDS_LONGTEXT N_( \
+         "Don't use presets, but manually specified bands. You need to " \
+         "provide 10 values between -20dB and 20dB, separated by spaces, " \
+         "e.g. \"0 2 4 2 0 -2 -4 -2 0\"." )
 
 #define TWOPASS_TEXT N_( "Two pass" )
-#define TWOPASS_LONGTEXT N_( "Filter twice the audio" )
+#define TWOPASS_LONGTEXT N_( "Filter the audio twice. This provides a more "  \
+         "intense effect.")
 
 #define PREAMP_TEXT N_("Global gain" )
-#define PREAMP_LONGTEXT N_("Set the global gain in dB (-20 ... 20)" )
-
-static char *preset_list[] = {
-    "flat", "classical", "club", "dance", "fullbass", "fullbasstreeble",
-    "fulltreeble", "headphones","largehall", "live", "party", "pop", "reggae",
-    "rock", "ska", "soft", "softrock", "techno"
-};
-static char *preset_list_text[] = {
-    N_("Flat"), N_("Classical"), N_("Club"), N_("Dance"), N_("Full bass"),
-    N_("Full bass and treeble"), N_("Full treeble"), N_("Headphones"),
-    N_("Large Hall"), N_("Live"), N_("Party"), N_("Pop"), N_("Reggae"),
-    N_("Rock"), N_("Ska"), N_("Soft"), N_("Soft rock"), N_("Techno"),
-};
+#define PREAMP_LONGTEXT N_("Set the global gain in dB (-20 ... 20)." )
 
 vlc_module_begin();
-    set_description( _("Equalizer 10 bands") );
+    set_description( N_("Equalizer with 10 bands") );
+    set_shortname( N_("Equalizer" ) );
     set_capability( "audio filter", 0 );
+    set_category( CAT_AUDIO );
+    set_subcategory( SUBCAT_AUDIO_AFILTER );
+
     add_string( "equalizer-preset", "flat", NULL, PRESET_TEXT,
-                PRESET_LONGTEXT, VLC_TRUE );
+                PRESET_LONGTEXT, false );
         change_string_list( preset_list, preset_list_text, 0 );
     add_string( "equalizer-bands", NULL, NULL, BANDS_TEXT,
-                BANDS_LONGTEXT, VLC_TRUE );
+                BANDS_LONGTEXT, true );
     add_bool( "equalizer-2pass", 0, NULL, TWOPASS_TEXT,
-              TWOPASS_LONGTEXT, VLC_TRUE );
-    add_float( "equalizer-preamp", 0.0, NULL, PREAMP_TEXT,
-               PREAMP_LONGTEXT, VLC_TRUE );
+              TWOPASS_LONGTEXT, true );
+    add_float( "equalizer-preamp", 12.0, NULL, PREAMP_TEXT,
+               PREAMP_LONGTEXT, true );
     set_callbacks( Open, Close );
     add_shortcut( "equalizer" );
 vlc_module_end();
@@ -91,7 +92,6 @@ vlc_module_end();
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-
 typedef struct aout_filter_sys_t
 {
     /* Filter static config */
@@ -100,10 +100,14 @@ typedef struct aout_filter_sys_t
     float *f_beta;
     float *f_gamma;
 
+    float f_newpreamp;
+    char *psz_newbands;
+    bool b_first;
+
     /* Filter dyn config */
     float *f_amp;   /* Per band amp */
     float f_gamp;   /* Global preamp */
-    vlc_bool_t b_2eqz;
+    bool b_2eqz;
 
     /* Filter state */
     float x[32][2];
@@ -120,9 +124,19 @@ static void DoWork( aout_instance_t *, aout_filter_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 EqzFilter( aout_filter_t *, float *, float *,
+                        int, int );
 static void EqzClean( aout_filter_t * );
 
+static int PresetCallback( vlc_object_t *, char const *,
+                                           vlc_value_t, vlc_value_t, void * );
+static int PreampCallback( vlc_object_t *, char const *,
+                                           vlc_value_t, vlc_value_t, void * );
+static int BandsCallback ( vlc_object_t *, char const *,
+                                           vlc_value_t, vlc_value_t, void * );
+
+
+
 /*****************************************************************************
  * Open:
  *****************************************************************************/
@@ -130,21 +144,31 @@ 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;
 
     if( p_filter->input.i_format != VLC_FOURCC('f','l','3','2' ) ||
         p_filter->output.i_format != VLC_FOURCC('f','l','3','2') )
     {
-        msg_Warn( p_filter, "Bad input or output format" );
-        return VLC_EGENERIC;
+        b_fit = false;
+        p_filter->input.i_format = VLC_FOURCC('f','l','3','2');
+        p_filter->output.i_format = VLC_FOURCC('f','l','3','2');
+        msg_Warn( p_filter, "bad input or output format" );
     }
     if ( !AOUT_FMTS_SIMILAR( &p_filter->input, &p_filter->output ) )
     {
+        b_fit = false;
+        memcpy( &p_filter->output, &p_filter->input,
+                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 = VLC_TRUE;
+    p_filter->b_in_place = true;
 
     /* Allocate structure */
     p_sys = p_filter->p_sys = malloc( sizeof( aout_filter_sys_t ) );
@@ -175,6 +199,7 @@ 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 )
 {
+    VLC_UNUSED(p_aout);
     p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
     p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes;
 
@@ -196,7 +221,7 @@ typedef struct
         float f_alpha;
         float f_beta;
         float f_gamma;
-    } band[];
+    } band[EQZ_BANDS_MAX];
 
 } eqz_config_t;
 
@@ -234,130 +259,6 @@ static const eqz_config_t eqz_config_48000_10b =
     }
 };
 
-typedef struct
-{
-    char *psz_name;
-    int  i_band;
-    float f_preamp;
-    float f_amp[];
-} eqz_preset_t;
-
-static const eqz_preset_t eqz_preset_flat_10b=
-{
-    "flat", 10, 12.0,
-    { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 },
-};
-static const eqz_preset_t eqz_preset_classical_10b=
-{
-    "classical", 10, 12.0,
-    { -1.11022e-15, -1.11022e-15, -1.11022e-15, -1.11022e-15, -1.11022e-15, -1.11022e-15, -7.2, -7.2, -7.2, -9.6 }
-};
-static const eqz_preset_t eqz_preset_club_10b=
-{
-    "club", 10, 6.0,
-    { -1.11022e-15, -1.11022e-15, 8, 5.6, 5.6, 5.6, 3.2, -1.11022e-15, -1.11022e-15, -1.11022e-15 }
-};
-static const eqz_preset_t eqz_preset_dance_10b=
-{
-    "dance", 10, 5.0,
-    { 9.6, 7.2, 2.4, -1.11022e-15, -1.11022e-15, -5.6, -7.2, -7.2, -1.11022e-15, -1.11022e-15 }
-};
-static const eqz_preset_t eqz_preset_fullbass_10b=
-{
-    "fullbass", 10, 5.0,
-    { -8, 9.6, 9.6, 5.6, 1.6, -4, -8, -10.4, -11.2, -11.2  }
-};
-static const eqz_preset_t eqz_preset_fullbasstreeble_10b=
-{
-    "fullbasstreeble", 10, 4.0,
-    { 7.2, 5.6, -1.11022e-15, -7.2, -4.8, 1.6, 8, 11.2, 12, 12 }
-};
-
-static const eqz_preset_t eqz_preset_fulltreeble_10b=
-{
-    "fulltreeble", 10, 3.0,
-    { -9.6, -9.6, -9.6, -4, 2.4, 11.2, 16, 16, 16, 16.8 }
-};
-static const eqz_preset_t eqz_preset_headphones_10b=
-{
-    "headphones", 10, 4.0,
-    { 4.8, 11.2, 5.6, -3.2, -2.4, 1.6, 4.8, 9.6, 12.8, 14.4 }
-};
-static const eqz_preset_t eqz_preset_largehall_10b=
-{
-    "largehall", 10, 5.0,
-    { 10.4, 10.4, 5.6, 5.6, -1.11022e-15, -4.8, -4.8, -4.8, -1.11022e-15, -1.11022e-15 }
-};
-static const eqz_preset_t eqz_preset_live_10b=
-{
-    "live", 10, 7.0,
-    { -4.8, -1.11022e-15, 4, 5.6, 5.6, 5.6, 4, 2.4, 2.4, 2.4 }
-};
-static const eqz_preset_t eqz_preset_party_10b=
-{
-    "party", 10, 6.0,
-    { 7.2, 7.2, -1.11022e-15, -1.11022e-15, -1.11022e-15, -1.11022e-15, -1.11022e-15, -1.11022e-15, 7.2, 7.2 }
-};
-static const eqz_preset_t eqz_preset_pop_10b=
-{
-    "pop", 10, 6.0,
-    { -1.6, 4.8, 7.2, 8, 5.6, -1.11022e-15, -2.4, -2.4, -1.6, -1.6 }
-};
-static const eqz_preset_t eqz_preset_reggae_10b=
-{
-    "reggae", 10, 8.0,
-    { -1.11022e-15, -1.11022e-15, -1.11022e-15, -5.6, -1.11022e-15, 6.4, 6.4, -1.11022e-15, -1.11022e-15, -1.11022e-15 }
-};
-static const eqz_preset_t eqz_preset_rock_10b=
-{
-    "rock", 10, 5.0,
-    { 8, 4.8, -5.6, -8, -3.2, 4, 8.8, 11.2, 11.2, 11.2 }
-};
-static const eqz_preset_t eqz_preset_ska_10b=
-{
-    "ska", 10, 6.0,
-    { -2.4, -4.8, -4, -1.11022e-15, 4, 5.6, 8.8, 9.6, 11.2, 9.6 }
-};
-static const eqz_preset_t eqz_preset_soft_10b=
-{
-    "soft", 10, 5.0,
-    { 4.8, 1.6, -1.11022e-15, -2.4, -1.11022e-15, 4, 8, 9.6, 11.2, 12 }
-};
-static const eqz_preset_t eqz_preset_softrock_10b=
-{
-    "softrock", 10, 7.0,
-    { 4, 4, 2.4, -1.11022e-15, -4, -5.6, -3.2, -1.11022e-15, 2.4, 8.8 }
-};
-static const eqz_preset_t eqz_preset_techno_10b=
-{
-    "techno", 10, 5.0,
-    { 8, 5.6, -1.11022e-15, -5.6, -4.8, -1.11022e-15, 8, 9.6, 9.6, 8.8 }
-};
-
-static const eqz_preset_t *eqz_preset_10b[] =
-{
-    &eqz_preset_flat_10b,
-    &eqz_preset_classical_10b,
-    &eqz_preset_club_10b,
-    &eqz_preset_dance_10b,
-    &eqz_preset_fullbass_10b,
-    &eqz_preset_fullbasstreeble_10b,
-    &eqz_preset_fulltreeble_10b,
-    &eqz_preset_headphones_10b,
-    &eqz_preset_largehall_10b,
-    &eqz_preset_live_10b,
-    &eqz_preset_party_10b,
-    &eqz_preset_pop_10b,
-    &eqz_preset_reggae_10b,
-    &eqz_preset_rock_10b,
-    &eqz_preset_ska_10b,
-    &eqz_preset_soft_10b,
-    &eqz_preset_softrock_10b,
-    &eqz_preset_techno_10b,
-    NULL
-};
-
-
 static inline float EqzConvertdB( float db )
 {
     /* Map it to gain,
@@ -379,9 +280,9 @@ static int EqzInit( aout_filter_t *p_filter, int i_rate )
 {
     aout_filter_sys_t *p_sys = p_filter->p_sys;
     const eqz_config_t *p_cfg;
-    char *psz;
     int i, ch;
-    float f_float;
+    vlc_value_t val1, val2, val3;
+    aout_instance_t *p_aout = (aout_instance_t *)p_filter->p_parent;
 
     /* Select the config */
     if( i_rate == 48000 )
@@ -395,7 +296,7 @@ static int EqzInit( aout_filter_t *p_filter, int i_rate )
     else
     {
         /* TODO compute the coeffs on the fly */
-        msg_Err( p_filter, "unsupported rate" );
+        msg_Err( p_filter, "rate not supported" );
         return VLC_EGENERIC;
     }
 
@@ -412,7 +313,7 @@ static int EqzInit( aout_filter_t *p_filter, int i_rate )
     }
 
     /* Filter dyn config */
-    p_sys->b_2eqz = VLC_FALSE;
+    p_sys->b_2eqz = false;
     p_sys->f_gamp = 1.0;
     p_sys->f_amp   = malloc( p_sys->i_band * sizeof(float) );
     for( i = 0; i < p_sys->i_band; i++ )
@@ -437,66 +338,49 @@ static int EqzInit( aout_filter_t *p_filter, int i_rate )
         }
     }
 
-    /* Now parse config */
-    p_sys->b_2eqz = var_CreateGetBool( p_filter, "equalizer-2pass" );
-    f_float = var_CreateGetFloat( p_filter, "equalizer-preamp" );
-    if( f_float < -20.0 )
-        f_float = -20.0;
-    else if( f_float > 20.0 )
-        f_float = 20.0;
-    p_sys->f_gamp = pow( 10, f_float /20.0);
-
-    psz = var_CreateGetString( p_filter, "equalizer-preset" );
-    if( *psz && p_sys->i_band == 10 )
-    {
-        int i;
-        /* */
-        for( i = 0; eqz_preset_10b[i] != NULL; i++ )
-        {
-            if( !strcasecmp( eqz_preset_10b[i]->psz_name, psz ) )
-            {
-                int j;
-                p_sys->f_gamp *= pow( 10, eqz_preset_10b[i]->f_preamp / 20.0 );
-                for( j = 0; j < p_sys->i_band; j++ )
-                    p_sys->f_amp[j] = EqzConvertdB( eqz_preset_10b[i]->f_amp[j] );
-                break;
-            }
-        }
-        if( eqz_preset_10b[i] == NULL )
-        {
-            msg_Err( p_filter, "equalizer preset '%s' not found", psz );
-            msg_Dbg( p_filter, "full list:" );
-            for( i = 0; eqz_preset_10b[i] != NULL; i++ )
-                msg_Dbg( p_filter, "  - '%s'", eqz_preset_10b[i]->psz_name );
-        }
-    }
-    free( psz );
+    char *psz_tmp = var_CreateGetString( p_aout,"equalizer-bands" );
+    free( psz_tmp );
+    psz_tmp = var_CreateGetString( p_aout, "equalizer-preset" );
+    free( psz_tmp );
 
-    psz = var_CreateGetString( p_filter, "equalizer-bands" );
-    if( *psz )
-    {
-        char *p = psz;
-        int i;
-        for( i = 0; i < p_sys->i_band; i++ )
-        {
-            float f;
+    p_sys->b_2eqz = var_CreateGetBool( p_aout, "equalizer-2pass" );
 
-            /* Read dB -20/20*/
-            f = strtof( p, &p );
+    var_CreateGetFloat( p_aout, "equalizer-preamp" );
 
-            p_sys->f_amp[i] = EqzConvertdB( f );
+    /* Get initial values */
+    var_Get( p_aout, "equalizer-preset", &val1 );
+    var_Get( p_aout, "equalizer-bands", &val2 );
+    var_Get( p_aout, "equalizer-preamp", &val3 );
 
-            if( p == NULL )
-                break;
-            p++;
-            if( *p == '\0' )
-                break;
-        }
+    p_sys->b_first = true;
+    PresetCallback( VLC_OBJECT( p_aout ), NULL, val1, val1, p_sys );
+    BandsCallback(  VLC_OBJECT( p_aout ), NULL, val2, val2, p_sys );
+    PreampCallback( VLC_OBJECT( p_aout ), NULL, val3, val3, p_sys );
+    p_sys->b_first = false;
+
+    /* Register preset bands (for intf) if : */
+    /* We have no bands info --> the preset info must be given to the intf */
+    /* or The bands info matches the preset */
+    if (p_sys->psz_newbands == NULL)
+    {
+        msg_Err(p_filter, "No preset selected");
+        return (VLC_EGENERIC);
+    }
+    if( ( *(val2.psz_string) &&
+        strstr( p_sys->psz_newbands, val2.psz_string ) ) || !*val2.psz_string )
+    {
+        var_SetString( p_aout, "equalizer-bands", p_sys->psz_newbands );
+        if( p_sys->f_newpreamp == p_sys->f_gamp )
+            var_SetFloat( p_aout, "equalizer-preamp", p_sys->f_newpreamp );
     }
-    free( psz );
+
+    /* Add our own callbacks */
+    var_AddCallback( p_aout, "equalizer-preset", PresetCallback, p_sys );
+    var_AddCallback( p_aout, "equalizer-bands", BandsCallback, p_sys );
+    var_AddCallback( p_aout, "equalizer-preamp", PreampCallback, p_sys );
 
     msg_Dbg( p_filter, "equalizer loaded for %d Hz with %d bands %d pass",
-             i_rate, p_sys->i_band, p_sys->b_2eqz ? 2 : 1 );
+                        i_rate, p_sys->i_band, p_sys->b_2eqz ? 2 : 1 );
     for( i = 0; i < p_sys->i_band; i++ )
     {
         msg_Dbg( p_filter, "   %d Hz -> factor:%f alpha:%f beta:%f gamma:%f",
@@ -571,9 +455,126 @@ static void EqzClean( aout_filter_t *p_filter )
 {
     aout_filter_sys_t *p_sys = p_filter->p_sys;
 
+    var_DelCallback( (aout_instance_t *)p_filter->p_parent,
+                        "equalizer-bands", BandsCallback, p_sys );
+    var_DelCallback( (aout_instance_t *)p_filter->p_parent,
+                        "equalizer-preset", PresetCallback, p_sys );
+    var_DelCallback( (aout_instance_t *)p_filter->p_parent,
+                        "equalizer-preamp", PreampCallback, p_sys );
+
     free( p_sys->f_alpha );
     free( p_sys->f_beta );
     free( p_sys->f_gamma );
 
     free( p_sys->f_amp );
 }
+
+
+static int PresetCallback( vlc_object_t *p_this, 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;
+
+    char *psz_preset = newval.psz_string;
+    char psz_newbands[120];
+
+    memset( psz_newbands, 0, 120 );
+
+    if( *psz_preset && p_sys->i_band == 10 )
+    {
+        int i;
+        /* */
+        for( i = 0; eqz_preset_10b[i] != NULL; i++ )
+        {
+            if( !strcasecmp( eqz_preset_10b[i]->psz_name, psz_preset ) )
+            {
+                int j;
+                p_sys->f_gamp *= pow( 10, eqz_preset_10b[i]->f_preamp / 20.0 );
+                for( j = 0; j < p_sys->i_band; j++ )
+                {
+                    lldiv_t div;
+                    p_sys->f_amp[j] = EqzConvertdB(
+                                        eqz_preset_10b[i]->f_amp[j] );
+                    div = lldiv( eqz_preset_10b[i]->f_amp[j] * 10000000,
+                                 10000000 );
+                    sprintf( psz_newbands, "%s %"PRId64".%07u", psz_newbands,
+                                      (int64_t)div.quot, (unsigned int) div.rem );
+                }
+                if( p_sys->b_first == false )
+                {
+                    var_SetString( p_aout, "equalizer-bands", psz_newbands );
+                    var_SetFloat( p_aout, "equalizer-preamp",
+                                    eqz_preset_10b[i]->f_preamp );
+                }
+                else
+                {
+                    p_sys->psz_newbands = strdup( psz_newbands );
+                    p_sys->f_newpreamp = eqz_preset_10b[i]->f_preamp;
+                }
+                break;
+            }
+        }
+        if( eqz_preset_10b[i] == NULL )
+        {
+            msg_Err( p_aout, "equalizer preset '%s' not found", psz_preset );
+            msg_Dbg( p_aout, "full list:" );
+            for( i = 0; eqz_preset_10b[i] != NULL; i++ )
+                msg_Dbg( p_aout, "  - '%s'", eqz_preset_10b[i]->psz_name );
+        }
+    }
+    return VLC_SUCCESS;
+}
+
+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;
+
+    if( newval.f_float < -20.0 )
+        newval.f_float = -20.0;
+    else if( newval.f_float > 20.0 )
+        newval.f_float = 20.0;
+    p_sys->f_gamp = pow( 10, newval.f_float /20.0);
+
+    return VLC_SUCCESS;
+}
+
+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;
+    char *psz_bands = newval.psz_string;
+    char *psz_next;
+    char *p = psz_bands;
+    int i;
+
+    /* Same thing for bands */
+    for( i = 0; i < p_sys->i_band; i++ )
+    {
+        float f;
+
+        if( *psz_bands == '\0' )
+            break;
+
+        /* Read dB -20/20 */
+#ifdef HAVE_STRTOF
+        f = strtof( p, &psz_next );
+#else
+        f = (float)strtod( p, &psz_next );
+#endif
+        if( psz_next == p )
+            break; /* no conversion */
+
+        p_sys->f_amp[i] = EqzConvertdB( f );
+
+        if( *psz_next == '\0' )
+            break; /* end of line */
+        p = &psz_next[1];
+    }
+    return VLC_SUCCESS;
+}
+