From 592eaf37e13ad9a2f1cee00e014b436c49e97987 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 22 Apr 2013 15:17:40 +0200 Subject: libav decoder plugin: basic support for s16 planar audio --- src/decoder/libav_decoder_plugin.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/decoder/libav_decoder_plugin.c b/src/decoder/libav_decoder_plugin.c index c6535150..026f0c9c 100644 --- a/src/decoder/libav_decoder_plugin.c +++ b/src/decoder/libav_decoder_plugin.c @@ -196,16 +196,17 @@ copy_interleave_frame(const AVCodecContext *codec_context, codec_context->channels, frame->nb_samples, codec_context->sample_fmt, 1); + uint16_t *dst = (uint16_t*)buffer; + if (buffer_size < (size_t)data_size) /* buffer is too small - shouldn't happen */ return AVERROR(EINVAL); if (av_sample_fmt_is_planar(codec_context->sample_fmt) && codec_context->channels > 1) { - for (int i = 0, channels = codec_context->channels; - i < channels; i++) { - memcpy(buffer, frame->extended_data[i], plane_size); - buffer += plane_size; + for (int i = 0; i < frame->nb_samples; i++) { + for (int j = 0; j < codec_context->channels; j++) + dst[i * codec_context->channels + j] = ((uint16_t*)frame->extended_data[j])[i]; } } else { memcpy(buffer, frame->extended_data[0], data_size); @@ -274,6 +275,7 @@ libav_sample_format(G_GNUC_UNUSED const AVCodecContext *codec_context) { switch (codec_context->sample_fmt) { case AV_SAMPLE_FMT_S16: + case AV_SAMPLE_FMT_S16P: return SAMPLE_FORMAT_S16; case AV_SAMPLE_FMT_S32: -- cgit v1.2.3