changeset 4189:6871d97e4261

initial support for FILM file demuxing
author melanson
date Wed, 16 Jan 2002 03:25:07 +0000
parents cfd1eed5961d
children 2ed90891750e
files help_mp-cs.h help_mp-de.h help_mp-dk.h help_mp-en.h help_mp-es.h help_mp-fr.h help_mp-hu.h help_mp-it.h help_mp-ko.h help_mp-nl.h help_mp-no.h help_mp-pl.h help_mp-ro.h help_mp-ru.h libmpdemux/Makefile libmpdemux/demux_film.c libmpdemux/demuxer.c libmpdemux/demuxer.h libmpdemux/stream.h
diffstat 19 files changed, 223 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/help_mp-cs.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/help_mp-cs.h	Wed Jan 16 03:25:07 2002 +0000
@@ -146,6 +146,7 @@
 #define MSGTR_TooManyAudioInBuffer "\nDEMUXER: Pøíli¹ mnoho (%d v %d bajtech) audio paketù v bufferu!\n"
 #define MSGTR_TooManyVideoInBuffer "\nDEMUXER: Pøíli¹ mnoho (%d v %d bajtech) video paketù v bufferu!\n"
 #define MSGTR_MaybeNI "(mo¾ná pøehráváte neprokládaný proud/soubor nebo kodek selhal)\n"
+#define MSGTR_DetectedFILMfile "Detekován FILM formát souboru!\n"
 #define MSGTR_DetectedFLIfile "Detekován FLI formát souboru!\n"
 #define MSGTR_DetectedAVIfile "Detekován AVI formát souboru!\n"
 #define MSGTR_DetectedASFfile "Detekován ASF formát souboru!\n"
--- a/help_mp-de.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/help_mp-de.h	Wed Jan 16 03:25:07 2002 +0000
@@ -140,6 +140,7 @@
 #define MSGTR_TooManyAudioInBuffer "\nDEMUXER: Zu viele (%d in %d bytes) Audiopakete im Puffer!\n"
 #define MSGTR_TooManyVideoInBuffer "\nDEMUXER: Zu viele (%d in %d bytes) Videopakete im Puffer!\n"
 #define MSGTR_MaybeNI "Vielleicht spielst du einen non-interleaved Stream/Datei oder der Codec funktioniert nicht.\n"
+#define MSGTR_DetectedFILMfile "FILM Dateiformat erkannt!\n"
 #define MSGTR_DetectedFLIfile "FLI Dateiformat erkannt!\n"
 #define MSGTR_DetectedAVIfile "AVI Dateiformat erkannt!\n"
 #define MSGTR_DetectedASFfile "ASF Dateiformat erkannt!\n"
--- a/help_mp-dk.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/help_mp-dk.h	Wed Jan 16 03:25:07 2002 +0000
@@ -144,6 +144,7 @@
 #define MSGTR_TooManyAudioInBuffer "\nDEMUXER: For mange (%d i %d bytes) lyd pakker i bufferen!\n"
 #define MSGTR_TooManyVideoInBuffer "\nDEMUXER: For mange (%d i %d bytes) video pakker i bufferen!\n"
 #define MSGTR_MaybeNI "(måske afspiller du en 'non-interleaved' stream/fil ellers fejlede codec'et)\n"
+#define MSGTR_DetectedFILMfile "Detecterede FILM fil format!\n"
 #define MSGTR_DetectedFLIfile "Detecterede FLI fil format!\n"
 #define MSGTR_DetectedAVIfile "Detecterede AVI fil format!\n"
 #define MSGTR_DetectedASFfile "Detecterede ASF fil format!\n"
--- a/help_mp-en.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/help_mp-en.h	Wed Jan 16 03:25:07 2002 +0000
@@ -147,6 +147,7 @@
 #define MSGTR_TooManyAudioInBuffer "\nDEMUXER: Too many (%d in %d bytes) audio packets in the buffer!\n"
 #define MSGTR_TooManyVideoInBuffer "\nDEMUXER: Too many (%d in %d bytes) video packets in the buffer!\n"
 #define MSGTR_MaybeNI "(maybe you play a non-interleaved stream/file or the codec failed)\n"
