AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2010.12.14 17:55 "[Tiff] patch to tif_jpeg.c", by Dwight Kelly
2010.12.15 00:00 "Re: [Tiff] patch to tif_jpeg.c", by Lee Howard
2011.01.01 13:41 "[Tiff] Regression in libtiff 4.0 CVS when creating a JPEG RGB contig", by Even Rouault
2011.01.01 13:53 "Re: [Tiff] Regression in libtiff 4.0 CVS when creating a JPEG RGB contig", by Even Rouault
2011.01.04 02:52 "Re: [Tiff] Regression in libtiff 4.0 CVS when creating a JPEG RGB contig", by Lee Howard
2011.01.04 19:20 "Re: [Tiff] Regression in libtiff 4.0 CVS when creating a JPEG RGB contig", by Even Rouault
2011.01.04 19:47 "Re: [Tiff] Regression in libtiff 4.0 CVS when creating a JPEG RGB contig", by Lee Howard
2011.01.04 20:50 "Re: [Tiff] Regression in libtiff 4.0 CVS when creating a JPEG RGB contig", by Even Rouault
2011.01.04 21:39 "[SPAM WARNING]Re: [Tiff] Regression in libtiff 4.0 CVS when creating a JPEG RGB contig", by
2011.01.04 22:10 "Re: [Tiff] libtiff 4.0 stable? [was: Regression in libtiff 4.0 CVS when creating a JPEG RGB contig]", by Edward Lam
2011.01.05 00:03 "Re: [Tiff] libtiff 4.0 stable? [was: Regression in libtiff 4.0 CVS when creating a JPEG RGB contig]", by Frank Warmerdam
2011.01.05 02:19 "Re: [Tiff] libtiff 4.0 stable? [was: Regression in libtiff 4.0 CVS when creating a JPEG RGB contig]", by Bob Friesenhahn
2011.01.07 14:58 "Re: [Tiff] libtiff 4.0 stable? [was: Regression in libtiff 4.0 CVS when creating a JPEG RGB contig]", by Edward Lam
2011.01.07 17:42 "Re: [Tiff] libtiff 4.0 stable? [was: Regression in libtiff 4.0 CVS when creating a JPEG RGB contig]", by Bob Friesenhahn
2011.01.10 17:52 "Re: [Tiff] libtiff 4.0 stable? [was: Regression in libtiff 4.0 CVS when creating a JPEG RGB contig]", by
2011.01.05 02:06 "Re: [Tiff] Regression in libtiff 4.0 CVS when creating a JPEG RGB contig", by Bob Friesenhahn
2011.01.04 19:28 "Re: [Tiff] Regression in libtiff 4.0 CVS when creating a JPEG RGB contig", by Dwight Kelly
2011.01.04 19:32 "Re: [Tiff] Regression in libtiff 4.0 CVS when creating a JPEG RGB contig", by Even Rouault
2011.01.04 02:44 "Re: [Tiff] Regression in libtiff 4.0 CVS when creating a JPEG RGB contig", by Lee Howard
2011.01.21 00:51 "[Tiff] Cannot read YCbCr JPEG-compressed images", by Craig Bruce
2011.01.21 12:11 "Re: [Tiff] Cannot read YCbCr JPEG-compressed images", by John
2011.01.23 03:30 "Re: [Tiff] Cannot read YCbCr JPEG-compressed images", by Charles Auer
2011.01.23 16:01 "Re: [Tiff] Cannot read YCbCr JPEG-compressed images", by Bob Friesenhahn
2011.01.25 01:02 "Re: [Tiff] Cannot read YCbCr JPEG-compressed images", by Craig Bruce
2011.01.25 02:00 "Re: [Tiff] Cannot read YCbCr JPEG-compressed images", by Olivier Paquet
2011.01.26 02:40 "Re: [Tiff] Cannot read YCbCr JPEG-compressed images", by Craig Bruce
2011.01.26 04:50 "Re: [Tiff] Cannot read YCbCr JPEG-compressed images", by Bob Friesenhahn

2011.01.25 01:02 "Re: [Tiff] Cannot read YCbCr JPEG-compressed images", by Craig Bruce

Using TIFFReadEncodedTile, I was able to decode all 7 images in the sample file without any errors.

I put together the following test program:

#include <stdio.h>
#include <stdlib.h>
#include <tiffio.h>

main()
{
    TIFF *tiff;
    ttile_t tileNum;
    tsize_t tileSize;
    int readSize;
    tdata_t buf;

    tiff = TIFFOpen( "Q09050_006_NIR.tif", "r" );
    if (tiff == NULL) goto ERROR;
    tileNum = TIFFComputeTile( tiff, 0, 0, 0, 0 );
    tileSize = TIFFTileSize( tiff );
    buf = malloc( tileSize );
    printf( "tileNum=%ld, tileSize=%ld, buf=%p\n", (long) tileNum,
             (long) tileSize, (long) buf );
    readSize = TIFFReadEncodedTile( tiff, tileNum, buf, tileSize );
    if (readSize == -1) goto ERROR;
    printf("successful read, size=%d\n", readSize );
    exit( 0 );

ERROR:
    printf( "ERROR!\n" );
    exit( 1 );
}

If I build it using the system libraries on my computer (Linux x86_64, Fedora 13, libtiff 3.9.4), it works:

$ gcc tile.c -ltiff -ljpeg -lz -lm -o tile_test
$ ./tile_test

TIFFReadDirectory: Warning, Q09050_006_NIR.tif: unknown field with tag 50742 (0xc636) encountered. tileNum=0, tileSize=98304, buf=0x2124a60

successful read, size=98304

However, if I build and link with my own libtiff 4.0.0beta6 with the default configuration, I get the buffer error:

$ gcc -I ~/tiff-4.0.0beta6/libtiff tile.c ~/tiff-4.0.0beta6/libtiff/.libs/libtiff.a -ljpeg -lz -lm -o tile_test $ ./tile_test

TIFFReadDirectory: Warning, Unknown field with tag 50742 (0xc636) encountered. TIFFFetchNormalTag: Warning, ASCII value for tag "ImageDescription" does not end in null byte.

TIFFFetchNormalTag: Warning, ASCII value for tag "Software" does not end in null byte. tileNum=0, tileSize=98304, buf=0x22092b0

JPEGDecodeRaw: application buffer not large enough for all data..

ERROR!

The behaviour is consistent across a couple different versions of Fedora- built and personally-build libtiffs. Is there some special libtiff configuration needed to make YCbCr/JPEG reading work properly? I need to use a custom-built libtiff.

--------------------------+----------------------+--------------------------
Dr. Craig S. Bruce        | Ph 819-771-8303 x205 |             CubeWerx Inc.
Senior Software Developer |   Fax 819-771-8388   |  Gatineau, Québec, Canada
csbruce@cubewerx.com      |  http://csbruce.com/ |  http://www.cubewerx.com/
--------------------------+----------------------+--------------------------

The Free Market is why Canadian flags are made in China instead of Singapore.