summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfwarmerdam <fwarmerdam>2010-06-14 02:47:16 +0000
committerfwarmerdam <fwarmerdam>2010-06-14 02:47:16 +0000
commit005840d648f5d66ff4dc9db7721611b84eef5466 (patch)
tree33240b9f3ddfcd6e12475ed0154e0cfc45e458ab
parentca24b1957b9dc0a9cbe24754eb38b18553e18fb2 (diff)
downloadlibtiff-005840d648f5d66ff4dc9db7721611b84eef5466.tar.gz
avoid recreate jpegtables unnecessarily (#2135, gdal#3633)
-rw-r--r--ChangeLog3
-rw-r--r--libtiff/tif_jpeg.c18
2 files changed, 14 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index a02246d2..2c414b29 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2010-06-13 Frank Warmerdam <warmerdam@pobox.com>
+ * libtiff/tif_jpeg.c: avoid re-preparing jpeg tables unnecessarily
+ (gdal #3633, libtiff #2135).
+
* libtiff/tif_dirread.c: Fixed bad handling of out of order tags
definated late by a codec (#2210)
diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c
index 0f7c8dc1..a967827e 100644
--- a/libtiff/tif_jpeg.c
+++ b/libtiff/tif_jpeg.c
@@ -1,4 +1,4 @@
-/* $Id: tif_jpeg.c,v 1.50.2.8 2010-06-08 18:50:42 bfriesen Exp $ */
+/* $Id: tif_jpeg.c,v 1.50.2.9 2010-06-14 02:47:16 fwarmerdam Exp $ */
/*
* Copyright (c) 1994-1997 Sam Leffler
@@ -1269,12 +1269,16 @@ JPEGSetupEncode(TIFF* tif)
/* Create a JPEGTables field if appropriate */
if (sp->jpegtablesmode & (JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF)) {
- if (!prepare_JPEGTables(tif))
- return (0);
- /* Mark the field present */
- /* Can't use TIFFSetField since BEENWRITING is already set! */
- TIFFSetFieldBit(tif, FIELD_JPEGTABLES);
- tif->tif_flags |= TIFF_DIRTYDIRECT;
+ if( sp->jpegtables == NULL
+ || memcmp(sp->jpegtables,"\0\0\0\0\0\0\0\0\0",8) == 0 )
+ {
+ if (!prepare_JPEGTables(tif))
+ return (0);
+ /* Mark the field present */
+ /* Can't use TIFFSetField since BEENWRITING is already set! */
+ tif->tif_flags |= TIFF_DIRTYDIRECT;
+ TIFFSetFieldBit(tif, FIELD_JPEGTABLES);
+ }
} else {
/* We do not support application-supplied JPEGTables, */
/* so mark the field not present */