jbig2dec
Ralph Giles <[email protected]> Mon, 08 Jul 2002 12:21:37 -0700
| Newsgroups | gmane.comp.printing.ghostscript.jbig2dec.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jbig2dec/jbig2dec
In directory usw-pr-cvs1:/tmp/cvs-serv25779
Modified Files:
jbig2.c
Log Message:
Fix parsing of sequential files.
Index: jbig2.c
===================================================================
RCS file: /cvsroot/jbig2dec/jbig2dec/jbig2.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- jbig2.c 8 Jul 2002 14:54:01 -0000 1.14
+++ jbig2.c 8 Jul 2002 19:21:35 -0000 1.15
@@ -170,7 +170,7 @@
if (ctx->buf == NULL)
{
- int buf_size = initial_buf_size;
+ size_t buf_size = initial_buf_size;
do
buf_size <<= 1;
@@ -229,19 +229,23 @@
"Not a JBIG2 file header");
/* D.4.2 */
ctx->file_header_flags = ctx->buf[ctx->buf_rd_ix + 8];
+ if (ctx->file_header_flags & 0xFC) {
+ jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1,
+ "reserved bits (2-7) of file header flags are not zero (0x%02x)", ctx->file_header_flags);
+ }
/* D.4.3 */
if (!(ctx->file_header_flags & 2)) /* number of pages is known */
{
if (ctx->buf_wr_ix - ctx->buf_rd_ix < 13)
return 0;
ctx->n_pages = jbig2_get_int32(ctx->buf + ctx->buf_rd_ix + 9);
+ ctx->buf_rd_ix += 13;
if (ctx->n_pages == 1)
jbig2_error(ctx, JBIG2_SEVERITY_INFO, -1, "file header indicates a single page document");
else
jbig2_error(ctx, JBIG2_SEVERITY_INFO, -1, "file header indicates a %d page document", ctx->n_pages);
- ctx->buf_rd_ix += 13;
}
- else
+ else /* number of pages not known */
{
ctx->n_pages=0;
ctx->buf_rd_ix += 9;
@@ -250,10 +254,13 @@
if (ctx->file_header_flags & 1)
{
ctx->state = JBIG2_FILE_SEQUENTIAL_HEADER;
+ jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, -1, "file header indicates sequential organization");
}
else
{
- ctx->state = JBIG2_FILE_RANDOM_HEADERS;
+ ctx->state = JBIG2_FILE_RANDOM_HEADERS;
+ jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, -1, "file header indicates random-access organization");
+
}
break;
case JBIG2_FILE_SEQUENTIAL_HEADER:
@@ -285,17 +292,14 @@
return 0;
code = jbig2_parse_segment(ctx, segment, ctx->buf + ctx->buf_rd_ix);
ctx->buf_rd_ix += segment->data_length;
-// jbig2_free_segment(ctx, segment);
-// ctx->segments[ctx->segment_index] = NULL;
+ ctx->segment_index++;
if (ctx->state == JBIG2_FILE_RANDOM_BODIES)
{
- ctx->segment_index++;
if (ctx->segment_index == ctx->n_segments)
ctx->state = JBIG2_FILE_EOF;
}
else /* JBIG2_FILE_SEQUENCIAL_BODY */
{
- ctx->n_segments = 0;
ctx->state = JBIG2_FILE_SEQUENTIAL_HEADER;
}
if (code < 0)