GraphicsMagick: Enable JXL support by default. Add instrumentat...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.4288.1647716445.1506.graphicsmagick-commit@lists.sourceforge.net>
changeset b2a4fb7af59b in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=b2a4fb7af59b
summary: Enable JXL support by default.  Add instrumentation.

diffstat:

 ChangeLog                              |    8 +
 VisualMagick/installer/inc/version.isx |    4 +-
 coders/jxl.c                           |   99 +++-
 configure                              |    4 +-
 configure.ac                           |    6 +-
 locale/C.mgk                           |    2 +-
 magick/gm_messages.mc                  |    2 +-
 magick/locale_c.h                      |  714 ++++++++++++++++----------------
 magick/version.h                       |    4 +-
 www/Changelog.html                     |    7 +
 10 files changed, 468 insertions(+), 382 deletions(-)

diffs (truncated from 1025 to 500 lines):

diff -r 0fe658be8f34 -r b2a4fb7af59b ChangeLog
--- a/ChangeLog	Fri Mar 11 13:53:13 2022 -0600
+++ b/ChangeLog	Sat Mar 19 14:00:30 2022 -0500
@@ -1,3 +1,11 @@
+2022-03-19  Bob Friesenhahn  <[email protected]>
+
+        * coders/jxl.c: Added some debug logging instrumentation so we can
+        see the information the JXL reader is provided by libjxl.
+
+        * configure.ac: JXL is working well enough to enable it by
+        default.
+
 2022-03-11  Bob Friesenhahn  <[email protected]>
 
         * coders/jxl.c (WriteJXLImage): Call JxlEncoderCloseInput() so
diff -r 0fe658be8f34 -r b2a4fb7af59b VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx	Fri Mar 11 13:53:13 2022 -0600
+++ b/VisualMagick/installer/inc/version.isx	Sat Mar 19 14:00:30 2022 -0500
@@ -10,5 +10,5 @@
 
 #define public MagickPackageName "GraphicsMagick"
 #define public MagickPackageVersion "1.4"
-#define public MagickPackageVersionAddendum ".020220311"
-#define public MagickPackageReleaseDate "snapshot-20220311"
+#define public MagickPackageVersionAddendum ".020220319"
+#define public MagickPackageReleaseDate "snapshot-20220319"
diff -r 0fe658be8f34 -r b2a4fb7af59b coders/jxl.c
--- a/coders/jxl.c	Fri Mar 11 13:53:13 2022 -0600
+++ b/coders/jxl.c	Sat Mar 19 14:00:30 2022 -0500
@@ -348,6 +348,41 @@
   return MagickTrue;
 }
 
+static const char *JxlTransferFunctionAsString(const JxlTransferFunction fn)
+{
+  const char *str = "Unknown";
+
+  switch (fn)
+    {
+    case JXL_TRANSFER_FUNCTION_709:
+      str = "Rec709 (SMPTE RP 431-2)";
+      break;
+    case JXL_TRANSFER_FUNCTION_UNKNOWN:
+      str = "Unknown";
+      break;
+    case JXL_TRANSFER_FUNCTION_LINEAR:
+      str = "Linear (Gamma 1.0)";
+      break;
+    case JXL_TRANSFER_FUNCTION_SRGB:
+      str = "sRGB (IEC 61966-2-1)";
+      break;
+    case JXL_TRANSFER_FUNCTION_PQ:
+      str = "PQ (SMPTE ST 428-1)";
+      break;
+    case JXL_TRANSFER_FUNCTION_DCI:
+      str = "DCI (SMPTE ST 428-1)";
+      break;
+    case JXL_TRANSFER_FUNCTION_HLG:
+      str = "HLG (Rec. ITU-R BT.2100-1)";
+      break;
+    case JXL_TRANSFER_FUNCTION_GAMMA:
+      str = "Gamma (use gamma from JxlColorEncoding)";
+      break;
+    }
+
+  return str;
+}
+
 #define JXLReadCleanup()                                \
   MagickFreeResourceLimitedMemory(out_buf);             \
   MagickFreeResourceLimitedMemory(in_buf);              \
