[FFmpeg-devel] [PATCH]Fix tiff grayscale palette

Michael Niedermayer michaelni at gmx.at
Mon Sep 5 18:25:37 CEST 2011


On Mon, Sep 05, 2011 at 03:03:13PM +0000, Carl Eugen Hoyos wrote:
> Michael Niedermayer <michaelni <at> gmx.at> writes:
> 
> > > +++ b/libavcodec/tiff.c
> > > @@ -294,8 +294,8 @@ static int init_image(TiffContext *s)
> > >  } else {
> > >      /* make default grayscale pal */
> > >      pal = (uint32_t *) s->picture.data[1];
> > > -    for (i = 0; i < 256; i++)
> > > -        pal[i] = i * 0x010101;
> > > +    for (i = 0; i < 1<<s->bpp; i++)
> > > +        pal[256 - (1<<s->bpp) + i] = i * 255 / ((1<<s->bpp) - 1) * 0x010101;
> > 
> > filling the top only looks a bit strange why is it not
> > pal[0..(1<<bpp)] ?
> 
> That doesn't work / shows wrong colours because TIFF_INVERT triggers "src[i] =
> 255 - src[i]" in the decode function.
> 
> Should the palette be filled from both ends?
> Or is there a better solution?

invert (1<<bpp-1) - src[i] instead of 255 - src[i]
or apply the invert to the palette and never invert the pixels
should work

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110905/2fdc8953/attachment.asc>


More information about the ffmpeg-devel mailing list