shithub: jbig2

Download patch

ref: c8ca06c65a11e60cbcefa02693ba1f937cfda427
parent: c81291302e56c89dd2c2015212dffa75eddab338
author: Sebastian Rasmussen <[email protected]>
date: Sun Apr 22 19:08:49 EDT 2018

jbig2dec: Remove unnecessary comments, whitespace and unused code.

--- a/jbig2.c
+++ b/jbig2.c
@@ -283,7 +283,6 @@
             } else {
                 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:
--- a/jbig2_generic.c
+++ b/jbig2_generic.c
@@ -61,9 +61,6 @@
     int x, y;
     byte *gbreg_line = (byte *) image->data;
 
-    /* todo: currently we only handle the nominal gbat location */
-    /* when resolved make sure to call jbig2_check_adaptive_pixel_in_field() */
-
 #ifdef OUTPUT_PBM
     printf("P4\n%d %d\n", GBW, GBH);
 #endif
--- a/jbig2_halftone.c
+++ b/jbig2_halftone.c
@@ -65,7 +65,6 @@
         for (i = 0; i < N; i++) {
             new->patterns[i] = jbig2_image_new(ctx, HPW, HPH);
             if (new->patterns[i] == NULL) {
-
                 jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "failed to allocate pattern element image");
                 for (j = 0; j < i; j++)
                     jbig2_free(ctx->allocator, new->patterns[j]);
@@ -324,7 +323,6 @@
         }
 
         code = jbig2_decode_generic_region(ctx, segment, &rparams, as, GSPLANES[GSBPP - 1], GB_stats);
-
     }
     if (code != 0) {
         jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "error decoding GSPLANES for halftone image");
--- a/jbig2_huffman.c
+++ b/jbig2_huffman.c
@@ -278,7 +278,7 @@
         entry = &table->entries[log_table_size > 0 ? this_word >> (32 - log_table_size) : 0];
         flags = entry->flags;
         PREFLEN = entry->PREFLEN;
-        if ((flags == (byte) - 1) && (PREFLEN == (byte) - 1) && (entry->u.RANGELOW == -1)) {
+        if (flags == (byte) -1 && PREFLEN == (byte) -1 && entry->u.RANGELOW == -1) {
             if (oob)
                 *oob = -1;
             return -1;
--- a/jbig2_image.c
+++ b/jbig2_image.c
@@ -266,15 +266,6 @@
 #endif
         return 0;
     }
-#if 0
-    /* special case complete/strip replacement */
-    /* disabled because it's only safe to do when the destination
-       buffer is all-blank. */
-    if ((x == 0) && (w == src->width)) {
-        memcpy(dst->data + y * dst->stride, src->data, h * src->stride);
-        return 0;
-    }
-#endif
 
     leftbyte = (uint32_t) x >> 3;
     rightbyte = ((uint32_t) x + w - 1) >> 3;
--- a/jbig2_page.c
+++ b/jbig2_page.c
@@ -86,7 +86,6 @@
                     ctx->pages[j].state = JBIG2_PAGE_FREE;
                     ctx->pages[j].number = 0;
                     ctx->pages[j].image = NULL;
-
                 }
             }
         }
@@ -166,7 +165,7 @@
     end_row = jbig2_get_uint32(segment_data);
     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)", end_row, page.end_row);
+                    "end of stripe segment with non-positive end row advance (new end row %d vs current end row %d)", end_row, page.end_row);
     } else {
         jbig2_error(ctx, JBIG2_SEVERITY_INFO, segment->number, "end of stripe: advancing end row to %d", end_row);
     }
@@ -269,7 +268,7 @@
         if (page->image->height < new_height) {
             Jbig2Image *resized_image = NULL;
 
-            jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, -1, "growing page buffer to %d rows " "to accommodate new stripe", new_height);
+            jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, -1, "growing page buffer to %d rows to accommodate new stripe", new_height);
             resized_image = jbig2_image_resize(ctx, page->image, page->image->width, new_height);
             if (resized_image == NULL) {
                 return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "unable to resize image to accommodate new stripe");
