GraphicsMagick: Detect and use new JasPer function jas_initializ...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.28690.1630008644.1385.graphicsmagick-commit@lists.sourceforge.net>
changeset 123d0f5b82c3 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=123d0f5b82c3
summary: Detect and use new JasPer function jas_initialize() in order to avoid severe problems with jas_init().

diffstat:

 ChangeLog                              |   8 ++++++
 VisualMagick/installer/inc/version.isx |   4 +-
 coders/jp2.c                           |  44 +++++++++++++++++++++++++++++++--
 configure                              |   2 +-
 configure.ac                           |   2 +-
 magick/magick_config.h.in              |   4 +-
 magick/version.h                       |   4 +-
 www/Changelog.html                     |   7 +++++
 8 files changed, 64 insertions(+), 11 deletions(-)

diffs (166 lines):

diff -r 631b7f2d66e8 -r 123d0f5b82c3 ChangeLog
--- a/ChangeLog	Sat Aug 14 14:55:58 2021 -0500
+++ b/ChangeLog	Thu Aug 26 15:10:23 2021 -0500
@@ -1,3 +1,11 @@
+2021-08-26  Bob Friesenhahn  <[email protected]>
+
+        * coders/jp2.c (initialize_jasper): Make minimal use of new JasPer
+        function jas_initialize() in order to avoid severe problems with
+        jas_init().
+
+        * configure.ac: Detect new JasPer function jas_initialize().
+
 2021-08-14  Bob Friesenhahn  <[email protected]>
 
         * coders/msl.c (MSLError): Call xmlStopParser() rather than
diff -r 631b7f2d66e8 -r 123d0f5b82c3 VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx	Sat Aug 14 14:55:58 2021 -0500
+++ b/VisualMagick/installer/inc/version.isx	Thu Aug 26 15:10:23 2021 -0500
@@ -10,5 +10,5 @@
 
 #define public MagickPackageName "GraphicsMagick"
 #define public MagickPackageVersion "1.4"
-#define public MagickPackageVersionAddendum ".020210814"
-#define public MagickPackageReleaseDate "snapshot-20210814"
+#define public MagickPackageVersionAddendum ".020210826"
+#define public MagickPackageReleaseDate "snapshot-20210826"
diff -r 631b7f2d66e8 -r 123d0f5b82c3 coders/jp2.c
--- a/coders/jp2.c	Sat Aug 14 14:55:58 2021 -0500
+++ b/coders/jp2.c	Thu Aug 26 15:10:23 2021 -0500
@@ -424,6 +424,9 @@
 #if HAVE_JAS_INIT_CUSTOM
       jas_conf_t jas_conf;
 
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "Initializing JasPer...");
+
       /* Get the default configuration parameters that were selected at
          when the library was built. */
       jas_get_default_conf(&jas_conf);
@@ -439,11 +442,42 @@
       /* Do not register jas_cleanup() via atexit() */
       jas_conf.atexit_cleanup = false;
 
-      (void) jas_init_custom(&jas_conf);
+      if (jas_init_custom(&jas_conf) == 0)
+        {
+          jasper_initialized=MagickTrue;
+        }
+#elif HAVE_JAS_INITIALIZE
+      {
+        /* static jas_std_allocator_t allocator; */
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Initializing JasPer...");
+        jas_conf_clear();
+        /* jas_std_allocator_init(&allocator); */
+        /* jas_conf_set_allocator(&allocator.base); */
+        /* jas_conf_set_debug_level(cmdopts->debug); */
+        /* jas_conf_set_max_mem(cmdopts->max_mem); */
+
+        if (jas_initialize() == 0)
+          {
+            jasper_initialized=MagickTrue;
+          }
+      }
 #else
-      jas_init();
+      {
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Initializing JasPer...");
+        if (jas_init() == 0)
+          {
+            jasper_initialized=MagickTrue;
+          }
+      }
 #endif  /* HAVE_JAS_INIT_CUSTOM */
