*
* 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
*
* 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
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
*
* 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
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
-static void DoWork ( aout_instance_t * , aout_filter_t *,
- aout_buffer_t * , aout_buffer_t *);
+static block_t *DoWork( filter_t *, block_t * );
#define BUFF_TEXT N_("Number of audio buffers" )
#define BUFF_LONGTEXT N_("This is the number of audio buffers on which the " \
"power measurement is made. A higher number of buffers will " \
#define BUFF_TEXT N_("Number of audio buffers" )
#define BUFF_LONGTEXT N_("This is the number of audio buffers on which the " \
"power measurement is made. A higher number of buffers will " \
- "increase the response time of the filter to a high " \
- "power but will make it less sensitive to short variations." )
+ "increase the response time of the filter to a spike " \
+ "but will make it less sensitive to short variations." )
#define LEVEL_TEXT N_("Max level" )
#define LEVEL_LONGTEXT N_("If the average power over the last N buffers " \
#define LEVEL_TEXT N_("Max level" )
#define LEVEL_LONGTEXT N_("If the average power over the last N buffers " \
-vlc_module_begin();
- set_description( _("Volume normalizer") );
- set_shortname( N_("Volume normalizer") );
- set_category( CAT_AUDIO );
- set_subcategory( SUBCAT_AUDIO_AFILTER );
- add_shortcut( "volnorm" );
+vlc_module_begin ()
+ set_description( N_("Volume normalizer") )
+ set_shortname( N_("Volume normalizer") )
+ set_category( CAT_AUDIO )
+ set_subcategory( SUBCAT_AUDIO_AFILTER )
+ add_shortcut( "volnorm" )
add_integer( "norm-buff-size", 20 ,NULL ,BUFF_TEXT, BUFF_LONGTEXT,
add_integer( "norm-buff-size", 20 ,NULL ,BUFF_TEXT, BUFF_LONGTEXT,
add_float( "norm-max-level", 2.0, NULL, LEVEL_TEXT,
add_float( "norm-max-level", 2.0, NULL, LEVEL_TEXT,
- LEVEL_LONGTEXT, VLC_TRUE );
- set_capability( "audio filter", 0 );
- set_callbacks( Open, Close );
-vlc_module_end();
+ LEVEL_LONGTEXT, true )
+ set_capability( "audio filter", 0 )
+ set_callbacks( Open, Close )
+vlc_module_end ()
/*****************************************************************************
* Open: initialize and create stuff
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
/*****************************************************************************
* Open: initialize and create stuff
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
- if( p_filter->input.i_format != VLC_FOURCC('f','l','3','2' ) ||
- p_filter->output.i_format != VLC_FOURCC('f','l','3','2') )
+ if( 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;
+ 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;
p_sys->i_nb = var_CreateGetInteger( p_filter->p_parent, "norm-buff-size" );
p_sys->f_max = var_CreateGetFloat( p_filter->p_parent, "norm-max-level" );
if( p_sys->f_max <= 0 ) p_sys->f_max = 0.01;
/* We need to store (nb_buffers+1)*nb_channels floats */
p_sys->i_nb = var_CreateGetInteger( p_filter->p_parent, "norm-buff-size" );
p_sys->f_max = var_CreateGetFloat( p_filter->p_parent, "norm-max-level" );
if( p_sys->f_max <= 0 ) p_sys->f_max = 0.01;
/* We need to store (nb_buffers+1)*nb_channels floats */
- p_sys->p_last = malloc( sizeof( float ) * (i_channels) *
- (p_filter->p_sys->i_nb + 2) );
- memset( p_sys->p_last, 0 ,sizeof( float ) * (i_channels) *
- (p_filter->p_sys->i_nb + 2) );
+ p_sys->p_last = calloc( i_channels * (p_filter->p_sys->i_nb + 2), sizeof(float) );
+ if( !p_sys->p_last )
+ {
+ free( p_sys );
+ return VLC_ENOMEM;
+ }
+
return VLC_SUCCESS;
}
/*****************************************************************************
* DoWork : normalizes and sends a buffer
*****************************************************************************/
return VLC_SUCCESS;
}
/*****************************************************************************
* DoWork : normalizes and sends a buffer
*****************************************************************************/
- 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 )
- int i_channels = aout_FormatNbChannels( &p_filter->input );
- float *p_out = (float*)p_out_buf->p_buffer;
+ int i_channels = aout_FormatNbChannels( &p_filter->fmt_in.audio );
+ float *p_out = (float*)p_in_buf->p_buffer;
- pf_sum = (float *)malloc( sizeof(float) * i_channels );
- memset( pf_sum, 0, sizeof(float) * i_channels );
+ pf_sum = calloc( i_channels, sizeof(float) );
+ if( !pf_sum )
+ goto out;
- pf_gain = (float *)malloc( sizeof(float) * i_channels );
-
- p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
- p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes;
+ pf_gain = malloc( sizeof(float) * i_channels );
+ if( !pf_gain )
+ {
+ free( pf_sum );
+ goto out;
+ }
&p_sys->p_last[i_chan * p_sys->i_nb + 1],
(p_sys->i_nb-1) * sizeof( float ) );
&p_sys->p_last[i_chan * p_sys->i_nb + 1],
(p_sys->i_nb-1) * sizeof( float ) );
//fprintf(stderr,"Average %f, max %f\n", f_average, p_sys->f_max );
if( f_average > p_sys->f_max )
//fprintf(stderr,"Average %f, max %f\n", f_average, p_sys->f_max );
if( f_average > p_sys->f_max )
**********************************************************************/
static void Close( vlc_object_t *p_this )
{
**********************************************************************/
static void Close( vlc_object_t *p_this )
{