See patches.
>From dea58b6f978032253c263233ea0d4dec6215fe57 Mon Sep 17 00:00:00 2001
From: Stefano Sabatini <[email protected]>
Date: Tue, 24 May 2011 01:17:25 +0200
Subject: [PATCH] tiff: set palette in the context when specified in TIFF_PAL tag
Fix regression with palette data. Since image initialization has been
moved after tag parsing, palette need to be specified in the context,
and then copied to the allocated image in init_image().
In particular, fix trac issue #230, file Test_Flate_8bpp.tif.
---
libavcodec/tiff.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 683527b..0ecbac0 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -39,6 +39,8 @@ typedef struct TiffContext {
int width, height;
unsigned int bpp, bppcount;
+ uint32_t palette[256];
+ int palette_is_set;
int le;
enum TiffCompr compr;
int invert;
@@ -255,11 +257,15 @@ static int init_image(TiffContext *s)
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
- if (s->bpp == 8 && s->picture.data[1]){
+ if (s->avctx->pix_fmt == PIX_FMT_PAL8) {
+ if (s->palette_is_set) {
+ memcpy(s->picture.data[1], s->palette, sizeof(s->palette));
+ } else {
/* make default grayscale pal */
pal = (uint32_t *) s->picture.data[1];
for (i = 0; i < 256; i++)
pal[i] = i * 0x010101;
+ }
}
return 0;
}
@@ -442,11 +448,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
s->fill_order = value - 1;
break;
case TIFF_PAL:
- if(s->avctx->pix_fmt != PIX_FMT_PAL8){
- av_log(s->avctx, AV_LOG_ERROR, "Palette met but this is not palettized format\n");
- return -1;
- }
- pal = (uint32_t *) s->picture.data[1];
+ pal = (uint32_t *) s->palette;
off = type_sizes[type];
rp = buf;
gp = buf + count / 3 * off;
@@ -459,6 +461,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
j |= tget(&bp, type, s->le) >> off;
pal[i] = j;
}
+ s->palette_is_set = 1;
break;
case TIFF_PLANAR:
if(value == 2){
--
1.7.2.3
>From 0554de8eb6b5dc6c76019c8c5272e4e8cb7f021a Mon Sep 17 00:00:00 2001
From: Stefano Sabatini <[email protected]>
Date: Tue, 24 May 2011 01:19:53 +0200
Subject: [PATCH] tiff: reindent after previous commit
---
libavcodec/tiff.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 0ecbac0..c97cb94 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -261,10 +261,10 @@ static int init_image(TiffContext *s)
if (s->palette_is_set) {
memcpy(s->picture.data[1], s->palette, sizeof(s->palette));
} else {
- /* make default grayscale pal */
- pal = (uint32_t *) s->picture.data[1];
- for (i = 0; i < 256; i++)
- pal[i] = i * 0x010101;
+ /* make default grayscale pal */
+ pal = (uint32_t *) s->picture.data[1];
+ for (i = 0; i < 256; i++)
+ pal[i] = i * 0x010101;
}
}
return 0;
--
1.7.2.3
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel