[FFmpeg-devel] [PATCH]Fix some 1bpp tiff samples

Carl Eugen Hoyos cehoyos at ag.or.at
Sat Dec 31 16:52:35 CET 2011


On Saturday 31 December 2011 04:09:51 pm Michael Niedermayer wrote:
> On Sat, Dec 31, 2011 at 01:14:53PM +0000, Carl Eugen Hoyos wrote:
> > I will commit the third patch with fate changes if nobody objects.

Sorry for this nonsense...

> changing mono to pal8 when unneeded seems like a bad idea
> a 2000x1000 image changes from 250kb to 2mb

Of course, and thank you for the fix.

I believe attached (or similar) is still necessary for raw and packed, I only 
tested with forcing s->palette_is_set to 0.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index b353677..0ad8d97 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -224,7 +224,8 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
             if (ssrc + size - src < width)
                 return AVERROR_INVALIDDATA;
             if (!s->fill_order) {
-                horizontal_fill(s->bpp, dst, 1, src, 0, width, 0);
+                horizontal_fill(s->bpp * s->avctx->pix_fmt == PIX_FMT_PAL8,
+                                dst, 1, src, 0, width, 0);
             } else {
                 int i;
                 for (i = 0; i < width; i++)
@@ -241,7 +242,8 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
                         av_log(s->avctx, AV_LOG_ERROR, "Copy went out of bounds\n");
                         return -1;
                     }
-                    horizontal_fill(s->bpp, dst, 1, src, 0, code, pixels);
+                    horizontal_fill(s->bpp * s->avctx->pix_fmt == PIX_FMT_PAL8,
+                                    dst, 1, src, 0, code, pixels);
                     src += code;
                     pixels += code;
                 }else if(code != -128){ // -127..-1
@@ -251,7 +253,8 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
                         return -1;
                     }
                     c = *src++;
-                    horizontal_fill(s->bpp, dst, 0, NULL, c, code, pixels);
+                    horizontal_fill(s->bpp * s->avctx->pix_fmt == PIX_FMT_PAL8,
+                                    dst, 0, NULL, c, code, pixels);
                     pixels += code;
                 }
             }


More information about the ffmpeg-devel mailing list