annotate src/ffmpeg/libavformat/gifdec.c @ 828:c294c4700937 trunk

[svn] - more stuff to kill
author nenolod
date Mon, 12 Mar 2007 15:05:25 -0700
parents e8776388b02a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
808
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
1 /*
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
2 * GIF decoder
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
3 * Copyright (c) 2003 Fabrice Bellard.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
4 *
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
5 * This file is part of FFmpeg.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
6 *
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
11 *
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
15 * Lesser General Public License for more details.
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
16 *
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
20 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
21 #include "avformat.h"
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
22
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
23 int gif_write(ByteIOContext *pb, AVImageInfo *info);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
24
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
25 //#define DEBUG
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
26
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
27 #define MAXBITS 12
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
28 #define SIZTABLE (1<<MAXBITS)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
29
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
30 #define GCE_DISPOSAL_NONE 0
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
31 #define GCE_DISPOSAL_INPLACE 1
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
32 #define GCE_DISPOSAL_BACKGROUND 2
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
33 #define GCE_DISPOSAL_RESTORE 3
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
34
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
35 typedef struct GifState {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
36 int screen_width;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
37 int screen_height;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
38 int bits_per_pixel;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
39 int background_color_index;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
40 int transparent_color_index;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
41 int color_resolution;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
42 uint8_t *image_buf;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
43 int image_linesize;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
44 uint32_t *image_palette;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
45 int pix_fmt;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
46
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
47 /* after the frame is displayed, the disposal method is used */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
48 int gce_disposal;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
49 /* delay during which the frame is shown */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
50 int gce_delay;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
51
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
52 /* LZW compatible decoder */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
53 ByteIOContext *f;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
54 int eob_reached;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
55 uint8_t *pbuf, *ebuf;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
56 int bbits;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
57 unsigned int bbuf;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
58
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
59 int cursize; /* The current code size */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
60 int curmask;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
61 int codesize;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
62 int clear_code;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
63 int end_code;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
64 int newcodes; /* First available code */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
65 int top_slot; /* Highest code for current size */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
66 int slot; /* Last read code */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
67 int fc, oc;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
68 uint8_t *sp;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
69 uint8_t stack[SIZTABLE];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
70 uint8_t suffix[SIZTABLE];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
71 uint16_t prefix[SIZTABLE];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
72
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
73 /* aux buffers */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
74 uint8_t global_palette[256 * 3];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
75 uint8_t local_palette[256 * 3];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
76 uint8_t buf[256];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
77 } GifState;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
78
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
79
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
80 static const uint8_t gif87a_sig[6] = "GIF87a";
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
81 static const uint8_t gif89a_sig[6] = "GIF89a";
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
82
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
83 static const uint16_t mask[17] =
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
84 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
85 0x0000, 0x0001, 0x0003, 0x0007,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
86 0x000F, 0x001F, 0x003F, 0x007F,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
87 0x00FF, 0x01FF, 0x03FF, 0x07FF,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
88 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
89 };
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
90
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
91 /* Probe gif video format or gif image format. The current heuristic
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
92 supposes the gif87a is always a single image. For gif89a, we
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
93 consider it as a video only if a GCE extension is present in the
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
94 first kilobyte. */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
95 static int gif_video_probe(AVProbeData * pd)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
96 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
97 const uint8_t *p, *p_end;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
98 int bits_per_pixel, has_global_palette, ext_code, ext_len;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
99 int gce_flags, gce_disposal;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
100
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
101 if (pd->buf_size < 24 ||
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
102 memcmp(pd->buf, gif89a_sig, 6) != 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
103 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
104 p_end = pd->buf + pd->buf_size;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
105 p = pd->buf + 6;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
106 bits_per_pixel = (p[4] & 0x07) + 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
107 has_global_palette = (p[4] & 0x80);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
108 p += 7;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
109 if (has_global_palette)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
110 p += (1 << bits_per_pixel) * 3;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
111 for(;;) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
112 if (p >= p_end)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
113 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
114 if (*p != '!')
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
115 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
116 p++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
117 if (p >= p_end)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
118 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
119 ext_code = *p++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
120 if (p >= p_end)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
121 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
122 ext_len = *p++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
123 if (ext_code == 0xf9) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
124 if (p >= p_end)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
125 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
126 /* if GCE extension found with gce_disposal != 0: it is
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
127 likely to be an animation */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
128 gce_flags = *p++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
129 gce_disposal = (gce_flags >> 2) & 0x7;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
130 if (gce_disposal != 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
131 return AVPROBE_SCORE_MAX;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
132 else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
133 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
134 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
135 for(;;) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
136 if (ext_len == 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
137 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
138 p += ext_len;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
139 if (p >= p_end)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
140 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
141 ext_len = *p++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
142 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
143 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
144 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
145 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
146
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
147 static int gif_image_probe(AVProbeData * pd)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
148 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
149 if (pd->buf_size >= 24 &&
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
150 (memcmp(pd->buf, gif87a_sig, 6) == 0 ||
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
151 memcmp(pd->buf, gif89a_sig, 6) == 0))
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
152 return AVPROBE_SCORE_MAX - 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
153 else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
154 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
155 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
156
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
157
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
158 static void GLZWDecodeInit(GifState * s, int csize)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
159 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
160 /* read buffer */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
161 s->eob_reached = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
162 s->pbuf = s->buf;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
163 s->ebuf = s->buf;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
164 s->bbuf = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
165 s->bbits = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
166
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
167 /* decoder */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
168 s->codesize = csize;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
169 s->cursize = s->codesize + 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
170 s->curmask = mask[s->cursize];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
171 s->top_slot = 1 << s->cursize;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
172 s->clear_code = 1 << s->codesize;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
173 s->end_code = s->clear_code + 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
174 s->slot = s->newcodes = s->clear_code + 2;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
175 s->oc = s->fc = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
176 s->sp = s->stack;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
177 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
178
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
179 /* XXX: optimize */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
180 static inline int GetCode(GifState * s)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
181 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
182 int c, sizbuf;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
183 uint8_t *ptr;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
184
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
185 while (s->bbits < s->cursize) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
186 ptr = s->pbuf;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
187 if (ptr >= s->ebuf) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
188 if (!s->eob_reached) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
189 sizbuf = get_byte(s->f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
190 s->ebuf = s->buf + sizbuf;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
191 s->pbuf = s->buf;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
192 if (sizbuf > 0) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
193 get_buffer(s->f, s->buf, sizbuf);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
194 } else {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
195 s->eob_reached = 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
196 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
197 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
198 ptr = s->pbuf;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
199 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
200 s->bbuf |= ptr[0] << s->bbits;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
201 ptr++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
202 s->pbuf = ptr;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
203 s->bbits += 8;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
204 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
205 c = s->bbuf & s->curmask;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
206 s->bbuf >>= s->cursize;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
207 s->bbits -= s->cursize;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
208 return c;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
209 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
210
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
211 /* NOTE: the algorithm here is inspired from the LZW GIF decoder
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
212 written by Steven A. Bennett in 1987. */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
213 /* return the number of byte decoded */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
214 static int GLZWDecode(GifState * s, uint8_t * buf, int len)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
215 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
216 int l, c, code, oc, fc;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
217 uint8_t *sp;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
218
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
219 if (s->end_code < 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
220 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
221
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
222 l = len;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
223 sp = s->sp;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
224 oc = s->oc;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
225 fc = s->fc;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
226
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
227 while (sp > s->stack) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
228 *buf++ = *(--sp);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
229 if ((--l) == 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
230 goto the_end;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
231 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
232
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
233 for (;;) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
234 c = GetCode(s);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
235 if (c == s->end_code) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
236 s->end_code = -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
237 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
238 } else if (c == s->clear_code) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
239 s->cursize = s->codesize + 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
240 s->curmask = mask[s->cursize];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
241 s->slot = s->newcodes;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
242 s->top_slot = 1 << s->cursize;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
243 while ((c = GetCode(s)) == s->clear_code);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
244 if (c == s->end_code) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
245 s->end_code = -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
246 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
247 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
248 /* test error */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
249 if (c >= s->slot)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
250 c = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
251 fc = oc = c;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
252 *buf++ = c;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
253 if ((--l) == 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
254 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
255 } else {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
256 code = c;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
257 if (code >= s->slot) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
258 *sp++ = fc;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
259 code = oc;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
260 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
261 while (code >= s->newcodes) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
262 *sp++ = s->suffix[code];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
263 code = s->prefix[code];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
264 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
265 *sp++ = code;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
266 if (s->slot < s->top_slot) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
267 s->suffix[s->slot] = fc = code;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
268 s->prefix[s->slot++] = oc;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
269 oc = c;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
270 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
271 if (s->slot >= s->top_slot) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
272 if (s->cursize < MAXBITS) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
273 s->top_slot <<= 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
274 s->curmask = mask[++s->cursize];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
275 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
276 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
277 while (sp > s->stack) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
278 *buf++ = *(--sp);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
279 if ((--l) == 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
280 goto the_end;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
281 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
282 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
283 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
284 the_end:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
285 s->sp = sp;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
286 s->oc = oc;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
287 s->fc = fc;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
288 return len - l;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
289 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
290
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
291 static int gif_read_image(GifState *s)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
292 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
293 ByteIOContext *f = s->f;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
294 int left, top, width, height, bits_per_pixel, code_size, flags;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
295 int is_interleaved, has_local_palette, y, x, pass, y1, linesize, n, i;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
296 uint8_t *ptr, *line, *d, *spal, *palette, *sptr, *ptr1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
297
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
298 left = get_le16(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
299 top = get_le16(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
300 width = get_le16(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
301 height = get_le16(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
302 flags = get_byte(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
303 is_interleaved = flags & 0x40;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
304 has_local_palette = flags & 0x80;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
305 bits_per_pixel = (flags & 0x07) + 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
306 #ifdef DEBUG
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
307 printf("gif: image x=%d y=%d w=%d h=%d\n", left, top, width, height);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
308 #endif
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
309
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
310 if (has_local_palette) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
311 get_buffer(f, s->local_palette, 3 * (1 << bits_per_pixel));
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
312 palette = s->local_palette;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
313 } else {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
314 palette = s->global_palette;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
315 bits_per_pixel = s->bits_per_pixel;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
316 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
317
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
318 /* verify that all the image is inside the screen dimensions */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
319 if (left + width > s->screen_width ||
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
320 top + height > s->screen_height)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
321 return -EINVAL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
322
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
323 /* build the palette */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
324 if (s->pix_fmt == PIX_FMT_RGB24) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
325 line = av_malloc(width);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
326 if (!line)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
327 return -ENOMEM;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
328 } else {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
329 n = (1 << bits_per_pixel);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
330 spal = palette;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
331 for(i = 0; i < n; i++) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
332 s->image_palette[i] = (0xff << 24) |
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
333 (spal[0] << 16) | (spal[1] << 8) | (spal[2]);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
334 spal += 3;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
335 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
336 for(; i < 256; i++)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
337 s->image_palette[i] = (0xff << 24);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
338 /* handle transparency */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
339 if (s->transparent_color_index >= 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
340 s->image_palette[s->transparent_color_index] = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
341 line = NULL;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
342 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
343
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
344 /* now get the image data */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
345 s->f = f;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
346 code_size = get_byte(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
347 GLZWDecodeInit(s, code_size);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
348
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
349 /* read all the image */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
350 linesize = s->image_linesize;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
351 ptr1 = s->image_buf + top * linesize + (left * 3);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
352 ptr = ptr1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
353 pass = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
354 y1 = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
355 for (y = 0; y < height; y++) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
356 if (s->pix_fmt == PIX_FMT_RGB24) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
357 /* transcode to RGB24 */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
358 GLZWDecode(s, line, width);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
359 d = ptr;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
360 sptr = line;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
361 for(x = 0; x < width; x++) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
362 spal = palette + sptr[0] * 3;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
363 d[0] = spal[0];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
364 d[1] = spal[1];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
365 d[2] = spal[2];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
366 d += 3;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
367 sptr++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
368 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
369 } else {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
370 GLZWDecode(s, ptr, width);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
371 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
372 if (is_interleaved) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
373 switch(pass) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
374 default:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
375 case 0:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
376 case 1:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
377 y1 += 8;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
378 ptr += linesize * 8;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
379 if (y1 >= height) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
380 y1 = 4;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
381 if (pass == 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
382 ptr = ptr1 + linesize * 4;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
383 else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
384 ptr = ptr1 + linesize * 2;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
385 pass++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
386 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
387 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
388 case 2:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
389 y1 += 4;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
390 ptr += linesize * 4;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
391 if (y1 >= height) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
392 y1 = 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
393 ptr = ptr1 + linesize;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
394 pass++;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
395 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
396 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
397 case 3:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
398 y1 += 2;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
399 ptr += linesize * 2;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
400 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
401 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
402 } else {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
403 ptr += linesize;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
404 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
405 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
406 av_free(line);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
407
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
408 /* read the garbage data until end marker is found */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
409 while (!s->eob_reached)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
410 GetCode(s);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
411 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
412 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
413
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
414 static int gif_read_extension(GifState *s)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
415 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
416 ByteIOContext *f = s->f;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
417 int ext_code, ext_len, i, gce_flags, gce_transparent_index;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
418
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
419 /* extension */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
420 ext_code = get_byte(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
421 ext_len = get_byte(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
422 #ifdef DEBUG
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
423 printf("gif: ext_code=0x%x len=%d\n", ext_code, ext_len);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
424 #endif
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
425 switch(ext_code) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
426 case 0xf9:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
427 if (ext_len != 4)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
428 goto discard_ext;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
429 s->transparent_color_index = -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
430 gce_flags = get_byte(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
431 s->gce_delay = get_le16(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
432 gce_transparent_index = get_byte(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
433 if (gce_flags & 0x01)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
434 s->transparent_color_index = gce_transparent_index;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
435 else
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
436 s->transparent_color_index = -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
437 s->gce_disposal = (gce_flags >> 2) & 0x7;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
438 #ifdef DEBUG
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
439 printf("gif: gce_flags=%x delay=%d tcolor=%d disposal=%d\n",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
440 gce_flags, s->gce_delay,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
441 s->transparent_color_index, s->gce_disposal);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
442 #endif
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
443 ext_len = get_byte(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
444 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
445 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
446
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
447 /* NOTE: many extension blocks can come after */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
448 discard_ext:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
449 while (ext_len != 0) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
450 for (i = 0; i < ext_len; i++)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
451 get_byte(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
452 ext_len = get_byte(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
453 #ifdef DEBUG
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
454 printf("gif: ext_len1=%d\n", ext_len);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
455 #endif
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
456 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
457 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
458 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
459
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
460 static int gif_read_header1(GifState *s)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
461 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
462 ByteIOContext *f = s->f;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
463 uint8_t sig[6];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
464 int ret, v, n;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
465 int has_global_palette;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
466
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
467 /* read gif signature */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
468 ret = get_buffer(f, sig, 6);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
469 if (ret != 6)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
470 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
471 if (memcmp(sig, gif87a_sig, 6) != 0 &&
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
472 memcmp(sig, gif89a_sig, 6) != 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
473 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
474
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
475 /* read screen header */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
476 s->transparent_color_index = -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
477 s->screen_width = get_le16(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
478 s->screen_height = get_le16(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
479 if( (unsigned)s->screen_width > 32767
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
480 || (unsigned)s->screen_height > 32767){
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
481 av_log(NULL, AV_LOG_ERROR, "picture size too large\n");
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
482 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
483 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
484
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
485 v = get_byte(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
486 s->color_resolution = ((v & 0x70) >> 4) + 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
487 has_global_palette = (v & 0x80);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
488 s->bits_per_pixel = (v & 0x07) + 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
489 s->background_color_index = get_byte(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
490 get_byte(f); /* ignored */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
491 #ifdef DEBUG
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
492 printf("gif: screen_w=%d screen_h=%d bpp=%d global_palette=%d\n",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
493 s->screen_width, s->screen_height, s->bits_per_pixel,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
494 has_global_palette);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
495 #endif
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
496 if (has_global_palette) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
497 n = 1 << s->bits_per_pixel;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
498 get_buffer(f, s->global_palette, n * 3);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
499 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
500 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
501 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
502
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
503 static int gif_parse_next_image(GifState *s)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
504 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
505 ByteIOContext *f = s->f;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
506 int ret, code;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
507
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
508 for (;;) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
509 code = url_fgetc(f);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
510 #ifdef DEBUG
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
511 printf("gif: code=%02x '%c'\n", code, code);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
512 #endif
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
513 switch (code) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
514 case ',':
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
515 if (gif_read_image(s) < 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
516 return AVERROR_IO;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
517 ret = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
518 goto the_end;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
519 case ';':
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
520 /* end of image */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
521 ret = AVERROR_IO;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
522 goto the_end;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
523 case '!':
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
524 if (gif_read_extension(s) < 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
525 return AVERROR_IO;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
526 break;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
527 case EOF:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
528 default:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
529 /* error or errneous EOF */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
530 ret = AVERROR_IO;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
531 goto the_end;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
532 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
533 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
534 the_end:
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
535 return ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
536 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
537
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
538 static int gif_read_header(AVFormatContext * s1,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
539 AVFormatParameters * ap)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
540 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
541 GifState *s = s1->priv_data;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
542 ByteIOContext *f = &s1->pb;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
543 AVStream *st;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
544
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
545 s->f = f;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
546 if (gif_read_header1(s) < 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
547 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
548
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
549 /* allocate image buffer */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
550 s->image_linesize = s->screen_width * 3;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
551 s->image_buf = av_malloc(s->screen_height * s->image_linesize);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
552 if (!s->image_buf)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
553 return -ENOMEM;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
554 s->pix_fmt = PIX_FMT_RGB24;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
555 /* now we are ready: build format streams */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
556 st = av_new_stream(s1, 0);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
557 if (!st)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
558 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
559
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
560 st->codec->codec_type = CODEC_TYPE_VIDEO;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
561 st->codec->codec_id = CODEC_ID_RAWVIDEO;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
562 st->codec->time_base.den = 5;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
563 st->codec->time_base.num = 1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
564 /* XXX: check if screen size is always valid */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
565 st->codec->width = s->screen_width;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
566 st->codec->height = s->screen_height;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
567 st->codec->pix_fmt = PIX_FMT_RGB24;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
568 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
569 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
570
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
571 static int gif_read_packet(AVFormatContext * s1,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
572 AVPacket * pkt)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
573 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
574 GifState *s = s1->priv_data;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
575 int ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
576
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
577 ret = gif_parse_next_image(s);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
578 if (ret < 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
579 return ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
580
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
581 /* XXX: avoid copying */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
582 if (av_new_packet(pkt, s->screen_width * s->screen_height * 3)) {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
583 return AVERROR_IO;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
584 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
585 pkt->stream_index = 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
586 memcpy(pkt->data, s->image_buf, s->screen_width * s->screen_height * 3);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
587 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
588 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
589
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
590 static int gif_read_close(AVFormatContext *s1)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
591 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
592 GifState *s = s1->priv_data;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
593 av_free(s->image_buf);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
594 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
595 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
596
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
597 /* read gif as image */
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
598 static int gif_read(ByteIOContext *f,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
599 int (*alloc_cb)(void *opaque, AVImageInfo *info), void *opaque)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
600 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
601 GifState s1, *s = &s1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
602 AVImageInfo info1, *info = &info1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
603 int ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
604
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
605 memset(s, 0, sizeof(GifState));
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
606 s->f = f;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
607 if (gif_read_header1(s) < 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
608 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
609 info->width = s->screen_width;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
610 info->height = s->screen_height;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
611 info->pix_fmt = PIX_FMT_PAL8;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
612 ret = alloc_cb(opaque, info);
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
613 if (ret)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
614 return ret;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
615 s->image_buf = info->pict.data[0];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
616 s->image_linesize = info->pict.linesize[0];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
617 s->image_palette = (uint32_t *)info->pict.data[1];
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
618
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
619 if (gif_parse_next_image(s) < 0)
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
620 return -1;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
621 return 0;
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
622 }
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
623
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
624 AVInputFormat gif_demuxer =
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
625 {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
626 "gif",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
627 "gif format",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
628 sizeof(GifState),
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
629 gif_video_probe,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
630 gif_read_header,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
631 gif_read_packet,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
632 gif_read_close,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
633 };
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
634
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
635 AVImageFormat gif_image_format = {
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
636 "gif",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
637 "gif",
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
638 gif_image_probe,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
639 gif_read,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
640 (1 << PIX_FMT_PAL8),
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
641 #ifdef CONFIG_GIF_MUXER
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
642 gif_write,
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
643 #endif
e8776388b02a [svn] - add ffmpeg
nenolod
parents:
diff changeset
644 };