ref: 376546a60ce0bf4ff095f234b1d8ad429b6b450b
parent: 5e048fb252ff7f9b0355e444b0fb65804e68e1c7
author: raph <raph@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Fri Feb 7 00:06:46 EST 2003
Fixes: make find_segment search globals, and also fix off-by-one. Disable memcpy optimization in jbig2_image_compose, because it's not always valid. git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@210 ded80894-8fb9-0310-811b-c03f3676ab4d
--- a/jbig2_image.c
+++ b/jbig2_image.c
@@ -8,7 +8,7 @@
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
- $Id: jbig2_image.c,v 1.20 2002/08/15 14:54:45 giles Exp $
+ $Id: jbig2_image.c,v 1.21 2003/02/07 05:06:46 raph Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -93,11 +93,15 @@
w, h, x, y);
#endif
+#if 0
/* special case complete/strip replacement */
+ /* disabled because it's only safe to do when the destination
+ buffer is all-blank. */
if ((x == 0) && (w == src->width)) {
memcpy(dst->data + y*dst->stride, src->data, h*src->stride);
return 0;
}
+#endif
leftbyte = x >> 3;
rightbyte = (x + w - 1) >> 3;
--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -8,7 +8,7 @@
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
- $Id: jbig2_text.c,v 1.20 2002/08/15 14:54:45 giles Exp $
+ $Id: jbig2_text.c,v 1.21 2003/02/07 05:06:46 raph Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -278,13 +278,19 @@
static Jbig2Segment *
find_segment(Jbig2Ctx *ctx, uint32_t number)
{
- int index, index_max = ctx->segment_index;
-
+ int index, index_max = ctx->segment_index - 1;
+ const Jbig2Ctx *global_ctx = ctx->global_ctx;
+
/* FIXME: binary search would be better? */
for (index = index_max; index >= 0; index--)
if (ctx->segments[index]->number == number)
return (ctx->segments[index]);
+ if (global_ctx)
+ for (index = global_ctx->segment_index - 1; index >= 0; index--)
+ if (global_ctx->segments[index]->number == number)
+ return (global_ctx->segments[index]);
+
/* didn't find a match */
return NULL;
}