rev 369 - trunk

[email protected] Tue, 21 Dec 2004 14:59:04 -0800 (PST)
Newsgroups gmane.comp.printing.ghostscript.jbig2dec.cvs
Message-ID <[email protected]>
Author: giles
Date: 2004-12-21 14:59:04 -0800 (Tue, 21 Dec 2004)
New Revision: 369

Modified:
   trunk/jbig2.h
   trunk/jbig2_image.c
   trunk/jbig2_page.c
   trunk/jbig2_text.c
Log:
replace individual memset calls for clearing images with a new=20
jbig2_image_clear() utility function.


Modified: trunk/jbig2.h
=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.h	2004-12-21 01:05:59 UTC (rev 368)
+++ trunk/jbig2.h	2004-12-21 22:59:04 UTC (rev 369)
@@ -63,8 +63,8 @@
 Jbig2Image*	jbig2_image_clone(Jbig2Ctx *ctx, Jbig2Image *image);
 void		jbig2_image_release(Jbig2Ctx *ctx, Jbig2Image *image);
 void            jbig2_image_free(Jbig2Ctx *ctx, Jbig2Image *image);
+void		jbig2_image_clear(Jbig2Ctx *ctx, Jbig2Image *image, int value);
=20
-
 /* errors are returned from the library via a callback. If no callback
    is provided (a NULL argument is passed ot jbig2_ctx_new) a default
    handler is used which prints fatal errors to the stderr stream. */

Modified: trunk/jbig2_image.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_image.c	2004-12-21 01:05:59 UTC (rev 368)
+++ trunk/jbig2_image.c	2004-12-21 22:59:04 UTC (rev 369)
@@ -56,7 +56,7 @@
 	image->height =3D height;
 	image->stride =3D stride;
 	image->refcount =3D 1;
-=09
+
 	return image;
 }
=20
@@ -169,6 +169,15 @@
     return 0;
 }
=20
+
+/* initialize an image bitmap to a constant value */
+void jbig2_image_clear(Jbig2Ctx *ctx, Jbig2Image *image, int value)
+{
+    const uint8_t fill =3D value ? 0xFF : 0x00;
+
+    memset(image->data, fill, image->stride*image->height);
+}
+
 /* look up a pixel value in an image.
    returns 0 outside the image frame for the convenience of
    the template code

Modified: trunk/jbig2_page.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_page.c	2004-12-21 01:05:59 UTC (rev 368)
+++ trunk/jbig2_page.c	2004-12-21 22:59:04 UTC (rev 369)
@@ -153,8 +153,7 @@
             "failed to allocate buffer for page image");
     } else {
 	/* 8.2 (3) fill the page with the default pixel value */
-	memset(page->image->data, (page->flags & 4) ? 0xFF : 0x00,
-	    page->image->stride*page->image->height);
+	jbig2_image_clear(ctx, page->image, (page->flags & 4));
         jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
             "allocated %dx%d page image (%d bytes)",
             page->image->width, page->image->height,

Modified: trunk/jbig2_text.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_text.c	2004-12-21 01:05:59 UTC (rev 368)
+++ trunk/jbig2_text.c	2004-12-21 22:59:04 UTC (rev 369)
@@ -149,7 +149,7 @@
     }
    =20
     /* 6.4.5 (1) */
-    memset(image->data, image->stride*image->height, params->SBDEFPIXEL =
? 0xFF: 0x00);
+    jbig2_image_clear(ctx, image, params->SBDEFPIXEL);
    =20
     /* 6.4.6 */
     if (params->SBHUFF) {
@@ -445,7 +445,6 @@
=20
     page_image =3D ctx->pages[ctx->current_page].image;
     image =3D jbig2_image_new(ctx, region_info.width, region_info.height=
);
-    memset(image->data, 0, image->stride*image->height);
=20
     code =3D jbig2_decode_text_region(ctx, segment, &params,
                 (const Jbig2SymbolDict * const *)dicts, n_dicts, image,