[vlc-devel] [PATCH 1/2] avcodec/audio: move DUALMONO hack in avcodec

Thomas Guillem thomas at gllm.fr
Tue Jul 11 10:01:33 CEST 2017


aout_CheckChannelExtraction() is only used by avcodec.
---
 modules/codec/avcodec/audio.c | 12 ++++++++++++
 src/audio_output/common.c     |  9 ---------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 2d751273f7..ea568f9dc7 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -607,6 +607,16 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
         if( i_channels_src != p_sys->p_context->channels && b_trust )
             msg_Err( p_dec, "Channel layout not understood" );
 
+        bool dual_mono = false;
+        /* Detect special dual mono case */
+        if( i_channels_src == 2 && pi_order_src[0] == AOUT_CHAN_CENTER
+         && pi_order_src[1] == AOUT_CHAN_CENTER )
+        {
+            dual_mono = true;
+            pi_order_src[0] = AOUT_CHAN_LEFT;
+            pi_order_src[1] = AOUT_CHAN_RIGHT;
+        }
+
         uint32_t i_layout_dst;
         int      i_channels_dst;
         p_sys->b_extract = aout_CheckChannelExtraction( p_sys->pi_extraction,
@@ -617,6 +627,8 @@ static void SetupOutputFormat( decoder_t *p_dec, bool b_trust )
 
         p_dec->fmt_out.audio.i_physical_channels =
         p_dec->fmt_out.audio.i_original_channels = i_layout_dst;
+        if (dual_mono)
+            p_dec->fmt_out.audio.i_original_channels |= AOUT_CHAN_DUALMONO;
     }
     else
     {
diff --git a/src/audio_output/common.c b/src/audio_output/common.c
index 57d1a7beb3..55b1550017 100644
--- a/src/audio_output/common.c
+++ b/src/audio_output/common.c
@@ -470,7 +470,6 @@ bool aout_CheckChannelExtraction( int *pi_selection,
     static_assert(AOUT_CHAN_MAX <= (sizeof (*pi_order_dst) * CHAR_BIT),
                   "Missing bits");
 
-    const uint32_t pi_order_dual_mono[] = { AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT };
     uint32_t i_layout = 0;
     int i_out = 0;
     int pi_index[AOUT_CHAN_MAX];
@@ -479,14 +478,6 @@ bool aout_CheckChannelExtraction( int *pi_selection,
     if( !pi_order_dst )
         pi_order_dst = pi_vlc_chan_order_wg4;
 
-    /* Detect special dual mono case */
-    if( i_channels == 2 &&
-        pi_order_src[0] == AOUT_CHAN_CENTER && pi_order_src[1] == AOUT_CHAN_CENTER )
-    {
-        i_layout |= AOUT_CHAN_DUALMONO;
-        pi_order_src = pi_order_dual_mono;
-    }
-
     /* */
     for( int i = 0; i < i_channels; i++ )
     {
-- 
2.11.0



More information about the vlc-devel mailing list