avcodec/audio: move DUALMONO hack in avcodec
authorThomas Guillem <thomas@gllm.fr>
Wed, 28 Jun 2017 14:00:55 +0000 (16:00 +0200)
committerThomas Guillem <thomas@gllm.fr>
Thu, 13 Jul 2017 15:13:14 +0000 (17:13 +0200)
aout_CheckChannelExtraction() is only used by avcodec.

modules/codec/avcodec/audio.c
src/audio_output/common.c

index 2d75127..ea568f9 100644 (file)
@@ -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
     {
index 47f4836..bba122d 100644 (file)
@@ -461,7 +461,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];
@@ -470,14 +469,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++ )
     {