Mercurial > mplayer.hg
annotate libmpdemux/demux_gif.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 | 9eeba22fd78a |
children | 1a889d9a4540 |
rev | line source |
---|---|
9133 | 1 /* |
29238
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
27385
diff
changeset
|
2 * GIF file parser |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
27385
diff
changeset
|
3 * Copyright (C) 2003 Joey Parrish |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
27385
diff
changeset
|
4 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
27385
diff
changeset
|
5 * This file is part of MPlayer. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
27385
diff
changeset
|
6 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
27385
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:
27385
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:
27385
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:
27385
diff
changeset
|
10 * (at your option) any later version. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
27385
diff
changeset
|
11 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
27385
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:
27385
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:
27385
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
27385
diff
changeset
|
15 * GNU General Public License for more details. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
27385
diff
changeset
|
16 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
27385
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:
27385
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:
27385
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:
27385
diff
changeset
|
20 */ |
9133 | 21 |
22 #include <stdio.h> | |
23 #include <stdlib.h> | |
24 #include <unistd.h> | |
25 | |
26 #include "config.h" | |
27 | |
28 #include "mp_msg.h" | |
29 #include "help_mp.h" | |
30 | |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
22377
diff
changeset
|
31 #include "stream/stream.h" |
9133 | 32 #include "demuxer.h" |
33 #include "stheader.h" | |
34 | |
35 #include <gif_lib.h> | |
21885 | 36 #include "libvo/fastmemcpy.h" |
21880
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
37 typedef struct { |
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
38 int current_pts; |
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
39 unsigned char *palette; |
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
40 GifFileType *gif; |
21882
68ebac1f2b8d
Fix crash for gif images that have Top or Left set
reimar
parents:
21881
diff
changeset
|
41 int w, h; |
21891 | 42 int useref; |
21921 | 43 uint8_t *refimg; |
21880
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
44 } gif_priv_t; |
9133 | 45 |
46 #define GIF_SIGNATURE (('G' << 16) | ('I' << 8) | 'F') | |
47 | |
27385
2113bd9c6bd9
Rename preprocessor directives related to image libraries.
diego
parents:
25707
diff
changeset
|
48 #ifndef CONFIG_GIF_TVT_HACK |
9463
93375ee56629
gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents:
9345
diff
changeset
|
49 // not supported by certain versions of the library |
30570
98dc6ae7ede2
libmpdemux: Mark functions not used outside of their files as static.
diego
parents:
29263
diff
changeset
|
50 static int my_read_gif(GifFileType *gif, uint8_t *buf, int len) |
98dc6ae7ede2
libmpdemux: Mark functions not used outside of their files as static.
diego
parents:
29263
diff
changeset
|
51 { |
9344
bd7b5078475e
1) codecs.conf changed recently and demux_gif no longer needs to spit
arpi
parents:
9133
diff
changeset
|
52 return stream_read(gif->UserData, buf, len); |
bd7b5078475e
1) codecs.conf changed recently and demux_gif no longer needs to spit
arpi
parents:
9133
diff
changeset
|
53 } |
9463
93375ee56629
gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents:
9345
diff
changeset
|
54 #endif |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
55 |
16175 | 56 static int gif_check_file(demuxer_t *demuxer) |
9133 | 57 { |
58 if (stream_read_int24(demuxer->stream) == GIF_SIGNATURE) | |
16175 | 59 return DEMUXER_TYPE_GIF; |
9133 | 60 return 0; |
61 } | |
62 | |
21920
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
63 static void memcpy_transp_pic(uint8_t *dst, uint8_t *src, int w, int h, |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
64 int dstride, int sstride, int transp, uint8_t trans_col) { |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
65 if (transp) { |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
66 dstride -= w; |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
67 sstride -= w; |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
68 while (h-- > 0) { |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
69 int wleft = w; |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
70 while (wleft-- > 0) { |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
71 if (*src != trans_col) |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
72 *dst = *src; |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
73 dst++; src++; |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
74 } |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
75 dst += dstride; |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
76 src += sstride; |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
77 } |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
78 } else |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
79 memcpy_pic(dst, src, w, h, dstride, sstride); |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
80 } |
65b2a9b3bd35
"Cosmetics" Introduce a memcpy function doing both transparent
reimar
parents:
21896
diff
changeset
|
81 |
16175 | 82 static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds) |
9133 | 83 { |
21880
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
84 gif_priv_t *priv = demuxer->priv; |
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
85 GifFileType *gif = priv->gif; |
9133 | 86 GifRecordType type = UNDEFINED_RECORD_TYPE; |
87 int len = 0; | |
88 demux_packet_t *dp = NULL; | |
89 ColorMapObject *effective_map = NULL; | |
21921 | 90 uint8_t *buf = NULL; |
21891 | 91 int refmode = 0; |
21895 | 92 int transparency = 0; |
93 uint8_t transparent_col; | |
9133 | 94 |
95 while (type != IMAGE_DESC_RECORD_TYPE) { | |
96 if (DGifGetRecordType(gif, &type) == GIF_ERROR) { | |
97 PrintGifError(); | |
98 return 0; // oops | |
99 } | |
100 if (type == TERMINATE_RECORD_TYPE) | |
101 return 0; // eof | |
102 if (type == SCREEN_DESC_RECORD_TYPE) { | |
103 if (DGifGetScreenDesc(gif) == GIF_ERROR) { | |
104 PrintGifError(); | |
105 return 0; // oops | |
106 } | |
107 } | |
108 if (type == EXTENSION_RECORD_TYPE) { | |
109 int code; | |
110 unsigned char *p = NULL; | |
111 if (DGifGetExtension(gif, &code, &p) == GIF_ERROR) { | |
112 PrintGifError(); | |
113 return 0; // oops | |
114 } | |
115 if (code == 0xF9) { | |
116 int frametime = 0; | |
117 if (p[0] == 4) // is the length correct? | |
21891 | 118 { |
21895 | 119 transparency = p[1] & 1; |
21896 | 120 refmode = (p[1] >> 2) & 3; |
22020
a40f222a31df
Hack: use refmode == 1 instead of == 0, as browsers behave like this
reimar
parents:
22019
diff
changeset
|
121 // HACK: specification says |
a40f222a31df
Hack: use refmode == 1 instead of == 0, as browsers behave like this
reimar
parents:
22019
diff
changeset
|
122 // > 0 - No disposal specified. The decoder is not required to take any action. |
a40f222a31df
Hack: use refmode == 1 instead of == 0, as browsers behave like this
reimar
parents:
22019
diff
changeset
|
123 // but browsers treat it the same way as |
a40f222a31df
Hack: use refmode == 1 instead of == 0, as browsers behave like this
reimar
parents:
22019
diff
changeset
|
124 // > 1 - Do not dispose. The graphic is to be left in place. |
a40f222a31df
Hack: use refmode == 1 instead of == 0, as browsers behave like this
reimar
parents:
22019
diff
changeset
|
125 // Some broken files rely on this, e.g. |
a40f222a31df
Hack: use refmode == 1 instead of == 0, as browsers behave like this
reimar
parents:
22019
diff
changeset
|
126 // http://samples.mplayerhq.hu/GIF/broken-gif/CLAIRE.GIF |
a40f222a31df
Hack: use refmode == 1 instead of == 0, as browsers behave like this
reimar
parents:
22019
diff
changeset
|
127 if (refmode == 0) refmode = 1; |
21875
d81cf0be50f0
Frametime was being read from the wrong offset, compare
diego
parents:
18958
diff
changeset
|
128 frametime = (p[3] << 8) | p[2]; // set the time, centiseconds |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
129 transparent_col = p[4]; |
21891 | 130 } |
21880
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
131 priv->current_pts += frametime; |
9133 | 132 } else if ((code == 0xFE) && (verbose)) { // comment extension |
133 // print iff verbose | |
134 printf("GIF comment: "); | |
135 while (p != NULL) { | |
136 int length = p[0]; | |
137 char *comments = p + 1; | |
138 comments[length] = 0; | |
139 printf("%s", comments); | |
140 if (DGifGetExtensionNext(gif, &p) == GIF_ERROR) { | |
141 PrintGifError(); | |
142 return 0; // oops | |
143 } | |
144 } | |
145 printf("\n"); | |
146 } | |
147 while (p != NULL) { | |
148 if (DGifGetExtensionNext(gif, &p) == GIF_ERROR) { | |
149 PrintGifError(); | |
150 return 0; // oops | |
151 } | |
152 } | |
153 } | |
154 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
155 |
9133 | 156 if (DGifGetImageDesc(gif) == GIF_ERROR) { |
157 PrintGifError(); | |
158 return 0; // oops | |
159 } | |
160 | |
161 len = gif->Image.Width * gif->Image.Height; | |
21882
68ebac1f2b8d
Fix crash for gif images that have Top or Left set
reimar
parents:
21881
diff
changeset
|
162 dp = new_demux_packet(priv->w * priv->h); |
21890 | 163 buf = calloc(gif->Image.Width, gif->Image.Height); |
21891 | 164 if (priv->useref) |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
22605
diff
changeset
|
165 fast_memcpy(dp->buffer, priv->refimg, priv->w * priv->h); |
21891 | 166 else |
167 memset(dp->buffer, gif->SBackGroundColor, priv->w * priv->h); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
168 |
9133 | 169 if (DGifGetLine(gif, buf, len) == GIF_ERROR) { |
170 PrintGifError(); | |
32614 | 171 free(buf); |
35346 | 172 free_demux_packet(dp); |
9133 | 173 return 0; // oops |
174 } | |
175 | |
176 effective_map = gif->Image.ColorMap; | |
177 if (effective_map == NULL) effective_map = gif->SColorMap; | |
178 | |
179 { | |
180 int y; | |
21883 | 181 int cnt = FFMIN(effective_map->ColorCount, 256); |
22377
fd54975f9135
Use libavutil's av_clip* instead of unreadable MIN/MAX chaos.
reimar
parents:
22024
diff
changeset
|
182 int l = av_clip(gif->Image.Left, 0, priv->w); |
fd54975f9135
Use libavutil's av_clip* instead of unreadable MIN/MAX chaos.
reimar
parents:
22024
diff
changeset
|
183 int t = av_clip(gif->Image.Top, 0, priv->h); |
fd54975f9135
Use libavutil's av_clip* instead of unreadable MIN/MAX chaos.
reimar
parents:
22024
diff
changeset
|
184 int w = av_clip(gif->Image.Width, 0, priv->w - l); |
fd54975f9135
Use libavutil's av_clip* instead of unreadable MIN/MAX chaos.
reimar
parents:
22024
diff
changeset
|
185 int h = av_clip(gif->Image.Height, 0, priv->h - t); |
21885 | 186 unsigned char *dest = dp->buffer + priv->w * t + l; |
9133 | 187 |
21876 | 188 // copy the palette |
21881
a10888bc9758
Fix invalid read for gifs with a palette for less than 256 colors
reimar
parents:
21880
diff
changeset
|
189 for (y = 0; y < cnt; y++) { |
21893 | 190 priv->palette[(y * 4) + 0] = effective_map->Colors[y].Blue; |
191 priv->palette[(y * 4) + 1] = effective_map->Colors[y].Green; | |
192 priv->palette[(y * 4) + 2] = effective_map->Colors[y].Red; | |
193 priv->palette[(y * 4) + 3] = 0; | |
9133 | 194 } |
195 | |
21922 | 196 if (gif->Image.Interlace) { |
197 uint8_t *s = buf; | |
22024 | 198 int ih = (h - 0 + 7) >> 3; |
199 memcpy_transp_pic(dest, s, w, ih, | |
21922 | 200 priv->w << 3, gif->Image.Width, |
201 transparency, transparent_col); | |
22024 | 202 s += ih * w; |
203 ih = (h - 4 + 7) >> 3; | |
204 memcpy_transp_pic(dest + (priv->w << 2), s, w, ih, | |
21922 | 205 priv->w << 3, gif->Image.Width, |
206 transparency, transparent_col); | |
22024 | 207 s += ih * w; |
208 ih = (h - 2 + 3) >> 2; | |
209 memcpy_transp_pic(dest + (priv->w << 1), s, w, ih, | |
21922 | 210 priv->w << 2, gif->Image.Width, |
211 transparency, transparent_col); | |
22024 | 212 s += ih * w; |
213 ih = (h - 1 + 1) >> 1; | |
214 memcpy_transp_pic(dest + priv->w, s, w, ih, | |
21922 | 215 priv->w << 1, gif->Image.Width, |
216 transparency, transparent_col); | |
217 } else | |
218 memcpy_transp_pic(dest, buf, w, h, priv->w, gif->Image.Width, | |
219 transparency, transparent_col); | |
21892 | 220 |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
22605
diff
changeset
|
221 if (refmode == 1) fast_memcpy(priv->refimg, dp->buffer, priv->w * priv->h); |
21892 | 222 if (refmode == 2 && priv->useref) { |
223 dest = priv->refimg + priv->w * t + l; | |
224 memset(buf, gif->SBackGroundColor, len); | |
225 memcpy_pic(dest, buf, w, h, priv->w, gif->Image.Width); | |
226 } | |
21894 | 227 if (!(refmode & 2)) priv->useref = refmode & 1; |
9133 | 228 } |
229 | |
230 free(buf); | |
231 | |
232 demuxer->video->dpos++; | |
21880
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
233 dp->pts = ((float)priv->current_pts) / 100; |
9133 | 234 dp->pos = stream_tell(demuxer->stream); |
235 ds_add_packet(demuxer->video, dp); | |
236 | |
237 return 1; | |
238 } | |
239 | |
16175 | 240 static demuxer_t* demux_open_gif(demuxer_t* demuxer) |
9133 | 241 { |
21880
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
242 gif_priv_t *priv = calloc(1, sizeof(gif_priv_t)); |
9133 | 243 sh_video_t *sh_video = NULL; |
244 GifFileType *gif = NULL; | |
245 | |
21880
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
246 priv->current_pts = 0; |
9133 | 247 demuxer->seekable = 0; // FIXME |
248 | |
249 // go back to the beginning | |
9345 | 250 stream_seek(demuxer->stream,demuxer->stream->start_pos); |
9133 | 251 |
27385
2113bd9c6bd9
Rename preprocessor directives related to image libraries.
diego
parents:
25707
diff
changeset
|
252 #ifdef CONFIG_GIF_TVT_HACK |
9463
93375ee56629
gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents:
9345
diff
changeset
|
253 // without the TVT functionality of libungif, a hard seek must be |
93375ee56629
gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents:
9345
diff
changeset
|
254 // done to the beginning of the file. this is because libgif is |
93375ee56629
gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents:
9345
diff
changeset
|
255 // unable to use mplayer's cache, and without this lseek libgif will |
93375ee56629
gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents:
9345
diff
changeset
|
256 // not read from the beginning of the file and the command will fail. |
93375ee56629
gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents:
9345
diff
changeset
|
257 // with this hack enabled, you will lose the ability to stream a GIF. |
93375ee56629
gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents:
9345
diff
changeset
|
258 lseek(demuxer->stream->fd, 0, SEEK_SET); |
93375ee56629
gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents:
9345
diff
changeset
|
259 gif = DGifOpenFileHandle(demuxer->stream->fd); |
93375ee56629
gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents:
9345
diff
changeset
|
260 #else |
9344
bd7b5078475e
1) codecs.conf changed recently and demux_gif no longer needs to spit
arpi
parents:
9133
diff
changeset
|
261 gif = DGifOpen(demuxer->stream, my_read_gif); |
9463
93375ee56629
gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents:
9345
diff
changeset
|
262 #endif |
9133 | 263 if (!gif) { |
264 PrintGifError(); | |
32614 | 265 free(priv); |
9133 | 266 return NULL; |
267 } | |
268 | |
269 // create a new video stream header | |
270 sh_video = new_sh_video(demuxer, 0); | |
271 | |
272 // make sure the demuxer knows about the new video stream header | |
273 // (even though new_sh_video() ought to take care of it) | |
274 demuxer->video->sh = sh_video; | |
275 | |
276 // make sure that the video demuxer stream header knows about its | |
277 // parent video demuxer stream (this is getting wacky), or else | |
278 // video_read_properties() will choke | |
279 sh_video->ds = demuxer->video; | |
280 | |
281 sh_video->format = mmioFOURCC(8, 'R', 'G', 'B'); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
282 |
9133 | 283 sh_video->fps = 5.0f; |
284 sh_video->frametime = 1.0f / sh_video->fps; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
285 |
32123 | 286 sh_video->bih = malloc(sizeof(*sh_video->bih) + (256 * 4)); |
9133 | 287 sh_video->bih->biCompression = sh_video->format; |
22019
f43d02e9b58b
Set sh_video->bih->biWidth properly, fixes decoding after latest dec_video.c change
reimar
parents:
21922
diff
changeset
|
288 sh_video->bih->biWidth = priv->w = (uint16_t)gif->SWidth; |
f43d02e9b58b
Set sh_video->bih->biWidth properly, fixes decoding after latest dec_video.c change
reimar
parents:
21922
diff
changeset
|
289 sh_video->bih->biHeight = priv->h = (uint16_t)gif->SHeight; |
9133 | 290 sh_video->bih->biBitCount = 8; |
291 sh_video->bih->biPlanes = 2; | |
21880
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
292 priv->palette = (unsigned char *)(sh_video->bih + 1); |
21891 | 293 priv->refimg = malloc(priv->w * priv->h); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
294 |
21880
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
295 priv->gif = gif; |
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
296 demuxer->priv = priv; |
9133 | 297 |
298 return demuxer; | |
299 } | |
300 | |
16175 | 301 static void demux_close_gif(demuxer_t* demuxer) |
9133 | 302 { |
21880
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
303 gif_priv_t *priv = demuxer->priv; |
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
304 if (!priv) return; |
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
305 if (priv->gif && DGifCloseFile(priv->gif) == GIF_ERROR) |
9133 | 306 PrintGifError(); |
21891 | 307 free(priv->refimg); |
21880
4e22e06485c6
Move global variables in gif demuxer into priv struct
reimar
parents:
21876
diff
changeset
|
308 free(priv); |
9133 | 309 } |
16175 | 310 |
311 | |
25707
d4fe6e23283e
Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents:
23457
diff
changeset
|
312 const demuxer_desc_t demuxer_desc_gif = { |
16175 | 313 "GIF demuxer", |
314 "gif", | |
315 "GIF", | |
316 "Joey Parrish", | |
317 "", | |
318 DEMUXER_TYPE_GIF, | |
319 0, // unsafe autodetect | |
320 gif_check_file, | |
321 demux_gif_fill_buffer, | |
322 demux_open_gif, | |
323 demux_close_gif, | |
324 NULL, | |
325 NULL | |
326 }; |