[FFmpeg-cvslog] tiff: Improve grayscale support

Diego Elio Pettenò git at videolan.org
Sun Aug 10 18:47:39 CEST 2014


ffmpeg | branch: master | Diego Elio Pettenò <flameeyes at flameeyes.eu> | Sat Aug  9 14:19:45 2014 +0100| [2597a842a0a2c7e8aa76f32733d27bf64817ae86] | committer: Luca Barbato

tiff: Improve grayscale support

Only use PAL8 if palette is present, else use GRAY8 for pixfmt.

Instead of simulating a grayscale palette, use real grayscale pixels, if no
palette is actually defined.

Signed-off-by: Diego Elio Pettenò <flameeyes at flameeyes.eu>
Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2597a842a0a2c7e8aa76f32733d27bf64817ae86
---

 libavcodec/tiff.c |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 2aff45a..ca5ec75 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -246,15 +246,14 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
 
 static int init_image(TiffContext *s, AVFrame *frame)
 {
-    int i, ret;
-    uint32_t *pal;
+    int ret;
 
     switch (s->bpp * 10 + s->bppcount) {
     case 11:
         s->avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
         break;
     case 81:
-        s->avctx->pix_fmt = AV_PIX_FMT_PAL8;
+        s->avctx->pix_fmt = s->palette_is_set ? AV_PIX_FMT_PAL8 : AV_PIX_FMT_GRAY8;
         break;
     case 243:
         s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
@@ -290,14 +289,7 @@ static int init_image(TiffContext *s, AVFrame *frame)
         return ret;
     }
     if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8) {
-        if (s->palette_is_set) {
-            memcpy(frame->data[1], s->palette, sizeof(s->palette));
-        } else {
-            /* make default grayscale pal */
-            pal = (uint32_t *) frame->data[1];
-            for (i = 0; i < 256; i++)
-                pal[i] = i * 0x010101;
-        }
+        memcpy(frame->data[1], s->palette, sizeof(s->palette));
     }
     return 0;
 }



More information about the ffmpeg-cvslog mailing list