ref: afe3a66d19d98cf0017f4c7b433ae65b2286e259
parent: d264e8daa8c30ea3d4d43e287bcc97462f244e9e
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Tue Dec 21 17:59:04 EST 2004
replace individual memset calls for clearing images with a new jbig2_image_clear() utility function. git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@369 ded80894-8fb9-0310-811b-c03f3676ab4d
--- a/jbig2.h
+++ b/jbig2.h
@@ -63,7 +63,7 @@
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
--- a/jbig2_image.c
+++ b/jbig2_image.c
@@ -56,7 +56,7 @@
image->height = height;
image->stride = stride;
image->refcount = 1;
-
+
return image;
}
@@ -167,6 +167,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.
--- a/jbig2_page.c
+++ b/jbig2_page.c
@@ -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,
--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -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, ¶ms,
(const Jbig2SymbolDict * const *)dicts, n_dicts, image,