[vlc-devel] [RFC] dcp: Audio channels reordering

Denis Charmet typx at dinauz.org
Mon Dec 9 10:45:58 CET 2013


Hi,
Le dimanche 08 décembre 2013 à 01:50:49, Nicolas Bertrand a écrit :
>  /* ASDCP headers */
>  #include <AS_DCP.h>
> @@ -133,6 +134,10 @@ class demux_sys_t
>      /* total number of frames */
>      uint32_t frames_total;
>  
> +    uint8_t i_chans_to_reorder;            /* do we need channel reordering */
> +    uint8_t pi_chan_table[AOUT_CHAN_MAX];
> +    uint8_t i_channels;
> +
>      mtime_t i_pts;
>  
>      demux_sys_t():
> @@ -168,6 +173,30 @@ class demux_sys_t
>      }
>  };
>  
> +/*TODO: basic correlation between SMPTE S428-3/S429-2
> + * Real sound is more complex with case of left/right surround, ...
> + * and hearing impaired/Narration channels */
> +static const uint32_t pi_channels_aout[][9] = {
> +    /* case CFG 1; 5.1 */
> +    { AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT,      AOUT_CHAN_CENTER,
> +      AOUT_CHAN_LFE,  AOUT_CHAN_REARLEFT,   AOUT_CHAN_REARRIGHT,
> +     0 ,              0,                    0 },
> +    /* case CFG2 : 6.1 */
> +    { AOUT_CHAN_LEFT,       AOUT_CHAN_RIGHT,    AOUT_CHAN_CENTER,
> +      AOUT_CHAN_LFE,        AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT,
> +      AOUT_CHAN_REARCENTER, 0,                  0  },
> +    /* case CFG2 : 7.1 */
> +    { AOUT_CHAN_LEFT,        AOUT_CHAN_RIGHT,      AOUT_CHAN_CENTER,
> +      AOUT_CHAN_LFE,         AOUT_CHAN_REARLEFT,   AOUT_CHAN_REARRIGHT,
> +      AOUT_CHAN_MIDDLELEFT,  AOUT_CHAN_MIDDLELEFT, 0 },
AOUT_CHAN_MIDDLELEFT twice?
> +};
> +
> +static const unsigned i_channel_mask[] = {
> +    AOUT_CHANS_5_1,
> +    AOUT_CHANS_6_1_MIDDLE,
> +    AOUT_CHANS_7_1
> +} ;
> +
>  /*****************************************************************************
>   * Local prototypes
>   *****************************************************************************/
> @@ -364,10 +393,22 @@ static int Open( vlc_object_t *obj )
>  
>          audio_format.audio.i_bitspersample = p_AudioDesc->QuantizationBits;
>          audio_format.audio.i_blockalign    = p_AudioDesc->BlockAlign;
> -        audio_format.audio.i_channels      = p_AudioDesc->ChannelCount;
> -
> +        audio_format.audio.i_channels      =
> +        p_sys->i_channels                  = p_AudioDesc->ChannelCount;
>          p_sys->i_audio_buffer = PCM::CalcFrameBufferSize(*p_AudioDesc);
>  
> +        /* Manage channel orders */
> +        /* TODO Case CF_CFG_1, CF_CFG_2, CF_CFG_3 only supported */
> +        if ( ( p_AudioDesc->ChannelFormat == PCM::CF_CFG_4 ) ||
> +           ( p_AudioDesc->ChannelFormat == PCM::CF_CFG_5 ) ) {
> +             msg_Err( p_demux, "Sound config not supported. Set to 7.1 order");
> +             p_AudioDesc->ChannelFormat = PCM::CF_CFG_3;
> +        };
> +        p_sys->i_chans_to_reorder =  aout_CheckChannelReorder(
> +                pi_channels_aout[p_AudioDesc->ChannelFormat], NULL,
> +                i_channel_mask[p_AudioDesc->ChannelFormat],
This assumes that CF_CFG_1 is 0, CF_CFG_2 is 1 and CF_CFG_3 is 2. Since
you have no control over it I'd rather an assert or a #if CF_CFG_1 != 0
[...] #error DCP header changed.
> +                p_sys->pi_chan_table );
> +
>          if( ( p_sys->p_audio_es = es_out_Add( p_demux->out, &audio_format ) ) == NULL ) {
>              msg_Err( p_demux, "Failed to add audio es" );
>              retval = VLC_EGENERIC;
> @@ -384,7 +425,6 @@ static int Open( vlc_object_t *obj )
>          goto error;
>      }
>  
> -
>      p_sys->p_out = p_demux->out;
>      p_demux->pf_demux = Demux;
>      p_demux->pf_control = Control;
> @@ -489,6 +529,11 @@ static int Demux( demux_t *p_demux )
>          goto error_asdcp;
>      }
>  
> +    if( p_sys->i_chans_to_reorder )
> +        aout_ChannelReorder( p_audio_frame->p_buffer, p_audio_frame->i_buffer,
> +                p_sys->i_channels,
> +                p_sys->pi_chan_table, VLC_CODEC_S24L );
> +
>      p_audio_frame->i_buffer = AudioFrameBuff.Size();
>      p_audio_frame->i_length = CLOCK_FREQ * p_sys->frame_rate_denom / p_sys->frame_rate_num;
>      p_audio_frame->i_pts = CLOCK_FREQ * p_sys->frame_no * p_sys->frame_rate_denom / p_sys->frame_rate_num;
> -- 
> 1.7.9.5
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel

-- 
Denis Charmet - TypX
Le mauvais esprit est un art de vivre



More information about the vlc-devel mailing list