]> git.sesse.net Git - vlc/commitdiff
Simple: fix comments and reorder functions
authorJean-Baptiste Kempf <jb@videolan.org>
Sun, 14 Apr 2013 22:20:01 +0000 (00:20 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Sun, 14 Apr 2013 22:25:50 +0000 (00:25 +0200)
modules/audio_filter/channel_mixer/simple.c

index 9292adfd29ff04764721f76a7ca1b9a4e3364d0e..85afee17a152454654e931ba7dfffb638e7e2f6c 100644 (file)
@@ -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;
-}