comparison libmpdemux/demux_gif.c @ 9344:bd7b5078475e

1) codecs.conf changed recently and demux_gif no longer needs to spit out BGR8 upside-down. the workaround for this is removed. 2) fixes a bug so that streaming gifs now works, and removes a workaround no longer needed. now libgif uses mplayer's stream_read function and thus http streaming, etc, works with demux_gif. 3) cosmetic clean-up because i no longer plan to support certain GIF extensions that would be more difficult to implement. patch by Joey Parrish <joey@nicewarrior.org>
author arpi
date Sat, 08 Feb 2003 15:49:03 +0000
parents a45282d6ad32
children fef4f1a9de5e
comparison
equal deleted inserted replaced
9343:5ac2ce9c0462 9344:bd7b5078475e
22 static int current_pts = 0; 22 static int current_pts = 0;
23 static unsigned char *pallete = NULL; 23 static unsigned char *pallete = NULL;
24 24
25 #define GIF_SIGNATURE (('G' << 16) | ('I' << 8) | 'F') 25 #define GIF_SIGNATURE (('G' << 16) | ('I' << 8) | 'F')
26 26
27 int my_read_gif(GifFileType *gif, uint8_t *buf, int len) {
28 return stream_read(gif->UserData, buf, len);
29 }
30
27 int gif_check_file(demuxer_t *demuxer) 31 int gif_check_file(demuxer_t *demuxer)
28 { 32 {
29 stream_reset(demuxer->stream);
30 stream_seek(demuxer->stream, 0);
31 if (stream_read_int24(demuxer->stream) == GIF_SIGNATURE) 33 if (stream_read_int24(demuxer->stream) == GIF_SIGNATURE)
32 return 1; 34 return 1;
33 return 0; 35 return 0;
34 } 36 }
35 37
80 PrintGifError(); 82 PrintGifError();
81 return 0; // oops 83 return 0; // oops
82 } 84 }
83 } 85 }
84 printf("\n"); 86 printf("\n");
85 // FIXME support these:
86 } else if (code == 0x01) { // plaintext extension
87 } else if (code == 0xFF) { // application extension
88 } 87 }
89 while (p != NULL) { 88 while (p != NULL) {
90 if (DGifGetExtensionNext(gif, &p) == GIF_ERROR) { 89 if (DGifGetExtensionNext(gif, &p) == GIF_ERROR) {
91 PrintGifError(); 90 PrintGifError();
92 return 0; // oops 91 return 0; // oops
125 pallete[(y * 4) + 3] = 0; 124 pallete[(y * 4) + 3] = 0;
126 } 125 }
127 126
128 for (y = 0; y < gif->Image.Height; y++) { 127 for (y = 0; y < gif->Image.Height; y++) {
129 unsigned char *drow = dp->buffer; 128 unsigned char *drow = dp->buffer;
130 int x = gif->Image.Height - y - 1; // BGR8 is flipped 129 unsigned char *gbuf = buf + (y * gif->Image.Width);
131 unsigned char *gbuf = buf + (x * gif->Image.Width);
132 130
133 drow += gif->Image.Width * (y + gif->Image.Top); 131 drow += gif->Image.Width * (y + gif->Image.Top);
134 drow += gif->Image.Left; 132 drow += gif->Image.Left;
135 133
136 memcpy(drow, gbuf, gif->Image.Width); 134 memcpy(drow, gbuf, gif->Image.Width);
154 152
155 current_pts = 0; 153 current_pts = 0;
156 demuxer->seekable = 0; // FIXME 154 demuxer->seekable = 0; // FIXME
157 155
158 // go back to the beginning 156 // go back to the beginning
159 stream_reset(demuxer->stream); 157 stream_seek(stream,stream->start_pos);
160 stream_seek(demuxer->stream, 0); 158
161 lseek(demuxer->stream->fd, 0, SEEK_SET); 159 gif = DGifOpen(demuxer->stream, my_read_gif);
162
163 gif = DGifOpenFileHandle(demuxer->stream->fd);
164 if (!gif) { 160 if (!gif) {
165 PrintGifError(); 161 PrintGifError();
166 return NULL; 162 return NULL;
167 } 163 }
168 164