Received: from [207.113.13.68] by phillip.cerious.com (NTMail 3.03.0017/7.aaxh) with ESMTP id pcrews for <pcrews@cerious.com>; Thu, 20 May 1999 05:57:43 -0400
Received: from localhost (bin@localhost)
	by gate7.olympiakos.com (8.8.7/8.8.7) with SMTP id FAA22463;
	Thu, 20 May 1999 05:48:16 -0400
Received: by gate7.olympiakos.com (bulk_mailer v1.9); Thu, 20 May 1999 05:45:26 -0400
Received: (from majordom@localhost)
	by gate7.olympiakos.com (8.8.7/8.8.7) id FAA22435
	for tiff-outgoing; Thu, 20 May 1999 05:45:25 -0400
X-Authentication-Warning: gate7.olympiakos.com: majordom set sender to owner-tiff@olympiakos.com using -f
Received: from sgi.com (sgi.SGI.COM [192.48.153.1])
	by gate7.olympiakos.com (8.8.7/8.8.7) with ESMTP id FAA22432
	for <tiff@olympiakos.com>; Thu, 20 May 1999 05:45:18 -0400
Received: from morgane.oleane.net (Morgane.OLEANE.Net [194.2.1.9]) 
	by sgi.com (980327.SGI.8.8.8-aspam/980304.SGI-aspam:
       SGI does not authorize the use of its proprietary
       systems or networks for unsolicited or bulk email
       from the Internet.) 
	via ESMTP id CAA08843
	for <tiff@sgi.com>; Thu, 20 May 1999 02:45:14 -0700 (PDT)
	mail_from (Francois.Dagand@mc2.fr)
Received: from mc2  (mc2-isdn.mc2.fr [194.2.35.1])  by morgane.oleane.net  with SMTP id LAA01435 for <tiff@sgi.com>; Thu, 20 May 1999 11:45:02 +0200
Received: from mc2.fr (f-dagand [172.21.14.105]) by mc2 (8.6.9/8.6.9) with ESMTP id LAA13909 for <tiff@sgi.com>; Thu, 20 May 1999 11:00:17 +0200
Message-ID: <3743CF64.524A269D@mc2.fr>
Date: Thu, 20 May 1999 11:01:25 +0200
From: "François Dagand" <Francois.Dagand@mc2.fr>
Organization: MC2
X-Mailer: Mozilla 4.06 [fr] (Win98; I)
MIME-Version: 1.0
To: tiff@sgi.com
Subject: Fix for decompression bug (sizes >= 65536)
Content-Type: text/plain; charset=us-ascii
Sender: owner-tiff@olympiakos.com
Content-Transfer-Encoding: 7bit


Hello again,

I just received a mail from Frank D. Cringle, the guy who wrote viewfax,
a software
for displaying TIFF files on X-Windows. The decompression algorithm for
this software
was used in libtiff, according to the comments. This soft also had a
problem for tiffs
wider than 65536 pixels. Frank gave me a correction for this bug in
viewfax, and I was
able to port the correction to libtiff. Don't ask me how it works,
though.

If you want to go over that limit of 65536, modify files tif_fax3.h and
tif_fax3.c (lines number
from  v3.4 beta). ">" is the modified code, "<" is the original :

tif_fax3.h :

46c46
<  * fillruns(unsigned char* buf, uint16* runs, uint16* erun, uint32
lastx)
>  * fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32
lastx)
55c55
< typedef void (*TIFFFaxFillFunc)(unsigned char*, uint16*, uint16*,
uint32);
> typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*,
uint32);
63c63
< extern void _TIFFFax3fillruns(unsigned char*, uint16*, uint16*,
uint32);
> extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*,
uint32);
87c87
<  uint16 Param;  /* unsigned 16-bit run length in bits */
>  uint32 Param;  /* unsigned 32-bit run length in bits */

tif_fax3.c :

81,83c81,83
<  uint16* runs;      /* b&w runs for current/previous row */
<  uint16* refruns;  /* runs for reference line */
<  uint16* curruns; /* runs for current line */
>  uint32* runs;      /* b&w runs for current/previous row */
>  uint32* refruns;  /* runs for reference line */
>  uint32* curruns; /* runs for current line */
120,121c120,121
<     uint16* pa;    /* place to stuff next run */ \
<     uint16* thisrun;   /* current row's run array */ \
>     uint32* pa;    /* place to stuff next run */ \
>     uint32* thisrun;   /* current row's run array */ \
128c128
<     uint16* pb    /* next run in reference line */\
>     uint32* pb    /* next run in reference line */\
298c298
<   SWAP(uint16*, sp->curruns, sp->refruns);
>   SWAP(uint32*, sp->curruns, sp->refruns);
361c361
< _TIFFFax3fillruns(u_char* buf, uint16* runs, uint16* erun, uint32
lastx)
> _TIFFFax3fillruns(u_char* buf, uint32* runs, uint32* erun, uint32
lastx)
502c502
<   dsp->runs = (uint16*) _TIFFmalloc(nruns*sizeof (uint16));
>   dsp->runs = (uint32*) _TIFFmalloc(nruns*sizeof (uint32));
1378c1378
<   SWAP(uint16*, sp->curruns, sp->refruns);
>   SWAP(uint32*, sp->curruns, sp->refruns);

--- end ---

