aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-04-22 15:17:40 +0200
committerAnton Khirnov <anton@khirnov.net>2013-11-04 11:02:12 +0100
commit592eaf37e13ad9a2f1cee00e014b436c49e97987 (patch)
tree7272d05385199bf1f7b321054a583550551a9dc2
parent8914dc15aaa9fef13ee1eb8da1aa74bd1b7d4911 (diff)
libav decoder plugin: basic support for s16 planar audio
-rw-r--r--src/decoder/libav_decoder_plugin.c10
1 files 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: