[vlc-commits] avcodec/encoder: fix fallback to stereo
Thomas Guillem
git at videolan.org
Fri Jan 5 09:47:39 CET 2018
vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jan 4 15:15:36 2018 +0100| [c4bcc88ccf9a0e9f82398e2d82ccacfb6a95005f] | 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.
(cherry picked from commit 024304087c549888ee824b1f03933dbcfa86d114)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=c4bcc88ccf9a0e9f82398e2d82ccacfb6a95005f
---
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 5f2f671c91..4d513bf02b 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