Mercurial > mplayer.hg
annotate libmpdemux/demux_fli.c @ 35418:cedb0ba2b5c6
Move the code to set guiInfo's Track, Chapter and Angle start values.
Set them before checking whether there is any media opened, because
with no media opened we clear the counters.
author | ib |
---|---|
date | Thu, 29 Nov 2012 14:11:03 +0000 |
parents | 8fa2f43cb760 |
children | f3c835ddce85 |
rev | line source |
---|---|
3101
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
1 /* |
29238
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
2 * FLI file parser |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
3 * copyright (c) 2001 Mike Melanson |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
4 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
5 * This file is part of MPlayer. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
6 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
7 * MPlayer is free software; you can redistribute it and/or modify |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
8 * it under the terms of the GNU General Public License as published by |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
9 * the Free Software Foundation; either version 2 of the License, or |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
10 * (at your option) any later version. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
11 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
12 * MPlayer is distributed in the hope that it will be useful, |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
15 * GNU General Public License for more details. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
16 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
17 * You should have received a copy of the GNU General Public License along |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
18 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
26758
diff
changeset
|
20 */ |
3101
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
21 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
22 #include <stdio.h> |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
23 #include <stdlib.h> |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
24 #include <unistd.h> |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
25 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
26 #include "config.h" |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
27 #include "mp_msg.h" |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
28 #include "help_mp.h" |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
29 |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
19062
diff
changeset
|
30 #include "stream/stream.h" |
3101
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
31 #include "demuxer.h" |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
32 #include "stheader.h" |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
33 |
24666 | 34 typedef struct { |
3101
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
35 int num_frames; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
36 int current_frame; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
37 off_t *filepos; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
38 unsigned int *frame_size; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
39 } fli_frames_t; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
40 |
17636 | 41 static void demux_seek_fli(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){ |
3544 | 42 fli_frames_t *frames = (fli_frames_t *)demuxer->priv; |
43 sh_video_t *sh_video = demuxer->video->sh; | |
25883
baf32110d3fc
Use defines to give names to the different seek flags.
reimar
parents:
25707
diff
changeset
|
44 int newpos=(flags&SEEK_ABSOLUTE)?0:frames->current_frame; |
baf32110d3fc
Use defines to give names to the different seek flags.
reimar
parents:
25707
diff
changeset
|
45 if(flags&SEEK_FACTOR){ |
3544 | 46 // float 0..1 |
47 newpos+=rel_seek_secs*frames->num_frames; | |
48 } else { | |
49 // secs | |
50 newpos+=rel_seek_secs*sh_video->fps; | |
51 } | |
52 if(newpos<0) newpos=0; else | |
53 if(newpos>frames->num_frames) newpos=frames->num_frames; | |
54 frames->current_frame=newpos; | |
55 } | |
56 | |
3101
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
57 // return value: |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
58 // 0 = EOF or no stream found |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
59 // 1 = successfully read a packet |
16175 | 60 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
|
61 fli_frames_t *frames = (fli_frames_t *)demuxer->priv; |
3221 | 62 sh_video_t *sh_video = demuxer->video->sh; |
3101
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 // see if the end has been reached |
3544 | 65 if (frames->current_frame >= frames->num_frames) |
3101
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
66 return 0; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
67 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
68 // fetch the frame from the file |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
69 // 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
|
70 // 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
|
71 stream_seek(demuxer->stream, frames->filepos[frames->current_frame]); |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
72 ds_read_packet(demuxer->video, |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
73 demuxer->stream, |
3101
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
74 frames->frame_size[frames->current_frame], |
3221 | 75 frames->current_frame/sh_video->fps, |
3101
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
76 frames->filepos[frames->current_frame], |
3221 | 77 0 /* what flags? -> demuxer.h (alex) */ |
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 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
80 // get the next frame ready |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
81 frames->current_frame++; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
82 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
83 return 1; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
84 } |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
85 |
16175 | 86 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
|
87 sh_video_t *sh_video = NULL; |
19062
83c3afeab35d
drops casts from void * on malloc/calloc from libmpdemux code
reynaldo
parents:
18558
diff
changeset
|
88 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
|
89 int frame_number; |
3104 | 90 int speed; |
3105
f951f3be126c
fixed FLI demuxer so that it skips over app-specific frames
melanson
parents:
3104
diff
changeset
|
91 unsigned int frame_size; |
f951f3be126c
fixed FLI demuxer so that it skips over app-specific frames
melanson
parents:
3104
diff
changeset
|
92 int magic_number; |
11846
e3c3d01e9b86
Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents:
5810
diff
changeset
|
93 unsigned char * header; |
3101
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
94 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
95 // go back to the beginning |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
96 stream_reset(demuxer->stream); |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
97 stream_seek(demuxer->stream, 0); |
11846
e3c3d01e9b86
Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents:
5810
diff
changeset
|
98 |
24667
036c49377d02
Make sure there is no uninitialized data in BITMAPINFOHEADER created by fli demuxer
reimar
parents:
24666
diff
changeset
|
99 header = calloc(1, sizeof(BITMAPINFOHEADER) + 128); |
11846
e3c3d01e9b86
Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents:
5810
diff
changeset
|
100 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
|
101 stream_seek(demuxer->stream, 0); |
e3c3d01e9b86
Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents:
5810
diff
changeset
|
102 |
3101
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
103 demuxer->movi_start = 128; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
104 demuxer->movi_end = stream_read_dword_le(demuxer->stream); |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
105 |
3229 | 106 magic_number = stream_read_word_le(demuxer->stream); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
107 |
3229 | 108 if ((magic_number != 0xAF11) && (magic_number != 0xAF12)) |
109 { | |
110 mp_msg(MSGT_DEMUX, MSGL_ERR, "Bad/unknown magic number (%04x)\n", | |
111 magic_number); | |
17804 | 112 free(header); |
113 free(frames); | |
26758
9fb1d2c3dbd4
cosmetics: Remove pointless parentheses from return statements.
diego
parents:
25883
diff
changeset
|
114 return NULL; |
3229 | 115 } |
3101
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 // fetch the number of frames |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
118 frames->num_frames = stream_read_word_le(demuxer->stream); |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
119 frames->current_frame = 0; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
120 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
121 // allocate enough entries for the indices |
18558
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
17804
diff
changeset
|
122 // 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
|
123 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
|
124 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
|
125 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
126 // create a new video stream header |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
127 sh_video = new_sh_video(demuxer, 0); |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
128 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
129 // 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
|
130 // (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
|
131 demuxer->video->sh = sh_video; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
132 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
133 // 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
|
134 // 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
|
135 // video_read_properties() will choke |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
136 sh_video->ds = demuxer->video; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
137 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
138 // custom fourcc for internal MPlayer use |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
139 sh_video->format = mmioFOURCC('F', 'L', 'I', 'C'); |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
140 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
141 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
|
142 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
|
143 |
11846
e3c3d01e9b86
Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents:
5810
diff
changeset
|
144 // pass extradata to codec |
e3c3d01e9b86
Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents:
5810
diff
changeset
|
145 sh_video->bih = (BITMAPINFOHEADER*)header; |
e3c3d01e9b86
Pass header to codec in extradata (needed by ffmpeg fli decoder)
rtognimp
parents:
5810
diff
changeset
|
146 sh_video->bih->biSize = sizeof(BITMAPINFOHEADER) + 128; |
24668 | 147 sh_video->bih->biWidth = sh_video->disp_w; |
148 sh_video->bih->biHeight = sh_video->disp_h; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
149 |
3101
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
150 // skip the video depth and flags |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
151 stream_skip(demuxer->stream, 4); |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
152 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
153 // get the speed |
3104 | 154 speed = stream_read_word_le(demuxer->stream); |
155 if (speed == 0) | |
156 speed = 1; | |
3229 | 157 if (magic_number == 0xAF11) |
158 speed *= 1000/70; | |
3104 | 159 sh_video->fps = 1000 / speed; |
3101
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
160 sh_video->frametime = 1/sh_video->fps; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
161 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
162 // build the frame index |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
163 stream_seek(demuxer->stream, demuxer->movi_start); |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
164 frame_number = 0; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
165 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
|
166 { |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
167 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
|
168 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
|
169 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
|
170 stream_skip(demuxer->stream, frame_size - 6); |
f951f3be126c
fixed FLI demuxer so that it skips over app-specific frames
melanson
parents:
3104
diff
changeset
|
171 |
f951f3be126c
fixed FLI demuxer so that it skips over app-specific frames
melanson
parents:
3104
diff
changeset
|
172 // 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
|
173 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
|
174 { |
f951f3be126c
fixed FLI demuxer so that it skips over app-specific frames
melanson
parents:
3104
diff
changeset
|
175 frames->frame_size[frame_number] = frame_size; |
f951f3be126c
fixed FLI demuxer so that it skips over app-specific frames
melanson
parents:
3104
diff
changeset
|
176 frame_number++; |
f951f3be126c
fixed FLI demuxer so that it skips over app-specific frames
melanson
parents:
3104
diff
changeset
|
177 } |
3101
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
178 } |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
179 |
3105
f951f3be126c
fixed FLI demuxer so that it skips over app-specific frames
melanson
parents:
3104
diff
changeset
|
180 // save the actual number of frames indexed |
f951f3be126c
fixed FLI demuxer so that it skips over app-specific frames
melanson
parents:
3104
diff
changeset
|
181 frames->num_frames = frame_number; |
f951f3be126c
fixed FLI demuxer so that it skips over app-specific frames
melanson
parents:
3104
diff
changeset
|
182 |
3101
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
183 demuxer->priv = frames; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
184 |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
185 return demuxer; |
637e540831b9
mostly complete support for loading and decoding FLI/FLC animations
melanson
parents:
diff
changeset
|
186 } |
5810 | 187 |
16175 | 188 static void demux_close_fli(demuxer_t* demuxer) { |
5810 | 189 fli_frames_t *frames = demuxer->priv; |
190 | |
191 if(!frames) | |
192 return; | |
193 | |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
29263
diff
changeset
|
194 free(frames->filepos); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
29263
diff
changeset
|
195 free(frames->frame_size); |
5810 | 196 free(frames); |
197 | |
198 } | |
16175 | 199 |
200 | |
201 static int fli_check_file(demuxer_t* demuxer) | |
202 { | |
203 int id; | |
204 | |
205 stream_seek(demuxer->stream, 4); | |
206 id=stream_read_word_le(demuxer->stream); | |
207 // check for the FLI file magic number | |
208 if((id==0xAF11) || (id==0xAF12)) | |
209 return DEMUXER_TYPE_FLI; | |
210 | |
211 return 0; | |
212 } | |
213 | |
214 | |
25707
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
24668
diff
changeset
|
215 const demuxer_desc_t demuxer_desc_fli = { |
16175 | 216 "Autodesk FLIC demuxer", |
217 "fli", | |
218 "FLI", | |
219 "Mike Melanson", | |
220 "Supports also some extensions", | |
221 DEMUXER_TYPE_FLI, | |
222 0, // unsafe autodetect (short signature) | |
223 fli_check_file, | |
224 demux_fli_fill_buffer, | |
225 demux_open_fli, | |
226 demux_close_fli, | |
227 demux_seek_fli, | |
228 NULL | |
229 }; |