GraphicsMagick: ReadJXLImage(): Cache and trace extra channel info.

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.1430.1673629558.1384.graphicsmagick-commit@lists.sourceforge.net>
changeset 24c27ef0e8eb in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=24c27ef0e8eb
summary: ReadJXLImage(): Cache and trace extra channel info.

diffstat:

 ChangeLog                              |    6 +-
 VisualMagick/installer/inc/version.isx |    4 +-
 coders/jxl.c                           |  131 +++++++++++++++++++++++++++++++-
 magick/version.h                       |    4 +-
 www/Changelog.html                     |    6 +
 5 files changed, 140 insertions(+), 11 deletions(-)

diffs (234 lines):

diff -r 2dc510ef624b -r 24c27ef0e8eb ChangeLog
--- a/ChangeLog	Wed Jan 11 08:28:31 2023 -0600
+++ b/ChangeLog	Fri Jan 13 11:05:47 2023 -0600
@@ -1,6 +1,10 @@
+2023-01-13  Bob Friesenhahn  <[email protected]>
+
+	* coders/jxl.c (ReadJXLImage): Cache and trace extra channel info.
+
 2023-01-11  Fojtik Jaroslav  <[email protected]>
 
-	* coders/wpg.c Fixed Monochromatic bilevel WPG should answer to 
+	* coders/wpg.c Fixed Monochromatic bilevel WPG should answer to
 	gm identify file.wpg ..... PseudoClass 2c 8-bit
 
 2023-01-08  Fojtik Jaroslav  <[email protected]>
diff -r 2dc510ef624b -r 24c27ef0e8eb VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx	Wed Jan 11 08:28:31 2023 -0600
+++ b/VisualMagick/installer/inc/version.isx	Fri Jan 13 11:05:47 2023 -0600
@@ -10,5 +10,5 @@
 
 #define public MagickPackageName "GraphicsMagick"
 #define public MagickPackageVersion "1.4"
-#define public MagickPackageVersionAddendum ".020230111"
-#define public MagickPackageReleaseDate "snapshot-20230111"
+#define public MagickPackageVersionAddendum ".020230113"
+#define public MagickPackageReleaseDate "snapshot-20230113"
diff -r 2dc510ef624b -r 24c27ef0e8eb coders/jxl.c
--- a/coders/jxl.c	Wed Jan 11 08:28:31 2023 -0600
+++ b/coders/jxl.c	Fri Jan 13 11:05:47 2023 -0600
@@ -168,6 +168,69 @@
   return quantum_size;
 }
 
+static const char *JxlExtraChannelTypeAsString(const JxlExtraChannelType extra_channel_type)
+{
+  const char *str = "Unknown";
+
+  /* Defined in jxl/codestream_header.h */
+  switch (extra_channel_type)
+    {
+    case JXL_CHANNEL_ALPHA:
+      str = "Alpha";
+      break;
+    case JXL_CHANNEL_DEPTH:
+      str = "Depth";
+      break;
+    case JXL_CHANNEL_SPOT_COLOR:
+      str = "SpotColor";
+      break;
+    case JXL_CHANNEL_SELECTION_MASK:
+      str = "SelectionMask";
+      break;
+    case JXL_CHANNEL_BLACK:
+      str = "Black";
+      break;
+    case JXL_CHANNEL_CFA:
+      str = "CFA";
+      break;
+    case JXL_CHANNEL_THERMAL:
+      str = "Thermal";
+      break;
+    case JXL_CHANNEL_RESERVED0:
+      str = "RESERVED0";
+      break;
+    case JXL_CHANNEL_RESERVED1:
+      str = "RESERVED1";
+      break;
+    case JXL_CHANNEL_RESERVED2:
+      str = "RESERVED2";
+      break;
+    case JXL_CHANNEL_RESERVED3:
+      str = "RESERVED3";
+      break;
+    case JXL_CHANNEL_RESERVED4:
+      str = "RESERVED4";
+      break;
+    case JXL_CHANNEL_RESERVED5:
+      str = "RESERVED5";
+      break;
+    case JXL_CHANNEL_RESERVED6:
+      str = "RESERVED6";
+      break;
+    case JXL_CHANNEL_RESERVED7:
+      str = "RESERVED7";
+      break;
+    case JXL_CHANNEL_UNKNOWN:
+      str = "Unknown";
+      break;
+    case JXL_CHANNEL_OPTIONAL:
+      str = "Optional";
+      break;
+    }
+
+  return str;
+}
+
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
@@ -326,6 +389,9 @@
   JxlPixelFormat
     pixel_format;
 
+  JxlExtraChannelInfo
+    extra_channel_info[5];
+
   struct MyJXLMemoryManager
     mm;
 
