# HG changeset patch # User kostya # Date 1163914243 0 # Node ID 42553b85aa7e8380b65da7ade90d6cbc1fc7a27a # Parent 68288509a1599c4844b35cc3b1566c82198aff44 Divide first audio buffer chunk into atomary bufffers. This slightly simplifies decoder and removes potential audio buffer overrun. diff -r 68288509a159 -r 42553b85aa7e vmdav.c --- a/vmdav.c Fri Nov 17 21:43:46 2006 +0000 +++ b/vmdav.c Sun Nov 19 05:30:43 2006 +0000 @@ -519,12 +519,10 @@ 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 @@ /* 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);