Commit b4400ea4 authored by Christophe Massiot's avatar Christophe Massiot

* modules/stream_out/transcode.c : Cleaned up the downmixing/upmixing

   facilities. Fixed a few incoherences with
   i_original_channels/i_physical_channels.
parent 66a06add
......@@ -593,9 +593,6 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
vlc_object_attach( id->p_decoder, p_stream );
id->p_decoder->p_module = NULL;
id->p_decoder->fmt_in = *p_fmt;
id->p_decoder->fmt_out = *p_fmt;
id->p_decoder->fmt_out.i_extra = 0;
id->p_decoder->fmt_out.p_extra = 0;
id->p_decoder->b_pace_control = VLC_TRUE;
/* Create encoder object */
......@@ -625,11 +622,28 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->p_encoder->fmt_out.i_codec = p_sys->i_acodec;
id->p_encoder->fmt_out.audio.i_rate = p_sys->i_sample_rate > 0 ?
p_sys->i_sample_rate : (int)p_fmt->audio.i_rate;
id->p_encoder->fmt_out.audio.i_channels = p_sys->i_channels > 0 ?
p_sys->i_channels : p_fmt->audio.i_channels;
id->p_encoder->fmt_out.i_bitrate = p_sys->i_abitrate;
id->p_encoder->fmt_out.audio.i_bitspersample =
p_fmt->audio.i_bitspersample;
id->p_encoder->fmt_out.audio.i_channels = p_sys->i_channels > 0 ?
p_sys->i_channels : p_fmt->audio.i_channels;
/* Sanity check for audio channels */
id->p_encoder->fmt_out.audio.i_channels =
__MIN( id->p_encoder->fmt_out.audio.i_channels,
id->p_decoder->fmt_in.audio.i_channels );
id->p_encoder->fmt_out.audio.i_original_channels =
id->p_decoder->fmt_in.audio.i_physical_channels;
if( id->p_decoder->fmt_in.audio.i_channels ==
id->p_encoder->fmt_out.audio.i_channels )
{
id->p_encoder->fmt_out.audio.i_physical_channels =
id->p_decoder->fmt_in.audio.i_physical_channels;
}
else
{
id->p_encoder->fmt_out.audio.i_physical_channels =
pi_channels_maps[id->p_encoder->fmt_out.audio.i_channels];
}
/* Build decoder -> filter -> encoder chain */
if( transcode_audio_new( p_stream, id ) )
......@@ -930,6 +944,9 @@ static int transcode_audio_new( sout_stream_t *p_stream,
*/
/* Initialization of decoder structures */
id->p_decoder->fmt_out = id->p_decoder->fmt_in;
id->p_decoder->fmt_out.i_extra = 0;
id->p_decoder->fmt_out.p_extra = 0;
id->p_decoder->pf_decode_audio = 0;
id->p_decoder->pf_aout_buffer_new = audio_new_buffer;
id->p_decoder->pf_aout_buffer_del = audio_del_buffer;
......@@ -958,27 +975,14 @@ static int transcode_audio_new( sout_stream_t *p_stream,
id->p_decoder->fmt_out.i_codec );
id->p_encoder->fmt_in.audio.i_format = id->p_decoder->fmt_out.i_codec;
/* Sanity check for audio channels */
id->p_encoder->fmt_out.audio.i_channels =
__MIN( id->p_encoder->fmt_out.audio.i_channels,
id->p_decoder->fmt_out.audio.i_channels );
if( id->p_decoder->fmt_out.audio.i_channels ==
id->p_encoder->fmt_out.audio.i_channels )
id->p_encoder->fmt_out.audio.i_physical_channels =
id->p_encoder->fmt_out.audio.i_original_channels =
id->p_decoder->fmt_out.audio.i_physical_channels;
else
id->p_encoder->fmt_out.audio.i_physical_channels =
id->p_encoder->fmt_out.audio.i_original_channels =
pi_channels_maps[id->p_encoder->fmt_out.audio.i_channels];
/* Initialization of encoder format structures */
es_format_Init( &id->p_encoder->fmt_in, AUDIO_ES, AOUT_FMT_S16_NE );
id->p_encoder->fmt_in.audio.i_format = AOUT_FMT_S16_NE;
id->p_encoder->fmt_in.audio.i_rate = id->p_encoder->fmt_out.audio.i_rate;
id->p_encoder->fmt_in.audio.i_physical_channels =
id->p_encoder->fmt_in.audio.i_original_channels =
id->p_encoder->fmt_out.audio.i_physical_channels;
id->p_encoder->fmt_out.audio.i_physical_channels;
id->p_encoder->fmt_in.audio.i_original_channels =
id->p_encoder->fmt_out.audio.i_original_channels;
id->p_encoder->fmt_in.audio.i_channels =
id->p_encoder->fmt_out.audio.i_channels;
id->p_encoder->fmt_in.audio.i_bitspersample =
......@@ -1209,6 +1213,9 @@ static int transcode_video_new( sout_stream_t *p_stream, sout_stream_id_t *id )
*/
/* Initialization of decoder structures */
id->p_decoder->fmt_out = id->p_decoder->fmt_in;
id->p_decoder->fmt_out.i_extra = 0;
id->p_decoder->fmt_out.p_extra = 0;
id->p_decoder->pf_decode_video = 0;
id->p_decoder->pf_vout_buffer_new = video_new_buffer_decoder;
id->p_decoder->pf_vout_buffer_del = video_del_buffer_decoder;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment