[vlc-devel] [RFC] dcp: Audio channels reordering
Nicolas Bertrand
nicoinattendu at gmail.com
Sun Dec 8 13:50:49 CET 2013
Just the part about channel ordering. based on patch v11.
---
modules/access/dcp/dcp.cpp | 51 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 48 insertions(+), 3 deletions(-)
diff --git a/modules/access/dcp/dcp.cpp b/modules/access/dcp/dcp.cpp
index bb7dee9..ba72a82 100644
--- a/modules/access/dcp/dcp.cpp
+++ b/modules/access/dcp/dcp.cpp
@@ -43,6 +43,7 @@
#include <vlc_plugin.h>
#include <vlc_xml.h>
#include <vlc_url.h>
+#include <vlc_aout.h>
/* 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 },
+};
+
+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],
+ 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
More information about the vlc-devel
mailing list