+#define MSGTR_DetectedFILMfile "Detected FILM file format!\n"
 #define MSGTR_DetectedFLIfile "Detected FLI file format!\n"
 #define MSGTR_DetectedAVIfile "Detected AVI file format!\n"
 #define MSGTR_DetectedASFfile "Detected ASF file format!\n"
--- a/help_mp-es.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/help_mp-es.h	Wed Jan 16 03:25:07 2002 +0000
@@ -147,6 +147,7 @@
 #define MSGTR_TooManyAudioInBuffer "\nDEMUXER: Demasiados (%d en %d bytes) paquetes de audio en el buffer!\n"
 #define MSGTR_TooManyVideoInBuffer "\nDEMUXER: Demasiados (%d en %d bytes) paquetes de video en el buffer!\n"
 #define MSGTR_MaybeNI "(tal vez está reproduciendo un stream/archivo 'non-interleaved' o falló el codec)\n"
+#define MSGTR_DetectedFILMfile "Detectado formato de archivo FILM!\n"
 #define MSGTR_DetectedFLIfile "Detectado formato de archivo FLI!\n"
 #define MSGTR_DetectedAVIfile "Detectado formato de archivo AVI!\n"
 #define MSGTR_DetectedASFfile "Detectado formato de archivo ASF!\n"
--- a/help_mp-fr.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/help_mp-fr.h	Wed Jan 16 03:25:07 2002 +0000
@@ -141,6 +141,7 @@
 #define MSGTR_TooManyAudioInBuffer "\nDEMUXER: Trop (%d dans %d octets) de packets audio dans le tampon!\n"
 #define MSGTR_TooManyVideoInBuffer "\nDEMUXER: Trop (%d dans %d octets) de packets vidéo dans le tampon!\n"
 #define MSGTR_MaybeNI "(Peut-être jouez-vous un flux/fichier non-entrelacé, ou le codec manque...)\n"
+#define MSGTR_DetectedFILMfile "Format de fichier FILE détecté!\n"
 #define MSGTR_DetectedFLIfile "Format de fichier FLI détecté!\n"
 #define MSGTR_DetectedAVIfile "Format de fichier AVI détecté!\n"
 #define MSGTR_DetectedASFfile "Format de fichier ASF détecté!\n"
--- a/help_mp-hu.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/help_mp-hu.h	Wed Jan 16 03:25:07 2002 +0000
@@ -143,6 +143,7 @@
 #define MSGTR_TooManyAudioInBuffer "\nDEMUXER: Túl sok (%d db, %d bájt) audio-csomag a pufferben!\n"
 #define MSGTR_TooManyVideoInBuffer "\nDEMUXER: Túl sok (%d db, %d bájt) video-csomag a pufferben!\n"
 #define MSGTR_MaybeNI "(talán ez egy nem összefésült file vagy a CODEC nem mûködik jól)\n"
+#define MSGTR_DetectedFILMfile "Ez egy FILM formátumú file!\n"
 #define MSGTR_DetectedFLIfile "Ez egy FLI formátumú file!\n"
 #define MSGTR_DetectedAVIfile "Ez egy AVI formátumú file!\n"
 #define MSGTR_DetectedASFfile "Ez egy ASF formátumú file!\n"
--- a/help_mp-it.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/help_mp-it.h	Wed Jan 16 03:25:07 2002 +0000
@@ -147,6 +147,7 @@
 #define MSGTR_TooManyAudioInBuffer "\nDEMUXER: Troppi (%d in %d byte) pacchetti audio nel buffer!\n"
 #define MSGTR_TooManyVideoInBuffer "\nDEMUXER: Troppi (%d in %d byte) pacchetti video nel buffer!\n"
 #define MSGTR_MaybeNI "(forse stai riproducendo un flusso/file non interlacciato o il codec non funziona)\n"
+#define MSGTR_DetectedFILMfile "Rilevato formato file FILM !\n"
 #define MSGTR_DetectedFLIfile "Rilevato formato file FLI !\n"
 #define MSGTR_DetectedAVIfile "Rilevato formato file AVI !\n"
 #define MSGTR_DetectedASFfile "Rilevato formato file ASF !\n"
--- a/help_mp-ko.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/help_mp-ko.h	Wed Jan 16 03:25:07 2002 +0000
@@ -147,6 +147,7 @@
 #define MSGTR_TooManyAudioInBuffer "\nDEMUXER: ¹öÆÛ¿¡ ³Ê¹« ¸¹Àº (%d in %d bytes) ¿Àµð¿À ÆÐŶÀÌ ÀÖ½À´Ï´Ù!\n"
 #define MSGTR_TooManyVideoInBuffer "\nDEMUXER: ¹öÆÛ¿¡ ³Ê¹« ¸¹Àº (%d in %d bytes) ºñµð¿À ÆÐŶÀÌ ÀÖ½À´Ï´Ù!\n"
 #define MSGTR_MaybeNI "(non-interleaved ½ºÆ®¸²/ÆÄÀÏÀ» Àç»ýÇÏ°íÀְųª ÄÚµ¦ÀÌ À߸øµÇ¾ú½À´Ï´Ù.)\n"
+#define MSGTR_DetectedFILMfile "FILM ÆÄÀÏ Çü½ÄÀ» ¹ß°ßÇß½À´Ï´Ù!\n"
 #define MSGTR_DetectedFLIfile "FLI ÆÄÀÏ Çü½ÄÀ» ¹ß°ßÇß½À´Ï´Ù!\n"
 #define MSGTR_DetectedAVIfile "AVI ÆÄÀÏ Çü½ÄÀ» ¹ß°ßÇß½À´Ï´Ù!\n"
 #define MSGTR_DetectedASFfile "ASF ÆÄÀÏ Çü½ÄÀ» ¹ß°ßÇß½À´Ï´Ù!\n"
--- a/help_mp-nl.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/help_mp-nl.h	Wed Jan 16 03:25:07 2002 +0000
@@ -142,6 +142,7 @@
 #define MSGTR_TooManyAudioInBuffer "\nDEMUXER: Te veel (%d in %d bytes) audio packets in de buffer!\n"
 #define MSGTR_TooManyVideoInBuffer "\nDEMUXER: Te veel (%d in %d bytes) video packets in de buffer!\n"
 #define MSGTR_MaybeNI "(misschien speel je een non-interleaved stream/bestand of werkte de codec niet)\n"
+#define MSGTR_DetectedFILMfile "FILM bestandsformaat gedetecteerd!\n"
 #define MSGTR_DetectedFLIfile "FLI bestandsformaat gedetecteerd!\n"
 #define MSGTR_DetectedAVIfile "AVI bestandsformaat gedetecteerd!\n"
 #define MSGTR_DetectedASFfile "ASF bestandsformaat gedetecteerd!\n"
--- a/help_mp-no.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/help_mp-no.h	Wed Jan 16 03:25:07 2002 +0000
@@ -147,6 +147,7 @@
 #define MSGTR_TooManyAudioInBuffer "\nDEMUXER: For mange (%d i %d bytes) lyd pakker i bufferen!\n"
 #define MSGTR_TooManyVideoInBuffer "\nDEMUXER: For mange (%d i %d bytes) video pakker i bufferen!\n"
 #define MSGTR_MaybeNI "(kanskje du spiller av en ikke-interleaved stream/fil eller codec'en feilet)\n"
+#define MSGTR_DetectedFILMfile "Detekterte FILM filformat!\n"
 #define MSGTR_DetectedFLIfile "Detekterte FLI filformat!\n"
 #define MSGTR_DetectedAVIfile "Detekterte AVI filformat!\n"
 #define MSGTR_DetectedASFfile "Detekterte ASF filformat!\n"
--- a/help_mp-pl.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/help_mp-pl.h	Wed Jan 16 03:25:07 2002 +0000
@@ -146,6 +146,7 @@
 #define MSGTR_TooManyAudioInBuffer "\nDEMUXER: Zbyt wiele (%d w %d bajtach) pakietów audio w buforze!\n"
 #define MSGTR_TooManyVideoInBuffer "\nDEMUXER: Zbyt wiele (%d w %d bajtach) pakietów video w buforze!\n"
 #define MSGTR_MaybeNI "(mo¿e odtwarzasz strumieñ/plik non-interleaved lub kodek nie zadzia³a³)\n"
+#define MSGTR_DetectedFILMfile "Wykryto format FILM!\n"
 #define MSGTR_DetectedFLIfile "Wykryto format FLI!\n"
 #define MSGTR_DetectedAVIfile "Wykryto format AVI!\n"
 #define MSGTR_DetectedASFfile "Wykryto format ASF!\n"
--- a/help_mp-ro.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/help_mp-ro.h	Wed Jan 16 03:25:07 2002 +0000
@@ -130,6 +130,7 @@
 #define MSGTR_TooManyAudioInBuffer "\nDEMUXER: Prea multe (%d în %d bytes) pachete audio în tampon!\n"
 #define MSGTR_TooManyVideoInBuffer "\nDEMUXER: Prea multe (%d în %d bytes) pachete video în tampon!\n"
 #define MSGTR_MaybeNI "(poate afiºaþi un film/pistã ne-întreþesut sau codec-ul a dat eroare)\n"
+#define MSGTR_DetectedFILMfile "Format fiºier detectat: FILM\n"
 #define MSGTR_DetectedFLIfile "Format fiºier detectat: FLI\n"
 #define MSGTR_DetectedAVIfile "Format fiºier detectat: AVI\n"
 #define MSGTR_DetectedASFfile "Format fiºier detectat: ASF\n"
--- a/help_mp-ru.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/help_mp-ru.h	Wed Jan 16 03:25:07 2002 +0000
@@ -144,6 +144,7 @@
 #define MSGTR_TooManyAudioInBuffer "\nDEMUXER: óÌÉÛËÏÍ ÍÎÏÇÏ (%d × %d ÂÁÊÔÁÈ) ÁÕÄÉÏ ÐÁËÅÔÏ× × ÂÕÆÅÒÅ!\n"
 #define MSGTR_TooManyVideoInBuffer "\nDEMUXER: óÌÉÛËÏÍ ÍÎÏÇÏ (%d × %d ÂÁÊÔÁÈ) ×ÉÄÅÏ ÐÁËÅÔÏ× × ÂÕÆÅÒÅ!\n"
 #define MSGTR_MaybeNI "(×ÏÚÍÏÖÎÏ ÷Ù ÐÒÏÉÇÒÙ×ÁÅÔÅ ÎÅÞÅÒÅÄÏ×ÁÎÎÙÊ ÐÏÔÏË/ÆÁÊÌ ÉÌÉ ÎÅÕÄÁÞÎÙÊ ËÏÄÅË)\n"
+#define MSGTR_DetectedFILMfile "ïÂÎÁÒÕÖÅÎ FILM ÆÏÒÍÁÔ ÆÁÊÌÁ!\n"
 #define MSGTR_DetectedFLIfile "ïÂÎÁÒÕÖÅÎ FLI ÆÏÒÍÁÔ ÆÁÊÌÁ!\n"
 #define MSGTR_DetectedAVIfile "ïÂÎÁÒÕÖÅÎ AVI ÆÏÒÍÁÔ ÆÁÊÌÁ!\n"
 #define MSGTR_DetectedASFfile "ïÂÎÁÒÕÖÅÎ ASF ÆÏÒÍÁÔ ÆÁÊÌÁ!\n"
