summaryrefslogtreecommitdiff
path: root/jbig2dec/jbig2_halftone.c
diff options
context:
space:
mode:
Diffstat (limited to 'jbig2dec/jbig2_halftone.c')
-rw-r--r--jbig2dec/jbig2_halftone.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/jbig2dec/jbig2_halftone.c b/jbig2dec/jbig2_halftone.c
index e67c6d18f..b2b7bdbcb 100644
--- a/jbig2dec/jbig2_halftone.c
+++ b/jbig2dec/jbig2_halftone.c
@@ -47,8 +47,7 @@ jbig2_hd_new(Jbig2Ctx *ctx, const Jbig2PatternDictParams *params, Jbig2Image *im
const uint32_t HPW = params->HDPW;
const uint32_t HPH = params->HDPH;
int code;
- uint32_t i;
- int j;
+ uint32_t i, j;
if (N == 0) {
/* We've wrapped. */
@@ -464,8 +463,7 @@ jbig2_decode_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
Jbig2Image *HSKIP = NULL;
Jbig2PatternDict *HPATS;
uint32_t i;
- int32_t mg, ng;
- int32_t x, y;
+ uint32_t mg, ng;
uint16_t gray_val;
int code = 0;
@@ -487,10 +485,10 @@ jbig2_decode_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
for (mg = 0; mg < params->HGH; ++mg) {
for (ng = 0; ng < params->HGW; ++ng) {
- x = (params->HGX + mg * params->HRY + ng * params->HRX) >> 8;
- y = (params->HGY + mg * params->HRX - ng * params->HRY) >> 8;
+ int64_t x = ((int64_t) params->HGX + mg * params->HRY + ng * params->HRX) >> 8;
+ int64_t y = ((int64_t) params->HGY + mg * params->HRX - ng * params->HRY) >> 8;
- if (x + HPATS->HPW <= 0 || x >= (int32_t) image->width || y + HPATS->HPH <= 0 || y >= (int32_t) image->height) {
+ if (x + HPATS->HPW <= 0 || x >= image->width || y + HPATS->HPH <= 0 || y >= image->height) {
jbig2_image_set_pixel(HSKIP, ng, mg, 1);
} else {
jbig2_image_set_pixel(HSKIP, ng, mg, 0);
@@ -519,8 +517,8 @@ jbig2_decode_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
/* 6.6.5 point 5. place patterns with procedure mentioned in 6.6.5.2 */
for (mg = 0; mg < params->HGH; ++mg) {
for (ng = 0; ng < params->HGW; ++ng) {
- x = (params->HGX + mg * (int32_t) params->HRY + ng * (int32_t) params->HRX) >> 8;
- y = (params->HGY + mg * (int32_t) params->HRX - ng * (int32_t) params->HRY) >> 8;
+ int64_t x = ((int64_t) params->HGX + mg * params->HRY + ng * params->HRX) >> 8;
+ int64_t y = ((int64_t) params->HGY + mg * params->HRX - ng * params->HRY) >> 8;
/* prevent pattern index >= HNUMPATS */
gray_val = GI[ng][mg];