Skip to content

Commit

Permalink
JPEG output: add compatibility with libjpeg-turbo 1.5.2 (libjpeg-turb…
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Oct 17, 2017
1 parent 581ec9f commit 04d3a61
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions mapimageio.c
Expand Up @@ -206,11 +206,16 @@ int saveAsJPEG(mapObj *map, rasterBufferObj *rb, streamInfo *info,
cinfo.optimize_coding = TRUE;

if( arithmetic || optimized ) {
if (map == NULL || msGetConfigOption(map, "JPEGMEM") == NULL) {
/* If the user doesn't provide a value for JPEGMEM, we want to be sure */
/* that at least the image size will be used before creating the temporary file */
cinfo.mem->max_memory_to_use =
MS_MAX(cinfo.mem->max_memory_to_use, cinfo.input_components * rb->width * rb->height);
/* 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( cinfo.mem->max_memory_to_use > 0 ) {
if (map == NULL || msGetConfigOption(map, "JPEGMEM") == NULL) {
/* If the user doesn't provide a value for JPEGMEM, we want to be sure */
/* that at least the image size will be used before creating the temporary file */
cinfo.mem->max_memory_to_use =
MS_MAX(cinfo.mem->max_memory_to_use, cinfo.input_components * rb->width * rb->height);
}
}
}

Expand Down

0 comments on commit 04d3a61

Please sign in to comment.