]> git.sesse.net Git - vlc/commitdiff
Reverse stereo option.
authorChristophe Massiot <massiot@videolan.org>
Wed, 22 Jan 2003 18:31:47 +0000 (18:31 +0000)
committerChristophe Massiot <massiot@videolan.org>
Wed, 22 Jan 2003 18:31:47 +0000 (18:31 +0000)
include/audio_output.h
modules/audio_filter/channel_mixer/trivial.c
modules/audio_filter/converter/a52tofloat32.c
src/audio_output/common.c
src/audio_output/output.c

index 44bb01aac3d523c4754470275f777df82f97db21..c17ad3f1999a195863a12c84fbaff2337014fb3f 100644 (file)
@@ -2,7 +2,7 @@
  * audio_output.h : audio output interface
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: audio_output.h,v 1.74 2002/12/07 23:50:30 massiot Exp $
+ * $Id: audio_output.h,v 1.75 2003/01/22 18:31:46 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -116,6 +116,7 @@ typedef int32_t vlc_fixed_t;
 /* Values available for original channels only */
 #define AOUT_CHAN_DOLBYSTEREO       0x10000
 #define AOUT_CHAN_DUALMONO          0x20000
+#define AOUT_CHAN_REVERSESTEREO     0x40000
 
 #define AOUT_CHAN_PHYSMASK          0xFFFF
 
index 5c257faa27ca80d5c9270389e9e975cee2d9cf72..0fa6314b10298b2f62341d71e8aa708d40149b06 100644 (file)
@@ -2,7 +2,7 @@
  * trivial.c : trivial channel mixer plug-in (drops unwanted channels)
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: trivial.c,v 1.9 2003/01/14 14:51:02 massiot Exp $
+ * $Id: trivial.c,v 1.10 2003/01/22 18:31:47 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -134,6 +134,17 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
                 p_src += 2;
             }
         }
+        else if ( p_filter->output.i_original_channels
+                                        & AOUT_CHAN_REVERSESTEREO )
+        {
+            /* Reverse-stereo mode */
+            for ( i = p_in_buf->i_nb_samples; i -= 2; )
+            {
+                *p_dest++ = p_src[1];
+                *p_dest++ = p_src[0];
+                p_src += 2;
+            }
+        }
         else
         {
             /* Fake-stereo mode */
index 85a4b61d714232f6227f4d802a80db66b9486371..7c0f3d3cdf56fd30d69e3b5e84c144d892db99b3 100644 (file)
@@ -4,7 +4,7 @@
  *   (http://liba52.sf.net/).
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: a52tofloat32.c,v 1.11 2003/01/22 09:54:28 massiot Exp $
+ * $Id: a52tofloat32.c,v 1.12 2003/01/22 18:31:47 massiot Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -278,6 +278,22 @@ static void Duplicate( float * p_out, const float * p_in )
     }
 }
 
+/*****************************************************************************
+ * Exchange: helper function to exchange left & right channels
+ *****************************************************************************/
+static void Exchange( float * p_out, const float * p_in )
+{
+    int i;
+    const float * p_first = p_in + 256;
+    const float * p_second = p_in;
+
+    for ( i = 0; i < 256; i++ )
+    {
+        *p_out++ = *p_first++;
+        *p_out++ = *p_second++;
+    }
+}
+
 /*****************************************************************************
  * DoWork: decode an ATSC A/52 frame.
  *****************************************************************************/
@@ -331,6 +347,12 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
             Duplicate( (float *)(p_out_buf->p_buffer + i * i_bytes_per_block),
                        p_samples );
         }
