[FFmpeg-devel] [PATCH]Fix png palette if input has a completely transparent colour

Carl Eugen Hoyos cehoyos at ag.or.at
Wed Dec 7 02:59:43 CET 2011


Hi!

Currently, no colour is set to transparent in the png encoder if the input has 
one completely transparent colour in the palette (alpha == 0).

Attached should fix that.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 29f4e1a..b35402e 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -336,7 +336,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
         for(i = 0; i < 256; i++) {
             v = palette[i];
             alpha = v >> 24;
-            if (alpha && alpha != 0xff)
+            if (alpha != 0xff)
                 has_alpha = 1;
             *alpha_ptr++ = alpha;
             bytestream_put_be24(&ptr, v);


More information about the ffmpeg-devel mailing list