--- a/libmpdemux/Makefile	Wed Jan 16 01:51:34 2002 +0000
+++ b/libmpdemux/Makefile	Wed Jan 16 03:25:07 2002 +0000
@@ -3,7 +3,7 @@
 
 include ../config.mak
 
-SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c demux_mpg.c demux_viv.c demuxer.c dvdauth.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c
+SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c demux_mpg.c demux_viv.c demuxer.c dvdauth.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c
 ifeq ($(STREAMING),yes)
 SRCS += asf_streaming.c url.c http.c network.c rtp.c
 endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmpdemux/demux_film.c	Wed Jan 16 03:25:07 2002 +0000
@@ -0,0 +1,180 @@
+/*
+	FILM file parser for the MPlayer program
+	by Mike Melanson
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "mp_msg.h"
+#include "help_mp.h"
+
+#include "stream.h"
+#include "demuxer.h"
+#include "stheader.h"
+
+// chunk types found in a FILM file
+#define CHUNK_FILM mmioFOURCC('F', 'I', 'L', 'M')
+#define CHUNK_FDSC mmioFOURCC('F', 'D', 'S', 'C')
+#define CHUNK_STAB mmioFOURCC('S', 'T', 'A', 'B')
+
+typedef struct _film_frames_t {
+  int num_frames;
+  int current_frame;
+  off_t *filepos;
+  unsigned int *frame_size;
+  unsigned int *flags1;
+  unsigned int *flags2;
+} film_frames_t;
+
+void demux_seek_film(demuxer_t *demuxer,float rel_seek_secs,int flags){
+  film_frames_t *frames = (film_frames_t *)demuxer->priv;
+  sh_video_t *sh_video = demuxer->video->sh;
+  int newpos=(flags&1)?0:frames->current_frame;
+  if(flags&2){
+      // float 0..1
+      newpos+=rel_seek_secs*frames->num_frames;
+  } else {
+      // secs
+      newpos+=rel_seek_secs*sh_video->fps;
+  }
+  if(newpos<0) newpos=0; else
+  if(newpos>frames->num_frames) newpos=frames->num_frames;
+  frames->current_frame=newpos;
+}
+
+// return value:
+//     0 = EOF or no stream found
+//     1 = successfully read a packet
+int demux_film_fill_buffer(demuxer_t *demuxer){
+  film_frames_t *frames = (film_frames_t *)demuxer->priv;
+  sh_video_t *sh_video = demuxer->video->sh;
+
+  // see if the end has been reached
+  if (frames->current_frame >= frames->num_frames)
+    return 0;
+
+  // fetch the frame from the file
+  // first, position the file properly since ds_read_packet() doesn't
+  // seem to do it, even though it takes a file offset as a parameter
+  stream_seek(demuxer->stream, frames->filepos[frames->current_frame]);
+  ds_read_packet(demuxer->video,
+    demuxer->stream, 
+    frames->frame_size[frames->current_frame],
+    frames->current_frame/sh_video->fps,
+    frames->filepos[frames->current_frame],
+    0 /* what flags? -> demuxer.h (alex) */
+  );
+
+  // get the next frame ready
+  frames->current_frame++;
+
+  return 1;
+}
+
+demuxer_t* demux_open_film(demuxer_t* demuxer){
+  sh_video_t *sh_video = NULL;
+  film_frames_t *frames = (film_frames_t *)malloc(sizeof(film_frames_t));
+  int header_size;
+  unsigned int chunk_type;
+  unsigned int chunk_size;
+  int i;
+
+  // go back to the beginning
+  stream_reset(demuxer->stream);
+  stream_seek(demuxer->stream, 0);
+
+  // read the master chunk type
+  chunk_type = stream_read_fourcc(demuxer->stream);
+  // validate the chunk type
+  if (chunk_type != CHUNK_FILM)
+  {
+    mp_msg(MSGT_DEMUX, MSGL_ERR, "Not a FILM file\n");
+    return(NULL);    
+  }
+
+  // get the header size, which implicitly points past the header and
+  // to the start of the data
+  header_size = stream_read_dword(demuxer->stream);
+  demuxer->movi_start = header_size;
+  demuxer->movi_end = demuxer->stream->end_pos;
+  header_size -= 16;
+
+  // skip to where the next chunk should be
+  stream_skip(demuxer->stream, 8);
+
+  // create a new video stream header
+  sh_video = new_sh_video(demuxer, 0);
+
+  // make sure the demuxer knows about the new video stream header
+  demuxer->video->sh = sh_video;
+
+  // make sure that the video demuxer stream header knows about its
+  // parent video demuxer stream, or else
+  // video_read_properties() will choke
+  sh_video->ds = demuxer->video;
+
+  // traverse through the header
+  while (header_size > 0)
+  {
+    // fetch the chunk type and size
+    chunk_type = stream_read_fourcc(demuxer->stream);
+    chunk_size = stream_read_dword(demuxer->stream);
+    header_size -= chunk_size;
+
+    switch (chunk_type)
+    {
+    case CHUNK_FDSC:
+printf ("parsing FDSC chunk\n");
+      // fetch the video codec fourcc, height, then width
+      sh_video->format = stream_read_fourcc(demuxer->stream);
+      sh_video->disp_h = stream_read_dword(demuxer->stream);
+      sh_video->disp_w = stream_read_dword(demuxer->stream);
+// temporary; one of these fields has to specify FPS
+stream_skip(demuxer->stream, 12);
+      break;
+
+    case CHUNK_STAB:
+printf ("parsing STAB chunk\n");
+      // skip unknown dword
+      stream_skip(demuxer->stream, 4);
+
+      // fetch the number of frames
+      frames->num_frames = stream_read_dword(demuxer->stream);
+      frames->current_frame = 1;
+//      frames->current_frame = 0;
+
+      // allocate enough entries for the indices
+      frames->filepos = (off_t *)malloc(frames->num_frames * sizeof(off_t));
+      frames->frame_size = (int *)malloc(frames->num_frames * sizeof(int));
+      frames->flags1 = (int *)malloc(frames->num_frames * sizeof(int));
+      frames->flags2 = (int *)malloc(frames->num_frames * sizeof(int));
+
+      // build the frame index
+      for (i = 0; i < frames->num_frames; i++)
+      {
+        frames->filepos[i] = demuxer->movi_start + stream_read_dword(demuxer->stream);
+        frames->frame_size[i] = stream_read_dword(demuxer->stream);
+        frames->flags1[i] = stream_read_dword(demuxer->stream);
+        frames->flags2[i] = stream_read_dword(demuxer->stream);
+      }
+      break;
+
+    default:
+      mp_msg(MSGT_DEMUX, MSGL_ERR, "Unrecognized FILM header chunk: %08X\n",
+        chunk_type);
+      return(NULL);    
+      break;
+    }
+  }
+
+  // hard code the speed for now
+  sh_video->fps = 1;
+  sh_video->frametime = 1;
+
+  demuxer->priv = frames;
+
+  return demuxer;
+}
--- a/libmpdemux/demuxer.c	Wed Jan 16 01:51:34 2002 +0000
+++ b/libmpdemux/demuxer.c	Wed Jan 16 03:25:07 2002 +0000
@@ -150,6 +150,7 @@
 // return value:
 //     0 = EOF or no stream found or invalid type
 //     1 = successfully read a packet
