From: Jean-Baptiste Kempf Date: Sun, 14 Apr 2013 22:20:01 +0000 (+0200) Subject: Simple: fix comments and reorder functions X-Git-Tag: 2.1.0-git~659 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=d8ae3c5a3900313754cb82f1aa7b1fd2d030b8d5;p=vlc Simple: fix comments and reorder functions --- diff --git a/modules/audio_filter/channel_mixer/simple.c b/modules/audio_filter/channel_mixer/simple.c index 9292adfd29..85afee17a1 100644 --- a/modules/audio_filter/channel_mixer/simple.c +++ b/modules/audio_filter/channel_mixer/simple.c @@ -52,13 +52,62 @@ vlc_module_end () /***************************************************************************** * Local prototypes *****************************************************************************/ -static bool IsSupported( const audio_format_t *p_input, const audio_format_t *p_output ); - struct filter_sys_t { void (*pf_dowork)(filter_t *, block_t *, block_t * ); }; +/***************************************************************************** + * IsSupported: can we downmix? + *****************************************************************************/ +static bool IsSupported( const audio_format_t *p_input, const audio_format_t *p_output ) +{ + if( p_input->i_format != VLC_CODEC_FL32 || + p_input->i_format != p_output->i_format || + p_input->i_rate != p_output->i_rate ) + { + return false; + } + + if( p_input->i_physical_channels == p_output->i_physical_channels && + p_input->i_original_channels == p_output->i_original_channels ) + { + return false; + } + + /* Only conversion to Mono, Stereo, 4.0 and 5.1 */ + if( p_output->i_physical_channels != AOUT_CHAN_CENTER && + p_output->i_physical_channels != AOUT_CHANS_2_0 && + p_output->i_physical_channels != AOUT_CHANS_4_0 && + p_output->i_physical_channels != AOUT_CHANS_5_1 ) + { + return false; + } + + /* Only from 7.x/5.x/4.0/3.x/2.0 + * NB 5.X rear and middle are handled the same way + * We don't support 2.1 -> 2.0 (trivial can do it) + * TODO: We don't support any 8.1 input + * TODO: We don't support any 6.x input + * TODO: We don't support 4.0 rear and 4.0 middle + * */ + if( (p_input->i_physical_channels & ~AOUT_CHAN_LFE) != AOUT_CHANS_7_0 && + (p_input->i_physical_channels & ~AOUT_CHAN_LFE) != AOUT_CHANS_5_0 && + (p_input->i_physical_channels & ~AOUT_CHAN_LFE) != AOUT_CHANS_5_0_MIDDLE && + (p_input->i_physical_channels & ~AOUT_CHAN_LFE) != AOUT_CHANS_4_CENTER_REAR && + (p_input->i_physical_channels & ~AOUT_CHAN_LFE) != AOUT_CHANS_3_0 && + p_input->i_physical_channels != AOUT_CHANS_2_0 ) + { + return false; + } + + /* Only downmixing */ + if( aout_FormatNbChannels( p_input ) <= aout_FormatNbChannels( p_output ) ) + return false; + + return true; +} + static block_t *Filter( filter_t *, block_t * ); static void DoWork_7_x_to_2_0( filter_t * p_filter, block_t * p_in_buf, block_t * p_out_buf ) { @@ -352,47 +401,4 @@ static block_t *Filter( filter_t *p_filter, block_t *p_block ) return p_out; } -/***************************************************************************** - * Helpers: - *****************************************************************************/ -static bool IsSupported( const audio_format_t *p_input, const audio_format_t *p_output ) -{ - if( p_input->i_format != VLC_CODEC_FL32 || - p_input->i_format != p_output->i_format || - p_input->i_rate != p_output->i_rate ) - return false; - - if( p_input->i_physical_channels == p_output->i_physical_channels && - p_input->i_original_channels == p_output->i_original_channels ) - { - return false; - } - - /* Only conversion to Mono, Stereo and 4.0 right now */ - if( p_output->i_physical_channels != AOUT_CHAN_CENTER && - p_output->i_physical_channels != AOUT_CHANS_2_0 && - p_output->i_physical_channels != AOUT_CHANS_4_0 && - p_output->i_physical_channels != AOUT_CHANS_5_1 ) - { - return false; - } - - /* Only from 7/7.1/5/5.1/3/3.1/2.0 - * XXX 5.X rear and middle are handled the same way */ - if( (p_input->i_physical_channels & ~AOUT_CHAN_LFE) != AOUT_CHANS_7_0 && - (p_input->i_physical_channels & ~AOUT_CHAN_LFE) != AOUT_CHANS_5_0 && - (p_input->i_physical_channels & ~AOUT_CHAN_LFE) != AOUT_CHANS_5_0_MIDDLE && - (p_input->i_physical_channels & ~AOUT_CHAN_LFE) != AOUT_CHANS_3_0 && - (p_input->i_physical_channels & ~AOUT_CHAN_LFE) != AOUT_CHANS_4_CENTER_REAR && - p_input->i_physical_channels != AOUT_CHANS_2_0 ) - { - return false; - } - - /* Only if we downmix */ - if( aout_FormatNbChannels( p_input ) <= aout_FormatNbChannels( p_output ) ) - return false; - - return true; -}