[gdal-dev] Problems with TIFF CCITT T.6

Frank Warmerdam warmerda at h...
Fri Sep 29 12:31:43 EDT 2000


Klaus Bartz wrote:
> 
> Hi Gurus,
> downloaded OpenEV 0.9.0 this morning.
> Nice, very nice ...
> only ( ? ) TIFF CCITT T.6 are not working. At loading such an image
> I get a Box from the system ( Windows NT 4.0 SP 6 ) wich tell me, that there
> is an unhandled exception ( 0xC0000005:Access Violation ).
> I love bugs, about that I have searched for it. Then I'm smiling ...
> I have only debugged GDAL 1.1.1.
> Unfortenly it is a little bit complicated. About that more then one line:
> 
> GDALOpen is called from _GV!011cffc6 ( don't know what it is )
> with the eAccess GA_Update, this is mapped in GTiffDataset::Open to
> "r+".
> TIFFClientOpen maps this to O_RDWR.
> Some lines later TIFFClientOpen calls ... -> ... -> InitCCITTFax3.
> There is allocated a Fax3EncodeState because the mode is not O_RDONLY
> ( we know, it is O_RDWR ). Some lines later the structure is initialisized -
> with values for encoding, not decoding.
> Later TIFFReadRGBAStrip is called which calls ...->...-> Fax3PreDecode.
> There is a cast from tif->tif_data to Fax3DecodeState *.
> The access to sp->refruns[0] raises then the exception because the value is not
> null, but also not a valid pointer.
> 
> OK, where is the bug. May be it is philosophic.
> Is it not allowed to open a file with r+ if we would read the image ( then
> the bug is in GDAL or OpenEV).
> Or is it not allowed to detect the read/write state at the file open mode
> ( then the bug is in libtiff ). In libtiff ( tif_fax3.c ) there are more than one
> if (tif->tif_mode == O_RDONLY)
> may be a little bit difficult to change it.
> Frank will be happy ( i like his comments in tif_fax3.c )
> libtiff is not able to update an TIFF file, about that r+ makes no sense (or ??).
> Or is the bug to click on a TIFF CCITT T.6 ?

Klaus, 

I have had no problem reproducing this bug. :-) A few points:

o OpenEV tries to open files with update access, and if that fails falls
back to read-only access. 

o GDAL trusts TIFFOpen() to fail if the underlying file really can't be
accessed in update mode. 

o I did some hacks to libtiff over the last year or so to allow 
"sort of update access" in some cases that it wouldn't otherwise be 
practical. Amoung other things this is important if you want to add
overviews to an existing file. I think I will have to trace through
some of the compression schemes and see how they determine their mode.
I think libtiff needs a concept of compressed files with read-only
access to existing imagery but update access to the file as a whole. 

I am entering your report into the libtiff bug database, and will fix it as
soon as I can. 

Finally, the OpenEV 0.9.0 uses a version of GDAL that doesn't work sensibly
with bitonal images anyways. I modified GDAL recently to translate odd
photometric interpretations, and images with < 8 bits/sample into RGBA format
on the fly. With a little luck there will be an OpenEV 1.0.0 release within
a few weeks that incorporates the updated GDAL.

Best regards,

---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerda at h...
light and sound - activate the windows | http://members.home.com/warmerda
and watch the world go round - Rush | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list