ref: a16825bb84c139c37b76c48d1ab22aa3431ad0fe
parent: 5bc215cd78619abe678381de5a63d603dfa1bbd3
author: Sebastian Rasmussen <[email protected]>
date: Thu Apr 19 22:33:31 EDT 2018
jbig2dec: Check for T.88 amendments 2/3 bitstreams. T.88 Amendment 2 adds up to 12 adaptive template pixels in generic regions. T.88 Amendment 3 adds support for generic/text regions to encode colors. Neither amendment is implemented and no sample files have been found. Return fatal errors for such bitstreams/files for the time being.
--- a/jbig2.c
+++ b/jbig2.c
@@ -256,6 +256,12 @@
return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "not a JBIG2 file header");
/* D.4.2 */
ctx->file_header_flags = ctx->buf[ctx->buf_rd_ix + 8];
+ /* Check for T.88 amendment 2 */
+ if (ctx->file_header_flags & 0x04)
+ return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "file header indicates use of 12 adaptive template pixels (NYI)");
+ /* Check for T.88 amendment 3 */
+ if (ctx->file_header_flags & 0x08)
+ return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "file header indicates use of colored region segments (NYI)");
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);
}
--- a/jbig2_generic.c
+++ b/jbig2_generic.c
@@ -806,6 +806,10 @@
offset = 18 + gbat_bytes;
+ /* Check for T.88 amendment 2 */
+ if ((seg_flags >> 5) & 1)
+ return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "segment uses 12 adaptive template pixels (NYI)");
+
/* Table 34 */
params.MMR = seg_flags & 1;
params.GBTEMPLATE = (seg_flags & 6) >> 1;
--- a/jbig2_page.c
+++ b/jbig2_page.c
@@ -109,6 +109,9 @@
page->x_resolution = jbig2_get_uint32(segment_data + 8);
page->y_resolution = jbig2_get_uint32(segment_data + 12);
page->flags = segment_data[16];
+ /* Check for T.88 amendment 3 */
+ if (page->flags & 0x80)
+ return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "page segment indicates use of color segments (NYI)");
/* 7.4.8.6 */
{
--- a/jbig2_segment.c
+++ b/jbig2_segment.c
@@ -282,6 +282,8 @@
return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "unhandled segment type 'profile'");
case 53: /* user-supplied huffman table */
return jbig2_table(ctx, segment, segment_data);
+ case 54:
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "unhandled segment type 'color palette'");
case 62:
return jbig2_parse_extension_segment(ctx, segment, segment_data);
default:
--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -579,6 +579,9 @@
goto too_short;
jbig2_get_region_segment_info(®ion_info, segment_data);
offset += 17;
+ /* Check for T.88 amendment 3 */
+ if (region_info.flags & 8)
+ return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "region segment flags indicate use of colored bitmap (NYI)");
/* 7.4.3.1.1 */
if (segment->data_length - offset < 2)