libtiff: * libtiff/tif_dirread.c: modify warnings

https://github.com/libsdl-org/libtiff/commit/b7c40af60276da91a2f4446cc70c4214edc3cb44

From b7c40af60276da91a2f4446cc70c4214edc3cb44 Mon Sep 17 00:00:00 2001
From: Lee Howard <[EMAIL REDACTED]>
Date: Sat, 11 Dec 2010 22:32:32 +0000
Subject: [PATCH]         * libtiff/tif_dirread.c: modify warnings        
 http://bugzilla.maptools.org/show_bug.cgi?id=2016

---
 ChangeLog             |  5 +++++
 libtiff/tif_dirread.c | 20 ++++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 38087716..96cdabab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-12-11  Lee Howard <faxguy@howardsilvan.com>
+
+	* libtiff/tif_dirread.c: modify warnings
+	http://bugzilla.maptools.org/show_bug.cgi?id=2016
+
 2010-12-11  Lee Howard <faxguy@howardsilvan.com>
 
         * libtiff/tif_ojpeg.c: fix buffer overflow on problem data
diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
index 8b6ecf96..5f974da1 100644
--- a/libtiff/tif_dirread.c
+++ b/libtiff/tif_dirread.c
@@ -1,4 +1,4 @@
-/* $Id: tif_dirread.c,v 1.92.2.11 2010-12-08 17:44:35 faxguy Exp $ */
+/* $Id: tif_dirread.c,v 1.92.2.12 2010-12-11 22:32:32 faxguy Exp $ */
 
 /*
  * Copyright (c) 1988-1997 Sam Leffler
@@ -606,8 +606,7 @@ TIFFReadDirectory(TIFF* tif)
 		}
 		if (!TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL))
 		{
-			if ((td->td_photometric==PHOTOMETRIC_RGB)
-			    || (td->td_photometric==PHOTOMETRIC_YCBCR))
+			if (td->td_photometric==PHOTOMETRIC_RGB)
 			{
 				TIFFWarningExt(tif->tif_clientdata,
 					       "TIFFReadDirectory",
@@ -616,13 +615,22 @@ TIFFReadDirectory(TIFF* tif)
 				if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3))
 					goto bad;
 			}
-			else if ((td->td_photometric==PHOTOMETRIC_MINISWHITE)
-				 || (td->td_photometric==PHOTOMETRIC_MINISBLACK))
+			if (td->td_photometric==PHOTOMETRIC_YCBCR)
 			{
 				TIFFWarningExt(tif->tif_clientdata,
 					       "TIFFReadDirectory",
 				"SamplesPerPixel tag is missing, "
-				"assuming correct SamplesPerPixel value is 1");
+				"applying correct SamplesPerPixel value of 3");
+				if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3))
+					goto bad;
+			}
+			else if ((td->td_photometric==PHOTOMETRIC_MINISWHITE)
+				 || (td->td_photometric==PHOTOMETRIC_MINISBLACK))
+			{
+				/*
+				 * SamplesPerPixel tag is missing, but is not required
+				 * by spec.  Assume correct SamplesPerPixel value of 1.
+				 */
 				if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,1))
 					goto bad;
 			}