summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorolivier <olivier>2010-12-31 16:12:40 +0000
committerolivier <olivier>2010-12-31 16:12:40 +0000
commitc377583233d7b1e54c6992add0dd18e346696fd3 (patch)
tree662105e649c574f5ffe3237f8d0573db07d7d495
parentbce7852762cc4b15d6106a543aab0845d5a60566 (diff)
downloadlibtiff-c377583233d7b1e54c6992add0dd18e346696fd3.tar.gz
* libtiff/tif_dirread.c: Allow reading directories where
TIFFTAG_SMINSAMPLEVALUE and TIFFTAG_SMAXSAMPLEVALUE values differ for each channel. The min/max of all channels is used as appropriate.
-rw-r--r--ChangeLog6
-rw-r--r--libtiff/tif_dirread.c38
2 files changed, 28 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 3f443998..4ddb920c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-12-31 Olivier Paquet <olivier.paquet@gmail.com>
+
+ * libtiff/tif_dirread.c: Allow reading directories where
+ TIFFTAG_SMINSAMPLEVALUE and TIFFTAG_SMAXSAMPLEVALUE values differ for each
+ channel. The min/max of all channels is used as appropriate.
+
2010-12-14 Lee Howard <faxguy@howardsilvan.com>
* libtiff/tif_dirread.c: tolerate some cases where
diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
index 9e8b9c5c..667a5d96 100644
--- a/libtiff/tif_dirread.c
+++ b/libtiff/tif_dirread.c
@@ -1,4 +1,4 @@
-/* $Id: tif_dirread.c,v 1.92.2.14 2010-12-15 01:04:34 faxguy Exp $ */
+/* $Id: tif_dirread.c,v 1.92.2.15 2010-12-31 16:12:40 olivier Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -54,7 +54,7 @@ static float TIFFFetchRational(TIFF*, TIFFDirEntry*);
static int TIFFFetchNormalTag(TIFF*, TIFFDirEntry*);
static int TIFFFetchPerSampleShorts(TIFF*, TIFFDirEntry*, uint16*);
static int TIFFFetchPerSampleLongs(TIFF*, TIFFDirEntry*, uint32*);
-static int TIFFFetchPerSampleAnys(TIFF*, TIFFDirEntry*, double*);
+static int TIFFFetchPerSampleAnys(TIFF*, TIFFDirEntry*, double*, double*);
static int TIFFFetchShortArray(TIFF*, TIFFDirEntry*, uint16*);
static int TIFFFetchStripThing(TIFF*, TIFFDirEntry*, long, uint32**);
static int TIFFFetchRefBlackWhite(TIFF*, TIFFDirEntry*);
@@ -480,11 +480,18 @@ TIFFReadDirectory(TIFF* tif)
}
break;
case TIFFTAG_SMINSAMPLEVALUE:
+ {
+ double minv = 0.0, maxv = 0.0;
+ if (!TIFFFetchPerSampleAnys(tif, dp, &minv, &maxv) ||
+ !TIFFSetField(tif, dp->tdir_tag, minv))
+ goto bad;
+ }
+ break;
case TIFFTAG_SMAXSAMPLEVALUE:
{
- double dv = 0.0;
- if (!TIFFFetchPerSampleAnys(tif, dp, &dv) ||
- !TIFFSetField(tif, dp->tdir_tag, dv))
+ double minv = 0.0, maxv = 0.0;
+ if (!TIFFFetchPerSampleAnys(tif, dp, &minv, &maxv) ||
+ !TIFFSetField(tif, dp->tdir_tag, maxv))
goto bad;
}
break;
@@ -1852,11 +1859,11 @@ TIFFFetchPerSampleLongs(TIFF* tif, TIFFDirEntry* dir, uint32* pl)
}
/*
- * Fetch samples/pixel ANY values for the specified tag and verify that all
- * values are the same.
+ * Fetch samples/pixel ANY values for the specified tag and returns their min
+ * and max.
*/
static int
-TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* pl)
+TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* minv, double* maxv)
{
uint16 samples = tif->tif_dir.td_samplesperpixel;
int status = 0;
@@ -1874,17 +1881,16 @@ TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* pl)
if( samples < check_count )
check_count = samples;
+ *minv = *maxv = v[0];
for (i = 1; i < check_count; i++)
- if (v[i] != v[0]) {
- TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
- "Cannot handle different per-sample values for field \"%s\"",
- _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
- goto bad;
- }
- *pl = v[0];
+ {
+ if (v[i] < *minv)
+ *minv = v[i];
+ if (v[i] > *maxv)
+ *maxv = v[i];
+ }
status = 1;
}
- bad:
if (v && v != buf)
_TIFFfree(v);
}