annotate libmpdemux/demux_fli.c @ 23088:6a40ec31cfa7

Add support for Bethesda Software VID video.
author diego
date Wed, 25 Apr 2007 00:02:23 +0000
parents 4d81dbdf46b9
children 58480b6d333f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
1 /*
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
2 FLI file parser for the MPlayer program
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
3 by Mike Melanson
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
4 */
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
5
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
6 #include <stdio.h>
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
7 #include <stdlib.h>
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
8 #include <unistd.h>
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
9
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
10 #include "config.h"
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
11 #include "mp_msg.h"
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
12 #include "help_mp.h"
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
13
22605
4d81dbdf46b9 Add explicit location for headers from the stream/ directory.
diego
parents: 19062
diff changeset
14 #include "stream/stream.h"
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
15 #include "demuxer.h"
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
16 #include "stheader.h"
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
17
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
18 typedef struct _fli_frames_t {
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
19 int num_frames;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
20 int current_frame;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
21 off_t *filepos;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
22 unsigned int *frame_size;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
23 } fli_frames_t;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
24
17636
b849a99cdc3c Second-try commit of this patch.
corey
parents: 17569
diff changeset
25 static void demux_seek_fli(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
3544
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
26 fli_frames_t *frames = (fli_frames_t *)demuxer->priv;
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
27 sh_video_t *sh_video = demuxer->video->sh;
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
28 int newpos=(flags&1)?0:frames->current_frame;
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
29 if(flags&2){
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
30 // float 0..1
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
31 newpos+=rel_seek_secs*frames->num_frames;
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
32 } else {
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
33 // secs
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
34 newpos+=rel_seek_secs*sh_video->fps;
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
35 }
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
36 if(newpos<0) newpos=0; else
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
37 if(newpos>frames->num_frames) newpos=frames->num_frames;
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
38 frames->current_frame=newpos;
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
39 }
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
40
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
41 // return value:
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
42 // 0 = EOF or no stream found
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
43 // 1 = successfully read a packet
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
44 static int demux_fli_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds){
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
45 fli_frames_t *frames = (fli_frames_t *)demuxer->priv;
3221
2b36eede0b5b pts support
alex
parents: 3105
diff changeset
46 sh_video_t *sh_video = demuxer->video->sh;
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
47
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
48 // see if the end has been reached
3544
61b89c10e4e8 fli seeking implemented
arpi
parents: 3401
diff changeset
49 if (frames->current_frame >= frames->num_frames)
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
50 return 0;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
51
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
52 // fetch the frame from the file
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
53 // first, position the file properly since ds_read_packet() doesn't
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
54 // seem to do it, even though it takes a file offset as a parameter
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
55 stream_seek(demuxer->stream, frames->filepos[frames->current_frame]);
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
56 ds_read_packet(demuxer->video,
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
57 demuxer->stream,
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
58 frames->frame_size[frames->current_frame],
3221
2b36eede0b5b pts support
alex
parents: 3105
diff changeset
59 frames->current_frame/sh_video->fps,
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
60 frames->filepos[frames->current_frame],
3221
2b36eede0b5b pts support
alex
parents: 3105
diff changeset
61 0 /* what flags? -> demuxer.h (alex) */
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
62 );
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
63
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
64 // get the next frame ready
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
65 frames->current_frame++;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
66
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
67 return 1;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
68 }
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
69
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
70 static demuxer_t* demux_open_fli(demuxer_t* demuxer){
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
71 sh_video_t *sh_video = NULL;
19062
83c3afeab35d drops casts from void * on malloc/calloc from libmpdemux code
reynaldo
parents: 18558
diff changeset
72 fli_frames_t *frames = malloc(sizeof(fli_frames_t));
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
73 int frame_number;
3104
829637d529e9 fixed divide-by-0 bug in FLI demuxer
melanson
parents: 3101
diff changeset
74 int speed;
3105
f951f3be126c fixed FLI demuxer so that it skips over app-specific frames
melanson
parents: 3104
diff changeset
75 unsigned int frame_size;
f951f3be126c fixed FLI demuxer so that it skips over app-specific frames
melanson
parents: 3104
diff changeset
76 int magic_number;
11846
e3c3d01e9b86 Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents: 5810
diff changeset
77 unsigned char * header;
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
78
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
79 // go back to the beginning
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
80 stream_reset(demuxer->stream);
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
81 stream_seek(demuxer->stream, 0);
11846
e3c3d01e9b86 Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents: 5810
diff changeset
82
e3c3d01e9b86 Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents: 5810
diff changeset
83 header = malloc(sizeof(BITMAPINFOHEADER) + 128);
e3c3d01e9b86 Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents: 5810
diff changeset
84 stream_read(demuxer->stream, header + sizeof(BITMAPINFOHEADER), 128);
e3c3d01e9b86 Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents: 5810
diff changeset
85 stream_seek(demuxer->stream, 0);
e3c3d01e9b86 Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents: 5810
diff changeset
86
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
87 demuxer->movi_start = 128;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
88 demuxer->movi_end = stream_read_dword_le(demuxer->stream);
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
89
3229
7eefc6e4f6d4 magic_number checking added
alex
parents: 3221
diff changeset
90 magic_number = stream_read_word_le(demuxer->stream);
7eefc6e4f6d4 magic_number checking added
alex
parents: 3221
diff changeset
91
7eefc6e4f6d4 magic_number checking added
alex
parents: 3221
diff changeset
92 if ((magic_number != 0xAF11) && (magic_number != 0xAF12))
7eefc6e4f6d4 magic_number checking added
alex
parents: 3221
diff changeset
93 {
7eefc6e4f6d4 magic_number checking added
alex
parents: 3221
diff changeset
94 mp_msg(MSGT_DEMUX, MSGL_ERR, "Bad/unknown magic number (%04x)\n",
7eefc6e4f6d4 magic_number checking added
alex
parents: 3221
diff changeset
95 magic_number);
17804
1a2aaf037d48 Fix memory leak cid 177
rtognimp
parents: 17636
diff changeset
96 free(header);
1a2aaf037d48 Fix memory leak cid 177
rtognimp
parents: 17636
diff changeset
97 free(frames);
3229
7eefc6e4f6d4 magic_number checking added
alex
parents: 3221
diff changeset
98 return(NULL);
7eefc6e4f6d4 magic_number checking added
alex
parents: 3221
diff changeset
99 }
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
100
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
101 // fetch the number of frames
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
102 frames->num_frames = stream_read_word_le(demuxer->stream);
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
103 frames->current_frame = 0;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
104
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
105 // allocate enough entries for the indices
18558
4928dd61f136 Fix potential integer overflows in memory allocation.
rtogni
parents: 17804
diff changeset
106 // audit: num_frames is 16bit so it is safe against overflow
19062
83c3afeab35d drops casts from void * on malloc/calloc from libmpdemux code
reynaldo
parents: 18558
diff changeset
107 frames->filepos = malloc(frames->num_frames * sizeof(off_t));
83c3afeab35d drops casts from void * on malloc/calloc from libmpdemux code
reynaldo
parents: 18558
diff changeset
108 frames->frame_size = malloc(frames->num_frames * sizeof(int));
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
109
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
110 // create a new video stream header
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
111 sh_video = new_sh_video(demuxer, 0);
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
112
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
113 // make sure the demuxer knows about the new video stream header
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
114 // (even though new_sh_video() ought to take care of it)
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
115 demuxer->video->sh = sh_video;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
116
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
117 // make sure that the video demuxer stream header knows about its
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
118 // parent video demuxer stream (this is getting wacky), or else
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
119 // video_read_properties() will choke
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
120 sh_video->ds = demuxer->video;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
121
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
122 // custom fourcc for internal MPlayer use
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
123 sh_video->format = mmioFOURCC('F', 'L', 'I', 'C');
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
124
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
125 sh_video->disp_w = stream_read_word_le(demuxer->stream);
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
126 sh_video->disp_h = stream_read_word_le(demuxer->stream);
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
127
11846
e3c3d01e9b86 Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents: 5810
diff changeset
128 // pass extradata to codec
e3c3d01e9b86 Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents: 5810
diff changeset
129 sh_video->bih = (BITMAPINFOHEADER*)header;
e3c3d01e9b86 Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents: 5810
diff changeset
130 sh_video->bih->biSize = sizeof(BITMAPINFOHEADER) + 128;
e3c3d01e9b86 Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents: 5810
diff changeset
131
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
132 // skip the video depth and flags
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
133 stream_skip(demuxer->stream, 4);
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
134
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
135 // get the speed
3104
829637d529e9 fixed divide-by-0 bug in FLI demuxer
melanson
parents: 3101
diff changeset
136 speed = stream_read_word_le(demuxer->stream);
829637d529e9 fixed divide-by-0 bug in FLI demuxer
melanson
parents: 3101
diff changeset
137 if (speed == 0)
829637d529e9 fixed divide-by-0 bug in FLI demuxer
melanson
parents: 3101
diff changeset
138 speed = 1;
3229
7eefc6e4f6d4 magic_number checking added
alex
parents: 3221
diff changeset
139 if (magic_number == 0xAF11)
7eefc6e4f6d4 magic_number checking added
alex
parents: 3221
diff changeset
140 speed *= 1000/70;
3104
829637d529e9 fixed divide-by-0 bug in FLI demuxer
melanson
parents: 3101
diff changeset
141 sh_video->fps = 1000 / speed;
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
142 sh_video->frametime = 1/sh_video->fps;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
143
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
144 // build the frame index
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
145 stream_seek(demuxer->stream, demuxer->movi_start);
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
146 frame_number = 0;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
147 while ((!stream_eof(demuxer->stream)) && (frame_number < frames->num_frames))
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
148 {
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
149 frames->filepos[frame_number] = stream_tell(demuxer->stream);
3105
f951f3be126c fixed FLI demuxer so that it skips over app-specific frames
melanson
parents: 3104
diff changeset
150 frame_size = stream_read_dword_le(demuxer->stream);
f951f3be126c fixed FLI demuxer so that it skips over app-specific frames
melanson
parents: 3104
diff changeset
151 magic_number = stream_read_word_le(demuxer->stream);
f951f3be126c fixed FLI demuxer so that it skips over app-specific frames
melanson
parents: 3104
diff changeset
152 stream_skip(demuxer->stream, frame_size - 6);
f951f3be126c fixed FLI demuxer so that it skips over app-specific frames
melanson
parents: 3104
diff changeset
153
f951f3be126c fixed FLI demuxer so that it skips over app-specific frames
melanson
parents: 3104
diff changeset
154 // if this chunk has the right magic number, index it
4800
e47b32c0eca8 discovered what appears to be another valid FLI frame magic number
melanson
parents: 3544
diff changeset
155 if ((magic_number == 0xF1FA) || (magic_number == 0xF5FA))
3105
f951f3be126c fixed FLI demuxer so that it skips over app-specific frames
melanson
parents: 3104
diff changeset
156 {
f951f3be126c fixed FLI demuxer so that it skips over app-specific frames
melanson
parents: 3104
diff changeset
157 frames->frame_size[frame_number] = frame_size;
f951f3be126c fixed FLI demuxer so that it skips over app-specific frames
melanson
parents: 3104
diff changeset
158 frame_number++;
f951f3be126c fixed FLI demuxer so that it skips over app-specific frames
melanson
parents: 3104
diff changeset
159 }
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
160 }
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
161
3105
f951f3be126c fixed FLI demuxer so that it skips over app-specific frames
melanson
parents: 3104
diff changeset
162 // save the actual number of frames indexed
f951f3be126c fixed FLI demuxer so that it skips over app-specific frames
melanson
parents: 3104
diff changeset
163 frames->num_frames = frame_number;
f951f3be126c fixed FLI demuxer so that it skips over app-specific frames
melanson
parents: 3104
diff changeset
164
3101
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
165 demuxer->priv = frames;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
166
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
167 return demuxer;
637e540831b9 mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff changeset
168 }
5810
8a357300d0ec Added demuxer uninit
albeu
parents: 4800
diff changeset
169
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
170 static void demux_close_fli(demuxer_t* demuxer) {
5810
8a357300d0ec Added demuxer uninit
albeu
parents: 4800
diff changeset
171 fli_frames_t *frames = demuxer->priv;
8a357300d0ec Added demuxer uninit
albeu
parents: 4800
diff changeset
172
8a357300d0ec Added demuxer uninit
albeu
parents: 4800
diff changeset
173 if(!frames)
8a357300d0ec Added demuxer uninit
albeu
parents: 4800
diff changeset
174 return;
8a357300d0ec Added demuxer uninit
albeu
parents: 4800
diff changeset
175
8a357300d0ec Added demuxer uninit
albeu
parents: 4800
diff changeset
176 if(frames->filepos)
8a357300d0ec Added demuxer uninit
albeu
parents: 4800
diff changeset
177 free(frames->filepos);
8a357300d0ec Added demuxer uninit
albeu
parents: 4800
diff changeset
178 if(frames->frame_size)
8a357300d0ec Added demuxer uninit
albeu
parents: 4800
diff changeset
179 free(frames->frame_size);
8a357300d0ec Added demuxer uninit
albeu
parents: 4800
diff changeset
180
8a357300d0ec Added demuxer uninit
albeu
parents: 4800
diff changeset
181 free(frames);
8a357300d0ec Added demuxer uninit
albeu
parents: 4800
diff changeset
182
8a357300d0ec Added demuxer uninit
albeu
parents: 4800
diff changeset
183 }
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
184
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
185
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
186 static int fli_check_file(demuxer_t* demuxer)
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
187 {
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
188 int id;
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
189
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
190 stream_seek(demuxer->stream, 4);
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
191 id=stream_read_word_le(demuxer->stream);
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
192 // check for the FLI file magic number
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
193 if((id==0xAF11) || (id==0xAF12))
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
194 return DEMUXER_TYPE_FLI;
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
195
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
196 return 0;
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
197 }
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
198
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
199
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
200 demuxer_desc_t demuxer_desc_fli = {
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
201 "Autodesk FLIC demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
202 "fli",
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
203 "FLI",
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
204 "Mike Melanson",
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
205 "Supports also some extensions",
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
206 DEMUXER_TYPE_FLI,
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
207 0, // unsafe autodetect (short signature)
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
208 fli_check_file,
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
209 demux_fli_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
210 demux_open_fli,
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
211 demux_close_fli,
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
212 demux_seek_fli,
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
213 NULL
6b86089c2edd Demuxer modularization
rtognimp
parents: 11846
diff changeset
214 };