ref: 74eba6a78944ccfada0ab7dc50f6363cfd225cbf
parent: a4d66009ee206247b2d9e61615a6fefbc49468c4
author: raph <raph@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Wed Dec 1 17:19:57 EST 2004
Implements IAID procedure for decoding reference symbol id's in symbol dict segs (was incorrectly using generic int procedure). Fixes off-by- one test for image bounds in jbig2_image_get_pixel and jbig2_image_set_pixel. git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@346 ded80894-8fb9-0310-811b-c03f3676ab4d
--- a/jbig2_image.c
+++ b/jbig2_image.c
@@ -180,8 +180,8 @@
const int byte = (x >> 3) + y*image->stride;
const int bit = 7 - (x & 7);
- if ((x < 0) || (x > w)) return 0;
- if ((y < 0) || (y > h)) return 0;
+ if ((x < 0) || (x >= w)) return 0;
+ if ((y < 0) || (y >= h)) return 0;
return ((image->data[byte]>>bit) & 1);
}
@@ -194,8 +194,8 @@
int i, scratch, mask;
int bit, byte;
- if ((x < 0) || (x > w)) return 0;
- if ((y < 0) || (y > h)) return 0;
+ if ((x < 0) || (x >= w)) return 0;
+ if ((y < 0) || (y >= h)) return 0;
byte = (x >> 3) + y*image->stride;
bit = 7 - (x & 7);
--- a/jbig2_symbol_dict.c
+++ b/jbig2_symbol_dict.c
@@ -30,6 +30,7 @@
#include "jbig2_priv.h"
#include "jbig2_arith.h"
#include "jbig2_arith_int.h"
+#include "jbig2_arith_iaid.h"
#include "jbig2_generic.h"
#include "jbig2_symbol_dict.h"
@@ -220,7 +221,7 @@
Jbig2ArithIntCtx *IADW = NULL;
Jbig2ArithIntCtx *IAEX = NULL;
Jbig2ArithIntCtx *IAAI = NULL;
- Jbig2ArithIntCtx *IAID = NULL;
+ Jbig2ArithIaidCtx *IAID = NULL;
Jbig2ArithIntCtx *IARDX = NULL;
Jbig2ArithIntCtx *IARDY = NULL;
int code = 0;
@@ -236,7 +237,12 @@
IADW = jbig2_arith_int_ctx_new(ctx);
IAEX = jbig2_arith_int_ctx_new(ctx);
IAAI = jbig2_arith_int_ctx_new(ctx);
- IAID = jbig2_arith_int_ctx_new(ctx);
+ if (params->SDREFAGG) {
+ int tmp = params->SDINSYMS->n_symbols + params->SDNUMNEWSYMS;
+ int SBSYMCODELEN;
+ for (SBSYMCODELEN = 0; (1 << SBSYMCODELEN) < tmp; SBSYMCODELEN++);
+ IAID = jbig2_arith_iaid_ctx_new(ctx, SBSYMCODELEN);
+ }
IARDX = jbig2_arith_int_ctx_new(ctx);
IARDY = jbig2_arith_int_ctx_new(ctx);
} else {
@@ -376,7 +382,7 @@
if (params->SDHUFF) {
/* todo */
} else {
- code = jbig2_arith_int_decode(IAID, as, &ID);
+ code = jbig2_arith_iaid_decode(IAID, as, &ID);
code = jbig2_arith_int_decode(IARDX, as, &RDX);
code = jbig2_arith_int_decode(IARDY, as, &RDY);
}