diff options
author | Max Kellermann <max@duempel.org> | 2012-10-05 16:38:41 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-10-05 16:38:55 +0200 |
commit | 1dc27be015622118a216284351915d7d7cceb153 (patch) | |
tree | b2f180615dc69bf6dcf4eb6e607e8cc4df0a6b89 | |
parent | 230a3eb4005702ef00040eb3cdda11ba7d19ac3e (diff) | |
download | mpd-1dc27be015622118a216284351915d7d7cceb153.tar.gz mpd-1dc27be015622118a216284351915d7d7cceb153.tar.xz mpd-1dc27be015622118a216284351915d7d7cceb153.zip |
decoder/ffmpeg: fix playback of planar PCM data
Interleaving was completely wrong. This code was never used, so it
didn't have an effect.
-rw-r--r-- | src/decoder/ffmpeg_decoder_plugin.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index 54a574b40..59a6632d5 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -236,12 +236,16 @@ time_to_ffmpeg(double t, const AVRational time_base) #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0) static void -copy_interleave_frame2(uint8_t *dest, const uint8_t *const*src, - unsigned nchannels, size_t plane_size) +copy_interleave_frame2(uint8_t *dest, uint8_t **src, + unsigned nframes, unsigned nchannels, + unsigned sample_size) { - for (unsigned channel = 0; channel < nchannels; ++channel) { - memcpy(dest, src[channel], plane_size); - dest += plane_size; + for (unsigned frame = 0; frame < nframes; ++frame) { + for (unsigned channel = 0; channel < nchannels; ++channel) { + memcpy(dest, src[channel] + frame * sample_size, + sample_size); + dest += sample_size; + } } } @@ -265,9 +269,10 @@ copy_interleave_frame(const AVCodecContext *codec_context, if (av_sample_fmt_is_planar(codec_context->sample_fmt) && codec_context->channels > 1) { - copy_interleave_frame2(buffer, - (const uint8_t *const*)frame->extended_data, - codec_context->channels, plane_size); + copy_interleave_frame2(buffer, frame->extended_data, + frame->nb_samples, + codec_context->channels, + av_get_bytes_per_sample(codec_context->sample_fmt)); } else { memcpy(buffer, frame->extended_data[0], data_size); } |