changeset 4213:42553b85aa7e libavcodec

Divide first audio buffer chunk into atomary bufffers. This slightly simplifies decoder and removes potential audio buffer overrun.
author kostya
date Sun, 19 Nov 2006 05:30:43 +0000
parents 68288509a159
children 6a546bbe5b31
files vmdav.c
diffstat 1 files changed, 3 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- 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);