From 0a94dc71fbfe665dd7de35d876492fae00f4576c Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sun, 6 Mar 2022 20:17:54 +0000 Subject: [PATCH 1/9] ECC-1343: Problems compiling with Jasper v3.0 (Try 01) --- src/grib_jasper_encoding.c | 44 ++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/src/grib_jasper_encoding.c b/src/grib_jasper_encoding.c index f51155929..a169750b3 100644 --- a/src/grib_jasper_encoding.c +++ b/src/grib_jasper_encoding.c @@ -18,7 +18,6 @@ #undef PACKAGE_TARNAME #undef PACKAGE_VERSION #include "jasper/jasper.h" - #define MAXOPTSSIZE 1024 int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* values, size_t* no_values) @@ -30,7 +29,12 @@ int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, doub jas_matrix_t* matrix = NULL; jas_image_cmpt_t* p; int i, j, k; - +#if JASPER_VERSION_MAJOR == 3 + jas_conf_clear(); + jas_conf_set_max_mem_usage(jas_get_total_mem_size()); + jas_init_library(); + jas_init_thread(); +#endif jpeg = jas_stream_memopen((char*)buf, *buflen); if (!jpeg) { code = GRIB_DECODING_ERROR; @@ -38,8 +42,11 @@ int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, doub } grib_context_log(c, GRIB_LOG_DEBUG, "grib_jasper_decode: Jasper version %s", jas_getversion()); - +#if JASPER_VERSION_MAJOR == 3 + image = jas_image_decode (jpeg, -1, 0); +#else image = jpc_decode(jpeg, NULL); +#endif if (!image) { code = GRIB_DECODING_ERROR; goto cleanup; @@ -77,7 +84,10 @@ cleanup: jas_image_destroy(image); if (jpeg) jas_stream_close(jpeg); - +#if JASPER_VERSION_MAJOR == 3 + jas_cleanup_thread(); + jas_cleanup_library(); +#endif return code; } @@ -94,6 +104,7 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) long no_values = helper->no_values; long bits8; int i; + int fmt; size_t buflen = 0; unsigned char* encoded = NULL; @@ -155,9 +166,12 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) buflen++; } } - - /*jas_init();*/ - +#if JASPER_VERSION_MAJOR == 3 + jas_conf_clear(); + jas_conf_set_max_mem_usage(jas_get_total_mem_size()); + jas_init_library(); + jas_init_thread(); +#endif opts[0] = 0; if (helper->compression != 0) { @@ -175,8 +189,13 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) cmpt.stream_ = istream; jpcstream = jas_stream_memopen((char*)helper->jpeg_buffer, helper->buffer_size); +#if JASPER_VERSION_MAJOR == 3 + fmt = jas_image_strtofmt("jpc"); + jaserr = jas_image_encode(&image, jpcstream, fmt, opts); +#else + (void)fmt; jaserr = jpc_encode(&image, jpcstream, opts); - +#endif if (jaserr != 0) { /* increase the number of guard bits */ strcat(opts, "\nnumgbits=4"); @@ -189,7 +208,11 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) istream = jas_stream_memopen((char*)encoded, buflen); cmpt.stream_ = istream; jpcstream = jas_stream_memopen((char*)helper->jpeg_buffer, helper->buffer_size); +#if JASPER_VERSION_MAJOR == 3 + jaserr = jas_image_encode(&image, jpcstream, fmt, opts); +#else jaserr = jpc_encode(&image, jpcstream, opts); +#endif } if (jaserr != 0) { @@ -210,7 +233,10 @@ cleanup: jas_stream_close(istream); if (jpcstream) jas_stream_close(jpcstream); - +#if JASPER_VERSION_MAJOR == 3 + jas_cleanup_thread(); + jas_cleanup_library(); +#endif return code; } From 86f0b35f1a8492cb16f82fb976a0a5acd2986ac2 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Sun, 6 Mar 2022 21:30:44 +0000 Subject: [PATCH 2/9] ECC-1343: Problems compiling with Jasper v3.0 (Try 02) --- src/grib_jasper_encoding.c | 94 ++++++++++++++++++++++---------------- 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/src/grib_jasper_encoding.c b/src/grib_jasper_encoding.c index a169750b3..d55a24779 100644 --- a/src/grib_jasper_encoding.c +++ b/src/grib_jasper_encoding.c @@ -20,21 +20,56 @@ #include "jasper/jasper.h" #define MAXOPTSSIZE 1024 -int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* values, size_t* no_values) +static void ecc_jasper_initialise() { - /*jas_setdbglevel(99999);*/ - jas_image_t* image = NULL; - jas_stream_t* jpeg = NULL; - int code = GRIB_SUCCESS; - jas_matrix_t* matrix = NULL; - jas_image_cmpt_t* p; - int i, j, k; #if JASPER_VERSION_MAJOR == 3 jas_conf_clear(); jas_conf_set_max_mem_usage(jas_get_total_mem_size()); jas_init_library(); jas_init_thread(); #endif +} + +static jas_image_t* ecc_jasper_decode(jas_stream_t *in) +{ +#if JASPER_VERSION_MAJOR == 3 + /* Second argument (=fmt) < 0 means "If possible, try to determine the format of the input data" */ + return jas_image_decode(in, -1, 0); +#else + return jpc_decode(in, NULL); +#endif +} + +static int ecc_jasper_encode(jas_image_t *image, jas_stream_t *jpcstream, const char *optstr) +{ +#if JASPER_VERSION_MAJOR == 3 + const int fmt = jas_image_strtofmt("jpc"); + return jas_image_encode(image, jpcstream, fmt, optstr); +#else + return jpc_encode(image, jpcstream, optstr); +#endif +} + +static void ecc_jasper_cleanup() +{ +#if JASPER_VERSION_MAJOR == 3 + jas_cleanup_thread(); + jas_cleanup_library(); +#endif +} + +int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* values, size_t* no_values) +{ + /* jas_setdbglevel(99999); */ + jas_image_t* image = NULL; + jas_stream_t* jpeg = NULL; + int code = GRIB_SUCCESS; + jas_matrix_t* matrix = NULL; + jas_image_cmpt_t* p; + int i, j, k; + + ecc_jasper_initialise(); + jpeg = jas_stream_memopen((char*)buf, *buflen); if (!jpeg) { code = GRIB_DECODING_ERROR; @@ -42,11 +77,8 @@ int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, doub } grib_context_log(c, GRIB_LOG_DEBUG, "grib_jasper_decode: Jasper version %s", jas_getversion()); -#if JASPER_VERSION_MAJOR == 3 - image = jas_image_decode (jpeg, -1, 0); -#else - image = jpc_decode(jpeg, NULL); -#endif + + image = ecc_jasper_decode(jpeg); if (!image) { code = GRIB_DECODING_ERROR; goto cleanup; @@ -84,10 +116,8 @@ cleanup: jas_image_destroy(image); if (jpeg) jas_stream_close(jpeg); -#if JASPER_VERSION_MAJOR == 3 - jas_cleanup_thread(); - jas_cleanup_library(); -#endif + ecc_jasper_cleanup(); + return code; } @@ -104,7 +134,6 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) long no_values = helper->no_values; long bits8; int i; - int fmt; size_t buflen = 0; unsigned char* encoded = NULL; @@ -166,12 +195,9 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) buflen++; } } -#if JASPER_VERSION_MAJOR == 3 - jas_conf_clear(); - jas_conf_set_max_mem_usage(jas_get_total_mem_size()); - jas_init_library(); - jas_init_thread(); -#endif + + ecc_jasper_initialise(); + opts[0] = 0; if (helper->compression != 0) { @@ -189,13 +215,8 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) cmpt.stream_ = istream; jpcstream = jas_stream_memopen((char*)helper->jpeg_buffer, helper->buffer_size); -#if JASPER_VERSION_MAJOR == 3 - fmt = jas_image_strtofmt("jpc"); - jaserr = jas_image_encode(&image, jpcstream, fmt, opts); -#else - (void)fmt; - jaserr = jpc_encode(&image, jpcstream, opts); -#endif + + jaserr = ecc_jasper_encode(&image, jpcstream, opts); if (jaserr != 0) { /* increase the number of guard bits */ strcat(opts, "\nnumgbits=4"); @@ -208,11 +229,7 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) istream = jas_stream_memopen((char*)encoded, buflen); cmpt.stream_ = istream; jpcstream = jas_stream_memopen((char*)helper->jpeg_buffer, helper->buffer_size); -#if JASPER_VERSION_MAJOR == 3 - jaserr = jas_image_encode(&image, jpcstream, fmt, opts); -#else - jaserr = jpc_encode(&image, jpcstream, opts); -#endif + jaserr = ecc_jasper_encode(&image, jpcstream, opts); } if (jaserr != 0) { @@ -233,10 +250,7 @@ cleanup: jas_stream_close(istream); if (jpcstream) jas_stream_close(jpcstream); -#if JASPER_VERSION_MAJOR == 3 - jas_cleanup_thread(); - jas_cleanup_library(); -#endif + ecc_jasper_cleanup(); return code; } From 2344760d1130fb15fc5de58fe353e383cd1b5eca Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 7 Mar 2022 13:53:52 +0000 Subject: [PATCH 3/9] Testing: Improved error message --- tests/grib_packing_order.c | 2 +- tests/grib_packing_order.sh | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/grib_packing_order.c b/tests/grib_packing_order.c index dfe8172eb..dd212df96 100644 --- a/tests/grib_packing_order.c +++ b/tests/grib_packing_order.c @@ -24849,7 +24849,7 @@ int main(int argc, char** argv) for (i = 0; i < values_len; i++) { const double diff = fabs(values[i] - vals[i]); if (diff > EPSILON) { - fprintf(stderr, "Unpacked value different: i=%lu values[i]=%.7f vals[i]=%.7f\n", + fprintf(stderr, "Unpacked value different at i=%lu: original=%.7f decoded=%.7f\n", i, values[i], vals[i]); return 1; } diff --git a/tests/grib_packing_order.sh b/tests/grib_packing_order.sh index 88f815c5c..dd40d842c 100755 --- a/tests/grib_packing_order.sh +++ b/tests/grib_packing_order.sh @@ -71,17 +71,18 @@ fi # IEEE # ------------ -#tests/grib_packing_order grid_ieee values_before_packing_type x2 # Does not work -$EXEC ${test_dir}/grib_packing_order grid_ieee packing_type_before_values $temp_ieee1 -$EXEC ${test_dir}/grib_packing_order grid_ieee values_before_packing_type $temp_ieee2 +if [ $HAVE_EXTRA_TESTS -eq 1 ]; then + #tests/grib_packing_order grid_ieee values_before_packing_type x2 # Does not work + $EXEC ${test_dir}/grib_packing_order grid_ieee packing_type_before_values $temp_ieee1 + $EXEC ${test_dir}/grib_packing_order grid_ieee values_before_packing_type $temp_ieee2 -${tools_dir}/grib_ls -n statistics $temp_ieee1 $temp_ieee2 -# TODO -# ${tools_dir}/grib_compare $temp_ieee1 $temp_ieee2 - -# No point comparing with grid_simple as grid_ieee will be closer to the actual values -# and less lossy + ${tools_dir}/grib_ls -n statistics $temp_ieee1 $temp_ieee2 + # TODO + # ${tools_dir}/grib_compare $temp_ieee1 $temp_ieee2 + # No point comparing with grid_simple as grid_ieee will be closer to the actual values + # and less lossy +fi # Second order Packing: TODO From 46c729d22a9230238f412d4ff86bae253512c010 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 7 Mar 2022 13:54:10 +0000 Subject: [PATCH 4/9] ECC-1343: cleanup --- src/grib_jasper_encoding.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/grib_jasper_encoding.c b/src/grib_jasper_encoding.c index d55a24779..e5f336d10 100644 --- a/src/grib_jasper_encoding.c +++ b/src/grib_jasper_encoding.c @@ -40,7 +40,7 @@ static jas_image_t* ecc_jasper_decode(jas_stream_t *in) #endif } -static int ecc_jasper_encode(jas_image_t *image, jas_stream_t *jpcstream, const char *optstr) +static int ecc_jasper_encode(jas_image_t *image, jas_stream_t *jpcstream, char *optstr) { #if JASPER_VERSION_MAJOR == 3 const int fmt = jas_image_strtofmt("jpc"); @@ -67,6 +67,7 @@ int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, doub jas_matrix_t* matrix = NULL; jas_image_cmpt_t* p; int i, j, k; + int jaserr = 0; /* 0 means success */ ecc_jasper_initialise(); @@ -99,7 +100,11 @@ int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, doub goto cleanup; } - jas_image_readcmpt(image, 0, 0, 0, jas_image_width(image), jas_image_height(image), matrix); + jaserr = jas_image_readcmpt(image, 0, 0, 0, jas_image_width(image), jas_image_height(image), matrix); + if (jaserr) { + code = GRIB_DECODING_ERROR; + goto cleanup; + } Assert(p->height_ * p->width_ == *no_values); @@ -124,7 +129,7 @@ cleanup: int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) { int code = GRIB_SUCCESS; - int jaserr; + int jaserr = 0; char opts[MAXOPTSSIZE]; double reference_value = helper->reference_value; @@ -217,8 +222,8 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) jpcstream = jas_stream_memopen((char*)helper->jpeg_buffer, helper->buffer_size); jaserr = ecc_jasper_encode(&image, jpcstream, opts); - if (jaserr != 0) { - /* increase the number of guard bits */ + if (jaserr) { + /* Failed to encode. Increase the number of guard bits */ strcat(opts, "\nnumgbits=4"); grib_context_log(c, GRIB_LOG_ERROR, "JASPER: error %d, increasing the number of guard bits", jaserr); jas_stream_close(istream); @@ -232,7 +237,7 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) jaserr = ecc_jasper_encode(&image, jpcstream, opts); } - if (jaserr != 0) { + if (jaserr) { grib_context_log(c, GRIB_LOG_ERROR, "JASPER: error %d", jaserr); code = GRIB_ENCODING_ERROR; goto cleanup; From 8fb498fc075f868d7a2565912f265ec35c88cabe Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 7 Mar 2022 16:18:30 +0000 Subject: [PATCH 5/9] ECC-1343: Catch errors from JasPer library --- src/grib_api_prototypes.h | 4 +--- src/grib_jasper_encoding.c | 33 +++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/grib_api_prototypes.h b/src/grib_api_prototypes.h index 9df6e31eb..761cc2bc9 100644 --- a/src/grib_api_prototypes.h +++ b/src/grib_api_prototypes.h @@ -675,9 +675,7 @@ bufr_descriptors_array* grib_accessor_class_expanded_descriptors_get_expanded(gr /* grib_accessor_class_md5.c */ /* grib_jasper_encoding.c */ -int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* values, size_t* no_values); -int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper); -int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* val, size_t* n_vals); +int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* values, const size_t* no_values); int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper); /* grib_openjpeg_encoding.c */ diff --git a/src/grib_jasper_encoding.c b/src/grib_jasper_encoding.c index e5f336d10..80f9844cf 100644 --- a/src/grib_jasper_encoding.c +++ b/src/grib_jasper_encoding.c @@ -20,14 +20,18 @@ #include "jasper/jasper.h" #define MAXOPTSSIZE 1024 -static void ecc_jasper_initialise() +static int ecc_jasper_initialise() { #if JASPER_VERSION_MAJOR == 3 + int jaserr = 0; jas_conf_clear(); jas_conf_set_max_mem_usage(jas_get_total_mem_size()); - jas_init_library(); - jas_init_thread(); + jaserr = jas_init_library(); + if (jaserr) return jaserr; + jaserr = jas_init_thread(); + if (jaserr) return jaserr; #endif + return 0; } static jas_image_t* ecc_jasper_decode(jas_stream_t *in) @@ -58,7 +62,7 @@ static void ecc_jasper_cleanup() #endif } -int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* values, size_t* no_values) +int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* values, const size_t* no_values) { /* jas_setdbglevel(99999); */ jas_image_t* image = NULL; @@ -69,7 +73,12 @@ int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, doub int i, j, k; int jaserr = 0; /* 0 means success */ - ecc_jasper_initialise(); + jaserr = ecc_jasper_initialise(); + if (jaserr) { + grib_context_log(c, GRIB_LOG_ERROR, "grib_jasper_decode: Failed to initialize JasPer library. JasPer error %d", jaserr); + code = GRIB_DECODING_ERROR; + goto cleanup; + } jpeg = jas_stream_memopen((char*)buf, *buflen); if (!jpeg) { @@ -77,7 +86,7 @@ int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, doub goto cleanup; } - grib_context_log(c, GRIB_LOG_DEBUG, "grib_jasper_decode: Jasper version %s", jas_getversion()); + grib_context_log(c, GRIB_LOG_DEBUG, "grib_jasper_decode: JasPer version %s", jas_getversion()); image = ecc_jasper_decode(jpeg); if (!image) { @@ -94,7 +103,6 @@ int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, doub } matrix = jas_matrix_create(jas_image_height(image), jas_image_width(image)); - if (!matrix) { code = GRIB_DECODING_ERROR; goto cleanup; @@ -102,6 +110,7 @@ int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, doub jaserr = jas_image_readcmpt(image, 0, 0, 0, jas_image_width(image), jas_image_height(image), matrix); if (jaserr) { + grib_context_log(c, GRIB_LOG_ERROR, "grib_jasper_decode: Failed to read JasPer component data. JasPer error %d", jaserr); code = GRIB_DECODING_ERROR; goto cleanup; } @@ -211,7 +220,7 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) } Assert(cmpt.width_ * cmpt.height_ * cmpt.cps_ == buflen); - grib_context_log(c, GRIB_LOG_DEBUG, "grib_jasper_encode: Jasper version %s", jas_getversion()); + grib_context_log(c, GRIB_LOG_DEBUG, "grib_jasper_encode: JasPer version %s", jas_getversion()); pcmpt = &cmpt; image.cmpts_ = &pcmpt; @@ -225,7 +234,7 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) if (jaserr) { /* Failed to encode. Increase the number of guard bits */ strcat(opts, "\nnumgbits=4"); - grib_context_log(c, GRIB_LOG_ERROR, "JASPER: error %d, increasing the number of guard bits", jaserr); + grib_context_log(c, GRIB_LOG_ERROR, "grib_jasper_encode: JasPer error %d, increasing the number of guard bits", jaserr); jas_stream_close(istream); istream = 0; jas_stream_close(jpcstream); @@ -238,7 +247,7 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) } if (jaserr) { - grib_context_log(c, GRIB_LOG_ERROR, "JASPER: error %d", jaserr); + grib_context_log(c, GRIB_LOG_ERROR, "grib_jasper_encode: Failed to encode. JasPer error %d", jaserr); code = GRIB_ENCODING_ERROR; goto cleanup; } @@ -264,14 +273,14 @@ cleanup: int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* val, size_t* n_vals) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_accessor_data_jpeg2000_packing: Jasper JPEG support not enabled."); + "grib_accessor_data_jpeg2000_packing: JasPer JPEG support not enabled."); return GRIB_FUNCTIONALITY_NOT_ENABLED; } int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper) { grib_context_log(c, GRIB_LOG_ERROR, - "grib_accessor_data_jpeg2000_packing: Jasper JPEG support not enabled."); + "grib_accessor_data_jpeg2000_packing: JasPer JPEG support not enabled."); return GRIB_FUNCTIONALITY_NOT_ENABLED; } From 4e3a31f25f3f5e87009d6c013e7d0b0717c08234 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 7 Mar 2022 16:38:34 +0000 Subject: [PATCH 6/9] Remove duplicate prototypes --- src/grib_api_prototypes.h | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/grib_api_prototypes.h b/src/grib_api_prototypes.h index 761cc2bc9..ae0951027 100644 --- a/src/grib_api_prototypes.h +++ b/src/grib_api_prototypes.h @@ -675,12 +675,12 @@ bufr_descriptors_array* grib_accessor_class_expanded_descriptors_get_expanded(gr /* grib_accessor_class_md5.c */ /* grib_jasper_encoding.c */ -int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* values, const size_t* no_values); +int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* values, const size_t* n_vals); int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper); /* grib_openjpeg_encoding.c */ +int grib_openjpeg_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* values, const size_t* n_vals); int grib_openjpeg_encode(grib_context* c, j2k_encode_helper* helper); -int grib_openjpeg_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* val, const size_t* n_vals); /* action_class_set_missing.c */ grib_action* grib_action_create_set_missing(grib_context* context, const char* name); @@ -712,7 +712,6 @@ grib_index* grib_index_read(grib_context* c, const char* filename, int* err); int grib_index_search_same(grib_index* index, grib_handle* h); int grib_index_add_file(grib_index* index, const char* filename); int _codes_index_add_file(grib_index* index, const char* filename, int message_type); -int grib_index_add_file(grib_index* index, const char* filename); grib_index* grib_index_new_from_file(grib_context* c, const char* filename, const char* keys, int* err); int grib_index_get_size(const grib_index* index, const char* key, size_t* size); int grib_index_get_string(const grib_index* index, const char* key, char** values, size_t* size); @@ -813,14 +812,6 @@ void grib_timer_print(grib_timer* t); void grib_timer_partial_rate(grib_timer* t, double start, long total); void grib_print_all_timers(void); void grib_reset_all_timers(void); -grib_timer* grib_get_timer(grib_context* c, const char* name, const char* statname, int elapsed); -int grib_timer_start(grib_timer* t); -int grib_timer_stop(grib_timer* t, long total); -double grib_timer_value(grib_timer* t); -void grib_timer_print(grib_timer* t); -void grib_timer_partial_rate(grib_timer* t, double start, long total); -void grib_print_all_timers(void); -void grib_reset_all_timers(void); /* grib_ibmfloat.c */ unsigned long grib_ibm_to_long(double x); @@ -839,15 +830,10 @@ double grib_ieeefloat_error(double x); double grib_long_to_ieee(unsigned long x); unsigned long grib_ieee_nearest_smaller_to_long(double x); int grib_nearest_smaller_ieee_float(double a, double* ret); -double grib_ieeefloat_error(double x); -double grib_long_to_ieee(unsigned long x); -int grib_nearest_smaller_ieee_float(double a, double* x); -unsigned long grib_ieee_to_long(double x); + unsigned long grib_ieee64_to_long(double x); double grib_long_to_ieee64(unsigned long x); int grib_ieee_decode_array(grib_context* c, unsigned char* buf, size_t nvals, int bytes, double* val); -int grib_ieee_decode_array(grib_context* c, unsigned char* buf, size_t nvals, int bytes, double* val); -int grib_ieee_encode_array(grib_context* c, double* val, size_t nvals, int bytes, unsigned char* buf); int grib_ieee_encode_array(grib_context* c, double* val, size_t nvals, int bytes, unsigned char* buf); /* grib_accessor_class_reference_value_error.c */ From c77d657a2df72a91d7bea1277a08e4098689427a Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 7 Mar 2022 16:38:55 +0000 Subject: [PATCH 7/9] ECC-1343: Const correctness --- src/grib_jasper_encoding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grib_jasper_encoding.c b/src/grib_jasper_encoding.c index 80f9844cf..e9ad29203 100644 --- a/src/grib_jasper_encoding.c +++ b/src/grib_jasper_encoding.c @@ -62,7 +62,7 @@ static void ecc_jasper_cleanup() #endif } -int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* values, const size_t* no_values) +int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* values, const size_t* no_values) { /* jas_setdbglevel(99999); */ jas_image_t* image = NULL; From 0a367b1d53f4b6cfe20c03e914684e18431f4e72 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 7 Mar 2022 16:42:22 +0000 Subject: [PATCH 8/9] ECC-1343: Fix signatures --- src/grib_jasper_encoding.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/grib_jasper_encoding.c b/src/grib_jasper_encoding.c index e9ad29203..e26157a02 100644 --- a/src/grib_jasper_encoding.c +++ b/src/grib_jasper_encoding.c @@ -62,7 +62,7 @@ static void ecc_jasper_cleanup() #endif } -int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* values, const size_t* no_values) +int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* values, const size_t* n_vals) { /* jas_setdbglevel(99999); */ jas_image_t* image = NULL; @@ -115,7 +115,7 @@ int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen goto cleanup; } - Assert(p->height_ * p->width_ == *no_values); + Assert(p->height_ * p->width_ == *n_vals); k = 0; for (i = 0; i < p->height_; i++) @@ -270,7 +270,7 @@ cleanup: #else -int grib_jasper_decode(grib_context* c, unsigned char* buf, size_t* buflen, double* val, size_t* n_vals) +int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* val, size_t* n_vals) { grib_context_log(c, GRIB_LOG_ERROR, "grib_accessor_data_jpeg2000_packing: JasPer JPEG support not enabled."); From 60f072f74dc720f06ac862585231bfb5b22252fd Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Mon, 7 Mar 2022 16:44:55 +0000 Subject: [PATCH 9/9] ECC-1343: Fix signatures --- src/grib_jasper_encoding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grib_jasper_encoding.c b/src/grib_jasper_encoding.c index e26157a02..fe8facf92 100644 --- a/src/grib_jasper_encoding.c +++ b/src/grib_jasper_encoding.c @@ -270,7 +270,7 @@ cleanup: #else -int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* val, size_t* n_vals) +int grib_jasper_decode(grib_context* c, unsigned char* buf, const size_t* buflen, double* val, const size_t* n_vals) { grib_context_log(c, GRIB_LOG_ERROR, "grib_accessor_data_jpeg2000_packing: JasPer JPEG support not enabled.");