ref: de541912decffc32bc9872bf37281add45f12cb5
parent: 56e2b41c18cccc6ed7eff3f0f5a769b19fb946a8
author: Sebastian Rasmussen <sebras@gmail.com>
date: Fri Jun 29 13:47:25 EDT 2018
jbig2dec: Always complete a page, attempting decode of problematic streams. When JBIG2 bitstreams contain end of page segments the parser in jbig2dec calls jbig2_complete_page() to signal that the page is now finished. JBIG2 bitstreams created by some producers do not contain end of page segments but are otherwise well-formed JBIG2 bitstreams. Embedded JBIG2 bitstreams do not have to contain end of page segments. jbig2dec previously tried to detect these cases and simulated an end of page segment by manually calling jbig2_complete_page() so as to be able to output a displayable image. Problematic non-embedded JBIG2 bitstreams that have parse errors before any end of page segment is reached, or bitstreams where the end of page segment itself is broken, do not fall into either of the categories above but may be missing end of page segments. Previously jbig2dec treated this type of bistreams as not having any displayable image because the pages were never finished. To handle all types of bitstreams and attempt to output a displayable image (possibly partial due to parse errors), jbig2dec now always calls jbig2_complete_page() function.
--- a/jbig2dec.c
+++ b/jbig2dec.c
@@ -478,13 +478,13 @@
Jbig2Image *image;
FILE *out;
- /* handle embedded streams and work around broken CVision embedded streams */
- if (params.embedded || f_page != NULL) {
- code = jbig2_complete_page(ctx);
- if (code < 0) {
- jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "unable to complete page");
- goto cleanup;
- }
+ /* always complete a page, working around streams that lack end of
+ page segments: broken CVision streams, embedded streams or streams
+ with parse errors. */
+ code = jbig2_complete_page(ctx);
+ if (code < 0) {
+ jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "unable to complete page");
+ goto cleanup;
}
if (params.output_filename == NULL) {