transparency support

Originally committed as revision 1808 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Fabrice Bellard 2003-04-21 21:18:51 +00:00
parent 7e2e1abf6b
commit a059da1227

View File

@ -94,7 +94,8 @@ static int gif_video_probe(AVProbeData * pd)
{
const uint8_t *p, *p_end;
int bits_per_pixel, has_global_palette, ext_code, ext_len;
int gce_flags, gce_disposal;
if (pd->buf_size < 24 ||
memcmp(pd->buf, gif89a_sig, 6) != 0)
return 0;
@ -114,16 +115,28 @@ static int gif_video_probe(AVProbeData * pd)
if (p >= p_end)
return 0;
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)
return 0;
ext_len = *p++;
if (ext_code == 0xf9) {
if (p >= p_end)
return 0;
ext_len = *p++;
/* 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)
break;
p += ext_len;
if (p >= p_end)
return 0;
ext_len = *p++;
}
}
return 0;
@ -320,6 +333,9 @@ static int gif_read_image(GifState *s)
}
for(; i < 256; i++)
s->image_palette[i] = (0xff << 24);
/* handle transparency */
if (s->transparent_color_index >= 0)
s->image_palette[s->transparent_color_index] = 0;
line = NULL;
}