[FFmpeg-devel] [PATCH]Animated gif transparency

Carl Eugen Hoyos cehoyos at ag.or.at
Fri Dec 21 19:20:11 CET 2012


On Friday 21 December 2012 06:27:31 pm Paul B Mahol wrote:
> >> as it is worse with it than without it.
> >
> > I disagree but it is honestly not that important.
>
> Well with it I get black rectangles for gifs that
> use disposals, dont you have same with ImageMagick?

LOL, I didn't even think of testing with ImageMagick 
that basically has the same problem as my original 
patch.

New patch attached. (Pure guessing!)

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
index 4f44fd4..a24c946 100644
--- a/libavcodec/gifdec.c
+++ b/libavcodec/gifdec.c
@@ -241,8 +241,12 @@ static int gif_read_image(GifState *s)
         pr = ptr + width;
 
         for (px = ptr, idx = s->idx_line; px < pr; px++, idx++) {
-            if (*idx != s->transparent_color_index)
-                *px = pal[*idx];
+            if (s->gce_prev_disposal != GCE_DISPOSAL_INPLACE ||
+                *idx != s->transparent_color_index)
+            *px = pal[*idx];
+            if (s->gce_prev_disposal != GCE_DISPOSAL_INPLACE &&
+                *idx == s->transparent_color_index)
+                *px &= 0xFFFFFF;
         }
 
         if (is_interleaved) {


More information about the ffmpeg-devel mailing list