mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-27 15:33:00 +02:00
libeplayer3/container_ffmpeg: fix mono->stereo conversion
This commit is contained in:
@@ -339,6 +339,7 @@ static void FFMPEGThread(Context_t *context) {
|
|||||||
SwrContext *swr = NULL;
|
SwrContext *swr = NULL;
|
||||||
AVFrame *decoded_frame = NULL;
|
AVFrame *decoded_frame = NULL;
|
||||||
int out_sample_rate = 44100;
|
int out_sample_rate = 44100;
|
||||||
|
int out_channels = 2;
|
||||||
uint64_t out_channel_layout = AV_CH_LAYOUT_STEREO;
|
uint64_t out_channel_layout = AV_CH_LAYOUT_STEREO;
|
||||||
|
|
||||||
ffmpeg_printf(10, "\n");
|
ffmpeg_printf(10, "\n");
|
||||||
@@ -566,6 +567,7 @@ static void FFMPEGThread(Context_t *context) {
|
|||||||
rate++;
|
rate++;
|
||||||
out_sample_rate = *rate ? *rate : 44100;
|
out_sample_rate = *rate ? *rate : 44100;
|
||||||
swr = swr_alloc();
|
swr = swr_alloc();
|
||||||
|
out_channels = c->channels;
|
||||||
if (c->channel_layout == 0) {
|
if (c->channel_layout == 0) {
|
||||||
// FIXME -- need to guess, looks pretty much like a bug in the FFMPEG WMA decoder
|
// FIXME -- need to guess, looks pretty much like a bug in the FFMPEG WMA decoder
|
||||||
c->channel_layout = AV_CH_LAYOUT_STEREO;
|
c->channel_layout = AV_CH_LAYOUT_STEREO;
|
||||||
@@ -573,7 +575,10 @@ static void FFMPEGThread(Context_t *context) {
|
|||||||
|
|
||||||
out_channel_layout = c->channel_layout;
|
out_channel_layout = c->channel_layout;
|
||||||
// player2 won't play mono
|
// 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, "in_channel_layout", c->channel_layout, 0);
|
||||||
av_opt_set_int(swr, "out_channel_layout", out_channel_layout, 0);
|
av_opt_set_int(swr, "out_channel_layout", out_channel_layout, 0);
|
||||||
@@ -618,7 +623,7 @@ static void FFMPEGThread(Context_t *context) {
|
|||||||
extradata.bLittleEndian = 1;
|
extradata.bLittleEndian = 1;
|
||||||
|
|
||||||
avOut.data = output;
|
avOut.data = output;
|
||||||
avOut.len = out_samples * sizeof(short) * c->channels;
|
avOut.len = out_samples * sizeof(short) * out_channels;
|
||||||
|
|
||||||
avOut.pts = pts;
|
avOut.pts = pts;
|
||||||
avOut.extradata = (unsigned char *) &extradata;
|
avOut.extradata = (unsigned char *) &extradata;
|
||||||
|
Reference in New Issue
Block a user