--- a/jbig2_refinement.c
+++ b/jbig2_refinement.c
@@ -37,16 +37,6 @@
 #include "jbig2_generic.h"
 #include "jbig2_image.h"
 
-#if 0                           /* currently not used */
-static int
-jbig2_decode_refinement_template0(Jbig2Ctx *ctx,
-                                  Jbig2Segment *segment,
-                                  const Jbig2RefinementRegionParams *params, Jbig2ArithState *as, Jbig2Image *image, Jbig2ArithCx *GR_stats)
-{
-    return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "refinement region template 0 NYI");
-}
-#endif
-
 static int
 jbig2_decode_refinement_template0_unopt(Jbig2Ctx *ctx,
                                         Jbig2Segment *segment,
--- a/jbig2_segment.c
+++ b/jbig2_segment.c
@@ -87,7 +87,7 @@
 
         referred_to_segments = jbig2_new(ctx, uint32_t, referred_to_segment_count * referred_to_segment_size);
         if (referred_to_segments == NULL) {
-            jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "could not allocate referred_to_segments " "in jbig2_parse_segment_header");
+            jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "could not allocate referred_to_segments in jbig2_parse_segment_header");
             return NULL;
         }
 
@@ -212,7 +212,7 @@
     necessary = type & 0x80000000;
 
     if (necessary && !reserved) {
-        jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "extension segment is marked 'necessary' but " "not 'reserved' contrary to spec");
+        jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "extension segment is marked 'necessary' but not 'reserved' contrary to spec");
     }
 
     switch (type) {
--- a/jbig2_symbol_dict.c
+++ b/jbig2_symbol_dict.c
@@ -418,7 +418,7 @@
                     if (params->SDHUFF) {
                         REFAGGNINST = jbig2_huffman_get(hs, params->SDHUFFAGGINST, &code);
                     } else {
-                        code = jbig2_arith_int_decode(ctx, IAAI, as, (int32_t *) & REFAGGNINST);
+                        code = jbig2_arith_int_decode(ctx, IAAI, as, (int32_t *) &REFAGGNINST);
                     }
                     if (code || (int32_t) REFAGGNINST <= 0) {
                         code = jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "invalid number of symbols or OOB in aggregate glyph");
@@ -558,7 +558,7 @@
                         }
 
                         jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
-                                    "symbol is a refinement of id %d with the " "refinement applied at (%d,%d)", ID, RDX, RDY);
+                                    "symbol is a refinement of id %d with the refinement applied at (%d,%d)", ID, RDX, RDY);
 
                         image = jbig2_image_new(ctx, SYMWIDTH, HCHEIGHT);
                         if (image == NULL) {
@@ -663,7 +663,7 @@
 
                 BMSIZE = image->height * stride;
                 jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number,
-                            "reading %dx%d uncompressed bitmap" " for %d symbols (%d bytes)", image->width, image->height, NSYMSDECODED - HCFIRSTSYM, BMSIZE);
+                            "reading %dx%d uncompressed bitmap for %d symbols (%d bytes)", image->width, image->height, NSYMSDECODED - HCFIRSTSYM, BMSIZE);
 
                 for (j = 0; j < image->height; j++) {
                     memcpy(dst, src, stride);
--- a/jbig2_text.c
+++ b/jbig2_text.c
@@ -398,7 +398,6 @@
                 if (params->SBHUFF) {
                     jbig2_huffman_advance(hs, BMSIZE);
                 }
-
             }
 
             /* (3c.vi) */
--- a/jbig2dec.c
+++ b/jbig2dec.c
@@ -225,7 +225,8 @@
             "       --hash      print a hash of the decoded document\n"
             "    -o <file>      send decoded output to <file>\n"
             "                   Defaults to the the input with a different\n"
-            "                   extension. Pass '-' for stdout.\n" "    -t <type>      force a particular output file format\n"
+            "                   extension. Pass '-' for stdout.\n"
+            "    -t <type>      force a particular output file format\n"
 #ifdef HAVE_LIBPNG
             "                   supported options are 'png' and 'pbm'\n"
 #else