ref: 1b6a01e666d0dbcd355c0b84fba43c1d02fb4b37
parent: 46ff1e6277a432b9e1d18784ab5c30fc40b45476
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Wed Jul 13 12:28:44 EDT 2005
Move a repeated calculation out of a loop. git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@415 ded80894-8fb9-0310-811b-c03f3676ab4d
--- a/jbig2_image.c
+++ b/jbig2_image.c
@@ -1,7 +1,7 @@
/*
jbig2dec
- Copyright (c) 2001-2003 artofcode LLC.
+ Copyright (c) 2001-2005 artofcode LLC.
This software is distributed under license and may not
be copied, modified or distributed except as expressly
@@ -51,7 +51,7 @@
jbig2_free(ctx->allocator, image);
return NULL;
}
-
+
image->width = width;
image->height = height;
image->stride = stride;
@@ -234,8 +234,9 @@
s = (ss += src->stride);
}
} else {
+ bool overlap = (((w + 7) >> 3) < ((x + w + 7) >> 3) - (x >> 3));
mask = 0x100 - (1 << shift);
- if (((w + 7) >> 3) < ((x + w + 7) >> 3) - (x >> 3))
+ if (overlap)
rightmask = (0x100 - (0x100 >> ((x + w) & 7))) >> (8 - shift);
else
rightmask = 0x100 - (0x100 >> (w & 7));
@@ -245,8 +246,8 @@
*d |= ((*s++ & ~mask) << (8 - shift));
*d++ |= ((*s & mask) >> shift);
}
- if (((w + 7) >> 3) < ((x + w + 7) >> 3) - (x >> 3))
- *d |= (s[0] & rightmask) << (8 - shift);
+ if (overlap)
+ *d |= (*s & rightmask) << (8 - shift);
else
*d |= ((s[0] & ~mask) << (8 - shift)) |
((s[1] & rightmask) >> shift);