diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2006-11-19 05:30:43 +0000 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2006-11-19 05:30:43 +0000 |
commit | c8f9f9b91a3d3254e62f4fbcd6065a504164b06b (patch) | |
tree | 5ad5eb7117e47080e3f328e2750f2f3c300bc441 /libavcodec/vmdav.c | |
parent | 5836d158b61241a556c8db53314182e4d78a5a32 (diff) | |
download | ffmpeg-c8f9f9b91a3d3254e62f4fbcd6065a504164b06b.tar.gz |
Divide first audio buffer chunk into atomary bufffers.
This slightly simplifies decoder and removes potential
audio buffer overrun.
Originally committed as revision 7121 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/vmdav.c')
-rw-r--r-- | libavcodec/vmdav.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c index 394d6d50d8..a9937144e4 100644 --- a/libavcodec/vmdav.c +++ b/libavcodec/vmdav.c @@ -519,12 +519,10 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size) { VmdAudioContext *s = (VmdAudioContext *)avctx->priv_data; - unsigned int sound_flags; unsigned char *output_samples = (unsigned char *)data; /* point to the start of the encoded data */ unsigned char *p = buf + 16; - unsigned char *p_end = buf + buf_size; if (buf_size < 16) return buf_size; @@ -533,24 +531,10 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, /* the chunk contains audio */ *data_size = vmdaudio_loadsound(s, output_samples, p, 0); } else if (buf[6] == 2) { - /* the chunk contains audio and silence mixed together */ - sound_flags = LE_32(p); + /* the chunk may contain audio */ p += 4; - - /* do something with extrabufs here? */ - - while (p < p_end) { - if (sound_flags & 0x01) - /* silence */ - *data_size += vmdaudio_loadsound(s, output_samples, p, 1); - else { - /* audio */ - *data_size += vmdaudio_loadsound(s, output_samples, p, 0); - p += s->block_align; - } - output_samples += (s->block_align * s->bits / 8); - sound_flags >>= 1; - } + *data_size = vmdaudio_loadsound(s, output_samples, p, (buf_size == 16)); + output_samples += (s->block_align * s->bits / 8); } else if (buf[6] == 3) { /* silent chunk */ *data_size = vmdaudio_loadsound(s, output_samples, p, 1); |