From 073c35418cdebf0c13227f4a5690d80c0711ceab Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 6 Dec 2016 11:51:41 +0000 Subject: [PATCH] ECC-396: Support for Jasper 2.0 --- CMakeLists.txt | 2 ++ eccodes_config.h.in | 4 ++++ src/grib_jasper_encoding.c | 6 ++++++ tools/grib_tools.c | 1 - 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15c62e951..896540587 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,6 +148,8 @@ if( ENABLE_JPG ) list( APPEND ECCODES_TPLS Jasper ) set( HAVE_JPEG 1 ) set( HAVE_LIBJASPER 1 ) + # Extract Jasper's major version number to enable conditional code. See ECC-396 + string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" JASPER_VERSION_MAJOR "${JASPER_VERSION_STRING}") endif() if( OPENJPEG_FOUND ) diff --git a/eccodes_config.h.in b/eccodes_config.h.in index 21cd2b245..0e3d5d8bc 100644 --- a/eccodes_config.h.in +++ b/eccodes_config.h.in @@ -107,4 +107,8 @@ #define ECCODES_IFS_SAMPLES_PATH "/MEMFS/ifs_samples" #endif +#ifdef HAVE_LIBJASPER +#define JASPER_VERSION_MAJOR @JASPER_VERSION_MAJOR@ +#endif + #endif /* eccodes_config_h */ diff --git a/src/grib_jasper_encoding.c b/src/grib_jasper_encoding.c index d27847106..5ef41fe92 100644 --- a/src/grib_jasper_encoding.c +++ b/src/grib_jasper_encoding.c @@ -110,7 +110,13 @@ int grib_jasper_encode(grib_context *c, j2k_encode_helper *helper) image.maxcmpts_ = 1; image.clrspc_ = JAS_CLRSPC_SGRAY; image.cmprof_ = 0; + +#if JASPER_VERSION_MAJOR == 1 + /* ECC-396: Support for Jasper 2.0 + * Jasper version 1 had the 'inmem_' data member but + * version 2 removed it from the interface */ image.inmem_ = 1; +#endif cmpt.tlx_ = 0; cmpt.tly_ = 0; diff --git a/tools/grib_tools.c b/tools/grib_tools.c index f924c754c..0d4111f11 100644 --- a/tools/grib_tools.c +++ b/tools/grib_tools.c @@ -21,7 +21,6 @@ #undef PACKAGE_STRING #undef PACKAGE_TARNAME #undef PACKAGE_VERSION -#include "jasper/jasper.h" #endif #ifdef ENABLE_FLOATING_POINT_EXCEPTIONS