@@ -468,12 +503,31 @@
           { /* got image information */
             JxlBasicInfo
               basic_info;
+
+            unsigned long
+              max_value_given_bits;
+
             JxlEncoderInitBasicInfo(&basic_info);
 
             status=JxlDecoderGetBasicInfo(jxl,&basic_info);
             if (status != JXL_DEC_SUCCESS)
               break;
 
+            if (image->logging)
+              {
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Basic Info:\n"
+                                      "    xsize=%u\n"
+                                      "    ysize=%u \n"
+                                      "    bits_per_sample=%u\n"
+                                      "    exponent_bits_per_sample=%u\n"
+                                      "    alpha_bits=%u\n"
+                                      "    num_color_channels=%u",
+                                      basic_info.xsize, basic_info.ysize,
+                                      basic_info.bits_per_sample, basic_info.exponent_bits_per_sample,
+                                      basic_info.alpha_bits, basic_info.num_color_channels);
+              }
+
             if (basic_info.have_animation == 1)
               ThrowJXLReaderException(CoderError, ImageTypeNotSupported, image);
 
@@ -484,10 +538,13 @@
               image->matte=MagickTrue;
 
             image->orientation=convert_orientation(basic_info.orientation);
+            max_value_given_bits=MaxValueGivenBits(basic_info.bits_per_sample);
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "max_value_given_bits=%lu",max_value_given_bits);
 
-            if (basic_info.num_color_channels == 1 && image->depth == 8)
+            if ((basic_info.num_color_channels == 1) && (max_value_given_bits < MaxColormapSize))
               {
-                if (!AllocateImageColormap(image,1 << image->depth))
+                if (!AllocateImageColormap(image,max_value_given_bits+1))
                   ThrowJXLReaderException(ResourceLimitError,MemoryAllocationFailed,image);
                 grayscale=MagickTrue;
                 format.num_channels=1;
@@ -543,16 +600,30 @@
               }
             else if (status == JXL_DEC_SUCCESS)
               {
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Color Transfer Function: %s",
+                                      JxlTransferFunctionAsString(color_encoding.transfer_function));
                 switch (color_encoding.transfer_function) {
                 case JXL_TRANSFER_FUNCTION_LINEAR:
                   isLinear=MagickTrue;
                   break;
-
                 case JXL_TRANSFER_FUNCTION_709:
+                  isLinear=MagickFalse;
+                  break;
                 case JXL_TRANSFER_FUNCTION_PQ:
+                  isLinear=MagickFalse;
+                  break;
                 case JXL_TRANSFER_FUNCTION_HLG:
+                  isLinear=MagickFalse;
+                  break;
                 case JXL_TRANSFER_FUNCTION_GAMMA:
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                        "Gamma: %g", color_encoding.gamma);
+                  isLinear=MagickFalse;
+                  break;
                 case JXL_TRANSFER_FUNCTION_DCI:
+                  isLinear=MagickFalse;
+                  break;
                 case JXL_TRANSFER_FUNCTION_SRGB:
                   isLinear=MagickFalse;
                   break;
@@ -585,7 +656,7 @@
                     }
                   break;
                 case JXL_COLOR_SPACE_GRAY:
-                  if(!grayscale || isLinear)
+                  if(!grayscale || isLinear) /* FIXME: Can't read linear gray */
                     ThrowJXLReaderException(CoderError, ImageTypeNotSupported, image);
                   break;
                 case JXL_COLOR_SPACE_XYB:
@@ -705,10 +776,10 @@
   MagickFreeResourceLimitedMemory(out_buf); \
 
 #define ThrowJXLWriterException(code_,reason_,image_) \
-{ \
-  JXLWriteCleanup() \
+do { \
+  JXLWriteCleanup();                          \
   ThrowWriterException(code_,reason_,image_); \
-}
+ } while(1)
 
 
 static unsigned int WriteJXLImage(const ImageInfo *image_info,Image *image)
