jasper3: use wrapper entry point for jpeg2000 decoder

This commit is contained in:
Mamoru TASAKA 2022-02-15 00:10:55 +09:00
parent c6b0799102
commit a086e5e7b2
2 changed files with 86 additions and 1 deletions

View File

@ -0,0 +1,75 @@
diff -urp -x '*~' -x redhat-linux-build -x '*.list' -x '.package_note*' eccodes-2.24.0-Source/src/grib_jasper_encoding.c eccodes-2.24.0-Source.new/src/grib_jasper_encoding.c
--- eccodes-2.24.0-Source/src/grib_jasper_encoding.c 2021-12-07 20:03:44.000000000 +0900
+++ eccodes-2.24.0-Source.new/src/grib_jasper_encoding.c 2022-02-14 23:35:10.954255326 +0900
@@ -30,7 +30,7 @@ int grib_jasper_decode(grib_context* c,
jas_matrix_t* matrix = NULL;
jas_image_cmpt_t* p;
int i, j, k;
-
+ jas_conf_clear(); jas_conf_set_max_mem_usage(jas_get_total_mem_size()); jas_init_library(); jas_init_thread();
jpeg = jas_stream_memopen((char*)buf, *buflen);
if (!jpeg) {
code = GRIB_DECODING_ERROR;
@@ -39,7 +39,7 @@ int grib_jasper_decode(grib_context* c,
grib_context_log(c, GRIB_LOG_DEBUG, "grib_jasper_decode: Jasper version %s", jas_getversion());
- image = jpc_decode(jpeg, NULL);
+ image = jas_image_decode (jpeg, -1, 0);
if (!image) {
code = GRIB_DECODING_ERROR;
goto cleanup;
@@ -77,7 +77,7 @@ cleanup:
jas_image_destroy(image);
if (jpeg)
jas_stream_close(jpeg);
-
+ jas_cleanup_thread(); jas_cleanup_library();
return code;
}
@@ -94,6 +94,7 @@ int grib_jasper_encode(grib_context* c,
long no_values = helper->no_values;
long bits8;
int i;
+ int fmt;
size_t buflen = 0;
unsigned char* encoded = NULL;
@@ -156,7 +157,7 @@ int grib_jasper_encode(grib_context* c,
}
}
- /*jas_init();*/
+ jas_conf_clear(); jas_conf_set_max_mem_usage(jas_get_total_mem_size()); jas_init_library(); jas_init_thread();
opts[0] = 0;
@@ -175,7 +176,8 @@ int grib_jasper_encode(grib_context* c,
cmpt.stream_ = istream;
jpcstream = jas_stream_memopen((char*)helper->jpeg_buffer, helper->buffer_size);
- jaserr = jpc_encode(&image, jpcstream, opts);
+ fmt = jas_image_strtofmt("jpc");
+ jaserr = jas_image_encode(&image, jpcstream, fmt, opts);
if (jaserr != 0) {
/* increase the number of guard bits */
@@ -189,7 +191,7 @@ int grib_jasper_encode(grib_context* c,
istream = jas_stream_memopen((char*)encoded, buflen);
cmpt.stream_ = istream;
jpcstream = jas_stream_memopen((char*)helper->jpeg_buffer, helper->buffer_size);
- jaserr = jpc_encode(&image, jpcstream, opts);
+ jaserr = jas_image_encode(&image, jpcstream, fmt, opts);
}
if (jaserr != 0) {
@@ -210,7 +212,7 @@ cleanup:
jas_stream_close(istream);
if (jpcstream)
jas_stream_close(jpcstream);
-
+ jas_cleanup_thread(); jas_cleanup_library();
return code;
}

View File

@ -1,6 +1,6 @@
Name: eccodes
Version: 2.24.0
Release: 3%{?dist}
Release: 4%{?dist}
Summary: WMO data format decoding and encoding
# force the shared libraries to have these so versions
@ -51,6 +51,13 @@ Patch1: eccodes-soversion.patch
# https://jira.ecmwf.int/browse/SUP-2410
Patch2: eccodes-grib_api_internal.h-reverse-definition-of-FAST_BIG_E.patch
# jasper3 now hides internal encoder / decoder. Use wrapper entry point
# c.f. https://github.com/jasper-software/jasper/commit/5fe57ac5829ec31396e7eaab59a688da014660af
# Also, now with jasper3, calling jas_stream_memopen (for example) always needs jasper
# library initialization
Patch3: eccodes-2.24.0-jasper3-use-wrapper-entry-point.patch
BuildRequires: cmake3
BuildRequires: gcc
BuildRequires: gcc-gfortran
@ -347,6 +354,9 @@ ctest3 -V %{?_smp_mflags}
%doc %{_datadir}/doc/%{name}/
%changelog
* Mon Feb 14 2022 Mamoru TASAKA <mtasaka@fedoraproject.org> - 2.24.0-4
- jasper3: use wrapper entry point for jpeg2000 decoder
* Sun Feb 13 2022 Josef Ridky <jridky@redhat.com> - 2.24.0-3
- Rebuilt for libjasper.so.6