+int demux_film_fill_buffer(demuxer_t *demux);
 int demux_fli_fill_buffer(demuxer_t *demux);
 int demux_mpg_es_fill_buffer(demuxer_t *demux);
 int demux_mpg_fill_buffer(demuxer_t *demux);
@@ -175,6 +176,7 @@
   // Note: parameter 'ds' can be NULL!
 //  printf("demux->type=%d\n",demux->type);
   switch(demux->type){
+    case DEMUXER_TYPE_FILM: return demux_film_fill_buffer(demux);
     case DEMUXER_TYPE_FLI: return demux_fli_fill_buffer(demux);
     case DEMUXER_TYPE_MPEG_ES: return demux_mpg_es_fill_buffer(demux);
     case DEMUXER_TYPE_MPEG_PS: return demux_mpg_fill_buffer(demux);
@@ -364,6 +366,7 @@
 int mov_check_file(demuxer_t* demuxer);
 int mov_read_header(demuxer_t* demuxer);
 int demux_open_fli(demuxer_t* demuxer);
+int demux_open_film(demuxer_t* demuxer);
 
 extern int vivo_check_file(demuxer_t *demuxer);
 extern void demux_open_vivo(demuxer_t *demuxer);
@@ -467,15 +470,28 @@
 if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_FLI){
   demuxer=new_demuxer(stream,DEMUXER_TYPE_FLI,audio_id,video_id,dvdsub_id);
   {
-    int size=stream_read_dword_le(demuxer->stream);
-    int id=stream_read_word_le(demuxer->stream);
-    // chech for the FLI file magic number
+    int id;
+    stream_seek(demuxer->stream, 4);
+    id=stream_read_word_le(demuxer->stream);
+    // check for the FLI file magic number
     if((id==0xAF11) || (id==0xAF12)){ 
       mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_DetectedFLIfile);
       file_format=DEMUXER_TYPE_FLI;
     }
   }
 }
