diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2013-01-25 14:40:15 -0500 |
---|---|---|
committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2013-01-26 12:23:14 +0000 |
commit | 76423a4ba7feccdd72937447997ca872c3bd094b (patch) | |
tree | f422795507574aaf17b1d21bccdebb48579d9909 /ext | |
parent | ed6561bee67a722eb0073aafb88d69d08688565b (diff) | |
download | gstreamer-76423a4ba7feccdd72937447997ca872c3bd094b.tar.gz |
avauddec: fix garbled audio decoding in some cases
Calculate output buffer size based on the number of
samples, channels and bytes per sample. The buffer
size was calculated based on linesize, which may
be larger than what's required.
https://bugzilla.gnome.org/show_bug.cgi?id=690940
Diffstat (limited to 'ext')
-rw-r--r-- | ext/libav/gstavauddec.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/ext/libav/gstavauddec.c b/ext/libav/gstavauddec.c index f47c95315a..0f120c4570 100644 --- a/ext/libav/gstavauddec.c +++ b/ext/libav/gstavauddec.c @@ -453,18 +453,20 @@ gst_ffmpegauddec_audio_frame (GstFFMpegAudDec * ffmpegdec, } else if (av_sample_fmt_is_planar (ffmpegdec->context->sample_fmt) && ffmpegdec->info.channels > 1) { gint i, j; - gint nsamples, channels; + gint nsamples, channels, byte_per_sample; GstMapInfo minfo; channels = ffmpegdec->info.channels; + nsamples = frame.nb_samples; + byte_per_sample = ffmpegdec->info.finfo->width / 8; + /* note: linesize[0] might contain padding, allocate only what's needed */ *outbuf = gst_audio_decoder_allocate_output_buffer (GST_AUDIO_DECODER - (ffmpegdec), frame.linesize[0] * channels); + (ffmpegdec), nsamples * byte_per_sample * channels); gst_buffer_map (*outbuf, &minfo, GST_MAP_WRITE); - nsamples = frame.nb_samples; switch (ffmpegdec->info.finfo->width) { case 8:{ guint8 *odata = minfo.data; |