AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

1999.09.15 06:57 "[Repost: Fix for decompression bug (sizes >= 65536)]", by
1999.09.15 08:57 "[Fwd: Fix for decompression bug (sizes >= 65536)]", by Jacques Thiebauld
1999.09.28 17:49 "Re: v3.5.2 released", by Ivo Penzar
1999.10.04 08:24 "Problem with g4 fax decode", by Ian
1999.10.21 02:12 "Re: v3.5.2 released", by Ken Cantwell

1999.09.28 17:49 "Re: v3.5.2 released", by Ivo Penzar

IMHO, few fixes/patches to be done:

1) Fix for 64k+ fax images is not complete. Apparently in the file libtiff/tif_fax3.c, line 502 should be changed from

> dsp->runs = (uint32*) _TIFFmalloc(nruns*sizeof (uint16));

to

>   dsp->runs = (uint32*) _TIFFmalloc(nruns*sizeof (uint32));

2) It would be nice if in the file libtiff/tif_dir, function TIFFAdvanceDirectory() would support memory mapped files. In the code enclosed below, I added the IF section:

> if (isMapped(tif))
> {
> // new code
> // browse the memory buffer, not the file
> }
> else
> {
> // old code
> // for unmapped files
> }

> static int
> TIFFAdvanceDirectory(TIFF* tif, uint32* nextdir, toff_t* off)
> {
> static const char module[] = "TIFFAdvanceDirectory";
> uint16 dircount;
>
> if (isMapped(tif))
> {

>   tsize_t poff=*nextdir;
>   if (poff+sizeof (uint16) > tif->tif_size)
>   {
>    TIFFError(module, "%s: Error fetching directory count",
>        tif->tif_name);
>    return (0);
>   }
>   _TIFFmemcpy(&dircount, tif->tif_base+poff, sizeof (uint16));
>   if (tif->tif_flags & TIFF_SWAB)
>    TIFFSwabShort(&dircount);
>   poff+=sizeof (uint16)+dircount*sizeof (TIFFDirEntry);
>   if (off != NULL)
>    *off = poff;
>   if (poff+sizeof (uint32) > tif->tif_size)
>   {
>    TIFFError(module, "%s: Error fetching directory link",
>        tif->tif_name);
>    return (0);
>   }
>   _TIFFmemcpy(nextdir, tif->tif_base+poff, sizeof (uint32));
>   if (tif->tif_flags & TIFF_SWAB)
>    TIFFSwabLong(nextdir);
>   return (1);
>  }
>  else
>  {
>   if (!SeekOK(tif, *nextdir) ||
>    !ReadOK(tif, &dircount, sizeof (uint16))) {
>    TIFFError(module, "%s: Error fetching directory count",
>     tif->tif_name);
>    return (0);
>   }
>   if (tif->tif_flags & TIFF_SWAB)
>    TIFFSwabShort(&dircount);
>   if (off != NULL)
>    *off = TIFFSeekFile(tif,
>        dircount*sizeof (TIFFDirEntry), SEEK_CUR);
>   else
>    (void) TIFFSeekFile(tif,
>        dircount*sizeof (TIFFDirEntry), SEEK_CUR);
>   if (!ReadOK(tif, nextdir, sizeof (uint32))) {
>    TIFFError(module, "%s: Error fetching directory link",
>        tif->tif_name);
>    return (0);
>   }
>   if (tif->tif_flags & TIFF_SWAB)
>    TIFFSwabLong(nextdir);
>   return (1);

> }
> }

3) The switch 'u' (to suppress the memory mapping of input files) as implemented in libtiff/tif_win32.c, function TIFFFdOpen(), does not correspond to the switch 'm' as used otherwise for the same thing (see the file libtiff/tif_open.c, function TIFFClientOpen()).

Because of this mismatch and the fact that TIFFFdOpen() actually calls TIFFClientOpen(), the suppression of memory mapping for input files does not work correctly on the Win32 platform.

This is an old problem, the same as in the version 3.4beta.

Obviously, the line

> BOOL fSuppressMap = (mode[1] == 'u' || mode[2] == 'u');

in TIFFFdOpen(), file libtiff/tif_win32.c, must be changed to

> BOOL fSuppressMap = (mode[1] == 'm' || mode[2] == 'm');

My two cents,

Ivo Penzar