[vlc-commits] avcodec/encoder: fix fallback to stereo
Thomas Guillem
git at videolan.org
Thu Jan 4 15:31:30 CET 2018
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jan 4 15:15:36 2018 +0100| [024304087c549888ee824b1f03933dbcfa86d114] | committer: Thomas Guillem
avcodec/encoder: fix fallback to stereo
Happens if the codec doesn't support more than 2 channels (like mp3lame).
Also ask for a channel conversion instead of dropping channels.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=024304087c549888ee824b1f03933dbcfa86d114
---
modules/codec/avcodec/encoder.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 59bf4a8c50..78a8ca4e05 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -667,9 +667,6 @@ int OpenEncoder( vlc_object_t *p_this )
}
else if( p_enc->fmt_in.i_cat == AUDIO_ES )
{
- /* work around bug in libmp3lame encoding */
- if( i_codec_id == AV_CODEC_ID_MP3 && p_enc->fmt_out.audio.i_channels > 2 )
- p_enc->fmt_out.audio.i_channels = 2;
p_context->codec_type = AVMEDIA_TYPE_AUDIO;
p_context->sample_fmt = p_codec->sample_fmts ?
p_codec->sample_fmts[0] :
@@ -892,7 +889,14 @@ errmsg:
if( p_context->channels > 2 )
{
p_context->channels = 2;
- p_enc->fmt_in.audio.i_channels = 2; // FIXME
+ p_context->channel_layout = channel_mask[p_context->channels][1];
+
+ /* Change fmt_in in order to ask for a channels conversion */
+ p_enc->fmt_in.audio.i_channels =
+ p_enc->fmt_out.audio.i_channels = 2;
+ p_enc->fmt_in.audio.i_physical_channels =
+ p_enc->fmt_out.audio.i_physical_channels = AOUT_CHANS_STEREO;
+ p_sys->i_channels_to_reorder = 0;
msg_Warn( p_enc, "stereo mode selected (codec limitation)" );
}
More information about the vlc-commits
mailing list