tiff: set palette in the context when specified in TIFF_PAL tag
Since image initialization was moved after tag parsing, the palette needs to be specified in the context and then copied to the allocated image in init_image(). Fixes a regression with TIFF images that have palette data, trac issue #230, file Test_Flate_8bpp.tif. Signed-off-by: Diego Biurrun <diego@biurrun.de>
This commit is contained in:
parent
4515f9b58a
commit
7ca5338b49
@ -41,6 +41,8 @@ typedef struct TiffContext {
|
|||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
unsigned int bpp, bppcount;
|
unsigned int bpp, bppcount;
|
||||||
|
uint32_t palette[256];
|
||||||
|
int palette_is_set;
|
||||||
int le;
|
int le;
|
||||||
enum TiffCompr compr;
|
enum TiffCompr compr;
|
||||||
int invert;
|
int invert;
|
||||||
@ -257,11 +259,15 @@ static int init_image(TiffContext *s)
|
|||||||
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if (s->bpp == 8 && s->picture.data[1]){
|
if (s->avctx->pix_fmt == PIX_FMT_PAL8) {
|
||||||
/* make default grayscale pal */
|
if (s->palette_is_set) {
|
||||||
pal = (uint32_t *) s->picture.data[1];
|
memcpy(s->picture.data[1], s->palette, sizeof(s->palette));
|
||||||
for (i = 0; i < 256; i++)
|
} else {
|
||||||
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;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -444,11 +450,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
|
|||||||
s->fill_order = value - 1;
|
s->fill_order = value - 1;
|
||||||
break;
|
break;
|
||||||
case TIFF_PAL:
|
case TIFF_PAL:
|
||||||
if(s->avctx->pix_fmt != PIX_FMT_PAL8){
|
pal = (uint32_t *) s->palette;
|
||||||
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];
|
|
||||||
off = type_sizes[type];
|
off = type_sizes[type];
|
||||||
rp = buf;
|
rp = buf;
|
||||||
gp = buf + count / 3 * off;
|
gp = buf + count / 3 * off;
|
||||||
@ -460,6 +462,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
|
|||||||
j |= tget(&bp, type, s->le) >> off;
|
j |= tget(&bp, type, s->le) >> off;
|
||||||
pal[i] = j;
|
pal[i] = j;
|
||||||
}
|
}
|
||||||
|
s->palette_is_set = 1;
|
||||||
break;
|
break;
|
||||||
case TIFF_PLANAR:
|
case TIFF_PLANAR:
|
||||||
if(value == 2){
|
if(value == 2){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user