-      jasper_initialized=MagickTrue;
+
+      if (!jasper_initialized)
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Failed to initialize JasPer!");
+        }
     }
 }
 
@@ -455,7 +489,11 @@
 {
   if (jasper_initialized)
     {
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "Destroying JasPer...");
+#if HAVE_JAS_INITIALIZE || HAVE_JAS_INIT_CUSTOM
       jas_cleanup();
+#endif /* if HAVE_JAS_INITIALIZE || HAVE_JAS_INIT_CUSTOM */
       jasper_initialized=MagickFalse;
     }
 }
diff -r 631b7f2d66e8 -r 123d0f5b82c3 configure
--- a/configure	Sat Aug 14 14:55:58 2021 -0500
+++ b/configure	Thu Aug 26 15:10:23 2021 -0500
@@ -26138,7 +26138,7 @@
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
         have_jp2='yes'
-        for ac_func in jas_init_custom jp2_decode jpc_decode pgx_decode
+        for ac_func in jas_initialize jp2_decode jpc_decode pgx_decode
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff -r 631b7f2d66e8 -r 123d0f5b82c3 configure.ac
--- a/configure.ac	Sat Aug 14 14:55:58 2021 -0500
+++ b/configure.ac	Thu Aug 26 15:10:23 2021 -0500
@@ -2234,7 +2234,7 @@
         AC_DEFINE([HasJP2],[1],[Define if you have JPEG version 2 "Jasper" library])
         AC_MSG_RESULT([yes])
         have_jp2='yes'
-        AC_CHECK_FUNCS([jas_init_custom jp2_decode jpc_decode pgx_decode])
+        AC_CHECK_FUNCS([jas_initialize jp2_decode jpc_decode pgx_decode])
     fi
     else
     AC_MSG_RESULT([no])
diff -r 631b7f2d66e8 -r 123d0f5b82c3 magick/magick_config.h.in
--- a/magick/magick_config.h.in	Sat Aug 14 14:55:58 2021 -0500
+++ b/magick/magick_config.h.in	Thu Aug 26 15:10:23 2021 -0500
@@ -146,8 +146,8 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
-/* Define to 1 if you have the `jas_init_custom' function. */
-#undef HAVE_JAS_INIT_CUSTOM
+/* Define to 1 if you have the `jas_initialize' function. */
+#undef HAVE_JAS_INITIALIZE
 
 /* Define to 1 if you have the `jp2_decode' function. */
 #undef HAVE_JP2_DECODE
diff -r 631b7f2d66e8 -r 123d0f5b82c3 magick/version.h
--- a/magick/version.h	Sat Aug 14 14:55:58 2021 -0500
+++ b/magick/version.h	Thu Aug 26 15:10:23 2021 -0500
@@ -38,8 +38,8 @@
 #define MagickLibVersion  0x252200
 #define MagickLibVersionText  "1.4"
 #define MagickLibVersionNumber 25,22,0
-#define MagickChangeDate   "20210814"
-#define MagickReleaseDate  "snapshot-20210814"
+#define MagickChangeDate   "20210826"
+#define MagickReleaseDate  "snapshot-20210826"
 
 /*
   The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines
diff -r 631b7f2d66e8 -r 123d0f5b82c3 www/Changelog.html
--- a/www/Changelog.html	Sat Aug 14 14:55:58 2021 -0500
+++ b/www/Changelog.html	Thu Aug 26 15:10:23 2021 -0500
@@ -35,6 +35,13 @@
 <div class="document">
 
 
+<p>2021-08-26  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<p>* coders/jp2.c (initialize_jasper): Make minimal use of new JasPer
+function jas_initialize() in order to avoid severe problems with
+jas_init().</p>
+<p>* configure.ac: Detect new JasPer function jas_initialize().</p>
+</blockquote>
 <p>2021-08-14  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <p>* coders/msl.c (MSLError): Call xmlStopParser() rather than
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.