+//=============== Try to open as FILM file: =================
+if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_FILM){
+  demuxer=new_demuxer(stream,DEMUXER_TYPE_FILM,audio_id,video_id,dvdsub_id);
+  {
+    int signature=stream_read_fourcc(demuxer->stream);
+    // check for the FLI file magic number
+    if(signature==mmioFOURCC('F', 'I', 'L', 'M')){ 
+      mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_DetectedFILMfile);
+      file_format=DEMUXER_TYPE_FILM;
+    }
+  }
+}
 //=============== Try to open as MPEG-PS file: =================
 if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_PS){
  int pes=1;
@@ -554,6 +570,10 @@
   if (!demux_open_fli(demuxer)) return NULL;
   break;
  }
+ case DEMUXER_TYPE_FILM: {
+  if (!demux_open_film(demuxer)) return NULL;
+  break;
+ }
  case DEMUXER_TYPE_MOV: {
   if(!mov_read_header(demuxer)) return NULL;
 //  sh_video=d_video->sh;if(sh_video) sh_video->ds=d_video;
@@ -807,4 +827,6 @@
 	if (info->encoder)
 	    mp_msg(MSGT_DEMUX, MSGL_INFO, " Encoder: %s\n", info->encoder);
     }
+
+    return 0;
 }
--- a/libmpdemux/demuxer.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/libmpdemux/demuxer.h	Wed Jan 16 03:25:07 2002 +0000
@@ -16,6 +16,7 @@
 #define DEMUXER_TYPE_REAL 11
 #define DEMUXER_TYPE_Y4M 12
 #define DEMUXER_TYPE_NUV 13
+#define DEMUXER_TYPE_FILM 14
 
 #define DEMUXER_TIME_NONE 0
 #define DEMUXER_TIME_PTS 1
--- a/libmpdemux/stream.h	Wed Jan 16 01:51:34 2002 +0000
+++ b/libmpdemux/stream.h	Wed Jan 16 03:25:07 2002 +0000
@@ -83,6 +83,8 @@
   return y;
 }
 
+#define stream_read_fourcc stream_read_dword_le
+
 inline static unsigned int stream_read_word_le(stream_t *s){
   int x,y;
   x=stream_read_char(s);