From e30b0c9f39414f0697f40826256c2eb7746e6143 Mon Sep 17 00:00:00 2001 From: Edward Hartnett <38856240+edwardhartnett@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:29:59 +0200 Subject: [PATCH] adding preprocessor constant for max memory for jasper (#562) * took out rest of setting of max memory for jasper * restored jasper max memory * added test for jasper warnings * added test for jasper warnings * comment * fixing * fixing * improve documentation * fixed workflow with -DBUILD_WITH_EXTRA_DEPS=ON --- .github/workflows/grib_utils.yml | 2 +- src/dec_jpeg2000.c | 2 +- src/enc_jpeg2000.c | 2 +- src/jpeg.h | 5 +++++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/grib_utils.yml b/.github/workflows/grib_utils.yml index 2cfd5128..72ca5b81 100644 --- a/.github/workflows/grib_utils.yml +++ b/.github/workflows/grib_utils.yml @@ -132,7 +132,7 @@ jobs: cd w3emc mkdir build cd build - cmake -DCMAKE_PREFIX_PATH=~/bacio -DCMAKE_INSTALL_PREFIX=~/w3emc -DBUILD_WITH_BUFR=OFF .. + cmake -DCMAKE_PREFIX_PATH=~/bacio -DCMAKE_INSTALL_PREFIX=~/w3emc -DBUILD_WITH_BUFR=OFF -DBUILD_WITH_EXTRA_DEPS=ON .. make -j2 make install diff --git a/src/dec_jpeg2000.c b/src/dec_jpeg2000.c index 7d589e7d..13b88177 100644 --- a/src/dec_jpeg2000.c +++ b/src/dec_jpeg2000.c @@ -54,7 +54,7 @@ int_dec_jpeg2000(char *injpc, g2int bufsize, void *outfld, int out_is_g2int) if (( g2jaspermaxmem = getenv("G2_JASPER_MAXMEM")) != NULL ) jas_conf_set_max_mem_usage(atoi(g2jaspermaxmem)); else - jas_conf_set_max_mem_usage(1073741824); + jas_conf_set_max_mem_usage(G2C_JASPER_MAX_MEMORY); jas_conf_set_multithread(true); if (jas_init_library()) return G2_JASPER_INIT; diff --git a/src/enc_jpeg2000.c b/src/enc_jpeg2000.c index a813217a..6707b00f 100644 --- a/src/enc_jpeg2000.c +++ b/src/enc_jpeg2000.c @@ -143,7 +143,7 @@ enc_jpeg2000(unsigned char *cin, g2int width, g2int height, g2int nbits, if (( g2jaspermaxmem = getenv("G2_JASPER_MAXMEM")) != NULL ) jas_conf_set_max_mem_usage(atoi(g2jaspermaxmem)); else - jas_conf_set_max_mem_usage(1073741824); + jas_conf_set_max_mem_usage(G2C_JASPER_MAX_MEMORY); jas_conf_set_multithread(true); if (jas_init_library()) return G2_JASPER_INIT; diff --git a/src/jpeg.h b/src/jpeg.h index 2a77d299..ecaafcff 100644 --- a/src/jpeg.h +++ b/src/jpeg.h @@ -23,3 +23,8 @@ typedef float g2float; /** Name of JPEG codec in Jasper. */ #define G2C_JASPER_JPEG_FORMAT_NAME "jpc" + +/** Max memory size setting for Jasper. This can be over-ridden at + * run-time by setting environment variable G2_JASPER_MAXMEM. */ +#define G2C_JASPER_MAX_MEMORY 1073741824 +