summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.com>2013-01-25 14:40:15 -0500
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2013-01-26 12:23:14 +0000
commit76423a4ba7feccdd72937447997ca872c3bd094b (patch)
treef422795507574aaf17b1d21bccdebb48579d9909 /ext
parented6561bee67a722eb0073aafb88d69d08688565b (diff)
downloadgstreamer-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.c8
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;