@@ -458,10 +524,48 @@
                                       "    bits_per_sample=%u\n"
                                       "    exponent_bits_per_sample=%u\n"
                                       "    alpha_bits=%u\n"
-                                      "    num_color_channels=%u",
+                                      "    num_color_channels=%u\n"
+                                      "    have_animation=%s",
                                       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);
+                                      basic_info.alpha_bits, basic_info.num_color_channels,
+                                      basic_info.have_animation == JXL_FALSE ? "False" : "True");
+              }
+            if (basic_info.num_extra_channels)
+              {
+                size_t index;
+                (void) memset(extra_channel_info,0,sizeof(extra_channel_info));
+                for (index = 0 ;index < Min(basic_info.num_extra_channels,
+                                            ArraySize(extra_channel_info));
+                     index++)
+                  {
+                    JxlExtraChannelInfo* ecip=&extra_channel_info[index];
+                    status=JxlDecoderGetExtraChannelInfo(jxl_decoder,
+                                                         index,
+                                                         ecip);
+                    if (JXL_DEC_SUCCESS == status)
+                      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                            "Extra Channel Info[%lu]:\n"
+                                            "    type=%s\n"
+                                            "    bits_per_sample=%u\n"
+                                            "    exponent_bits_per_sample=%u\n"
+                                            "    dim_shift=%u\n"
+                                            "    name_length=%u\n"
+                                            "    alpha_premultiplied=%s\n"
+                                            "    spot_color=%f,%f,%f,%f\n"
+                                            "    cfa_channel=%u"
+                                          ,
+                                            (unsigned long) index,
+                                            JxlExtraChannelTypeAsString(ecip->type),
+                                            ecip->bits_per_sample,
+                                            ecip->exponent_bits_per_sample,
+                                            ecip->dim_shift,
+                                            ecip->name_length,
+                                            ecip->alpha_premultiplied == JXL_FALSE ? "False" : "True",
+                                            ecip->spot_color[0],ecip->spot_color[1],
+                                            ecip->spot_color[2],ecip->spot_color[3],
+                                            ecip->cfa_channel);
+                  }
               }
 
             if (basic_info.have_animation == 1)
@@ -784,7 +888,7 @@
               do
                 {
                   JxlBoxType
-                    type;
+                    type; /* A 4 character string which is not null terminated! */
 
                   magick_uint64_t
                     profile_size = 0;
@@ -804,8 +908,8 @@
                     break;
 
                   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                        "JXL Box of type \"%s\" and %lu bytes",
-                                        type, (unsigned long) profile_size);
+                                        "JXL Box of type \"%c%c%c%c\" and %lu bytes",
+                                        type[0],type[1],type[2],type[3], (unsigned long) profile_size);
 
                   /* Ignore tiny profiles */
                   if (profile_size < 4)
@@ -1142,7 +1246,22 @@
   if ((jxl_status = JxlEncoderSetCodestreamLevel(jxl_encoder,-1)) != JXL_ENC_SUCCESS)
     {
     };
-
+  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\n"
+                            "    have_animation=%s",
+                            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,
+                            basic_info.have_animation == JXL_FALSE ? "False" : "True");
+    }
   /* Set the global metadata of the image encoded by this encoder. */
   if ((jxl_status = JxlEncoderSetBasicInfo(jxl_encoder,&basic_info)) != JXL_ENC_SUCCESS)
     {
diff -r 2dc510ef624b -r 24c27ef0e8eb magick/version.h
--- a/magick/version.h	Wed Jan 11 08:28:31 2023 -0600
+++ b/magick/version.h	Fri Jan 13 11:05:47 2023 -0600
@@ -38,8 +38,8 @@
 #define MagickLibVersion  0x272401
 #define MagickLibVersionText  "1.4"
 #define MagickLibVersionNumber 27,24,1
-#define MagickChangeDate   "20230111"
-#define MagickReleaseDate  "snapshot-20230111"
+#define MagickChangeDate   "20230113"
+#define MagickReleaseDate  "snapshot-20230113"
 
 /*
   The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines
diff -r 2dc510ef624b -r 24c27ef0e8eb www/Changelog.html
--- a/www/Changelog.html	Wed Jan 11 08:28:31 2023 -0600
+++ b/www/Changelog.html	Fri Jan 13 11:05:47 2023 -0600
@@ -37,6 +37,12 @@
 </div>
 
 <div class="document">
+<p>2023-01-13  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>
+<ul class="simple">
+<li><p>coders/jxl.c (ReadJXLImage): Cache and trace extra channel info.</p></li>
+</ul>
+</blockquote>
 <p>2023-01-11  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;yandex&#46;com">JaFojtik<span>&#64;</span>yandex<span>&#46;</span>com</a>&gt;</p>
 <blockquote>
 <ul class="simple">
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.