[jbig2-cvs] rev 286 - trunk
giles at ghostscript.com
giles at ghostscript.com
Sun Nov 9 10:00:09 PST 2003
Author: giles
Date: 2003-11-09 05:59:03 -0800 (Sun, 09 Nov 2003)
New Revision: 286
Modified:
trunk/jbig2.h
trunk/jbig2_generic.c
trunk/jbig2_image.c
trunk/jbig2_image_pbm.c
trunk/jbig2_text.c
Log:
Add reference counting to the image structure to permit sharing of the glyph images
between symbol dictionaries.
Modified: trunk/jbig2.h
===================================================================
--- trunk/jbig2.h 2003-11-06 18:08:48 UTC (rev 285)
+++ trunk/jbig2.h 2003-11-09 13:59:03 UTC (rev 286)
@@ -1,7 +1,7 @@
/*
jbig2dec
- Copyright (c) 2002 artofcode LLC.
+ Copyright (c) 2002-2003 artofcode LLC.
This software is distributed under license and may not
be copied, modified or distributed except as expressly
@@ -13,7 +13,7 @@
Artifex Software, Inc., 101 Lucas Valley Road #110,
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
- $Id: jbig2.h,v 1.17 2003/03/05 14:29:35 giles Exp $
+ $Id$
*/
#ifdef __cplusplus
@@ -56,9 +56,12 @@
struct _Jbig2Image {
int width, height, stride;
uint8_t *data;
+ int refcount;
};
Jbig2Image* jbig2_image_new(Jbig2Ctx *ctx, int width, int height);
+Jbig2Image* jbig2_image_clone(Jbig2Ctx *ctx, Jbig2Image *image);
+void jbig2_image_release(Jbig2Ctx *ctx, Jbig2Image *image);
void jbig2_image_free(Jbig2Ctx *ctx, Jbig2Image *image);
Modified: trunk/jbig2_generic.c
===================================================================
--- trunk/jbig2_generic.c 2003-11-06 18:08:48 UTC (rev 285)
+++ trunk/jbig2_generic.c 2003-11-09 13:59:03 UTC (rev 286)
@@ -16,7 +16,7 @@
Artifex Software, Inc., 101 Lucas Valley Road #110,
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
- $Id: jbig2_generic.c,v 1.13 2002/07/20 17:23:15 giles Exp $
+ $Id$
*/
/**
@@ -455,7 +455,7 @@
jbig2_image_compose(ctx, ctx->pages[ctx->current_page].image, image,
rsi.x, rsi.y, JBIG2_COMPOSE_OR);
- jbig2_image_free(ctx, image);
+ jbig2_image_release(ctx, image);
jbig2_free(ctx->allocator, GB_stats);
Modified: trunk/jbig2_image.c
===================================================================
--- trunk/jbig2_image.c 2003-11-06 18:08:48 UTC (rev 285)
+++ trunk/jbig2_image.c 2003-11-09 13:59:03 UTC (rev 286)
@@ -1,7 +1,7 @@
/*
jbig2dec
- Copyright (c) 2001-2002 artofcode LLC.
+ Copyright (c) 2001-2003 artofcode LLC.
This software is distributed under license and may not
be copied, modified or distributed except as expressly
@@ -55,11 +55,25 @@
image->width = width;
image->height = height;
image->stride = stride;
+ image->refcount = 1;
return image;
}
+/* clone an image pointer by bumping its reference count */
+Jbig2Image* jbig2_image_clone(Jbig2Ctx *ctx, Jbig2Image *image)
+{
+ image->refcount++;
+ return image;
+}
+/* release an image pointer, freeing it it appropriate */
+void jbig2_image_release(Jbig2Ctx *ctx, Jbig2Image *image)
+{
+ image->refcount--;
+ if (!image->refcount) jbig2_image_free(image);
+}
+
/* free a Jbig2Image structure and its associated memory */
void jbig2_image_free(Jbig2Ctx *ctx, Jbig2Image *image)
{
Modified: trunk/jbig2_image_pbm.c
===================================================================
--- trunk/jbig2_image_pbm.c 2003-11-06 18:08:48 UTC (rev 285)
+++ trunk/jbig2_image_pbm.c 2003-11-09 13:59:03 UTC (rev 286)
@@ -13,7 +13,7 @@
Artifex Software, Inc., 101 Lucas Valley Road #110,
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
- $Id: jbig2_image_pbm.c,v 1.12 2002/08/15 14:54:45 giles Exp $
+ $Id$
*/
#ifdef HAVE_CONFIG_H
@@ -134,7 +134,7 @@
fread(image->data, 1, image->height*image->stride, in);
if (feof(in)) {
fprintf(stderr, "unexpected end of pbm file.\n");
- jbig2_image_free(ctx, image);
+ jbig2_image_release(ctx, image);
return NULL;
}
/* success */
Modified: trunk/jbig2_text.c
===================================================================
--- trunk/jbig2_text.c 2003-11-06 18:08:48 UTC (rev 285)
+++ trunk/jbig2_text.c 2003-11-09 13:59:03 UTC (rev 286)
@@ -1,7 +1,7 @@
/*
jbig2dec
- Copyright (C) 2002 artofcode LLC.
+ Copyright (C) 2002-2003 artofcode LLC.
This software is distributed under license and may not
be copied, modified or distributed except as expressly
@@ -472,7 +472,7 @@
region_info.width, region_info.height, region_info.x, region_info.y);
jbig2_image_compose(ctx, page_image, image, region_info.x, region_info.y, JBIG2_COMPOSE_OR);
if (image != page_image)
- jbig2_image_free(ctx, image);
+ jbig2_image_release(ctx, image);
}
/* success */
More information about the jbig2-cvs
mailing list