Commit 1dc27be0 authored by Max Kellermann's avatar Max Kellermann

decoder/ffmpeg: fix playback of planar PCM data

Interleaving was completely wrong. This code was never used, so it didn't have an effect.
parent 230a3eb4
...@@ -236,12 +236,16 @@ time_to_ffmpeg(double t, const AVRational time_base) ...@@ -236,12 +236,16 @@ time_to_ffmpeg(double t, const AVRational time_base)
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0) #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0)
static void static void
copy_interleave_frame2(uint8_t *dest, const uint8_t *const*src, copy_interleave_frame2(uint8_t *dest, uint8_t **src,
unsigned nchannels, size_t plane_size) unsigned nframes, unsigned nchannels,
unsigned sample_size)
{ {
for (unsigned channel = 0; channel < nchannels; ++channel) { for (unsigned frame = 0; frame < nframes; ++frame) {
memcpy(dest, src[channel], plane_size); for (unsigned channel = 0; channel < nchannels; ++channel) {
dest += plane_size; memcpy(dest, src[channel] + frame * sample_size,
sample_size);
dest += sample_size;
}
} }
} }
...@@ -265,9 +269,10 @@ copy_interleave_frame(const AVCodecContext *codec_context, ...@@ -265,9 +269,10 @@ copy_interleave_frame(const AVCodecContext *codec_context,
if (av_sample_fmt_is_planar(codec_context->sample_fmt) && if (av_sample_fmt_is_planar(codec_context->sample_fmt) &&
codec_context->channels > 1) { codec_context->channels > 1) {
copy_interleave_frame2(buffer, copy_interleave_frame2(buffer, frame->extended_data,
(const uint8_t *const*)frame->extended_data, frame->nb_samples,
codec_context->channels, plane_size); codec_context->channels,
av_get_bytes_per_sample(codec_context->sample_fmt));
} else { } else {
memcpy(buffer, frame->extended_data[0], data_size); memcpy(buffer, frame->extended_data[0], data_size);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment