changeset 3105:f951f3be126c

fixed FLI demuxer so that it skips over app-specific frames
author melanson
date Sun, 25 Nov 2001 01:48:55 +0000
parents 829637d529e9
children fd7651748dec
files libmpdemux/demux_fli.c
diffstat 1 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_fli.c	Sun Nov 25 00:56:41 2001 +0000
+++ b/libmpdemux/demux_fli.c	Sun Nov 25 01:48:55 2001 +0000
@@ -55,6 +55,8 @@
   fli_frames_t *frames = (fli_frames_t *)malloc(sizeof(fli_frames_t));
   int frame_number;
   int speed;
+  unsigned int frame_size;
+  int magic_number;
 
   // go back to the beginning
   stream_reset(demuxer->stream);
@@ -107,11 +109,21 @@
   while ((!stream_eof(demuxer->stream)) && (frame_number < frames->num_frames))
   {
     frames->filepos[frame_number] = stream_tell(demuxer->stream);
-    frames->frame_size[frame_number] = stream_read_dword_le(demuxer->stream);
-    stream_skip(demuxer->stream, frames->frame_size[frame_number] - 4);
-    frame_number++;
+    frame_size = stream_read_dword_le(demuxer->stream);
+    magic_number = stream_read_word_le(demuxer->stream);
+    stream_skip(demuxer->stream, frame_size - 6);
+
+    // if this chunk has the right magic number, index it
+    if (magic_number == 0xF1FA)
+    {
+      frames->frame_size[frame_number] = frame_size;
+      frame_number++;
+    }
   }
 
+  // save the actual number of frames indexed
+  frames->num_frames = frame_number;
+
   demuxer->priv = frames;
 
   return demuxer;