2024.02.05 19:49 "[Tiff] error reading linearRaw subIFD from a TIFF file with libtiff built with libjpeg-turbo?", by Ellen Johnson

2024.02.05 21:18 "Re: [Tiff] error reading linearRaw subIFD from a TIFF file with libtiff built with libjpeg-turbo?", by Ellen Johnson

Hi Bob,

Thanks for the quick response!

We're building libtiff v4.6.0 with libjpeg-turbo v3.0.0. In fact, we worked extensively with the libjpeg-turbo maintainer to enable lossless support for 8-, 12-, and 16-bit images. And I modified our JPEG source code to work with the new jpeg12_read_scanlines, jpeg16_read_scanlines, etc. functions in libjpeg-turbo.

A few things to note that might be clues:

  1. Previously in our libjpeg v6b, we had heavily patched it with Ken Murchison's lossless patch to enable lossless support. But by working with the libjpeg-turbo maintainer to enable lossless support in libjpeg-turbo, we're now able to use libjpeg-turbo in place of our heavily patched libjpeg v6b. And because libjpeg-turbo allows run-time bit depth selection, we're able to use the same libjpeg-turbo library for the three bit-depths (instead of compiling it into three different bit-depth-specific libraries).
  2. I didn't do anything special when configuring libtiff v4.6.0 to build with libjpeg-turbo, other than to make sure I saw the "dual mode" configuration specification – if I remember correctly when I built libtiff v4.6.0, when it looked for libjpeg-turbo it made sure some dual mode configuration was set to enable 8- and 12-bit modes. Is there a config setting I might have missed that enables working with 16-bit images?
  3. I'm also now building libtiff dynamically with libjpeg-turbo (instead of the previous static linking with libjpeg v6.b).
  4. In our MATLAB imread test that's failing with the TIFF file that has the "linearRaw" subIFD, there's a note that even with libtiff built with libjpeg v6b, it was only able to decode the first 10 tiles of the linearRaw subIFD – for the rest of the tiles, it was returning uninitialized memory. Unfortunately the developer who wrote that test is out of office and I don't know the backstory on where that TIFF file came from, or why libtiff built with libjpeg v6b was only able to decode the first 10 tiles of the subIFD.

If you think of anything or if i missed a libtiff config setting for reading 16-bit images, please let me know. I'm really puzzled as to what's going on. I'm also reaching out to the libjpeg-turbo maintainer for help with this.

Thank you!

ellen