summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2003-04-21 21:18:51 +0000
committerFabrice Bellard <fabrice@bellard.org>2003-04-21 21:18:51 +0000
commita059da1227aa2ae12e2d417469243629b9edd01c (patch)
treeb1fce46188737693a2b2dd541049e030dda61c36 /libavformat
parent7e2e1abf6b239f5d304dd42f5078498b68914667 (diff)
transparency support
Originally committed as revision 1808 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/gifdec.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/libavformat/gifdec.c b/libavformat/gifdec.c
index 0ee59bc5f3..8c31869efc 100644
--- a/libavformat/gifdec.c
+++ b/libavformat/gifdec.c
@@ -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;
}