AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2013.04.27 21:34 "[Tiff] Problem with TIFFReadEndcodeStrip()", by Steve McKinney
2013.04.28 01:22 "Re: [Tiff] Problem with TIFFReadEndcodeStrip()", by Bob Friesenhahn
2013.04.28 03:22 "Re: [Tiff] Problem with TIFFReadEndcodeStrip()", by Steve McKinney
2013.04.28 13:51 "Re: [Tiff] Problem with TIFFReadEndcodeStrip()", by Bob Friesenhahn
2013.04.28 06:37 "Re: [Tiff] Problem with TIFFReadEndcodeStrip()", by Steve McKinney

2013.04.28 03:22 "Re: [Tiff] Problem with TIFFReadEndcodeStrip()", by Steve McKinney

Bob,

Thanks for the response, and sorry if I was too terse. The TIFF in question was produced using the tiffcp tool with the '-c jpeg' option from a 24 BPP RGB source TIFF. It is indeed in YCbCr format (that's what tiffcp gave me by default). It does not appear to be subsampled. Here's some output from the tiffinfo tool:

TIFF Directory at offset 0x1a258 (107096)
    Image Width: 576 Image Length: 768
    Resolution: 96, 96 pixels/inch
    Bits/Sample: 8
    Compression Scheme: JPEG
    Photometric Interpretation: YCbCr
    FillOrder: lsb-to-msb
    Orientation: row 0 top, col 0 lhs
    Samples/Pixel: 3
    Rows/Strip: 64
    Planar Configuration: single image plane

  Reference Black/White:
     0:     0   255
     1:   128   255
     2:   128   255
  JPEG Tables: (574 bytes)

I understand the effect of setting TIFFTAG_JPEGCOLORMODE to JPEGCOLORMODE_RGB, but why is it necessary for me to do this in order to prevent an access violation when calling TIFFReadEncodedStrip()? For what it's worth, the access violation occurred when reading strip zero, and the buffer I passed was large enough to hold the entire decoded image. Under what circumstances do I need to set TIFFTAG_JPEGCOLORMODE to JPEGCOLORMODE_RGB? Always? Only when the photometric interpretation is YCbCr? Is it not possible to read a JPEG compressed TIFF in YCbCr format without converting it to RGB? If so, shouldn't that be the default behavior under the circumstances? Certainly an access violation doesn't seem desirable.

Thanks,

Steve McKinney

-----Original Message-----
From: Bob Friesenhahn [mailto:bfriesen@simple.dallas.tx.us]
Sent: Saturday, April 27, 2013 6:22 PM
To: Steve McKinney
Cc: tiff@lists.maptools.org
Subject: Re: [Tiff] Problem with TIFFReadEndcodeStrip()

On Sat, 27 Apr 2013, Steve McKinney wrote:
>
> I?ve been just about tearing my hair out trying to track down the
> cause of an access violation when attempting to read a JPEG compressed
> TIFF using TIFFReadEncodedStrip().  After some research and fiddling I
> found I was able to work around the problem by setting
TIFFTAG_JPEGCOLORMODE to JPEGCOLORMODE_RGB before beginning to read the
TIFF.  All well and good, but *why* do I have to do this?  And should
libtiff really crash if I don?t?

The JPEG is likely in YCbCr format and may be subsampled as well.
Setting TIFFTAG_JPEGCOLORMODE to JPEGCOLORMODE_RGB causes libjpeg to return
RGB pixels instead.

You did not provide enough information for me to say any more.

Bob
--
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/