libtiff: fixed handling of tiled logluv images (#2005)

https://github.com/libsdl-org/libtiff/commit/816d6675d01079aa704862bb71655b33b4d12eca

From 816d6675d01079aa704862bb71655b33b4d12eca Mon Sep 17 00:00:00 2001
From: Frank Warmerdam <[EMAIL REDACTED]>
Date: Thu, 12 Feb 2009 18:08:40 +0000
Subject: [PATCH] fixed handling of tiled logluv images (#2005)

---
 ChangeLog         |  5 +++++
 libtiff/tif_luv.c | 12 +++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index efe62134..9fd66bee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-02-12  Frank Warmerdam  <warmerdam@pobox.com>
+
+	* libtiff/tif_luv.c: Fix handling of tiled logluv images. 
+	http://bugzilla.maptools.org/show_bug.cgi?id=2005
+
 2009-01-23  Frank Warmerdam  <warmerdam@pobox.com>
 
 	* libtiff/tif_predict.c: Add support for 32bit integer horz. predictors.
diff --git a/libtiff/tif_luv.c b/libtiff/tif_luv.c
index 30f16c25..7e308458 100644
--- a/libtiff/tif_luv.c
+++ b/libtiff/tif_luv.c
@@ -1,4 +1,4 @@
-/* $Id: tif_luv.c,v 1.17.2.1 2007-04-07 14:58:30 dron Exp $ */
+/* $Id: tif_luv.c,v 1.17.2.2 2009-02-12 18:08:40 fwarmerdam Exp $ */
 
 /*
  * Copyright (c) 1997 Greg Ward Larson
@@ -1200,7 +1200,10 @@ LogL16InitState(TIFF* tif)
 		    "No support for converting user data format to LogL");
 		return (0);
 	}
-	sp->tbuflen = multiply(td->td_imagewidth, td->td_rowsperstrip);
+        if( isTiled(tif) )
+            sp->tbuflen = multiply(td->td_tilewidth, td->td_tilelength);
+        else
+            sp->tbuflen = multiply(td->td_imagewidth, td->td_rowsperstrip);
 	if (multiply(sp->tbuflen, sizeof (int16)) == 0 ||
 	    (sp->tbuf = (tidata_t*) _TIFFmalloc(sp->tbuflen * sizeof (int16))) == NULL) {
 		TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for SGILog translation buffer",
@@ -1298,7 +1301,10 @@ LogLuvInitState(TIFF* tif)
 		    "No support for converting user data format to LogLuv");
 		return (0);
 	}
-	sp->tbuflen = multiply(td->td_imagewidth, td->td_rowsperstrip);
+        if( isTiled(tif) )
+            sp->tbuflen = multiply(td->td_tilewidth, td->td_tilelength);
+        else
+            sp->tbuflen = multiply(td->td_imagewidth, td->td_rowsperstrip);
 	if (multiply(sp->tbuflen, sizeof (uint32)) == 0 ||
 	    (sp->tbuf = (tidata_t*) _TIFFmalloc(sp->tbuflen * sizeof (uint32))) == NULL) {
 		TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for SGILog translation buffer",