From dd9a9c065352486a1cd2513ab1586562532e824e Mon Sep 17 00:00:00 2001 From: martii Date: Sun, 21 Jul 2013 14:54:57 +0200 Subject: [PATCH] libeplayer3/container_ffmpeg: fix mono->stereo conversion Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/5db41a87e35d1b7166298c213b2bacbd0fb58cfc Author: martii Date: 2013-07-21 (Sun, 21 Jul 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3/container/container_ffmpeg.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libeplayer3/container/container_ffmpeg.c b/libeplayer3/container/container_ffmpeg.c index 2283f17..4c7f85c 100644 --- a/libeplayer3/container/container_ffmpeg.c +++ b/libeplayer3/container/container_ffmpeg.c @@ -339,6 +339,7 @@ static void FFMPEGThread(Context_t *context) { SwrContext *swr = NULL; AVFrame *decoded_frame = NULL; int out_sample_rate = 44100; + int out_channels = 2; uint64_t out_channel_layout = AV_CH_LAYOUT_STEREO; ffmpeg_printf(10, "\n"); @@ -564,6 +565,7 @@ static void FFMPEGThread(Context_t *context) { rate++; out_sample_rate = *rate ? *rate : 44100; swr = swr_alloc(); + out_channels = c->channels; if (c->channel_layout == 0) { // FIXME -- need to guess, looks pretty much like a bug in the FFMPEG WMA decoder c->channel_layout = AV_CH_LAYOUT_STEREO; @@ -571,7 +573,10 @@ static void FFMPEGThread(Context_t *context) { out_channel_layout = c->channel_layout; // player2 won't play mono - out_channel_layout = (c->channel_layout == AV_CH_LAYOUT_MONO) ? AV_CH_LAYOUT_STEREO : c->channel_layout; + if (out_channel_layout == AV_CH_LAYOUT_MONO) { + out_channel_layout = AV_CH_LAYOUT_STEREO; + out_channels = 2; + } av_opt_set_int(swr, "in_channel_layout", c->channel_layout, 0); av_opt_set_int(swr, "out_channel_layout", out_channel_layout, 0); @@ -616,7 +621,7 @@ static void FFMPEGThread(Context_t *context) { extradata.bLittleEndian = 1; avOut.data = output; - avOut.len = out_samples * sizeof(short) * c->channels; + avOut.len = out_samples * sizeof(short) * out_channels; avOut.pts = pts; avOut.extradata = (unsigned char *) &extradata;