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
This commit is contained in:
Nicolas Dufresne 2013-01-25 14:40:15 -05:00 committed by Tim-Philipp Müller
parent ed6561bee6
commit 76423a4ba7

View file

@ -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;