@@ -857,19 +928,19 @@
     {
       /* TODO better error codes */
       if (jxl_status == JXL_ENC_ERROR)
-        ThrowJXLWriterException(CoderError,NoDataReturned,image)
-        else if (jxl_status == JXL_ENC_NOT_SUPPORTED)
-          ThrowJXLWriterException(CoderError,UnsupportedBitsPerSample,image)
-          else
-            ThrowJXLWriterException(CoderFatalError,Default,image)
-              }
+        ThrowJXLWriterException(CoderError,NoDataReturned,image);
+      else if (jxl_status == JXL_ENC_NOT_SUPPORTED)
+        ThrowJXLWriterException(CoderError,UnsupportedBitsPerSample,image);
+      else
+        ThrowJXLWriterException(CoderFatalError,Default,image);
+    }
 
   /* Set expected input colorspace */
   /* FIXME: For RGB we want to set JXL_COLOR_SPACE_RGB and for gray we want JXL_COLOR_SPACE_GRAY */
   basic_info.uses_original_profile = JXL_TRUE;
   JxlColorEncodingSetToSRGB(&color_encoding, pixel_format.num_channels < 3);
   if (JxlEncoderSetColorEncoding(jxl_encoder, &color_encoding) != JXL_ENC_SUCCESS)
-    ThrowJXLWriterException(CoderFatalError,Default,image)
+    ThrowJXLWriterException(CoderFatalError,Default,image);
 
   frame_settings = JxlEncoderFrameSettingsCreate(jxl_encoder, NULL);
   if (image_info->quality == 100)
diff -r 0fe658be8f34 -r b2a4fb7af59b configure
--- a/configure	Fri Mar 11 13:53:13 2022 -0600
+++ b/configure	Sat Mar 19 14:00:30 2022 -0500
@@ -1803,7 +1803,7 @@
   --without-heif          disable HEIF support
   --without-jpeg          disable JPEG support
   --without-jp2           disable JPEG v2 support
-  --with-jxl              enable JPEG-XL support
+  --without-jxl           disable JPEG-XL support
   --without-lcms2         disable lcms (v2.X) support
   --without-lzma          disable LZMA support
   --without-png           disable PNG support
@@ -19481,7 +19481,7 @@
 if test "${with_jxl+set}" = set; then :
   withval=$with_jxl; with_jxl=$withval
 else
-  with_jxl='no'
+  with_jxl='yes'
 fi
 
 if test "$with_jxl" != 'yes' ; then
diff -r 0fe658be8f34 -r b2a4fb7af59b configure.ac
--- a/configure.ac	Fri Mar 11 13:53:13 2022 -0600
+++ b/configure.ac	Sat Mar 19 14:00:30 2022 -0500
@@ -721,10 +721,10 @@
 
 # Disable JXL
 AC_ARG_WITH([jxl],
-              AS_HELP_STRING([--with-jxl],
-                             [enable JPEG-XL support]),
+              AS_HELP_STRING([--without-jxl],
+                             [disable JPEG-XL support]),
               [with_jxl=$withval],
-              [with_jxl='no'])
+              [with_jxl='yes'])
 if test "$with_jxl" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-jxl=$with_jxl "
 fi
diff -r 0fe658be8f34 -r b2a4fb7af59b locale/C.mgk
--- a/locale/C.mgk	Fri Mar 11 13:53:13 2022 -0600
+++ b/locale/C.mgk	Sat Mar 19 14:00:30 2022 -0500
@@ -767,7 +767,7 @@
         image colorspace mismatch
       </Message>
       <Message name="ImageDifferenceExceedsLimit">
-        image difference exceeds limit (%s)
+        image difference exceeds limit
       </Message>
       <Message name="ImageDoesNotContainResolution">
         image does not contain resolution
diff -r 0fe658be8f34 -r b2a4fb7af59b magick/gm_messages.mc
--- a/magick/gm_messages.mc	Fri Mar 11 13:53:13 2022 -0600
+++ b/magick/gm_messages.mc	Sat Mar 19 14:00:30 2022 -0500
@@ -1399,7 +1399,7 @@
 MessageId       = +1
 SymbolicName    = ImageErrorImageDifferenceExceedsLimit
 Language        = English
-image difference exceeds limit (%s)
+image difference exceeds limit
 .
 
 MessageId       = +1
