annotate libmpdemux/demux_gif.c @ 21406:3acff79cdd9f

100l confused FFMIN/FFMAX
author reimar
date Fri, 01 Dec 2006 19:43:36 +0000
parents a8e681ad7c90
children d81cf0be50f0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9133
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
1 /*
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
2 GIF file parser for MPlayer
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
3 by Joey Parrish
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
4 */
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
5
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
6 #include <stdio.h>
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
7 #include <stdlib.h>
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
8 #include <unistd.h>
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
9
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
10 #include "config.h"
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
11
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
12 #include "mp_msg.h"
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
13 #include "help_mp.h"
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
14
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
15 #include "stream.h"
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
16 #include "demuxer.h"
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
17 #include "stheader.h"
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
18
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
19 #include <gif_lib.h>
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
20 static int current_pts = 0;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
21 static unsigned char *pallete = NULL;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
22
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
23 #define GIF_SIGNATURE (('G' << 16) | ('I' << 8) | 'F')
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
24
9463
93375ee56629 gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents: 9345
diff changeset
25 #ifndef HAVE_GIF_TVT_HACK
93375ee56629 gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents: 9345
diff changeset
26 // not supported by certain versions of the library
9344
bd7b5078475e 1) codecs.conf changed recently and demux_gif no longer needs to spit
arpi
parents: 9133
diff changeset
27 int my_read_gif(GifFileType *gif, uint8_t *buf, int len) {
bd7b5078475e 1) codecs.conf changed recently and demux_gif no longer needs to spit
arpi
parents: 9133
diff changeset
28 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
29 }
9463
93375ee56629 gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents: 9345
diff changeset
30 #endif
9344
bd7b5078475e 1) codecs.conf changed recently and demux_gif no longer needs to spit
arpi
parents: 9133
diff changeset
31
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
32 static int gif_check_file(demuxer_t *demuxer)
9133
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
33 {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
34 if (stream_read_int24(demuxer->stream) == GIF_SIGNATURE)
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
35 return DEMUXER_TYPE_GIF;
9133
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
36 return 0;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
37 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
38
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
39 static int demux_gif_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds)
9133
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
40 {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
41 GifFileType *gif = (GifFileType *)demuxer->priv;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
42 GifRecordType type = UNDEFINED_RECORD_TYPE;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
43 int len = 0;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
44 demux_packet_t *dp = NULL;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
45 ColorMapObject *effective_map = NULL;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
46 char *buf = NULL;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
47
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
48 while (type != IMAGE_DESC_RECORD_TYPE) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
49 if (DGifGetRecordType(gif, &type) == GIF_ERROR) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
50 PrintGifError();
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
51 return 0; // oops
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
52 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
53 if (type == TERMINATE_RECORD_TYPE)
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
54 return 0; // eof
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
55 if (type == SCREEN_DESC_RECORD_TYPE) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
56 if (DGifGetScreenDesc(gif) == GIF_ERROR) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
57 PrintGifError();
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
58 return 0; // oops
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
59 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
60 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
61 if (type == EXTENSION_RECORD_TYPE) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
62 int code;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
63 unsigned char *p = NULL;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
64 if (DGifGetExtension(gif, &code, &p) == GIF_ERROR) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
65 PrintGifError();
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
66 return 0; // oops
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
67 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
68 if (code == 0xF9) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
69 int frametime = 0;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
70 if (p[0] == 4) // is the length correct?
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
71 frametime = (p[1] << 8) | p[2]; // set the time, centiseconds
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
72 current_pts += frametime;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
73 } else if ((code == 0xFE) && (verbose)) { // comment extension
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
74 // print iff verbose
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
75 printf("GIF comment: ");
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
76 while (p != NULL) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
77 int length = p[0];
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
78 char *comments = p + 1;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
79 comments[length] = 0;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
80 printf("%s", comments);
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
81 if (DGifGetExtensionNext(gif, &p) == GIF_ERROR) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
82 PrintGifError();
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
83 return 0; // oops
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
84 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
85 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
86 printf("\n");
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
87 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
88 while (p != NULL) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
89 if (DGifGetExtensionNext(gif, &p) == GIF_ERROR) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
90 PrintGifError();
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
91 return 0; // oops
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
92 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
93 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
94 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
95 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
96
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
97 if (DGifGetImageDesc(gif) == GIF_ERROR) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
98 PrintGifError();
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
99 return 0; // oops
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
100 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
101
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
102 len = gif->Image.Width * gif->Image.Height;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
103 dp = new_demux_packet(len);
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
104 buf = malloc(len);
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
105 memset(buf, 0, len);
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
106 memset(dp->buffer, 0, len);
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
107
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
108 if (DGifGetLine(gif, buf, len) == GIF_ERROR) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
109 PrintGifError();
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
110 return 0; // oops
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
111 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
112
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
113 effective_map = gif->Image.ColorMap;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
114 if (effective_map == NULL) effective_map = gif->SColorMap;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
115
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
116 {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
117 int y;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
118
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
119 // copy the pallete
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
120 for (y = 0; y < 256; y++) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
121 pallete[(y * 4) + 0] = effective_map->Colors[y].Blue;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
122 pallete[(y * 4) + 1] = effective_map->Colors[y].Green;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
123 pallete[(y * 4) + 2] = effective_map->Colors[y].Red;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
124 pallete[(y * 4) + 3] = 0;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
125 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
126
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
127 for (y = 0; y < gif->Image.Height; y++) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
128 unsigned char *drow = dp->buffer;
9344
bd7b5078475e 1) codecs.conf changed recently and demux_gif no longer needs to spit
arpi
parents: 9133
diff changeset
129 unsigned char *gbuf = buf + (y * gif->Image.Width);
9133
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
130
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
131 drow += gif->Image.Width * (y + gif->Image.Top);
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
132 drow += gif->Image.Left;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
133
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
134 memcpy(drow, gbuf, gif->Image.Width);
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
135 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
136 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
137
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
138 free(buf);
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
139
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
140 demuxer->video->dpos++;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
141 dp->pts = ((float)current_pts) / 100;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
142 dp->pos = stream_tell(demuxer->stream);
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
143 ds_add_packet(demuxer->video, dp);
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
144
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
145 return 1;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
146 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
147
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
148 static demuxer_t* demux_open_gif(demuxer_t* demuxer)
9133
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
149 {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
150 sh_video_t *sh_video = NULL;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
151 GifFileType *gif = NULL;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
152
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
153 current_pts = 0;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
154 demuxer->seekable = 0; // FIXME
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
155
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
156 // go back to the beginning
9345
fef4f1a9de5e compile fix
henry
parents: 9344
diff changeset
157 stream_seek(demuxer->stream,demuxer->stream->start_pos);
9133
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
158
9463
93375ee56629 gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents: 9345
diff changeset
159 #ifdef HAVE_GIF_TVT_HACK
93375ee56629 gif library incompatibility fixes and prefere libungif over libgif. Patch by Joey Parrish <joey@nicewarrior.org>
alex
parents: 9345
diff changeset
160 // 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
161 // 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
162 // 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
163 // 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
164 // 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
165 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
166 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
167 #else
9344
bd7b5078475e 1) codecs.conf changed recently and demux_gif no longer needs to spit
arpi
parents: 9133
diff changeset
168 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
169 #endif
9133
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
170 if (!gif) {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
171 PrintGifError();
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
172 return NULL;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
173 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
174
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
175 // create a new video stream header
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
176 sh_video = new_sh_video(demuxer, 0);
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
177
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
178 // make sure the demuxer knows about the new video stream header
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
179 // (even though new_sh_video() ought to take care of it)
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
180 demuxer->video->sh = sh_video;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
181
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
182 // make sure that the video demuxer stream header knows about its
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
183 // parent video demuxer stream (this is getting wacky), or else
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
184 // video_read_properties() will choke
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
185 sh_video->ds = demuxer->video;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
186
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
187 sh_video->disp_w = gif->SWidth;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
188 sh_video->disp_h = gif->SHeight;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
189
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
190 sh_video->format = mmioFOURCC(8, 'R', 'G', 'B');
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
191
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
192 sh_video->fps = 5.0f;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
193 sh_video->frametime = 1.0f / sh_video->fps;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
194
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
195 sh_video->bih = malloc(sizeof(BITMAPINFOHEADER) + (256 * 4));
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
196 sh_video->bih->biCompression = sh_video->format;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
197 sh_video->bih->biBitCount = 8;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
198 sh_video->bih->biPlanes = 2;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
199 pallete = (unsigned char *)(sh_video->bih + 1);
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
200
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
201 demuxer->priv = gif;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
202
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
203 return demuxer;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
204 }
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
205
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
206 static void demux_close_gif(demuxer_t* demuxer)
9133
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
207 {
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
208 GifFileType *gif = (GifFileType *)demuxer->priv;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
209
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
210 if(!gif)
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
211 return;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
212
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
213 if (DGifCloseFile(gif) == GIF_ERROR)
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
214 PrintGifError();
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
215
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
216 demuxer->stream->fd = 0;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
217 demuxer->priv = NULL;
a45282d6ad32 argh, i forgot to 'cvs add' it (again)
arpi
parents:
diff changeset
218 }
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
219
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
220
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
221 demuxer_desc_t demuxer_desc_gif = {
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
222 "GIF demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
223 "gif",
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
224 "GIF",
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
225 "Joey Parrish",
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
226 "",
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
227 DEMUXER_TYPE_GIF,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
228 0, // unsafe autodetect
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
229 gif_check_file,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
230 demux_gif_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
231 demux_open_gif,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
232 demux_close_gif,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
233 NULL,
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
234 NULL
6b86089c2edd Demuxer modularization
rtognimp
parents: 9463
diff changeset
235 };