[jbig2-cvs] rev 369 - trunk

giles at ghostscript.com giles at ghostscript.com
Tue Dec 21 14:59:04 PST 2004


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 
jbig2_image_clear() utility function.


Modified: trunk/jbig2.h
===================================================================
--- 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);
 
-
 /* 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
===================================================================
--- 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 = height;
 	image->stride = stride;
 	image->refcount = 1;
-	
+
 	return image;
 }
 
@@ -169,6 +169,15 @@
     return 0;
 }
 
+
+/* initialize an image bitmap to a constant value */
+void jbig2_image_clear(Jbig2Ctx *ctx, Jbig2Image *image, int value)
+{
+    const uint8_t fill = 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
===================================================================
--- 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
===================================================================
--- 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 @@
     }
     
     /* 6.4.5 (1) */
-    memset(image->data, image->stride*image->height, params->SBDEFPIXEL ? 0xFF: 0x00);
+    jbig2_image_clear(ctx, image, params->SBDEFPIXEL);
     
     /* 6.4.6 */
     if (params->SBHUFF) {
@@ -445,7 +445,6 @@
 
     page_image = ctx->pages[ctx->current_page].image;
     image = jbig2_image_new(ctx, region_info.width, region_info.height);
-    memset(image->data, 0, image->stride*image->height);
 
     code = jbig2_decode_text_region(ctx, segment, &params,
                 (const Jbig2SymbolDict * const *)dicts, n_dicts, image,



More information about the jbig2-cvs mailing list