[vlc-devel] commit: Added support for 3f->stereo/mono downmixing (close #2926). ( Laurent Aimar )
git version control
git at videolan.org
Sat Jul 4 14:46:39 CEST 2009
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Jul 4 14:43:44 2009 +0200| [9a55c487a03889a59ddb8126c9de2814910f4a83] | committer: Laurent Aimar
Added support for 3f->stereo/mono downmixing (close #2926).
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9a55c487a03889a59ddb8126c9de2814910f4a83
---
modules/audio_filter/channel_mixer/simple.c | 36 ++++++++++++++++++++++++--
1 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/modules/audio_filter/channel_mixer/simple.c b/modules/audio_filter/channel_mixer/simple.c
index c6cf8b0..407700a 100644
--- a/modules/audio_filter/channel_mixer/simple.c
+++ b/modules/audio_filter/channel_mixer/simple.c
@@ -1,5 +1,5 @@
/*****************************************************************************
- * simple.c : simple channel mixer plug-in (only 7/7.1/5/5.1 -> Stereo for now)
+ * simple.c : simple channel mixer plug-in
*****************************************************************************
* Copyright (C) 2002, 2006 the VideoLAN team
* $Id$
@@ -33,6 +33,7 @@
#include <vlc_aout.h>
#include <vlc_filter.h>
#include <vlc_block.h>
+#include <assert.h>
/*****************************************************************************
* Module descriptor
@@ -61,6 +62,7 @@ vlc_module_end ()
#define AOUT_CHANS_STEREO_MIDDLE (AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT )
#define AOUT_CHANS_2_0 AOUT_CHANS_STEREO_FRONT
+#define AOUT_CHANS_3_0 ( AOUT_CHANS_STEREO_FRONT | AOUT_CHAN_CENTER )
#define AOUT_CHANS_4_0 ( AOUT_CHANS_STEREO_FRONT | AOUT_CHANS_STEREO_REAR )
#define AOUT_CHANS_4_0_MIDDLE ( AOUT_CHANS_STEREO_FRONT | AOUT_CHANS_STEREO_MIDDLE )
#define AOUT_CHANS_5_0 ( AOUT_CHANS_4_0 | AOUT_CHAN_CENTER )
@@ -104,6 +106,8 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
const bool b_input_5_0 = !b_input_7_0 &&
( (i_input_physical & AOUT_CHANS_5_0) == AOUT_CHANS_5_0 ||
(i_input_physical & AOUT_CHANS_5_0_MIDDLE) == AOUT_CHANS_5_0_MIDDLE );
+ const bool b_input_3_0 = !b_input_7_0 && !b_input_5_0 &&
+ (i_input_physical & ~AOUT_CHAN_LFE) == AOUT_CHANS_3_0;
int i_input_nb = aout_FormatNbChannels( &p_filter->input );
int i_output_nb = aout_FormatNbChannels( &p_filter->output );
float *p_dest = (float *)p_out_buf->p_buffer;
@@ -127,7 +131,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
if( p_filter->input.i_physical_channels & AOUT_CHAN_LFE ) p_src++;
}
- else
+ else if( b_input_5_0 )
for( i = p_in_buf->i_nb_samples; i--; )
{
*p_dest = p_src[4] + 0.5 * p_src[0] + 0.33 * p_src[2];
@@ -139,6 +143,18 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
if( p_filter->input.i_physical_channels & AOUT_CHAN_LFE ) p_src++;
}
+ else if( b_input_3_0 )
+ for( i = p_in_buf->i_nb_samples; i--; )
+ {
+ *p_dest = p_src[2] + 0.5 * p_src[0];
+ p_dest++;
+ *p_dest = p_src[2] + 0.5 * p_src[1];
+ p_dest++;
+
+ p_src += 3;
+
+ if( p_filter->input.i_physical_channels & AOUT_CHAN_LFE ) p_src++;
+ }
}
else if( p_filter->output.i_physical_channels == AOUT_CHAN_CENTER )
{
@@ -162,6 +178,16 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
if( p_filter->input.i_physical_channels & AOUT_CHAN_LFE ) p_src++;
}
+ else if( b_input_3_0 )
+ for( i = p_in_buf->i_nb_samples; i--; )
+ {
+ *p_dest = p_src[2] + p_src[0] / 4 + p_src[1] / 4;
+ p_dest++;
+
+ p_src += 3;
+
+ if( p_filter->input.i_physical_channels & AOUT_CHAN_LFE ) p_src++;
+ }
else
for( i = p_in_buf->i_nb_samples; i--; )
{
@@ -173,6 +199,9 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
}
else
{
+ assert( p_filter->output.i_physical_channels == AOUT_CHANS_4_0 );
+ assert( b_input_7_0 || b_input_5_0 );
+
if( b_input_7_0 )
for( i = p_in_buf->i_nb_samples; i--; )
{
@@ -310,11 +339,12 @@ static bool IsSupported( const audio_format_t *p_input, const audio_format_t *p_
return false;
}
- /* Only from 7/7.1/5/5.1/2.0
+ /* 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_CHANS_2_0 )
{
return false;
More information about the vlc-devel
mailing list