mirror of https://github.com/ecmwf/eccodes.git
ECC-1343: Problems compiling with Jasper v3.0 (Try 01)
This commit is contained in:
parent
2837446798
commit
0a94dc71fb
|
@ -18,7 +18,6 @@
|
||||||
#undef PACKAGE_TARNAME
|
#undef PACKAGE_TARNAME
|
||||||
#undef PACKAGE_VERSION
|
#undef PACKAGE_VERSION
|
||||||
#include "jasper/jasper.h"
|
#include "jasper/jasper.h"
|
||||||
|
|
||||||
#define MAXOPTSSIZE 1024
|
#define MAXOPTSSIZE 1024
|
||||||
|
|
||||||
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, 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_matrix_t* matrix = NULL;
|
||||||
jas_image_cmpt_t* p;
|
jas_image_cmpt_t* p;
|
||||||
int i, j, k;
|
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);
|
jpeg = jas_stream_memopen((char*)buf, *buflen);
|
||||||
if (!jpeg) {
|
if (!jpeg) {
|
||||||
code = GRIB_DECODING_ERROR;
|
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());
|
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);
|
image = jpc_decode(jpeg, NULL);
|
||||||
|
#endif
|
||||||
if (!image) {
|
if (!image) {
|
||||||
code = GRIB_DECODING_ERROR;
|
code = GRIB_DECODING_ERROR;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -77,7 +84,10 @@ cleanup:
|
||||||
jas_image_destroy(image);
|
jas_image_destroy(image);
|
||||||
if (jpeg)
|
if (jpeg)
|
||||||
jas_stream_close(jpeg);
|
jas_stream_close(jpeg);
|
||||||
|
#if JASPER_VERSION_MAJOR == 3
|
||||||
|
jas_cleanup_thread();
|
||||||
|
jas_cleanup_library();
|
||||||
|
#endif
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +104,7 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper)
|
||||||
long no_values = helper->no_values;
|
long no_values = helper->no_values;
|
||||||
long bits8;
|
long bits8;
|
||||||
int i;
|
int i;
|
||||||
|
int fmt;
|
||||||
|
|
||||||
size_t buflen = 0;
|
size_t buflen = 0;
|
||||||
unsigned char* encoded = NULL;
|
unsigned char* encoded = NULL;
|
||||||
|
@ -155,9 +166,12 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper)
|
||||||
buflen++;
|
buflen++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if JASPER_VERSION_MAJOR == 3
|
||||||
/*jas_init();*/
|
jas_conf_clear();
|
||||||
|
jas_conf_set_max_mem_usage(jas_get_total_mem_size());
|
||||||
|
jas_init_library();
|
||||||
|
jas_init_thread();
|
||||||
|
#endif
|
||||||
opts[0] = 0;
|
opts[0] = 0;
|
||||||
|
|
||||||
if (helper->compression != 0) {
|
if (helper->compression != 0) {
|
||||||
|
@ -175,8 +189,13 @@ int grib_jasper_encode(grib_context* c, j2k_encode_helper* helper)
|
||||||
cmpt.stream_ = istream;
|
cmpt.stream_ = istream;
|
||||||
|
|
||||||
jpcstream = jas_stream_memopen((char*)helper->jpeg_buffer, helper->buffer_size);
|
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);
|
jaserr = jpc_encode(&image, jpcstream, opts);
|
||||||
|
#endif
|
||||||
if (jaserr != 0) {
|
if (jaserr != 0) {
|
||||||
/* increase the number of guard bits */
|
/* increase the number of guard bits */
|
||||||
strcat(opts, "\nnumgbits=4");
|
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);
|
istream = jas_stream_memopen((char*)encoded, buflen);
|
||||||
cmpt.stream_ = istream;
|
cmpt.stream_ = istream;
|
||||||
jpcstream = jas_stream_memopen((char*)helper->jpeg_buffer, helper->buffer_size);
|
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);
|
jaserr = jpc_encode(&image, jpcstream, opts);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jaserr != 0) {
|
if (jaserr != 0) {
|
||||||
|
@ -210,7 +233,10 @@ cleanup:
|
||||||
jas_stream_close(istream);
|
jas_stream_close(istream);
|
||||||
if (jpcstream)
|
if (jpcstream)
|
||||||
jas_stream_close(jpcstream);
|
jas_stream_close(jpcstream);
|
||||||
|
#if JASPER_VERSION_MAJOR == 3
|
||||||
|
jas_cleanup_thread();
|
||||||
|
jas_cleanup_library();
|
||||||
|
#endif
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue