2009.02.12 13:23 "[Tiff] Bug in tif_luv.c (and a fix)", by Ive

2009.02.12 13:23 "[Tiff] Bug in tif_luv.c (and a fix)", by Ive

This effects only Photometric LogLUV images that are tiled. I guess LogLUV was quite rarely used and all the example images from Greg Ward's side are in strips, but with the current HDRI hype I stumbled across a HDR LogLUV tiff that crashed my application.

So the bug may be there for quite some time, but it definitely is in tiff-4.0beta3 and tiff_3.9.0beta.

In tif_luv.c the functions LogL16InitState and LogLuvInitState contain the statement (at line 1250 & 1347)

sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip);

this should be replaced by

if (!(isTiled(tif)))
    sp->tbuflen = multiply(td->td_imagewidth, td->td_rowsperstrip);
    sp->tbuflen = multiply(td->td_tilewidth, td->td_tilelength);

and all works fine again.

Note that Greg Wards LogLUV code already contained correct functions to be glued with tiled images and tiled LogLUV images are absolutely valid. I can provide an example tiff that shows the bug if someone needs it.