X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faudio_filter%2Fchannel_mixer%2Fmono.c;h=a6633249bee976d0e808d40edc33df988cae7597;hb=b674dab81ccd2a089896b26a2afc258118e6a990;hp=ae033ad35460579802d851134af4299f610e964f;hpb=43b5cae75d484829153b085c89739b551207b2d9;p=vlc diff --git a/modules/audio_filter/channel_mixer/mono.c b/modules/audio_filter/channel_mixer/mono.c index ae033ad354..a6633249be 100644 --- a/modules/audio_filter/channel_mixer/mono.c +++ b/modules/audio_filter/channel_mixer/mono.c @@ -24,8 +24,6 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include /* malloc(), free() */ -#include #include /* sqrt */ #ifdef HAVE_STDINT_H @@ -38,12 +36,16 @@ # include #endif -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include #include #include #include -#include -#include +#include /***************************************************************************** * Local prototypes @@ -53,12 +55,11 @@ static void CloseFilter ( vlc_object_t * ); static block_t *Convert( filter_t *p_filter, block_t *p_block ); -static unsigned int stereo_to_mono( aout_instance_t *, aout_filter_t *, - aout_buffer_t *, aout_buffer_t * ); -static unsigned int mono( aout_instance_t *, aout_filter_t *, - aout_buffer_t *, aout_buffer_t * ); -static void stereo2mono_downmix( aout_instance_t *, aout_filter_t *, - aout_buffer_t *, aout_buffer_t * ); +static unsigned int stereo_to_mono( aout_filter_t *, aout_buffer_t *, + aout_buffer_t * ); +static unsigned int mono( aout_filter_t *, aout_buffer_t *, aout_buffer_t * ); +static void stereo2mono_downmix( aout_filter_t *, aout_buffer_t *, + aout_buffer_t * ); /***************************************************************************** * Local structures @@ -73,30 +74,30 @@ struct atomic_operation_t struct filter_sys_t { - vlc_bool_t b_downmix; + bool b_downmix; unsigned int i_nb_channels; /* number of int16_t per sample */ int i_channel_selected; int i_bitspersample; size_t i_overflow_buffer_size;/* in bytes */ - byte_t * p_overflow_buffer; + uint8_t * p_overflow_buffer; unsigned int i_nb_atomic_operations; struct atomic_operation_t * p_atomic_operations; }; -#define MONO_DOWNMIX_TEXT N_("Use downmix algorithme.") +#define MONO_DOWNMIX_TEXT N_("Use downmix algorithm") #define MONO_DOWNMIX_LONGTEXT N_("This option selects a stereo to mono " \ "downmix algorithm that is used in the headphone channel mixer. It" \ "gives the effect of standing in a room full of speakers." ) #define MONO_CHANNEL_TEXT N_("Select channel to keep") #define MONO_CHANNEL_LONGTEXT N_("This option silences all other channels " \ - "except the selected channel. Choose one from (0=left, 1=right " \ + "except the selected channel. Choose one from (0=left, 1=right, " \ "2=rear left, 3=rear right, 4=center, 5=left front)") -static int pi_pos_values[] = { 0, 1, 2, 4, 8, 5 }; -static char *ppsz_pos_descriptions[] = +static const int pi_pos_values[] = { 0, 1, 2, 4, 8, 5 }; +static const char *const ppsz_pos_descriptions[] = { N_("Left"), N_("Right"), N_("Left rear"), N_("Right rear"), N_("Center"), N_("Left front") }; @@ -110,13 +111,13 @@ static const uint32_t pi_channels_out[] = * Module descriptor *****************************************************************************/ vlc_module_begin(); - set_description( _("Audio filter for stereo to mono conversion") ); + set_description( N_("Audio filter for stereo to mono conversion") ); set_capability( "audio filter2", 0 ); - add_bool( MONO_CFG "downmix", VLC_FALSE, NULL, MONO_DOWNMIX_TEXT, - MONO_DOWNMIX_LONGTEXT, VLC_FALSE ); + add_bool( MONO_CFG "downmix", false, NULL, MONO_DOWNMIX_TEXT, + MONO_DOWNMIX_LONGTEXT, false ); add_integer( MONO_CFG "channel", -1, NULL, MONO_CHANNEL_TEXT, - MONO_CHANNEL_LONGTEXT, VLC_FALSE ); + MONO_CHANNEL_LONGTEXT, false ); change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 ); set_category( CAT_AUDIO ); @@ -246,10 +247,7 @@ static int Init( vlc_object_t *p_this, struct filter_sys_t * p_data, p_data->p_atomic_operations = malloc( sizeof(struct atomic_operation_t) * p_data->i_nb_atomic_operations ); if( p_data->p_atomic_operations == NULL ) - { - msg_Err( p_this, "out of memory" ); return -1; - } /* For each virtual speaker, computes elementary wave propagation time * to each ear */ @@ -347,10 +345,7 @@ static int Init( vlc_object_t *p_this, struct filter_sys_t * p_data, } p_data->p_overflow_buffer = malloc( p_data->i_overflow_buffer_size ); if( p_data->p_atomic_operations == NULL ) - { - msg_Err( p_this, "out of memory" ); return -1; - } memset( p_data->p_overflow_buffer, 0, p_data->i_overflow_buffer_size ); /* end */ @@ -392,10 +387,7 @@ static int OpenFilter( vlc_object_t *p_this ) /* Allocate the memory needed to store the module's structure */ p_sys = p_filter->p_sys = malloc( sizeof(filter_sys_t) ); if( p_sys == NULL ) - { - msg_Err( p_filter, "out of memory" ); return VLC_EGENERIC; - } var_Create( p_this, MONO_CFG "downmix", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); @@ -526,15 +518,12 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block ) memset( p_out->p_buffer, 0, i_out_size ); if( p_filter->p_sys->b_downmix ) { - stereo2mono_downmix( (aout_instance_t *)p_filter, &aout_filter, - &in_buf, &out_buf ); - i_samples = mono( (aout_instance_t *)p_filter, &aout_filter, - &out_buf, &in_buf ); + stereo2mono_downmix( &aout_filter, &in_buf, &out_buf ); + i_samples = mono( &aout_filter, &out_buf, &in_buf ); } else { - i_samples = stereo_to_mono( (aout_instance_t *)p_filter, &aout_filter, - &out_buf, &in_buf ); + i_samples = stereo_to_mono( &aout_filter, &out_buf, &in_buf ); } p_out->i_buffer = out_buf.i_nb_bytes; @@ -549,7 +538,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block ) * converted from float into int16_t based downmix * Written by Boris Dorès */ -static void stereo2mono_downmix( aout_instance_t * p_aout, aout_filter_t * p_filter, +static void stereo2mono_downmix( aout_filter_t * p_filter, aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf ) { filter_sys_t *p_sys = (filter_sys_t *)p_filter->p_sys; @@ -558,9 +547,9 @@ static void stereo2mono_downmix( aout_instance_t * p_aout, aout_filter_t * p_fil int i_output_nb = aout_FormatNbChannels( &p_filter->output ); int16_t * p_in = (int16_t*) p_in_buf->p_buffer; - byte_t * p_out; - byte_t * p_overflow; - byte_t * p_slide; + uint8_t * p_out; + uint8_t * p_overflow; + uint8_t * p_slide; size_t i_overflow_size; /* in bytes */ size_t i_out_size; /* in bytes */ @@ -659,7 +648,7 @@ static void stereo2mono_downmix( aout_instance_t * p_aout, aout_filter_t * p_fil } /* Simple stereo to mono mixing. */ -static unsigned int mono( aout_instance_t * p_aout, aout_filter_t *p_filter, +static unsigned int mono( aout_filter_t *p_filter, aout_buffer_t *p_output, aout_buffer_t *p_input ) { filter_sys_t *p_sys = (filter_sys_t *)p_filter->p_sys; @@ -679,7 +668,7 @@ static unsigned int mono( aout_instance_t * p_aout, aout_filter_t *p_filter, } /* Simple stereo to mono mixing. */ -static unsigned int stereo_to_mono( aout_instance_t * p_aout, aout_filter_t *p_filter, +static unsigned int stereo_to_mono( aout_filter_t *p_filter, aout_buffer_t *p_output, aout_buffer_t *p_input ) { filter_sys_t *p_sys = (filter_sys_t *)p_filter->p_sys;