$NetBSD: patch-ag,v 1.6 2004/03/22 17:03:30 abs Exp $

--- libtiff/tif_fax3.c.orig	Thu Nov  6 08:22:13 2003
+++ libtiff/tif_fax3.c
@@ -309,7 +309,7 @@ Fax3Decode2D(TIFF* tif, tidata_t buf, ts
  * this is <8 bytes.  We optimize the code here to reflect the
  * machine characteristics.
  */
-#if defined(__alpha) || _MIPS_SZLONG == 64 || defined(__LP64__) || defined(__arch64__)
+#if defined(__alpha) || _MIPS_SZLONG == 64 || defined(__LP64__) || defined(__arch64__) || defined(_LP64)
 #define FILL(n, cp)							    \
     switch (n) {							    \
     case 15:(cp)[14] = 0xff; case 14:(cp)[13] = 0xff; case 13: (cp)[12] = 0xff;\
@@ -451,7 +451,7 @@ Fax3SetupState(TIFF* tif)
 	Fax3BaseState* sp = Fax3State(tif);
 	long rowbytes, rowpixels;
 	int needsRefLine;
-	Fax3CodecState* dsp = DecoderState(tif);
+	Fax3CodecState* dsp = (Fax3CodecState*) Fax3State(tif);
 	uint32 nruns;
 
 	if (td->td_bitspersample != 1) {
@@ -1284,7 +1284,8 @@ InitCCITTFax3(TIFF* tif)
 	sp->recvparams = 0;
 	sp->subaddress = NULL;
 
-	tif->tif_flags |= TIFF_NOBITREV;	/* decoder does bit reversal */
+	if (sp->rw_mode == O_RDONLY)			/* FIXME: improve for in place update */
+		tif->tif_flags |= TIFF_NOBITREV;	/* decoder does bit reversal */
 	DecoderState(tif)->runs = NULL;
 	TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, _TIFFFax3fillruns);
 	EncoderState(tif)->refline = NULL;
