aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-05-29 16:59:13 +0200
committerReinhard Tartler <siretart@tauware.de>2013-05-31 23:14:01 +0200
commitdbaf3f7b0bc9e99dff8e06bd29fcb3e84eebfe7c (patch)
tree2c8d4f21ba6d01d7d132137e4c72b1b745d5135d /libavcodec
parent5a8dcc993dac545050c8c8de04dbf54f4292c724 (diff)
downloadffmpeg-dbaf3f7b0bc9e99dff8e06bd29fcb3e84eebfe7c.tar.gz
vmd: drop incomplete chunks and spurious samples
Odd chunk size makes no sense for stereo and incomplete chunks are not supported. Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org (cherry picked from commit 701966730ce10290fd49c5ccedd73f505680f764) Signed-off-by: Reinhard Tartler <siretart@tauware.de>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/vmdav.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c
index a66d2eae63..526cf304ee 100644
--- a/libavcodec/vmdav.c
+++ b/libavcodec/vmdav.c
@@ -586,6 +586,9 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,
/* ensure output buffer is large enough */
audio_chunks = buf_size / s->chunk_size;
+ /* drop incomplete chunks */
+ buf_size = audio_chunks * s->chunk_size;
+
/* get output buffer */
s->frame.nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) / avctx->channels;
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
@@ -597,7 +600,8 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,
/* decode silent chunks */
if (silent_chunks > 0) {
- int silent_size = avctx->block_align * silent_chunks;
+ int silent_size = FFMIN(avctx->block_align * silent_chunks,
+ s->frame.nb_samples * avctx->channels);
if (s->out_bps == 2) {
memset(output_samples_s16, 0x00, silent_size * 2);
output_samples_s16 += silent_size;
@@ -609,7 +613,7 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,
/* decode audio chunks */
if (audio_chunks > 0) {
- buf_end = buf + buf_size;
+ buf_end = buf + (buf_size & ~(avctx->channels > 1));
while (buf + s->chunk_size <= buf_end) {
if (s->out_bps == 2) {
decode_audio_s16(output_samples_s16, buf, s->chunk_size,