+        else if ( p_filter->output.i_original_channels
+                    & AOUT_CHAN_REVERSESTEREO )
+        {
+            Exchange( (float *)(p_out_buf->p_buffer + i * i_bytes_per_block),
+                      p_samples );
+        }
         else
         {
             /* Interleave the *$£%ù samples. */
index 8495e9f5d35eb236373b712f05a8cba552503144..c63e3055c4df0ec23a42ca926dc2150961882294 100644 (file)
@@ -2,7 +2,7 @@
  * common.c : audio output management of common data structures
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: common.c,v 1.14 2003/01/20 10:59:29 massiot Exp $
+ * $Id: common.c,v 1.15 2003/01/22 18:31:47 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -166,17 +166,26 @@ const char * aout_FormatPrintChannels( const audio_sample_format_t * p_format )
             return "Left";
         return "Right";
     case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT:
-        if ( p_format->i_original_channels & AOUT_CHAN_DOLBYSTEREO )
-            return "Dolby";
-        else if ( p_format->i_original_channels & AOUT_CHAN_DUALMONO )
-            return "Dual-mono";
-        else if ( p_format->i_original_channels == AOUT_CHAN_CENTER )
-            return "Stereo/Mono";
-        else if ( !(p_format->i_original_channels & AOUT_CHAN_RIGHT) )
-            return "Stereo/Left";
-        else if ( !(p_format->i_original_channels & AOUT_CHAN_LEFT) )
-            return "Stereo/Right";
-        return "Stereo";
+        if ( p_format->i_original_channels & AOUT_CHAN_REVERSESTEREO )
+        {
+            if ( p_format->i_original_channels & AOUT_CHAN_DOLBYSTEREO )
+                return "Dolby/Reverse";
+            return "Stereo/Reverse";
+        }
+        else
+        {
+            if ( p_format->i_original_channels & AOUT_CHAN_DOLBYSTEREO )
+                return "Dolby";
+            else if ( p_format->i_original_channels & AOUT_CHAN_DUALMONO )
+                return "Dual-mono";
+            else if ( p_format->i_original_channels == AOUT_CHAN_CENTER )
+                return "Stereo/Mono";
+            else if ( !(p_format->i_original_channels & AOUT_CHAN_RIGHT) )
+                return "Stereo/Left";
+            else if ( !(p_format->i_original_channels & AOUT_CHAN_LEFT) )
+                return "Stereo/Right";
+            return "Stereo";
+        }
     case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER:
         return "3F";
     case AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARCENTER:
index 8b015eb5e1a057864e8467da941e572aec95361b..425c1061f094121381fa02fa1193a7cd28005a30 100644 (file)
@@ -2,7 +2,7 @@
  * output.c : internal management of output streams for the audio output
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: output.c,v 1.30 2003/01/22 09:54:29 massiot Exp $
+ * $Id: output.c,v 1.31 2003/01/22 18:31:47 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -69,7 +69,12 @@ int aout_OutputNew( aout_instance_t * p_aout,
         /* The user may have selected a different channels configuration. */
         var_Get( p_aout, "audio-channels", &val );
 
-        if ( !strcmp( val.psz_string, N_("Both") ) )
+        if ( !strcmp( val.psz_string, N_("Reverse stereo") ) )
+        {
+            p_aout->output.output.i_original_channels |=
+                                        AOUT_CHAN_REVERSESTEREO;
+        }
+        else if ( !strcmp( val.psz_string, N_("Both") ) )
         {
             p_aout->output.output.i_original_channels =
                 AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
@@ -113,9 +118,7 @@ int aout_OutputNew( aout_instance_t * p_aout,
                          NULL );
     }
     else if ( p_aout->output.output.i_physical_channels ==
-                 (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT)
-              && (p_aout->output.output.i_original_channels
-                   & AOUT_CHAN_PHYSMASK) == (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) )
+                 (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) )
     {
         /* Stereo - create the audio-channels variable. */
         var_Create( p_aout, "audio-channels", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
@@ -132,6 +135,8 @@ int aout_OutputNew( aout_instance_t * p_aout,
         var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val );
         val.psz_string = N_("Right");
         var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val );
+        val.psz_string = N_("Reverse stereo");
+        var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val );
         var_AddCallback( p_aout, "audio-channels", aout_ChannelsRestart,
                          NULL );
     }