[jbig2-cvs] rev 346 - trunk

raph at ghostscript.com raph at ghostscript.com
Wed Dec 1 14:19:58 PST 2004


Author: raph
Date: 2004-12-01 14:19:57 -0800 (Wed, 01 Dec 2004)
New Revision: 346

Modified:
   trunk/jbig2_image.c
   trunk/jbig2_symbol_dict.c
Log:
Implements IAID procedure for decoding reference symbol id's in symbol
dict segs (was incorrectly using generic int procedure). Fixes off-by-
one test for image bounds in jbig2_image_get_pixel and
jbig2_image_set_pixel.


Modified: trunk/jbig2_image.c
===================================================================
--- trunk/jbig2_image.c	2004-12-01 19:50:07 UTC (rev 345)
+++ trunk/jbig2_image.c	2004-12-01 22:19:57 UTC (rev 346)
@@ -180,8 +180,8 @@
   const int byte = (x >> 3) + y*image->stride;
   const int bit = 7 - (x & 7);
 
-  if ((x < 0) || (x > w)) return 0;
-  if ((y < 0) || (y > h)) return 0;
+  if ((x < 0) || (x >= w)) return 0;
+  if ((y < 0) || (y >= h)) return 0;
   
   return ((image->data[byte]>>bit) & 1);
 }
@@ -194,8 +194,8 @@
   int i, scratch, mask;
   int bit, byte;
 
-  if ((x < 0) || (x > w)) return 0;
-  if ((y < 0) || (y > h)) return 0;
+  if ((x < 0) || (x >= w)) return 0;
+  if ((y < 0) || (y >= h)) return 0;
 
   byte = (x >> 3) + y*image->stride;
   bit = 7 - (x & 7);

Modified: trunk/jbig2_symbol_dict.c
===================================================================
--- trunk/jbig2_symbol_dict.c	2004-12-01 19:50:07 UTC (rev 345)
+++ trunk/jbig2_symbol_dict.c	2004-12-01 22:19:57 UTC (rev 346)
@@ -30,6 +30,7 @@
 #include "jbig2_priv.h"
 #include "jbig2_arith.h"
 #include "jbig2_arith_int.h"
+#include "jbig2_arith_iaid.h"
 #include "jbig2_generic.h"
 #include "jbig2_symbol_dict.h"
 
@@ -220,7 +221,7 @@
   Jbig2ArithIntCtx *IADW = NULL;
   Jbig2ArithIntCtx *IAEX = NULL;
   Jbig2ArithIntCtx *IAAI = NULL;
-  Jbig2ArithIntCtx *IAID = NULL;
+  Jbig2ArithIaidCtx *IAID = NULL;
   Jbig2ArithIntCtx *IARDX = NULL;
   Jbig2ArithIntCtx *IARDY = NULL;
   int code = 0;
@@ -236,7 +237,12 @@
       IADW = jbig2_arith_int_ctx_new(ctx);
       IAEX = jbig2_arith_int_ctx_new(ctx);
       IAAI = jbig2_arith_int_ctx_new(ctx);
-      IAID = jbig2_arith_int_ctx_new(ctx);
+      if (params->SDREFAGG) {
+	  int tmp = params->SDINSYMS->n_symbols + params->SDNUMNEWSYMS;
+	  int SBSYMCODELEN;
+	  for (SBSYMCODELEN = 0; (1 << SBSYMCODELEN) < tmp; SBSYMCODELEN++);
+	  IAID = jbig2_arith_iaid_ctx_new(ctx, SBSYMCODELEN);
+      }
       IARDX = jbig2_arith_int_ctx_new(ctx);
       IARDY = jbig2_arith_int_ctx_new(ctx);
   } else {
@@ -376,7 +382,7 @@
 		      if (params->SDHUFF) {
 			  /* todo */
 		      } else {
-			  code = jbig2_arith_int_decode(IAID, as, &ID);
+			  code = jbig2_arith_iaid_decode(IAID, as, &ID);
 		          code = jbig2_arith_int_decode(IARDX, as, &RDX);
 		          code = jbig2_arith_int_decode(IARDY, as, &RDY);
 		      }



More information about the jbig2-cvs mailing list