Browse Source

Merge commit '701966730ce10290fd49c5ccedd73f505680f764'

* commit '701966730ce10290fd49c5ccedd73f505680f764':
  vmd: drop incomplete chunks and spurious samples

Conflicts:
	libavcodec/vmdav.c

2 of the changes are replaced by assert0s, as they should
be impossible.
The actual bug is likely caused by a invalid block_align
which is checked for and thus impossible in ffmpeg.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
tags/n2.0
Michael Niedermayer 12 years ago
parent
commit
103ffde5a3
1 changed files with 7 additions and 0 deletions
  1. +7
    -0
      libavcodec/vmdav.c

+ 7
- 0
libavcodec/vmdav.c View File

@@ -43,6 +43,7 @@
#include <stdlib.h>
#include <string.h>

#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
@@ -588,6 +589,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 */
frame->nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) /
avctx->channels;
@@ -599,6 +603,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;
av_assert0(avctx->block_align * silent_chunks <= frame->nb_samples * avctx->channels);

if (s->out_bps == 2) {
memset(output_samples_s16, 0x00, silent_size * 2);
output_samples_s16 += silent_size;
@@ -611,6 +617,7 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,
/* decode audio chunks */
if (audio_chunks > 0) {
buf_end = buf + buf_size;
av_assert0((buf_size & (avctx->channels > 1)) == 0);
while (buf_end - buf >= s->chunk_size) {
if (s->out_bps == 2) {
decode_audio_s16(output_samples_s16, buf, s->chunk_size,


Loading…
Cancel
Save