summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Warmerdam <warmerdam@pobox.com>2010-06-14 02:47:16 +0000
committerFrank Warmerdam <warmerdam@pobox.com>2010-06-14 02:47:16 +0000
commit35c4f9d3f9b4100f8249f7e1fdba3aa344eb97c8 (patch)
treefe88cc9fe2a2ea62c0cbf4ecdd30039817c0bdf0
parent7801642bce2ce0c6500e835ca2a6c87ab01087bd (diff)
downloadlibtiff-git-35c4f9d3f9b4100f8249f7e1fdba3aa344eb97c8.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 */