Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

Commit

Permalink
* libtiff/tif_jpeg.c: add compatibility with libjpeg-turbo 1.5.2 that
Browse files Browse the repository at this point in the history
honours max_memory_to_use > 0.
Cf libjpeg-turbo/libjpeg-turbo#162
  • Loading branch information
rouault committed Oct 17, 2017
1 parent 46195f7 commit e568614
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 16 additions & 6 deletions libtiff/tif_jpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e568614

Please sign in to comment.