diff options
author | erouault <erouault> | 2017-10-17 19:04:47 +0000 |
---|---|---|
committer | erouault <erouault> | 2017-10-17 19:04:47 +0000 |
commit | 808ef617aa29a75a0a15859e58485ee70f71aec3 (patch) | |
tree | 11ef95acf377dd6bafbc1530eaaabc9d3aa50dc6 | |
parent | 5ae18d2a7299ecaabe7489e4ae4ffb67e4ce1f7f (diff) | |
download | libtiff-808ef617aa29a75a0a15859e58485ee70f71aec3.tar.gz |
* libtiff/tif_jpeg.c: add compatibility with libjpeg-turbo 1.5.2 that
honours max_memory_to_use > 0.
Cf https://github.com/libjpeg-turbo/libjpeg-turbo/issues/162
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | libtiff/tif_jpeg.c | 24 |
2 files changed, 23 insertions, 7 deletions
@@ -1,3 +1,9 @@ +2017-10-17 Even Rouault <even.rouault at spatialys.com> + + * libtiff/tif_jpeg.c: add compatibility with libjpeg-turbo 1.5.2 that + honours max_memory_to_use > 0. + Cf https://github.com/libjpeg-turbo/libjpeg-turbo/issues/162 + 2017-10-10 Even Rouault <even.rouault at spatialys.com> * nmake.opt: support a DEBUG=1 option, so as to adjust OPTFLAGS and use diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c index eed13574..0fbdb354 100644 --- a/libtiff/tif_jpeg.c +++ b/libtiff/tif_jpeg.c @@ -1,4 +1,4 @@ -/* $Id: tif_jpeg.c,v 1.133 2017-08-29 08:08:10 erouault Exp $ */ +/* $Id: tif_jpeg.c,v 1.134 2017-10-17 19:04:47 erouault Exp $ */ /* * Copyright (c) 1994-1997 Sam Leffler @@ -2456,12 +2456,22 @@ static int JPEGInitializeLibJPEG( TIFF * tif, int decompress ) #ifndef TIFF_JPEG_MAX_MEMORY_TO_USE #define TIFF_JPEG_MAX_MEMORY_TO_USE (10 * 1024 * 1024) #endif - /* Increase the max memory usable. This helps when creating files */ - /* with "big" tile, without using libjpeg temporary files. */ - /* For example a 512x512 tile with 3 bands */ - /* requires 1.5 MB which is above libjpeg 1MB default */ - if( sp->cinfo.c.mem->max_memory_to_use < TIFF_JPEG_MAX_MEMORY_TO_USE ) - sp->cinfo.c.mem->max_memory_to_use = TIFF_JPEG_MAX_MEMORY_TO_USE; + /* libjpeg turbo 1.5.2 honours max_memory_to_use, but has no backing */ + /* store implementation, so better not set max_memory_to_use ourselves. */ + /* See https://github.com/libjpeg-turbo/libjpeg-turbo/issues/162 */ + if( sp->cinfo.c.mem->max_memory_to_use > 0 ) + { + /* This is to address bug related in ticket GDAL #1795. */ + if (getenv("JPEGMEM") == NULL) + { + /* Increase the max memory usable. This helps when creating files */ + /* with "big" tile, without using libjpeg temporary files. */ + /* For example a 512x512 tile with 3 bands */ + /* requires 1.5 MB which is above libjpeg 1MB default */ + if( sp->cinfo.c.mem->max_memory_to_use < TIFF_JPEG_MAX_MEMORY_TO_USE ) + sp->cinfo.c.mem->max_memory_to_use = TIFF_JPEG_MAX_MEMORY_TO_USE; + } + } } sp->cinfo_initialized = TRUE; |