diff -r 0fe658be8f34 -r b2a4fb7af59b magick/locale_c.h
--- a/magick/locale_c.h	Fri Mar 11 13:53:13 2022 -0600
+++ b/magick/locale_c.h	Sat Mar 19 14:00:30 2022 -0500
@@ -1531,7 +1531,7 @@
     "Colorspace color profile mismatch\0"
     "image colorspace differs\0"
     "image colorspace mismatch\0"
-    "image difference exceeds limit (%s)\0"
+    "image difference exceeds limit\0"
     "image does not contain resolution\0"
     "image is not colormapped\0"
     "image opacity differs\0"
@@ -2125,362 +2125,362 @@
     6923,
     6948,
     6974,
-    7010,
-    7044,
-    7069,
-    7091,
-    7118,
-    7137,
-    7160,
-    7194,
-    7215,
-    7237,
-    7265,
-    7282,
-    7305,
-    7330,
-    7354,
-    7379,
-    7404,
-    7434,
-    7464,
-    7501,
-    7531,
-    7555,
-    7579,
-    7608,
-    7639,
-    7669,
-    7692,
-    7716,
-    7740,
-    7769,
-    7791,
-    7821,
-    7843,
-    7859,
-    7888,
-    7917,
-    7951,
-    7993,
-    8019,
-    8044,
-    8085,
-    8126,
-    8156,
-    8185,
-    8219,
-    8261,
-    8275,
-    8291,
-    8314,
-    8336,
-    8358,
-    8390,
-    8410,
-    8445,
-    8461,
-    8475,
-    8489,
-    8529,
-    8545,
-    8569,
-    8600,
-    8630,
-    8659,
-    8691,
-    8730,
-    8759,
-    8788,
-    8820,
-    8846,
-    8877,
-    8908,
-    8939,
-    8966,
-    9001,
-    9036,
-    9064,
-    9090,
-    9148,
-    9174,
-    9198,
-    9230,
-    9248,
-    9283,
-    9309,
-    9328,
-    9353,
-    9378,
-    9419,
-    9451,
-    9474,
-    9496,
-    9537,
-    9577,
-    9609,
-    9642,
-    9663,
-    9684,
-    9713,
-    9740,
-    9765,
-    9786,
-    9811,
-    9834,
-    9867,
-    9889,
-    9915,
-    9937,
-    9959,
-    9983,
-    10009,
-    10030,
-    10053,
-    10079,
-    10098,
-    10125,
-    10155,
-    10227,
-    10257,
-    10285,
-    10306,
-    10331,
-    10357,
-    10386,
-    10417,
-    10443,
-    10469,
-    10493,
-    10517,
-    10542,
-    10570,
-    10593,
-    10619,
-    10642,
-    10666,
-    10688,
-    10708,
-    10739,
-    10762,
-    10788,
-    10815,
-    10833,
-    10857,
-    10891,
-    10919,
-    10966,
-    10990,
-    11010,
-    11029,
-    11052,
-    11078,
-    11136,
-    11158,
-    11186,
-    11218,
-    11241,
-    11263,
-    11290,
-    11319,
-    11347,
-    11372,
-    11397,
-    11427,
-    11451,
-    11479,
-    11499,
-    11526,
-    11560,
-    11579,
-    11594,
-    11614,
-    11638,
-    11664,
-    11687,
-    11710,
-    11724,
-    11740,
-    11784,
-    11838,
-    11885,
-    11937,
-    11962,
-    12016,
-    12063,
-    12115,
-    12142,
-    12172,
-    12210,
-    12242,
-    12272,
-    12299,
-    12331,
-    12363,
-    12391,
-    12422,
-    12447,
-    12473,
-    12498,
-    12531,
-    12560,
-    12582,
-    12616,
-    12643,
-    12666,
-    12702,
-    12728,
-    12761,
-    12793,
-    12822,
-    12853,
-    12879,
-    12900,
-    12926,
-    12958,
-    13005,
-    13028,
-    13052,
-    13073,
-    13096,
-    13120,
-    13146,
-    13176,
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.