shithub: jbig2

Download patch

ref: 49519f4cfa5ca7d4f06ab11261e86a0d5aa55c64
parent: 0d020e4fcfa9039853e76f0456e65805cff3d19d
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Fri Dec 2 22:35:00 EST 2005

Correct an operator precedence bug that was corrupting reading of uncompressed
collective bitmaps. Also improve debugging messages.


git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@439 ded80894-8fb9-0310-811b-c03f3676ab4d

--- a/jbig2_symbol_dict.c
+++ b/jbig2_symbol_dict.c
@@ -499,26 +499,30 @@
 	  return NULL;
 	}
 
-	jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
-	  "reading %dx%d collective bitmap for %d symbols (%d bytes%s)",
-	  image->width, image->height, NSYMSDECODED - HCFIRSTSYM,
-	  BMSIZE, BMSIZE ? "" : " uncompressed");
-
 	if (BMSIZE == 0) {
 	  /* if BMSIZE == 0 bitmap is uncompressed */
 	  const byte *src = data + jbig2_huffman_offset(hs);
 	  const int stride = (image->width >> 3) + 
-		(image->width & 7) ? 1 : 0;
+		((image->width & 7) ? 1 : 0);
 	  byte *dst = image->data;
 
+	  BMSIZE = image->height * stride;
+	  jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
+	    "reading %dx%d uncompressed bitmap"
+	    " for %d symbols (%d bytes)",
+	    image->width, image->height, NSYMSDECODED - HCFIRSTSYM, BMSIZE);
+
 	  for (j = 0; j < image->height; j++) {
 	    memcpy(dst, src, stride);
 	    dst += image->stride;
 	    src += stride;
 	  }
-	  BMSIZE = image->height * stride;
 	} else {
 	  Jbig2GenericRegionParams rparams;
+
+	  jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
+	    "reading %dx%d collective bitmap for %d symbols (%d bytes)",
+	    image->width, image->height, NSYMSDECODED - HCFIRSTSYM, BMSIZE);
 
 	  rparams.MMR = 1;
 	  code = jbig2_decode_generic_mmr(ctx, segment, &rparams,