GraphicsMagick: ReadJP2Image(): Trace JPEG 2000 component parame...

GraphicsMagick Commits <[email protected]> Wed, 30 Oct 2024 16:18:47 -0500
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.31235.1730323140.8001.graphicsmagick-commit@lists.sourceforge.net>
changeset eccd8cac7612 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=eccd8cac7612
summary: ReadJP2Image(): Trace JPEG 2000 component parameters.

diffstat:

 ChangeLog          |   3 ++
 coders/jp2.c       |  56 +++++++++++++++++++++++++++++++++++++++++++----------
 www/ChangeLog.html |   6 ++++-
 3 files changed, 53 insertions(+), 12 deletions(-)

diffs (106 lines):

diff -r 48efc018916a -r eccd8cac7612 ChangeLog
--- a/ChangeLog	Wed Oct 30 14:39:00 2024 -0500
+++ b/ChangeLog	Wed Oct 30 16:18:23 2024 -0500
@@ -1,5 +1,8 @@
 2024-10-30  Bob Friesenhahn  <[email protected]>
 
+	* coders/jp2.c (ReadJP2Image): Trace JPEG 2000 component
+	parameters.
+
 	* fuzzing/oss-fuzz-build.sh: Skip re-bootstrap of GraphicsMagick
 	since it sometimes fails due to network issues.
 	(enable_x265): Enable x265 in oss-fuzz build (and re-enable de265,
diff -r 48efc018916a -r eccd8cac7612 coders/jp2.c
--- a/coders/jp2.c	Wed Oct 30 14:39:00 2024 -0500
+++ b/coders/jp2.c	Wed Oct 30 16:18:23 2024 -0500
@@ -246,7 +246,9 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  Method IsPGX returns True if the image format type, identified by the
-%  magick string, is PGX.
+%  magick string, is PGX. PGX is an uncompressed raster image file format
+%  used in JPEG 2000 conformance testing. PGX file stores only a single
+%  component, so it is limited to grayscale.
 %
 %  The format of the IsPGX method is:
 %
@@ -967,20 +969,52 @@
     }
   image->columns=jas_image_width(jp2_image);
   image->rows=jas_image_height(jp2_image);
-  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                        "columns=%lu rows=%lu components=%d",image->columns,image->rows,
-                        number_components);
+  if (image->logging)
+    {
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "columns=%lu rows=%lu components=%d",image->columns,image->rows,
+                            number_components);
+      for (component=0; component < number_components; component++)
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Component %u:\n"
+                                "    width                         = %ld\n" /* width */
+                                "    height                        = %ld\n" /* height */
+                                "    tl x,y coordinate             = %ld,%ld\n" /* x,y-coordinates of the top-left corner */
+                                "    br x,y coordinate             = %ld,%ld\n" /* x,y-coordinates of the bottom-right corner */
+                                "    horizontal subsampling factor = %ld\n" /* horizontal subsampling factor */
+                                "    vertical subsampling factor   = %ld\n" /* vertical subsampling factor */
+                                "    depth                         = %u\n"  /* depth */
+                                "    signed sample data            = %d",   /* signedness of the sample data (true == signed) */
+                                component,
+                                jas_image_cmptwidth(jp2_image,components[component]),
+                                jas_image_cmptheight(jp2_image,components[component]),
+                                jas_image_cmpttlx(jp2_image, components[component]),
+                                jas_image_cmpttly(jp2_image, components[component]),
+                                jas_image_cmptbrx(jp2_image, components[component]),
+                                jas_image_cmptbry(jp2_image, components[component]),
+                                jas_image_cmpthstep(jp2_image, components[component]),
+                                jas_image_cmptvstep(jp2_image, components[component]),
+                                jas_image_cmptprec(jp2_image,components[component]),
+                                jas_image_cmptsgnd(jp2_image, components[component]));
+        }
+    }
   for (component=0; component < number_components; component++)
     {
-      if(((unsigned long) jas_image_cmptwidth(jp2_image,components[component]) != image->columns) ||
-         ((unsigned long) jas_image_cmptheight(jp2_image,components[component]) != image->rows) ||
-         (jas_image_cmpttlx(jp2_image, components[component]) != 0) ||
-         (jas_image_cmpttly(jp2_image, components[component]) != 0) ||
-         (jas_image_cmpthstep(jp2_image, components[component]) != 1) ||
-         (jas_image_cmptvstep(jp2_image, components[component]) != 1) ||
-         (jas_image_cmptsgnd(jp2_image, components[component]) != false))
+      if (((unsigned long) jas_image_cmptwidth(jp2_image,components[component]) != image->columns) ||
+          ((unsigned long) jas_image_cmptheight(jp2_image,components[component]) != image->rows) ||
+          (jas_image_cmpttlx(jp2_image, components[component]) != 0) ||
+          (jas_image_cmpttly(jp2_image, components[component]) != 0) ||
+          (jas_image_cmpthstep(jp2_image, components[component]) != 1) ||
+          (jas_image_cmptvstep(jp2_image, components[component]) != 1))
         ThrowJP2ReaderException(CoderError,IrregularChannelGeometryNotSupported,image);
     }
+  /* FIXME: It would be good to support signed data! */
+  for (component=0; component < number_components; component++)
+    {
+      if ((jas_image_cmptsgnd(jp2_image, components[component]) != false))
+        ThrowJP2ReaderException(CoderError,DataStorageTypeIsNotSupported,image);
+    }
 
   image->matte=number_components > 3;
   for (component=0; component < number_components; component++)
diff -r 48efc018916a -r eccd8cac7612 www/ChangeLog.html
--- a/www/ChangeLog.html	Wed Oct 30 14:39:00 2024 -0500
+++ b/www/ChangeLog.html	Wed Oct 30 16:18:23 2024 -0500
@@ -41,8 +41,12 @@
 <p>2024-10-30  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/jp2.c (ReadJP2Image): Trace JPEG 2000 component
+parameters.</p></li>
 <li><p>fuzzing/oss-fuzz-build.sh: Skip re-bootstrap of GraphicsMagick
-since it sometimes fails due to network issues.</p></li>
+since it sometimes fails due to network issues.
+(enable_x265): Enable x265 in oss-fuzz build (and re-enable de265,
+which was accidentally disabled).</p></li>
 </ul>
 </blockquote>
 <p>2024-10-29  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>