[gs-commits] rev 11875 - trunk/gs/base
mvrhel at ghostscript.com
mvrhel at ghostscript.com
Fri Oct 29 23:40:30 UTC 2010
Author: mvrhel
Date: 2010-10-29 23:40:30 +0000 (Fri, 29 Oct 2010)
New Revision: 11875
Modified:
trunk/gs/base/gxidata.c
trunk/gs/base/gximage.h
trunk/gs/base/gxipixel.c
Log:
Fix so that the image clues array is dynamically allocate only when needed as opposed to being a static array in gx_image_enum. clues is used only in the case of monochrome or indexed with bps <= 8 and masked images. Another optimization to do is to make it allocate only 2 entries for the masked case rather than all 256.
Modified: trunk/gs/base/gxidata.c
===================================================================
--- trunk/gs/base/gxidata.c 2010-10-29 19:35:48 UTC (rev 11874)
+++ trunk/gs/base/gxidata.c 2010-10-29 23:40:30 UTC (rev 11875)
@@ -466,6 +466,9 @@
if (penum->icc_link != NULL) {
gsicc_release_link(penum->icc_link);
}
+ if (penum->clues != NULL) {
+ gs_free_object(mem,penum->clues, "image clues");
+ }
gs_free_object(mem, penum->line, "image line");
gs_free_object(mem, penum->buffer, "image buffer");
gx_image_free_enum(&info);
Modified: trunk/gs/base/gximage.h
===================================================================
--- trunk/gs/base/gximage.h 2010-10-29 19:35:48 UTC (rev 11874)
+++ trunk/gs/base/gximage.h 2010-10-29 23:40:30 UTC (rev 11875)
@@ -276,7 +276,7 @@
sample_map map[GS_IMAGE_MAX_COMPONENTS];
/* Entries 0 and 255 of the following are set at initialization */
/* for monochrome images; other entries are updated dynamically. */
- gx_image_clue clues[256];
+ gx_image_clue *clues;
gx_device_color icolor0_val; /* This is used if clues is not used */
gx_device_color icolor1_val;
gx_device_color *icolor0;
@@ -290,8 +290,8 @@
#define gx_image_enum_do_ptrs(m)\
m(0,pis) m(1,pcs) m(2,dev) m(3,buffer) m(4,line)\
m(5,clip_dev) m(6,rop_dev) m(7,scaler) m(8,icc_link)\
- m(9,cie_range)
-#define gx_image_enum_num_ptrs 10
+ m(9,cie_range) m(10,clues)
+#define gx_image_enum_num_ptrs 11
#define private_st_gx_image_enum() /* in gsimage.c */\
gs_private_st_composite(st_gx_image_enum, gx_image_enum, "gx_image_enum",\
image_enum_enum_ptrs, image_enum_reloc_ptrs)
Modified: trunk/gs/base/gxipixel.c
===================================================================
--- trunk/gs/base/gxipixel.c 2010-10-29 19:35:48 UTC (rev 11874)
+++ trunk/gs/base/gxipixel.c 2010-10-29 23:40:30 UTC (rev 11875)
@@ -67,17 +67,23 @@
/* the clues may have been cleared by gx_image_free_enum, but not freed in that */
/* function due to being at a different save level. Only trace if dev_color.type != 0. */
if (eptr->spp == 1) {
- if (eptr->clues[(index/st_device_color_max_ptrs) * (255 / ((1 << bps) - 1))].dev_color.type != 0)
+ if (eptr->clues != NULL) {
+ if (eptr->clues[(index/st_device_color_max_ptrs) *
+ (255 / ((1 << bps) - 1))].dev_color.type != 0) {
ret = ENUM_USING(st_device_color,
&eptr->clues[(index / st_device_color_max_ptrs) *
(255 / ((1 << bps) - 1))].dev_color,
sizeof(eptr->clues[0].dev_color),
index % st_device_color_max_ptrs);
- else
+ } else {
ret = 0;
+ }
} else {
ret = 0;
}
+ } else {
+ ret = 0;
+ }
if (ret == 0) /* don't stop early */
ENUM_RETURN(0);
return ret;
@@ -220,6 +226,7 @@
bool device_color = true;
gs_fixed_rect obox, cbox;
+ penum->clues = NULL;
penum->icc_setup.has_transfer = false;
penum->icc_setup.is_lab = false;
penum->icc_setup.must_halftone = false;
@@ -304,6 +311,11 @@
1spp or an imagemask, otherwise image clues is not used and
we have these values point to other member variables */
if (masked || cs_num_components(pcs) == 1) {
+ /* Go ahead and allocate now if not already done. For a mask
+ we really should only do 2 values. For now, the goal is to
+ eliminate the 256 bytes for the >8bpp image enumerator */
+ penum->clues = (gx_image_clue*) gs_alloc_bytes(mem, sizeof(gx_image_clue)*256,
+ "gx_image_enum_begin");
penum->icolor0 = &(penum->clues[0].dev_color);
penum->icolor1 = &(penum->clues[255].dev_color);
} else {
More information about the gs-commits
mailing list