Commit a059da12 authored by Fabrice Bellard's avatar Fabrice Bellard

transparency support

Originally committed as revision 1808 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 7e2e1abf
...@@ -94,6 +94,7 @@ static int gif_video_probe(AVProbeData * pd) ...@@ -94,6 +94,7 @@ static int gif_video_probe(AVProbeData * pd)
{ {
const uint8_t *p, *p_end; const uint8_t *p, *p_end;
int bits_per_pixel, has_global_palette, ext_code, ext_len; int bits_per_pixel, has_global_palette, ext_code, ext_len;
int gce_flags, gce_disposal;
if (pd->buf_size < 24 || if (pd->buf_size < 24 ||
memcmp(pd->buf, gif89a_sig, 6) != 0) memcmp(pd->buf, gif89a_sig, 6) != 0)
...@@ -114,16 +115,28 @@ static int gif_video_probe(AVProbeData * pd) ...@@ -114,16 +115,28 @@ static int gif_video_probe(AVProbeData * pd)
if (p >= p_end) if (p >= p_end)
return 0; return 0;
ext_code = *p++; ext_code = *p++;
/* if GCE extension found: it is likely to be an animation */
if (ext_code == 0xf9)
return AVPROBE_SCORE_MAX;
for(;;) {
if (p >= p_end) if (p >= p_end)
return 0; return 0;
ext_len = *p++; ext_len = *p++;
if (ext_code == 0xf9) {
if (p >= p_end)
return 0;
/* if GCE extension found with gce_disposal != 0: it is
likely to be an animation */
gce_flags = *p++;
gce_disposal = (gce_flags >> 2) & 0x7;
if (gce_disposal != 0)
return AVPROBE_SCORE_MAX;
else
return 0;
}
for(;;) {
if (ext_len == 0) if (ext_len == 0)
break; break;
p += ext_len; p += ext_len;
if (p >= p_end)
return 0;
ext_len = *p++;
} }
} }
return 0; return 0;
...@@ -320,6 +333,9 @@ static int gif_read_image(GifState *s) ...@@ -320,6 +333,9 @@ static int gif_read_image(GifState *s)
} }
for(; i < 256; i++) for(; i < 256; i++)
s->image_palette[i] = (0xff << 24); s->image_palette[i] = (0xff << 24);
/* handle transparency */
if (s->transparent_color_index >= 0)
s->image_palette[s->transparent_color_index] = 0;
line = NULL; line = NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment