rev 356 - trunk

[email protected] Sun, 5 Dec 2004 21:37:43 -0800 (PST)
Newsgroups gmane.comp.printing.ghostscript.jbig2dec.cvs
Message-ID <[email protected]>
Author: giles
Date: 2004-12-05 21:37:42 -0800 (Sun, 05 Dec 2004)
New Revision: 356

Modified:
   trunk/jbig2_refinement.c
Log:
Code cleanup. The refinement region decode procedures use a 'GR' prefix=20
in the spec even when the function is identical to the 'GB' prefix=20
variables in the generic region procedures. Change our code to match.


Modified: trunk/jbig2_refinement.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/jbig2_refinement.c	2004-12-06 05:36:28 UTC (rev 355)
+++ trunk/jbig2_refinement.c	2004-12-06 05:37:42 UTC (rev 356)
@@ -46,7 +46,7 @@
                               const Jbig2RefinementRegionParams *params,
                               Jbig2ArithState *as,
                               Jbig2Image *image,
-                              Jbig2ArithCx *GB_stats)
+                              Jbig2ArithCx *GR_stats)
 {
   return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number,
     "refinement region template 0 NYI");
@@ -58,10 +58,10 @@
                               const Jbig2RefinementRegionParams *params,
                               Jbig2ArithState *as,
                               Jbig2Image *image,
-                              Jbig2ArithCx *GB_stats)
+                              Jbig2ArithCx *GR_stats)
 {
-  const int GBW =3D image->width;
-  const int GBH =3D image->height;
+  const int GRW =3D image->width;
+  const int GRH =3D image->height;
   const int dx =3D params->DX;
   const int dy =3D params->DY;
   Jbig2Image *ref =3D params->reference;
@@ -69,8 +69,8 @@
   int x,y;
   bool bit;
=20
-  for (y =3D 0; y < GBH; y++) {
-    for (x =3D 0; x < GBW; x++) {
+  for (y =3D 0; y < GRH; y++) {
+    for (x =3D 0; x < GRW; x++) {
       CONTEXT =3D 0;
       CONTEXT |=3D jbig2_image_get_pixel(image, x - 1, y + 0) << 0;=20
       CONTEXT |=3D jbig2_image_get_pixel(image, x + 1, y - 1) << 1;=20
@@ -87,7 +87,7 @@
       CONTEXT |=3D jbig2_image_get_pixel(ref, x-dx+0, y-dy-1) << 11;
       CONTEXT |=3D jbig2_image_get_pixel(ref, x-dx+params->grat[2],=20
 	y-dy+params->grat[3]) << 12;
-      bit =3D jbig2_arith_decode(as, &GB_stats[CONTEXT]);
+      bit =3D jbig2_arith_decode(as, &GR_stats[CONTEXT]);
       jbig2_image_set_pixel(image, x, y, bit);
     }
   }
@@ -113,10 +113,10 @@
                               const Jbig2RefinementRegionParams *params,
                               Jbig2ArithState *as,
                               Jbig2Image *image,
-                              Jbig2ArithCx *GB_stats)
+                              Jbig2ArithCx *GR_stats)
 {
-  const int GBW =3D image->width;
-  const int GBH =3D image->height;
+  const int GRW =3D image->width;
+  const int GRH =3D image->height;
   const int dx =3D params->DX;
   const int dy =3D params->DY;
   Jbig2Image *ref =3D params->reference;
@@ -124,8 +124,8 @@
   int x,y;
   bool bit;
=20
-  for (y =3D 0; y < GBH; y++) {
-    for (x =3D 0; x < GBW; x++) {
+  for (y =3D 0; y < GRH; y++) {
+    for (x =3D 0; x < GRW; x++) {
       CONTEXT =3D 0;
       CONTEXT |=3D jbig2_image_get_pixel(image, x - 1, y + 0) << 0;=20
       CONTEXT |=3D jbig2_image_get_pixel(image, x + 1, y - 1) << 1;=20
@@ -137,7 +137,7 @@
       CONTEXT |=3D jbig2_image_get_pixel(ref, x-dx+0, y-dy+0) << 7;
       CONTEXT |=3D jbig2_image_get_pixel(ref, x-dx-1, y-dy+0) << 8;
       CONTEXT |=3D jbig2_image_get_pixel(ref, x-dx+0, y-dy-1) << 9;
-      bit =3D jbig2_arith_decode(as, &GB_stats[CONTEXT]);
+      bit =3D jbig2_arith_decode(as, &GR_stats[CONTEXT]);
       jbig2_image_set_pixel(image, x, y, bit);
     }
   }
@@ -163,10 +163,10 @@
                               const Jbig2RefinementRegionParams *params,
                               Jbig2ArithState *as,
                               Jbig2Image *image,
-                              Jbig2ArithCx *GB_stats)
+                              Jbig2ArithCx *GR_stats)
 {
-  const int GBW =3D image->width;
-  const int GBH =3D image->height;
+  const int GRW =3D image->width;
+  const int GRH =3D image->height;
   const int stride =3D image->stride;
   const int refstride =3D params->reference->stride;
   const int dx =3D params->DX;
@@ -175,8 +175,8 @@
   byte *grref_line =3D (byte *)params->reference->data;
   int x,y;
=20
-  for (y =3D 0; y < GBH; y++) {
-    const int padded_width =3D (GBW + 7) & -8;
+  for (y =3D 0; y < GRH; y++) {
+    const int padded_width =3D (GRW + 7) & -8;
     uint32_t CONTEXT;
     uint32_t refline_m1; /* previous line of the reference bitmap */
     uint32_t refline_0;  /* current line of the reference bitmap */
@@ -185,8 +185,8 @@
=20
     line_m1 =3D (y >=3D 1) ? grreg_line[-stride] : 0;
     refline_m1 =3D ((y-dy) >=3D 1) ? grref_line[(-1-dy)*stride] << 2: 0;
-    refline_0  =3D (((y-dy) > 0) && ((y-dy) < GBH)) ? grref_line[(0-dy)*=
stride] << 4 : 0;
-    refline_1  =3D (y < GBH - 1) ? grref_line[(+1-dy)*stride] << 7 : 0;
+    refline_0  =3D (((y-dy) > 0) && ((y-dy) < GRH)) ? grref_line[(0-dy)*=
stride] << 4 : 0;
+    refline_1  =3D (y < GRH - 1) ? grref_line[(+1-dy)*stride] << 7 : 0;
     CONTEXT =3D ((line_m1 >> 5) & 0x00e) |
 	      ((refline_1 >> 5) & 0x030) |
 	      ((refline_0 >> 5) & 0x1c0) |
@@ -195,21 +195,21 @@
     for (x =3D 0; x < padded_width; x +=3D 8) {
       byte result =3D 0;
       int x_minor;
-      const int minor_width =3D GBW - x > 8 ? 8 : GBW - x;
+      const int minor_width =3D GRW - x > 8 ? 8 : GRW - x;
=20
       if (y >=3D 1) {
 	line_m1 =3D (line_m1 << 8) |=20
-	  (x + 8 < GBW ? grreg_line[-stride + (x >> 3) + 1] : 0);
+	  (x + 8 < GRW ? grreg_line[-stride + (x >> 3) + 1] : 0);
 	refline_m1 =3D (refline_m1 << 8) |=20
-	  (x + 8 < GBW ? grref_line[-refstride + (x >> 3) + 1] << 2 : 0);
+	  (x + 8 < GRW ? grref_line[-refstride + (x >> 3) + 1] << 2 : 0);
       }
=20
       refline_0 =3D (refline_0 << 8) |
-	  (x + 8 < GBW ? grref_line[(x >> 3) + 1] << 4 : 0);
+	  (x + 8 < GRW ? grref_line[(x >> 3) + 1] << 4 : 0);
=20
-      if (y < GBH - 1)
+      if (y < GRH - 1)
 	refline_1 =3D (refline_1 << 8) |
-	  (x + 8 < GBW ? grref_line[+refstride + (x >> 3) + 1] << 7 : 0);
+	  (x + 8 < GRW ? grref_line[+refstride + (x >> 3) + 1] << 7 : 0);
       else
 	refline_1 =3D 0;
=20
@@ -217,7 +217,7 @@
       for (x_minor =3D 0; x_minor < minor_width; x_minor++) {
 	bool bit;
=20
-	bit =3D jbig2_arith_decode(as, &GB_stats[CONTEXT]);
+	bit =3D jbig2_arith_decode(as, &GR_stats[CONTEXT]);
 	result |=3D bit << (7 - x_minor);
 	CONTEXT =3D ((CONTEXT & 0x0d6) << 1) | bit |
 	  ((line_m1 >> (9 - x_minor)) & 0x002) |
@@ -247,7 +247,7 @@
  * @params: Decoding parameter set.
  * @as: Arithmetic decoder state.
  * @image: Where to store the decoded image.
- * @GB_stats: Arithmetic stats.
+ * @GR_stats: Arithmetic stats.
  *
  * Decodes a generic refinement region, according to section 6.3.
  * an already allocated Jbig2Image object in @image for the result.
@@ -263,7 +263,7 @@
 			    const Jbig2RefinementRegionParams *params,
 			    Jbig2ArithState *as,
 			    Jbig2Image *image,
-			    Jbig2ArithCx *GB_stats)
+			    Jbig2ArithCx *GR_stats)
 {
   {
     jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
@@ -277,10 +277,10 @@
         "decode_refinement_region: typical prediction coding NYI");
   if (params->GRTEMPLATE)
     return jbig2_decode_refinement_template1_unopt(ctx, segment, params,=
=20
-                                             as, image, GB_stats);
+                                             as, image, GR_stats);
   else
     return jbig2_decode_refinement_template0_unopt(ctx, segment, params,
-                                             as, image, GB_stats);
+                                             as, image, GR_stats);
 }
=20
 /**
@@ -400,7 +400,7 @@
   {
     Jbig2WordStream *ws;
     Jbig2ArithState *as;
-    Jbig2ArithCx *GB_stats =3D NULL;
+    Jbig2ArithCx *GR_stats =3D NULL;
     int stats_size;
     Jbig2Image *image;
     int code;
@@ -414,17 +414,17 @@
           rsi.width, rsi.height);
=20
     stats_size =3D params.GRTEMPLATE ? 1 << 10 : 1 << 13;
-    GB_stats =3D jbig2_alloc(ctx->allocator, stats_size);
-    memset(GB_stats, 0, stats_size);
+    GR_stats =3D jbig2_alloc(ctx->allocator, stats_size);
+    memset(GR_stats, 0, stats_size);
=20
     ws =3D jbig2_word_stream_buf_new(ctx, segment_data + offset,
            segment->data_length - offset);
     as =3D jbig2_arith_new(ctx, ws);
     code =3D jbig2_decode_refinement_region(ctx, segment, &params,
-                              as, image, GB_stats);
+                              as, image, GR_stats);
=20
     /* TODO: free ws, as */
-    jbig2_free(ctx->allocator, GB_stats);
+    jbig2_free(ctx->allocator, GR_stats);
=20
     if ((segment->flags & 63) =3D=3D 40) {
         /* intermediate region. save the result for later */