ref: c3f6e30d4f07e021cc818e584b085456b25865e6
parent: a01d4e48567de8c803e993a76b5d7749f597875d
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Wed Nov 24 14:26:35 EST 2004
Rename the refinement region typical prediction flag TPGRON in correspondence with the spec. Also fixes some index comparison errors. git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@336 ded80894-8fb9-0310-811b-c03f3676ab4d
--- a/jbig2_generic.h
+++ b/jbig2_generic.h
@@ -48,7 +48,7 @@
bool GRTEMPLATE;
Jbig2Image *reference;
int32_t DX, DY;
- bool TPGDON;
+ bool TPGRON;
byte grat[4];
} Jbig2RefinementRegionParams;
--- a/jbig2_refinement.c
+++ b/jbig2_refinement.c
@@ -70,7 +70,7 @@
bool bit;
for (y = 0; y < GBH; y++) {
- for (x = 0; x < GBH; x++) {
+ for (x = 0; x < GBW; x++) {
CONTEXT = 0;
CONTEXT |= jbig2_image_get_pixel(image, x - 1, y + 0) << 0;
CONTEXT |= jbig2_image_get_pixel(image, x + 1, y - 1) << 1;
@@ -119,7 +119,7 @@
bool bit;
for (y = 0; y < GBH; y++) {
- for (x = 0; x < GBH; x++) {
+ for (x = 0; x < GBW; x++) {
CONTEXT = 0;
CONTEXT |= jbig2_image_get_pixel(image, x - 1, y + 0) << 0;
CONTEXT |= jbig2_image_get_pixel(image, x + 1, y - 1) << 1;
@@ -178,7 +178,7 @@
line_m1 = (y >= 1) ? grreg_line[-stride] : 0;
refline_m1 = ((y-dy) >= 1) ? grref_line[(-1-dy)*stride] << 2: 0;
refline_0 = (((y-dy) > 0) && ((y-dy) < GBH)) ? grref_line[(0-dy)*stride] << 4 : 0;
- refline_1 = (y < GBW - 1) ? grref_line[(+1-dy)*stride] << 7 : 0;
+ refline_1 = (y < GBH - 1) ? grref_line[(+1-dy)*stride] << 7 : 0;
CONTEXT = ((line_m1 >> 5) & 0x00e) |
((refline_1 >> 5) & 0x030) |
((refline_0 >> 5) & 0x1c0) |
@@ -260,11 +260,11 @@
{
jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
"decoding generic refinement region with offset %d,%x,\n"
- " GRTEMPLATE=%d, TPGDON=%d, RA1=(%d,%d) RA2=(%d,%d)\n",
- params->DX, params->DY, params->GRTEMPLATE, params->TPGDON,
+ " GRTEMPLATE=%d, TPGRON=%d, RA1=(%d,%d) RA2=(%d,%d)\n",
+ params->DX, params->DY, params->GRTEMPLATE, params->TPGRON,
params->grat[0], params->grat[1], params->grat[2], params->grat[3]);
}
- if (params->TPGDON)
+ if (params->TPGRON)
return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number,
"decode_refinement_region: typical prediction coding NYI");
if (params->GRTEMPLATE)
@@ -335,11 +335,11 @@
/* 7.4.7.2 */
seg_flags = segment_data[17];
params.GRTEMPLATE = seg_flags & 0x01;
- params.TPGDON = seg_flags & 0x02;
+ params.TPGRON = seg_flags & 0x02 ? 1 : 0;
jbig2_error(ctx, JBIG2_SEVERITY_INFO, segment->number,
"segment flags = %02x %s%s", seg_flags,
params.GRTEMPLATE ? " GRTEMPLATE" :"",
- params.TPGDON ? " TPGON" : "" );
+ params.TPGRON ? " TPGRON" : "" );
if (seg_flags & 0xFC)
jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number,
"reserved segment flag bits are non-zero");
--- a/jbig2_symbol_dict.c
+++ b/jbig2_symbol_dict.c
@@ -391,7 +391,7 @@
SDNEWSYMS->glyphs[ID-ninsyms];
rparams.DX = RDX;
rparams.DY = RDY;
- rparams.TPGDON = 0;
+ rparams.TPGRON = 0;
memcpy(rparams.grat, params->sdrat, 4);
jbig2_decode_refinement_region(ctx, segment,
&rparams, as, image, GB_stats);