rev 468 - trunk
[email protected] Mon, 26 May 2008 11:52:22 -0700 (PDT)
| Newsgroups | gmane.comp.printing.ghostscript.jbig2dec.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: giles
Date: 2008-05-26 11:52:22 -0700 (Mon, 26 May 2008)
New Revision: 468
Modified:
trunk/jbig2_page.c
Log:
Work around broken streams created by Xerox WorkCentre products, where
the final segment length is written as -1. Ghostscript bug 689841.
Modified: trunk/jbig2_page.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/jbig2_page.c 2008-05-17 00:08:26 UTC (rev 467)
+++ trunk/jbig2_page.c 2008-05-26 18:52:22 UTC (rev 468)
@@ -177,7 +177,7 @@
if (end_row < page.end_row) {
jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number,
"end of stripe segment with non-positive end row advance"
- "(new end row %d vs current end row %d)",
+ " (new end row %d vs current end row %d)",
end_row, page.end_row);
} else {
jbig2_error(ctx, JBIG2_SEVERITY_INFO, segment->number,
@@ -200,6 +200,24 @@
int
jbig2_complete_page (Jbig2Ctx *ctx)
{
+
+ /* check for unfinished segments */
+ if (ctx->segment_index !=3D ctx->n_segments) {
+ Jbig2Segment *segment =3D ctx->segments[ctx->segment_index];
+ int code =3D 0;
+ /* Some versions of Xerox Workcentre generate PDF files
+ with the segment data length field of the last segment
+ set to -1. Try to cope with this here. */
+ if ((segment->data_length & 0xffffffff) =3D=3D 0xffffffff) {
+ jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number,
+ "File has an invalid segment data length!"
+ " Trying to decode using the available data.");
+ segment->data_length =3D ctx->buf_wr_ix - ctx->buf_rd_ix;
+ code =3D jbig2_parse_segment(ctx, segment, ctx->buf + ctx->buf_r=
d_ix);
+ ctx->buf_rd_ix +=3D segment->data_length;
+ ctx->segment_index++;
+ }
+ }
ctx->pages[ctx->current_page].state =3D JBIG2_PAGE_COMPLETE;
=20
return 0;