[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1651-gb5e5ed8

[email protected] (Sebastian Rasmussen)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  b5e5ed8620f348e0fa619171d6f05a966a4bcf83 (commit)
       via  ccc1a52f59194193450747e41006982d322c43a5 (commit)
       via  758951f873b4b80de3c11294c3bc76ca0d6144d7 (commit)
       via  cd815dfe5e8db6e997466765218c80bb54902234 (commit)
       via  1ae9b9b92bfa6fef04a50b8f27c3dc6e9e03fba0 (commit)
       via  14cc5cb07861b8bd8c3a2cfd1d7ac21dd98fa202 (commit)
       via  49a6ff2b166a4cda4d7b8c9d8192bb6f419c7ca3 (commit)
       via  8719833a6a4242880ad8b81cb8fe19e03667af52 (commit)
       via  d75727a7fd5efb2245c7b0d0b33ee8611446c150 (commit)
       via  b3f859987f152e13ab141143234f686749f2caf7 (commit)
       via  49fa7d21bc555a96e19318b56301185f12f68c55 (commit)
       via  314250a3126243a228249ebf1e6272c0beaec9d6 (commit)
       via  a9b92d33e7ed5e06d0728d6a1be771d8b464c50e (commit)
       via  8b3ffd237746e2bab2867ad460e8635a79cd5916 (commit)
       via  2e957c0b1afc6d2d705c9d075fc55db2de5df854 (commit)
       via  1c5c3a1f14c85582d09ab58f55b1fd83435b6562 (commit)
      from  5a6832ca60dfc34cb9a0680590cbd086f528fd22 (commit)

----------------------------------------------------------------------
commit b5e5ed8620f348e0fa619171d6f05a966a4bcf83
Author: Sebastian Rasmussen <[email protected]>
Date:   Thu Jun 13 01:35:36 2019 +0200

    jbig2dec: Validate coordinates when add image onto page.
    
    Detected by Coverity in CID 94850.

diff --git a/jbig2dec/jbig2_page.c b/jbig2dec/jbig2_page.c
index 019d70a..4744559 100644
--- a/jbig2dec/jbig2_page.c
+++ b/jbig2dec/jbig2_page.c
@@ -34,6 +34,9 @@
 #include "jbig2_page.h"
 #include "jbig2_segment.h"
 
+#if !defined (INT32_MAX)
+#define INT32_MAX  0x7fffffff
+#endif
 #if !defined (UINT32_MAX)
 #define UINT32_MAX 0xffffffff
 #endif
@@ -266,6 +269,9 @@ jbig2_page_add_result(Jbig2Ctx *ctx, Jbig2Page *page, Jbig2Image *image, uint32_
 {
     int code;
 
+    if (x > INT32_MAX || y > INT32_MAX)
+        return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "unsupported image coordinates");
+
     /* ensure image exists first */
     if (page->image == NULL)
         return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "page info possibly missing, no image defined");

----------------------------------------------------------------------
commit ccc1a52f59194193450747e41006982d322c43a5
Author: Sebastian Rasmussen <[email protected]>
Date:   Wed Jun 12 18:55:16 2019 +0200

    jbig2dec: Avoid extending page image beyond INT_MAX pixels high.
    
    Detected by Coverity in CID 95080.

diff --git a/jbig2dec/jbig2_page.c b/jbig2dec/jbig2_page.c
index c07842b..019d70a 100644
--- a/jbig2dec/jbig2_page.c
+++ b/jbig2dec/jbig2_page.c
@@ -34,6 +34,10 @@
 #include "jbig2_page.h"
 #include "jbig2_segment.h"
 
+#if !defined (UINT32_MAX)
+#define UINT32_MAX 0xffffffff
+#endif
+
 /* dump the page struct info */
 static void
 dump_page_info(Jbig2Ctx *ctx, Jbig2Segment *segment, Jbig2Page *page)
@@ -268,7 +272,12 @@ jbig2_page_add_result(Jbig2Ctx *ctx, Jbig2Page *page, Jbig2Image *image, uint32_
 
     /* grow the page to accommodate a new stripe if necessary */
     if (page->striped && page->height == 0xFFFFFFFF) {
-        uint32_t new_height = y + image->height;
+        uint32_t new_height;
+
+        if (y > UINT32_MAX - image->height)
+                return jbig2_error(ctx, JBIG2_SEVERITY_FATAL, -1, "adding image at coordinate would grow page out of bounds");
+        new_height = y + image->height;
+
         if (page->image->height < new_height) {
             Jbig2Image *resized_image = NULL;
 

----------------------------------------------------------------------
commit 758951f873b4b80de3c11294c3bc76ca0d6144d7
Author: Sebastian Rasmussen <[email protected]>
Date:   Wed Jun 12 18:52:44 2019 +0200

    jbig2dec: Validate range of Huffman Table range values.
    
    Detected by Coverity in CID 94835.

diff --git a/jbig2dec/jbig2_huffman.c b/jbig2dec/jbig2_huffman.c
index 235233e..57113bc 100644
--- a/jbig2dec/jbig2_huffman.c
+++ b/jbig2dec/jbig2_huffman.c
@@ -583,6 +583,11 @@ jbig2_table(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segment_data)
                     code_table_flags, HTOOB, HTPS, HTRS, HTLOW, HTHIGH);
 #endif
 
+        if (HTLOW >= HTHIGH) {
+            jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "invalid Huffman Table range");
+            goto error_exit;
+        }
+
         /* allocate HuffmanParams & HuffmanLine */
         params = jbig2_new(ctx, Jbig2HuffmanParams, 1);
         if (params == NULL) {

----------------------------------------------------------------------
commit cd815dfe5e8db6e997466765218c80bb54902234
Author: Sebastian Rasmussen <[email protected]>
Date:   Fri Jun 7 13:29:40 2019 +0200

    jbig2dec: Avoid double checks for negative coordinates.
    
    Negative coordinates are already handled prior in the function
    by falling back to the unoptimized case.
    
    This was detected by Coverity in CID 303984 and CID 303985.

diff --git a/jbig2dec/jbig2_image.c b/jbig2dec/jbig2_image.c
index 05a81bd..fa51825 100644
--- a/jbig2dec/jbig2_image.c
+++ b/jbig2dec/jbig2_image.c
@@ -290,20 +290,6 @@ jbig2_image_compose(Jbig2Ctx *ctx, Jbig2Image *dst, Jbig2Image *src, int x, int
     h = src->height;
     ss = src->data;
 
-    if (x < 0) {
-        if (w < (uint32_t) -x)
-            w = 0;
-        else
-            w += x;
-        x = 0;
-    }
-    if (y < 0) {
-        if (h < (uint32_t) -y)
-            h = 0;
-        else
-            h += y;
-        y = 0;
-    }
     w = ((uint32_t) x + w < dst->width) ? w : ((dst->width >= (uint32_t) x) ? dst->width - (uint32_t) x : 0);
     h = ((uint32_t) y + h < dst->height) ? h : ((dst->height >= (uint32_t) y) ? dst->height - (uint32_t) y : 0);
 #ifdef JBIG2_DEBUG

----------------------------------------------------------------------
commit 1ae9b9b92bfa6fef04a50b8f27c3dc6e9e03fba0
Author: Sebastian Rasmussen <[email protected]>
Date:   Wed Jul 3 02:27:40 2019 +0200

    jbig2dec: A small collection of code cleanups.
    
     * Refer to Jbig2ArithCx for memsetting in case it ever changes.
     * Fix typo.
     * Avoid using local variable when unnecessary.

diff --git a/jbig2dec/jbig2.c b/jbig2dec/jbig2.c
index 07c7969..97018ea 100644
--- a/jbig2dec/jbig2.c
+++ b/jbig2dec/jbig2.c
@@ -384,7 +384,7 @@ jbig2_data_in(Jbig2Ctx *ctx, const unsigned char *data, size_t size)
             if (ctx->state == JBIG2_FILE_RANDOM_BODIES) {
                 if (ctx->segment_index == ctx->n_segments)
                     ctx->state = JBIG2_FILE_EOF;
-            } else {            /* JBIG2_FILE_SEQUENCIAL_BODY */
+            } else {            /* JBIG2_FILE_SEQUENTIAL_BODY */
                 ctx->state = JBIG2_FILE_SEQUENTIAL_HEADER;
             }
             if (code < 0) {
diff --git a/jbig2dec/jbig2_symbol_dict.c b/jbig2dec/jbig2_symbol_dict.c
index 93ea09d..7545ca4 100644
--- a/jbig2dec/jbig2_symbol_dict.c
+++ b/jbig2dec/jbig2_symbol_dict.c
@@ -1034,7 +1034,7 @@ jbig2_symbol_dictionary(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segmen
             jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "failed to allocate arithmetic decoder states for generic regions");
             goto cleanup;
         }
-        memset(GB_stats, 0, stats_size);
+        memset(GB_stats, 0, sizeof (Jbig2ArithCx) * stats_size);
 
         stats_size = params.SDRTEMPLATE ? 1 << 10 : 1 << 13;
         GR_stats = jbig2_new(ctx, Jbig2ArithCx, stats_size);
diff --git a/jbig2dec/jbig2_text.c b/jbig2dec/jbig2_text.c
index 7fb9eb0..57b31de 100644
--- a/jbig2dec/jbig2_text.c
+++ b/jbig2dec/jbig2_text.c
@@ -221,9 +221,8 @@ cleanup1:
         jbig2_release_huffman_table(ctx, runcodes);
 
         if (SBSYMCODES == NULL) {
-            code = jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "failed to construct symbol ID huffman table");
             jbig2_huffman_free(ctx, hs);
-            return code;
+            return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "failed to construct symbol ID huffman table");
         }
     }
 

----------------------------------------------------------------------
commit 14cc5cb07861b8bd8c3a2cfd1d7ac21dd98fa202
Author: Sebastian Rasmussen <[email protected]>
Date:   Fri Jun 21 15:02:14 2019 +0200

    jbig2dec: Add all ubc test files.

diff --git a/jbig2dec/test_jbig2dec.py b/jbig2dec/test_jbig2dec.py
index 4ff13fd..629b685 100755
--- a/jbig2dec/test_jbig2dec.py
+++ b/jbig2dec/test_jbig2dec.py
@@ -67,87 +67,76 @@ class KnownFileHash(SelfTest):
 
   # these are known test files in the form
   # (filename, sha-1(file), sha-1(decoded document)
-  known_hashes = ( ('tests/ubc/042_1.jb2',
-                        "673e1ee5c55ab241b171e476ba1168a42733ddaa",
-                        known_042_DECODED),
-                   ('tests/ubc/042_2.jb2', 
-                        "9aa2804e2d220952035c16fb3c907547884067c5",
-                        known_042_DECODED),
-                   ('tests/ubc/042_3.jb2',
-                        "9663a5f35727f13e61a0a2f0a64207b1f79e7d67",
-                        known_042_DECODED),
-                   ('tests/ubc/042_4.jb2',
-                        "014df658c8b99b600c2ceac3f1d53c7cc2b4917c",
-                        known_042_DECODED),
-                   ('tests/ubc/042_5.jb2',
-                        "264720a6ccbbf72aa6a2cfb6343f43b8e6f2da4b",
-                        known_042_DECODED),
-                   ('tests/ubc/042_6.jb2',
-                        "96f7dc9df4a1b305f9ac082dd136f85ef5b108fe",
-                        known_042_DECODED),
-                   ('tests/ubc/042_7.jb2',
-                        "5526371ba9dc2b8743f20ae3e05a7e60b3dcba76",
-                        known_042_DECODED),
-                   ('tests/ubc/042_8.jb2',
-                        "4bf0c87dfaf40d67c36f2a083579eeda26d54641",
-                        known_042_DECODED),
-                   ('tests/ubc/042_9.jb2',
-                        "53e630e7fe2fe6e1d6164758e15fc93382e07f55",
-                        known_042_DECODED),
-                   ('tests/ubc/042_10.jb2',
-                        "5ca1364367e25cb8f642e9dc677a94d5cfed0c8b",
-                        known_042_DECODED),
-                   ('tests/ubc/042_11.jb2',
-                        "bc194caf022bc5345fc41259e05cea3c08245216",
-                        known_042_DECODED),
-                   ('tests/ubc/042_12.jb2',
-                        "f354df8eb4849bc707f088739e322d1fe3a14ef3",
-                        known_042_DECODED),
-                   ('tests/ubc/042_13.jb2',
-                        "7d428bd542f58591b254d9827f554b0552c950a7",
-                        known_WHITE_PAGE_DECODED),
-                   ('tests/ubc/042_14.jb2',
-                        "c40fe3a02acb6359baf9b40fc9c49bc0800be589",
-                        known_WHITE_PAGE_DECODED),
-                   ('tests/ubc/042_15.jb2',
-                        "a9e39fc1ecb178aec9f05039514d75ea3246246c",
-                        known_042_DECODED),
-                   ('tests/ubc/042_16.jb2',
-                        "4008bbca43670f3c90eaee26516293ba95baaf3d",
-                        known_042_DECODED),
-                   ('tests/ubc/042_17.jb2',
-                        "0ff95637b64c57d659a41c582da03e25321551fb",
-                        known_042_DECODED),
-                   ('tests/ubc/042_18.jb2',
-                        "87381d044f00c4329200e44decbe91bebfa31595",
-                        known_042_DECODED),
-                   ('tests/ubc/042_19.jb2',
-                        "387d95a140b456d4742622c788cf5b51cebbf438",
-                        known_042_DECODED),
-                   ('tests/ubc/042_20.jb2',
-                        "85c19e9ec42b8ddd6b860a1bebea1c67610e7a59",
-                        known_042_DECODED),
-                   ('tests/ubc/042_21.jb2',
-                        "ab535c7d7a61a7b9dc53d546e7419ca78ac7f447",
-                        known_042_DECODED),
-                   ('tests/ubc/042_22.jb2',
-                        "a9e2b365be63716dbde74b0661c3c6efd2a6844d",
-                        known_042_DECODED),
-                   ('tests/ubc/042_23.jb2',
-                        "8ffa40a05e93e10982b38a2233a8da58c1b5c343",
-                        known_042_DECODED),
-                   ('tests/ubc/042_24.jb2',
-                        "2553fe65111c58f6412de51d8cdc71651e778ccf",
-                        known_042_DECODED),
-                   ('tests/ubc/042_25.jb2',
-                        "52de4a3b86252d896a8d783ba71dd0699333dd69",
-                        known_042_DECODED),
-                   ('tests/ubc/amb_1.jb2',
-                        "d6d6d1c981dc37a09108c1e3ed990aa5b345fa6a",
-                        known_amb_DECODED),
-                   ('tests/ubc/amb_2.jb2',
-                        "9af6616a89eb03f8934de72626e301a716366c3c",
-                        known_amb_DECODED)
+  known_hashes = (
+                   ('tests/ubc/042_1.jb2', "673e1ee5c55ab241b171e476ba1168a42733ddaa", known_042_DECODED),
+                   ('tests/ubc/042_2.jb2', "9aa2804e2d220952035c16fb3c907547884067c5", known_042_DECODED),
+                   ('tests/ubc/042_3.jb2', "9663a5f35727f13e61a0a2f0a64207b1f79e7d67", known_042_DECODED),
+                   ('tests/ubc/042_4.jb2', "014df658c8b99b600c2ceac3f1d53c7cc2b4917c", known_042_DECODED),
+                   ('tests/ubc/042_5.jb2', "264720a6ccbbf72aa6a2cfb6343f43b8e6f2da4b", known_042_DECODED),
+                   ('tests/ubc/042_6.jb2', "96f7dc9df4a1b305f9ac082dd136f85ef5b108fe", known_042_DECODED),
+                   ('tests/ubc/042_7.jb2', "5526371ba9dc2b8743f20ae3e05a7e60b3dcba76", known_042_DECODED),
+                   ('tests/ubc/042_8.jb2', "4bf0c87dfaf40d67c36f2a083579eeda26d54641", known_042_DECODED),
+                   ('tests/ubc/042_9.jb2', "53e630e7fe2fe6e1d6164758e15fc93382e07f55", known_042_DECODED),
+                   ('tests/ubc/042_10.jb2', "5ca1364367e25cb8f642e9dc677a94d5cfed0c8b", known_042_DECODED),
+                   ('tests/ubc/042_11.jb2', "bc194caf022bc5345fc41259e05cea3c08245216", known_042_DECODED),
+                   ('tests/ubc/042_12.jb2', "f354df8eb4849bc707f088739e322d1fe3a14ef3", known_042_DECODED),
+                   ('tests/ubc/042_13.jb2', "7d428bd542f58591b254d9827f554b0552c950a7", known_WHITE_PAGE_DECODED),
+                   ('tests/ubc/042_14.jb2', "c40fe3a02acb6359baf9b40fc9c49bc0800be589", known_WHITE_PAGE_DECODED),
+                   ('tests/ubc/042_15.jb2', "a9e39fc1ecb178aec9f05039514d75ea3246246c", known_042_DECODED),
+                   ('tests/ubc/042_16.jb2', "4008bbca43670f3c90eaee26516293ba95baaf3d", known_042_DECODED),
+                   ('tests/ubc/042_17.jb2', "0ff95637b64c57d659a41c582da03e25321551fb", known_042_DECODED),
+                   ('tests/ubc/042_18.jb2', "87381d044f00c4329200e44decbe91bebfa31595", known_042_DECODED),
+                   ('tests/ubc/042_19.jb2', "387d95a140b456d4742622c788cf5b51cebbf438", known_042_DECODED),
+                   ('tests/ubc/042_20.jb2', "85c19e9ec42b8ddd6b860a1bebea1c67610e7a59", known_042_DECODED),
+                   ('tests/ubc/042_21.jb2', "ab535c7d7a61a7b9dc53d546e7419ca78ac7f447", known_042_DECODED),
+                   ('tests/ubc/042_22.jb2', "a9e2b365be63716dbde74b0661c3c6efd2a6844d", known_042_DECODED),
+                   ('tests/ubc/042_23.jb2', "8ffa40a05e93e10982b38a2233a8da58c1b5c343", known_042_DECODED),
+                   ('tests/ubc/042_24.jb2', "2553fe65111c58f6412de51d8cdc71651e778ccf", known_042_DECODED),
+                   ('tests/ubc/042_25.jb2', "52de4a3b86252d896a8d783ba71dd0699333dd69", known_042_DECODED),
+
+                   ('tests/ubc/amb_1.jb2', "d6d6d1c981dc37a09108c1e3ed990aa5b345fa6a", known_amb_DECODED),
+                   ('tests/ubc/amb_2.jb2', "9af6616a89eb03f8934de72626e301a716366c3c", known_amb_DECODED),
+
+                   ('tests/ubc/200-10-0.jb2', "f6014b43775640ef0874497e0873f8deb291cc32", "49cddf903d3451ba23297a6b68502504093979cf"),
+                   ('tests/ubc/200-10-0-stripe.jb2', "d19f58cd180afd1ae2afd11c96471e98c7c6f125", "ac89ae2046c4859348418830287982b6d60bf39b"),
+                   ('tests/ubc/200-10-45.jb2', "504297b028810f812cbf075597f589a9fb82121b", "38aa99e40c6a746391c26c953223bcd4549cadd0"),
+                   ('tests/ubc/200-10-45-stripe.jb2', "0d9f2a63c9fd224a6b60a9b7c0cd658f47551edd", "2921889fc5ffaafb348084761aa7c54831ec57ba"),
+                   ('tests/ubc/200-20-0.jb2', "a40aaf33dd4c3225728ddfc0fad12167ceff1b17", "cc1732742d5d68c6d5c3f4eec9d5887e9ee24cd0"),
+                   ('tests/ubc/200-20-0-stripe.jb2', "d499a89baf69a1b5f6fa450ec20b21136052b4cd", "743aa86e7abc9e238e23d02fbc993b048589282a"),
+                   ('tests/ubc/200-20-45.jb2', "a39f1e2670f1c08dbd07d14a99965bf7253e6318", "7213fb351f65397c12accf662787aa3bc028c40f"),
+                   ('tests/ubc/200-20-45-stripe.jb2', "3aa44cdef38fc8e34376480408ca99364ccbf0ee", "9021716b3eca4da549508db691655eddc4d51548"),
+                   ('tests/ubc/200-2-0.jb2', "087f529ba6e3cc5fca3773c1d07e39fb642f5052", "534fceffada398444ce065088a37b6d6517a3406"),
+                   ('tests/ubc/200-2-0-stripe.jb2', "dc227f7531ccecda08511bda9359864c66a8d230", "56f0e25ae5863a75d69a1825b820ba004e48d2c4"),
+                   ('tests/ubc/200-3-0.jb2', "024a20b82e794eb469b4fae2b4f930c5c079fd6b", "57fe3645b028e6c7a68dcf707674f889038ee4b5"),
+                   ('tests/ubc/200-3-0-stripe.jb2', "2322db7dc956863b7257d28a212431e304661998", "32ea498b28a46bf04e0b799c70114ab99ce7d15e"),
+                   ('tests/ubc/200-3-45.jb2', "21ba06f8cfcc31b5bd7fa39ad98093180d3e05aa", "83e01d0a83d167fe00f7389e5fec0a660841aeef"),
+                   ('tests/ubc/200-3-45-stripe.jb2', "6dfe3cbb019ef0c30ecae7d2196b1b3fd7634288", "20c2ade5766eeb3a70dca9963029c0a74171064b"),
+                   ('tests/ubc/200-4-0.jb2', "c7d8d8b8a97388b0fcc6e5e3d8708fbce0881edf", "b85fe470db7542789b0632dc87dbdc721e07ddf5"),
+                   ('tests/ubc/200-4-0-stripe.jb2', "840f076fd542b2ae8d0d1663ed7efd5683326bc7", "0acd5a6f24637dad4b948fa24563b1fae04996be"),
+                   ('tests/ubc/200-4-45.jb2', "6ed49af06268d57137436ffeea2def6f93ea17eb", "5177abf7e9d641ca4f553bd4847134e51bb1159a"),
+                   ('tests/ubc/200-4-45-stripe.jb2', "0dfc5b59a046ab05364298b1767334298fa03eeb", "944a399d8763007ae0477f69b80ec28d7fbe6edd"),
+                   ('tests/ubc/200-5-0.jb2', "47770e4144b022790af00098ac830ac8665f62a0", "515eaf8e4537bbda841abf3b7ffbd1b4728c7597"),
+                   ('tests/ubc/200-5-0-stripe.jb2', "23f784c297c204bc1bf7cd1559a7c38a95097266", "c69e97f9e1a7e45d6eb3975ecb8a4a7dd7f09e2e"),
+                   ('tests/ubc/200-5-45.jb2', "193376e966e8bc22868e38791289e810953b5483", "77fff5286023b77316221d5c36a6d40f8b905ca9"),
+                   ('tests/ubc/200-5-45-stripe.jb2', "d211863df684b5c113c2e29aec72c6a533681356", "efd7b9ae877bf3d71c0baa604a1014e1218ada90"),
+                   ('tests/ubc/200-6-0.jb2', "e66a8cff6c00575018253a06f9309192cc796fb2", "7b5dae69e6f8953463dd29707f77225cd8a543ad"),
+                   ('tests/ubc/200-6-0-stripe.jb2', "55ba1b94e73d96defbb7abbe35ccf13b4e1ac89f", "e8a1b55780dde4102f37ca5fafeff29bbd30e867"),
+                   ('tests/ubc/200-6-45.jb2', "71d167f8af4e6c2a3202c26873aedf490e8da8f2", "9093ba8bfc65b87dddc310d437b8ca626ee2283c"),
+                   ('tests/ubc/200-6-45-stripe.jb2', "abcf8f71f9ce0cb65c43942ecf0cfda7ece5d7ff", "397a48e4f3a3261928b2175699104117e36349e6"),
+                   ('tests/ubc/200-8-0.jb2', "e7004846acb5529d5335c16315d11c188edea89d", "8cfa43f514911d35d9666e52ae51bbd93a9bddfc"),
+                   ('tests/ubc/200-8-0-stripe.jb2', "0d96be49231e7e5a52c41bfa7303768465a9fa81", "021fbcfa12122999cded6beea3b7aa3c7018acbd"),
+                   ('tests/ubc/200-8-45.jb2', "e28403c3bf1014a5b5e9c3c3e5e99cae47aa09ab", "669986963011b174d5352d38e6c77f459ff3bebd"),
+                   ('tests/ubc/200-8-45-stripe.jb2', "c2e19b3e51d06c102a06643f3ea15f77d6df3788", "ceb0ef29cb68fe53d9abceb45ab182c1e6a39ff7"),
+                   ('tests/ubc/200-lossless.jb2', "b9989aea1a3edd65e38e7fbeaa89a29d7a2aa342", "94d9324437bc27955e610ef4fbbd684ad3107fea"),
+                   ('tests/ubc/600-10-0.jb2', "46c9af206382243d838f86ea45c63e7ca2900b68", "0ad323815315270f02f8220ed3b69133a1639f74"),
+                   ('tests/ubc/600-10-45.jb2', "1f143e95bf57d8d2696525797e198efd785f7221", "16002bb4e4cefbb58da5dde531b1064b9e6ad1a7"),
+                   ('tests/ubc/600-20-0.jb2', "8c874b1fb89e714ef8c64f33d292db2aea4fd05f", "a537aac28d9e0ea27d43a38024962f86aa1e403b"),
+                   ('tests/ubc/600-20-45.jb2', "a9c94915dd140916bc14db7b4bc9fc5d7e73b5a9", "5af6ec6f2e8ae68cfb6df3f82bf47ee2f6c4f0b5"),
+                   ('tests/ubc/600-30-0.jb2', "f0b9eea13b5c7a18742238778f1a3b7e1a4d3361", "6feaffc771381922a578bc54c4b50d18e7933ea1"),
+                   ('tests/ubc/600-30-45.jb2', "65bb4202b575bba6063ef3597a5eefa356b5e660", "768788c5176d5ffb5d8d0855d8ab34312611f67d"),
+                   ('tests/ubc/600-6-0.jb2', "c54abd4bdbb26b1f1209dc03ab10c05cdfd7a63a", "baba4bc5359c0fafc54efcba14da2bd5943222be"),
+                   ('tests/ubc/600-6-45.jb2', "94f4f6ea60eda33e0cd8bb94a5a0f90dc05f96a7", "bc3afe7c37533ca43f3244e6877ce38b3e978e9f"),
+                   ('tests/ubc/600-lossless.jb2', "60ecd5ddfb0984e3d2691bc385f425a50c753019", "f632d82b3c3d500098ad560e5ab91c69bd20827f")
                  )
 
   def __init__(self, file, file_hash, decode_hash):

----------------------------------------------------------------------
commit 49a6ff2b166a4cda4d7b8c9d8192bb6f419c7ca3
Author: Sebastian Rasmussen <[email protected]>
Date:   Fri Jun 14 03:27:31 2019 +0200

    Bug 701197: jbig2dec: Fix incorrectly computed halftone skip mask.
    
    Halftone regions using a skip mask and negative horizontal grid origin
    offsets caused issues due to multiplying signed and unsigned integers.
    The mixed types expression was computed unsigned unsigned arithmetic
    before being converted back to a signed integer. This meant that an
    expected negative value became positive.
    
    Several of the test files mentioned in the README rendered incorrectly,
    e.g. 200-6-45.jb2. With this fix all files render correctly again.

diff --git a/jbig2dec/jbig2_halftone.c b/jbig2dec/jbig2_halftone.c
index 8a18fc7..69bd21e 100644
--- a/jbig2dec/jbig2_halftone.c
+++ b/jbig2dec/jbig2_halftone.c
@@ -458,7 +458,7 @@ jbig2_decode_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
     Jbig2Image *HSKIP = NULL;
     Jbig2PatternDict *HPATS;
     uint32_t i;
-    uint32_t mg, ng;
+    int32_t mg, ng;
     int32_t x, y;
     uint16_t gray_val;
     int code = 0;
@@ -481,8 +481,8 @@ jbig2_decode_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
 
         for (mg = 0; mg < params->HGH; ++mg) {
             for (ng = 0; ng < params->HGW; ++ng) {
-                x = (params->HGX + mg * (int32_t) params->HRY + ng * (int32_t) params->HRX) >> 8;
-                y = (params->HGY + mg * (int32_t) params->HRX - ng * (int32_t) params->HRY) >> 8;
+                x = (params->HGX + mg * params->HRY + ng * params->HRX) >> 8;
+                y = (params->HGY + mg * params->HRX - ng * params->HRY) >> 8;
 
                 if (x + HPATS->HPW <= 0 || x >= (int32_t) image->width || y + HPATS->HPH <= 0 || y >= (int32_t) image->height) {
                     jbig2_image_set_pixel(HSKIP, ng, mg, 1);

----------------------------------------------------------------------
commit 8719833a6a4242880ad8b81cb8fe19e03667af52
Author: Sebastian Rasmussen <[email protected]>
Date:   Fri Jun 14 15:09:12 2019 +0200

    jbig2dec: Avoid duplicate declarations of Huffman tables in test code.
    
    This is done by moving the tables into a separate compilation module and
    declaring the tables extern in the header file that is used elsewhere.

diff --git a/base/jbig2.mak b/base/jbig2.mak
index 6182fdd..c3d275b 100644
--- a/base/jbig2.mak
+++ b/base/jbig2.mak
@@ -48,6 +48,7 @@ libjbig2_OBJS1=\
 	$(JBIG2OBJ)jbig2_generic.$(OBJ) \
 	$(JBIG2OBJ)jbig2_refinement.$(OBJ) \
 	$(JBIG2OBJ)jbig2_huffman.$(OBJ) \
+	$(JBIG2OBJ)jbig2_hufftab.$(OBJ) \
 	$(JBIG2OBJ)jbig2_image.$(OBJ) \
 	$(JBIG2OBJ)jbig2_mmr.$(OBJ)
 
@@ -140,6 +141,9 @@ $(JBIG2OBJ)jbig2_refinement.$(OBJ) : $(JBIG2SRC)jbig2_refinement.c $(libjbig2_HD
 $(JBIG2OBJ)jbig2_huffman.$(OBJ) : $(JBIG2SRC)jbig2_huffman.c $(libjbig2_HDRS) $(JBIG2DEP) $(JBIG2_MAK) $(MAKEDIRS)
 	$(JBIG2_CC) $(JBIG2O_)jbig2_huffman.$(OBJ) $(C_) $(JBIG2SRC)jbig2_huffman.c
 
+$(JBIG2OBJ)jbig2_hufftab.$(OBJ) : $(JBIG2SRC)jbig2_hufftab.c $(libjbig2_HDRS) $(JBIG2DEP) $(JBIG2_MAK) $(MAKEDIRS)
+	$(JBIG2_CC) $(JBIG2O_)jbig2_hufftab.$(OBJ) $(C_) $(JBIG2SRC)jbig2_hufftab.c
+
 $(JBIG2OBJ)jbig2_image.$(OBJ) : $(JBIG2SRC)jbig2_image.c $(libjbig2_HDRS) $(JBIG2DEP) $(JBIG2_MAK) $(MAKEDIRS)
 	$(JBIG2_CC) $(JBIG2O_)jbig2_image.$(OBJ) $(C_) $(JBIG2SRC)jbig2_image.c
 
diff --git a/jbig2dec/Makefile.am b/jbig2dec/Makefile.am
index e207b7a..da46c35 100644
--- a/jbig2dec/Makefile.am
+++ b/jbig2dec/Makefile.am
@@ -12,7 +12,7 @@ AM_CFLAGS = $(XCFLAGS)
 
 libjbig2dec_la_LDFLAGS = -version-info @JBIG2DEC_LT_CURRENT@:@JBIG2DEC_LT_REVISION@:@JBIG2DEC_LT_AGE@ -no-undefined
 libjbig2dec_la_SOURCES = jbig2.c \
-	jbig2_arith.c jbig2_arith_int.c jbig2_arith_iaid.c jbig2_huffman.c \
+	jbig2_arith.c jbig2_arith_int.c jbig2_arith_iaid.c jbig2_huffman.c jbig2_hufftab.c \
 	jbig2_segment.c jbig2_page.c \
 	jbig2_symbol_dict.c jbig2_text.c \
 	jbig2_generic.c jbig2_refinement.c jbig2_mmr.c \
diff --git a/jbig2dec/Makefile.unix b/jbig2dec/Makefile.unix
index 24bb12d..cd386b5 100644
--- a/jbig2dec/Makefile.unix
+++ b/jbig2dec/Makefile.unix
@@ -8,9 +8,9 @@ CFLAGS := -Wall -Wextra -Wno-unused-parameter -g -O2
 
 LIB_SRCS := \
 	jbig2_arith.c jbig2_arith_int.c jbig2_arith_iaid.c \
-	jbig2_huffman.c jbig2_segment.c jbig2_page.c jbig2_symbol_dict.c \
-	jbig2_text.c jbig2_halftone.c jbig2_generic.c jbig2_refinement.c \
-	jbig2_mmr.c jbig2_image.c jbig2.c
+	jbig2_huffman.c jbig2_hufftab.c jbig2_segment.c jbig2_page.c \
+	jbig2_symbol_dict.c jbig2_text.c jbig2_halftone.c jbig2_generic.c \
+	jbig2_refinement.c jbig2_mmr.c jbig2_image.c jbig2.c
 LIB_OBJS := $(LIB_SRCS:%.c=%.o)
 LIB_HDRS := \
 	jbig2.h jbig2_arith.h jbig2_arith_iaid.h jbig2_arith_int.h \
diff --git a/jbig2dec/jbig2_hufftab.h b/jbig2dec/jbig2_hufftab.c
similarity index 86%
copy from jbig2dec/jbig2_hufftab.h
copy to jbig2dec/jbig2_hufftab.c
index 29a39db..80b9bf2 100644
--- a/jbig2dec/jbig2_hufftab.h
+++ b/jbig2dec/jbig2_hufftab.c
@@ -20,15 +20,22 @@
 /* predefined Huffman table definitions
     -- See Annex B of the JBIG2 specification */
 
-#ifndef _JBIG2_HUFFTAB_H
-#define _JBIG2_HUFFTAB_H
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "os_types.h"
 
-/* types are in jbig2_huffman.h, you must include that first */
+#include <stdlib.h>
+
+#include "jbig2.h"
+#include "jbig2_priv.h"
+#include "jbig2_huffman.h"
+#include "jbig2_hufftab.h"
 
 #define JBIG2_COUNTOF(x) (sizeof((x)) / sizeof((x)[0]))
 
 /* Table B.1 */
-const Jbig2HuffmanLine jbig2_huffman_lines_A[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_A[] = {
     {1, 4, 0},
     {2, 8, 16},
     {3, 16, 272},
@@ -39,7 +46,7 @@ const Jbig2HuffmanLine jbig2_huffman_lines_A[] = {
 const Jbig2HuffmanParams jbig2_huffman_params_A = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_A), jbig2_huffman_lines_A };
 
 /* Table B.2 */
-const Jbig2HuffmanLine jbig2_huffman_lines_B[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_B[] = {
     {1, 0, 0},
     {2, 0, 1},
     {3, 0, 2},
@@ -53,7 +60,7 @@ const Jbig2HuffmanLine jbig2_huffman_lines_B[] = {
 const Jbig2HuffmanParams jbig2_huffman_params_B = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_B), jbig2_huffman_lines_B };
 
 /* Table B.3 */
-const Jbig2HuffmanLine jbig2_huffman_lines_C[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_C[] = {
     {8, 8, -256},
     {1, 0, 0},
     {2, 0, 1},
@@ -68,7 +75,7 @@ const Jbig2HuffmanLine jbig2_huffman_lines_C[] = {
 const Jbig2HuffmanParams jbig2_huffman_params_C = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_C), jbig2_huffman_lines_C };
 
 /* Table B.4 */
-const Jbig2HuffmanLine jbig2_huffman_lines_D[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_D[] = {
     {1, 0, 1},
     {2, 0, 2},
     {3, 0, 3},
@@ -81,7 +88,7 @@ const Jbig2HuffmanLine jbig2_huffman_lines_D[] = {
 const Jbig2HuffmanParams jbig2_huffman_params_D = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_D), jbig2_huffman_lines_D };
 
 /* Table B.5 */
-const Jbig2HuffmanLine jbig2_huffman_lines_E[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_E[] = {
     {7, 8, -255},
     {1, 0, 1},
     {2, 0, 2},
@@ -95,7 +102,7 @@ const Jbig2HuffmanLine jbig2_huffman_lines_E[] = {
 const Jbig2HuffmanParams jbig2_huffman_params_E = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_E), jbig2_huffman_lines_E };
 
 /* Table B.6 */
-const Jbig2HuffmanLine jbig2_huffman_lines_F[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_F[] = {
     {5, 10, -2048},
     {4, 9, -1024},
     {4, 8, -512},
@@ -115,7 +122,7 @@ const Jbig2HuffmanLine jbig2_huffman_lines_F[] = {
 const Jbig2HuffmanParams jbig2_huffman_params_F = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_F), jbig2_huffman_lines_F };
 
 /* Table B.7 */
-const Jbig2HuffmanLine jbig2_huffman_lines_G[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_G[] = {
     {4, 9, -1024},
     {3, 8, -512},
     {4, 7, -256},
@@ -136,7 +143,7 @@ const Jbig2HuffmanLine jbig2_huffman_lines_G[] = {
 const Jbig2HuffmanParams jbig2_huffman_params_G = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_G), jbig2_huffman_lines_G };
 
 /* Table B.8 */
-const Jbig2HuffmanLine jbig2_huffman_lines_H[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_H[] = {
     {8, 3, -15},
     {9, 1, -7},
     {8, 1, -5},
@@ -163,7 +170,7 @@ const Jbig2HuffmanLine jbig2_huffman_lines_H[] = {
 const Jbig2HuffmanParams jbig2_huffman_params_H = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_H), jbig2_huffman_lines_H };
 
 /* Table B.9 */
-const Jbig2HuffmanLine jbig2_huffman_lines_I[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_I[] = {
     {8, 4, -31},
     {9, 2, -15},
     {8, 2, -11},
@@ -191,7 +198,7 @@ const Jbig2HuffmanLine jbig2_huffman_lines_I[] = {
 const Jbig2HuffmanParams jbig2_huffman_params_I = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_I), jbig2_huffman_lines_I };
 
 /* Table B.10 */
-const Jbig2HuffmanLine jbig2_huffman_lines_J[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_J[] = {
     {7, 4, -21},
     {8, 0, -5},
     {7, 0, -4},
@@ -218,7 +225,7 @@ const Jbig2HuffmanLine jbig2_huffman_lines_J[] = {
 const Jbig2HuffmanParams jbig2_huffman_params_J = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_J), jbig2_huffman_lines_J };
 
 /* Table B.11 */
-const Jbig2HuffmanLine jbig2_huffman_lines_K[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_K[] = {
     {1, 0, 1},
     {2, 1, 2},
     {4, 0, 4},
@@ -238,7 +245,7 @@ const Jbig2HuffmanLine jbig2_huffman_lines_K[] = {
 const Jbig2HuffmanParams jbig2_huffman_params_K = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_K), jbig2_huffman_lines_K };
 
 /* Table B.12 */
-const Jbig2HuffmanLine jbig2_huffman_lines_L[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_L[] = {
     {1, 0, 1},
     {2, 0, 2},
     {3, 1, 3},
@@ -259,7 +266,7 @@ const Jbig2HuffmanLine jbig2_huffman_lines_L[] = {
 const Jbig2HuffmanParams jbig2_huffman_params_L = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_L), jbig2_huffman_lines_L };
 
 /* Table B.13 */
-const Jbig2HuffmanLine jbig2_huffman_lines_M[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_M[] = {
     {1, 0, 1},
     {3, 0, 2},
     {4, 0, 3},
@@ -279,7 +286,7 @@ const Jbig2HuffmanLine jbig2_huffman_lines_M[] = {
 const Jbig2HuffmanParams jbig2_huffman_params_M = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_M), jbig2_huffman_lines_M };
 
 /* Table B.14 */
-const Jbig2HuffmanLine jbig2_huffman_lines_N[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_N[] = {
     {3, 0, -2},
     {3, 0, -1},
     {1, 0, 0},
@@ -292,7 +299,7 @@ const Jbig2HuffmanLine jbig2_huffman_lines_N[] = {
 const Jbig2HuffmanParams jbig2_huffman_params_N = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_N), jbig2_huffman_lines_N };
 
 /* Table B.15 */
-const Jbig2HuffmanLine jbig2_huffman_lines_O[] = {
+static const Jbig2HuffmanLine jbig2_huffman_lines_O[] = {
     {7, 4, -24},
     {6, 2, -8},
     {5, 1, -4},
@@ -309,7 +316,3 @@ const Jbig2HuffmanLine jbig2_huffman_lines_O[] = {
 };
 
 const Jbig2HuffmanParams jbig2_huffman_params_O = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_O), jbig2_huffman_lines_O };
-
-#undef JBIG2_COUNTOF
-
-#endif /* _JBIG2_HUFFTAB_H */
diff --git a/jbig2dec/jbig2_hufftab.h b/jbig2dec/jbig2_hufftab.h
index 29a39db..68d1b61 100644
--- a/jbig2dec/jbig2_hufftab.h
+++ b/jbig2dec/jbig2_hufftab.h
@@ -18,298 +18,25 @@
 */
 
 /* predefined Huffman table definitions
-    -- See Annex B of the JBIG2 specification */
+    -- See Annex B.5 of the JBIG2 specification */
 
 #ifndef _JBIG2_HUFFTAB_H
 #define _JBIG2_HUFFTAB_H
 
-/* types are in jbig2_huffman.h, you must include that first */
-
-#define JBIG2_COUNTOF(x) (sizeof((x)) / sizeof((x)[0]))
-
-/* Table B.1 */
-const Jbig2HuffmanLine jbig2_huffman_lines_A[] = {
-    {1, 4, 0},
-    {2, 8, 16},
-    {3, 16, 272},
-    {0, 32, -1},                /* low */
-    {3, 32, 65808}              /* high */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_A = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_A), jbig2_huffman_lines_A };
-
-/* Table B.2 */
-const Jbig2HuffmanLine jbig2_huffman_lines_B[] = {
-    {1, 0, 0},
-    {2, 0, 1},
-    {3, 0, 2},
-    {4, 3, 3},
-    {5, 6, 11},
-    {0, 32, -1},                /* low */
-    {6, 32, 75},                /* high */
-    {6, 0, 0}                   /* OOB */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_B = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_B), jbig2_huffman_lines_B };
-
-/* Table B.3 */
-const Jbig2HuffmanLine jbig2_huffman_lines_C[] = {
-    {8, 8, -256},
-    {1, 0, 0},
-    {2, 0, 1},
-    {3, 0, 2},
-    {4, 3, 3},
-    {5, 6, 11},
-    {8, 32, -257},              /* low */
-    {7, 32, 75},                /* high */
-    {6, 0, 0}                   /* OOB */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_C = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_C), jbig2_huffman_lines_C };
-
-/* Table B.4 */
-const Jbig2HuffmanLine jbig2_huffman_lines_D[] = {
-    {1, 0, 1},
-    {2, 0, 2},
-    {3, 0, 3},
-    {4, 3, 4},
-    {5, 6, 12},
-    {0, 32, -1},                /* low */
-    {5, 32, 76},                /* high */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_D = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_D), jbig2_huffman_lines_D };
-
-/* Table B.5 */
-const Jbig2HuffmanLine jbig2_huffman_lines_E[] = {
-    {7, 8, -255},
-    {1, 0, 1},
-    {2, 0, 2},
-    {3, 0, 3},
-    {4, 3, 4},
-    {5, 6, 12},
-    {7, 32, -256},              /* low */
-    {6, 32, 76}                 /* high */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_E = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_E), jbig2_huffman_lines_E };
-
-/* Table B.6 */
-const Jbig2HuffmanLine jbig2_huffman_lines_F[] = {
-    {5, 10, -2048},
-    {4, 9, -1024},
-    {4, 8, -512},
-    {4, 7, -256},
-    {5, 6, -128},
-    {5, 5, -64},
-    {4, 5, -32},
-    {2, 7, 0},
-    {3, 7, 128},
-    {3, 8, 256},
-    {4, 9, 512},
-    {4, 10, 1024},
-    {6, 32, -2049},             /* low */
-    {6, 32, 2048}               /* high */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_F = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_F), jbig2_huffman_lines_F };
-
-/* Table B.7 */
-const Jbig2HuffmanLine jbig2_huffman_lines_G[] = {
-    {4, 9, -1024},
-    {3, 8, -512},
-    {4, 7, -256},
-    {5, 6, -128},
-    {5, 5, -64},
-    {4, 5, -32},
-    {4, 5, 0},
-    {5, 5, 32},
-    {5, 6, 64},
-    {4, 7, 128},
-    {3, 8, 256},
-    {3, 9, 512},
-    {3, 10, 1024},
-    {5, 32, -1025},             /* low */
-    {5, 32, 2048}               /* high */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_G = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_G), jbig2_huffman_lines_G };
-
-/* Table B.8 */
-const Jbig2HuffmanLine jbig2_huffman_lines_H[] = {
-    {8, 3, -15},
-    {9, 1, -7},
-    {8, 1, -5},
-    {9, 0, -3},
-    {7, 0, -2},
-    {4, 0, -1},
-    {2, 1, 0},
-    {5, 0, 2},
-    {6, 0, 3},
-    {3, 4, 4},
-    {6, 1, 20},
-    {4, 4, 22},
-    {4, 5, 38},
-    {5, 6, 70},
-    {5, 7, 134},
-    {6, 7, 262},
-    {7, 8, 390},
-    {6, 10, 646},
-    {9, 32, -16},               /* low */
-    {9, 32, 1670},              /* high */
-    {2, 0, 0}                   /* OOB */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_H = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_H), jbig2_huffman_lines_H };
-
-/* Table B.9 */
-const Jbig2HuffmanLine jbig2_huffman_lines_I[] = {
-    {8, 4, -31},
-    {9, 2, -15},
-    {8, 2, -11},
-    {9, 1, -7},
-    {7, 1, -5},
-    {4, 1, -3},
-    {3, 1, -1},
-    {3, 1, 1},
-    {5, 1, 3},
-    {6, 1, 5},
-    {3, 5, 7},
-    {6, 2, 39},
-    {4, 5, 43},
-    {4, 6, 75},
-    {5, 7, 139},
-    {5, 8, 267},
-    {6, 8, 523},
-    {7, 9, 779},
-    {6, 11, 1291},
-    {9, 32, -32},               /* low */
-    {9, 32, 3339},              /* high */
-    {2, 0, 0}                   /* OOB */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_I = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_I), jbig2_huffman_lines_I };
-
-/* Table B.10 */
-const Jbig2HuffmanLine jbig2_huffman_lines_J[] = {
-    {7, 4, -21},
-    {8, 0, -5},
-    {7, 0, -4},
-    {5, 0, -3},
-    {2, 2, -2},
-    {5, 0, 2},
-    {6, 0, 3},
-    {7, 0, 4},
-    {8, 0, 5},
-    {2, 6, 6},
-    {5, 5, 70},
-    {6, 5, 102},
-    {6, 6, 134},
-    {6, 7, 198},
-    {6, 8, 326},
-    {6, 9, 582},
-    {6, 10, 1094},
-    {7, 11, 2118},
-    {8, 32, -22},               /* low */
-    {8, 32, 4166},              /* high */
-    {2, 0, 0}                   /* OOB */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_J = { TRUE, JBIG2_COUNTOF(jbig2_huffman_lines_J), jbig2_huffman_lines_J };
-
-/* Table B.11 */
-const Jbig2HuffmanLine jbig2_huffman_lines_K[] = {
-    {1, 0, 1},
-    {2, 1, 2},
-    {4, 0, 4},
-    {4, 1, 5},
-    {5, 1, 7},
-    {5, 2, 9},
-    {6, 2, 13},
-    {7, 2, 17},
-    {7, 3, 21},
-    {7, 4, 29},
-    {7, 5, 45},
-    {7, 6, 77},
-    {0, 32, -1},                /* low */
-    {7, 32, 141}                /* high */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_K = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_K), jbig2_huffman_lines_K };
-
-/* Table B.12 */
-const Jbig2HuffmanLine jbig2_huffman_lines_L[] = {
-    {1, 0, 1},
-    {2, 0, 2},
-    {3, 1, 3},
-    {5, 0, 5},
-    {5, 1, 6},
-    {6, 1, 8},
-    {7, 0, 10},
-    {7, 1, 11},
-    {7, 2, 13},
-    {7, 3, 17},
-    {7, 4, 25},
-    {8, 5, 41},
-    {8, 32, 73},
-    {0, 32, -1},                /* low */
-    {0, 32, 0}                  /* high */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_L = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_L), jbig2_huffman_lines_L };
-
-/* Table B.13 */
-const Jbig2HuffmanLine jbig2_huffman_lines_M[] = {
-    {1, 0, 1},
-    {3, 0, 2},
-    {4, 0, 3},
-    {5, 0, 4},
-    {4, 1, 5},
-    {3, 3, 7},
-    {6, 1, 15},
-    {6, 2, 17},
-    {6, 3, 21},
-    {6, 4, 29},
-    {6, 5, 45},
-    {7, 6, 77},
-    {0, 32, -1},                /* low */
-    {7, 32, 141}                /* high */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_M = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_M), jbig2_huffman_lines_M };
-
-/* Table B.14 */
-const Jbig2HuffmanLine jbig2_huffman_lines_N[] = {
-    {3, 0, -2},
-    {3, 0, -1},
-    {1, 0, 0},
-    {3, 0, 1},
-    {3, 0, 2},
-    {0, 32, -1},                /* low */
-    {0, 32, 3},                 /* high */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_N = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_N), jbig2_huffman_lines_N };
-
-/* Table B.15 */
-const Jbig2HuffmanLine jbig2_huffman_lines_O[] = {
-    {7, 4, -24},
-    {6, 2, -8},
-    {5, 1, -4},
-    {4, 0, -2},
-    {3, 0, -1},
-    {1, 0, 0},
-    {3, 0, 1},
-    {4, 0, 2},
-    {5, 1, 3},
-    {6, 2, 5},
-    {7, 4, 9},
-    {7, 32, -25},               /* low */
-    {7, 32, 25}                 /* high */
-};
-
-const Jbig2HuffmanParams jbig2_huffman_params_O = { FALSE, JBIG2_COUNTOF(jbig2_huffman_lines_O), jbig2_huffman_lines_O };
-
-#undef JBIG2_COUNTOF
+extern const Jbig2HuffmanParams jbig2_huffman_params_A;
+extern const Jbig2HuffmanParams jbig2_huffman_params_B;
+extern const Jbig2HuffmanParams jbig2_huffman_params_C;
+extern const Jbig2HuffmanParams jbig2_huffman_params_D;
+extern const Jbig2HuffmanParams jbig2_huffman_params_E;
+extern const Jbig2HuffmanParams jbig2_huffman_params_F;
+extern const Jbig2HuffmanParams jbig2_huffman_params_G;
+extern const Jbig2HuffmanParams jbig2_huffman_params_H;
+extern const Jbig2HuffmanParams jbig2_huffman_params_I;
+extern const Jbig2HuffmanParams jbig2_huffman_params_J;
+extern const Jbig2HuffmanParams jbig2_huffman_params_K;
+extern const Jbig2HuffmanParams jbig2_huffman_params_L;
+extern const Jbig2HuffmanParams jbig2_huffman_params_M;
+extern const Jbig2HuffmanParams jbig2_huffman_params_N;
+extern const Jbig2HuffmanParams jbig2_huffman_params_O;
 
 #endif /* _JBIG2_HUFFTAB_H */
diff --git a/jbig2dec/msvc.mak b/jbig2dec/msvc.mak
index 94bc548..5c2d6bd 100644
--- a/jbig2dec/msvc.mak
+++ b/jbig2dec/msvc.mak
@@ -42,10 +42,11 @@ FE=-Fe
 #
 OBJS=getopt$(OBJ) getopt1$(OBJ) jbig2$(OBJ) jbig2_arith$(OBJ) \
  jbig2_arith_iaid$(OBJ) jbig2_arith_int$(OBJ) jbig2_huffman$(OBJ) \
- jbig2_generic$(OBJ) jbig2_refinement$(OBJ) jbig2_halftone$(OBJ)\
- jbig2_image$(OBJ) jbig2_image_pbm$(OBJ) $(JBIG2_IMAGE_PNG_OBJ) \
- jbig2_segment$(OBJ) jbig2_symbol_dict$(OBJ) jbig2_text$(OBJ) \
- jbig2_mmr$(OBJ) jbig2_page$(OBJ) jbig2dec$(OBJ) sha1$(OBJ)
+ jbig2_hufftab$(OBJ) jbig2_generic$(OBJ) jbig2_refinement$(OBJ) \
+ jbig2_halftone$(OBJ) jbig2_image$(OBJ) jbig2_image_pbm$(OBJ) \
+ $(JBIG2_IMAGE_PNG_OBJ) jbig2_segment$(OBJ) jbig2_symbol_dict$(OBJ) \
+ jbig2_text$(OBJ) jbig2_mmr$(OBJ) jbig2_page$(OBJ) jbig2dec$(OBJ) \
+ sha1$(OBJ)
 
 HDRS=getopt.h jbig2.h jbig2_arith.h jbig2_arith_iaid.h jbig2_arith_int.h \
  jbig2_generic.h jbig2_huffman.h jbig2_hufftab.h jbig2_image.h \
@@ -83,6 +84,9 @@ jbig2_refinement$(OBJ): jbig2_refinement.c $(HDRS)
 jbig2_huffman$(OBJ): jbig2_huffman.c $(HDRS)
 	$(CC) $(CFLAGS) -c jbig2_huffman.c
 
+jbig2_hufftab$(OBJ): jbig2_hufftab.c $(HDRS)
+	$(CC) $(CFLAGS) -c jbig2_hufftab.c
+
 jbig2_image$(OBJ): jbig2_image.c $(HDRS)
 	$(CC) $(CFLAGS) -c jbig2_image.c
 
diff --git a/windows/ghostscript.vcproj b/windows/ghostscript.vcproj
index efc15b9..71ba467 100644
--- a/windows/ghostscript.vcproj
+++ b/windows/ghostscript.vcproj
@@ -6940,6 +6940,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\jbig2dec\jbig2_hufftab.c"
+				>
+			</File>
+			<File
 				RelativePath="..\jbig2dec\jbig2_hufftab.h"
 				>
 			</File>
diff --git a/windows/ghostscript_rt.vcxproj b/windows/ghostscript_rt.vcxproj
index fca736b..41a3443 100644
--- a/windows/ghostscript_rt.vcxproj
+++ b/windows/ghostscript_rt.vcxproj
@@ -1028,6 +1028,7 @@
     <ClCompile Include="..\jbig2dec\jbig2_arith_int.c" />
     <ClCompile Include="..\jbig2dec\jbig2_generic.c" />
     <ClCompile Include="..\jbig2dec\jbig2_huffman.c" />
+    <ClCompile Include="..\jbig2dec\jbig2_hufftab.c" />
     <ClCompile Include="..\jbig2dec\jbig2_image.c" />
     <ClCompile Include="..\jbig2dec\jbig2_image_pbm.c" />
     <ClCompile Include="..\jbig2dec\jbig2_image_png.c" />

----------------------------------------------------------------------
commit d75727a7fd5efb2245c7b0d0b33ee8611446c150
Author: Sebastian Rasmussen <[email protected]>
Date:   Fri Jun 14 14:51:01 2019 +0200

    jbig2dec: Fix leak of huffman decoder state in test code.

diff --git a/jbig2dec/jbig2_huffman.c b/jbig2dec/jbig2_huffman.c
index 908ab59..235233e 100644
--- a/jbig2dec/jbig2_huffman.c
+++ b/jbig2dec/jbig2_huffman.c
@@ -747,7 +747,7 @@ static int test1()
 {
     Jbig2Ctx *ctx;
     Jbig2HuffmanTable *tables[5];
-    Jbig2HuffmanState *hs;
+    Jbig2HuffmanState *hs = NULL;
     Jbig2WordStream ws;
     bool oob;
     int32_t code;
@@ -799,6 +799,7 @@ static int test1()
     success = 1;
 
 cleanup:
+    jbig2_huffman_free(ctx, hs);
     for (i = 0; i < 5; i++)
         jbig2_release_huffman_table(ctx, tables[i]);
     jbig2_ctx_free(ctx);

----------------------------------------------------------------------
commit b3f859987f152e13ab141143234f686749f2caf7
Author: Sebastian Rasmussen <[email protected]>
Date:   Fri Jun 14 14:50:09 2019 +0200

    jbig2dec: Declare internal data array static.

diff --git a/jbig2dec/jbig2_arith.c b/jbig2dec/jbig2_arith.c
index 6416fad..69d2d93 100644
--- a/jbig2dec/jbig2_arith.c
+++ b/jbig2dec/jbig2_arith.c
@@ -195,7 +195,7 @@ typedef struct {
     byte lps_xor;               /* lps_xor = index ^ NLPS ^ (SWITCH << 7) */
 } Jbig2ArithQe;
 
-const Jbig2ArithQe jbig2_arith_Qe[MAX_QE_ARRAY_SIZE] = {
+static const Jbig2ArithQe jbig2_arith_Qe[MAX_QE_ARRAY_SIZE] = {
     {0x5601, 1 ^ 0, 1 ^ 0 ^ 0x80},
     {0x3401, 2 ^ 1, 6 ^ 1},
     {0x1801, 3 ^ 2, 9 ^ 2},

----------------------------------------------------------------------
commit 49fa7d21bc555a96e19318b56301185f12f68c55
Author: Sebastian Rasmussen <[email protected]>
Date:   Fri Jun 14 14:47:44 2019 +0200

    jbig2dec: Fix leak of log message in command line tool.

diff --git a/jbig2dec/jbig2dec.c b/jbig2dec/jbig2dec.c
index 5e3f5e5..47b88f9 100644
--- a/jbig2dec/jbig2dec.c
+++ b/jbig2dec/jbig2dec.c
@@ -589,6 +589,8 @@ main(int argc, char **argv)
 cleanup:
     flush_errors(&params);
     jbig2_ctx_free(ctx);
+    if (params.last_message)
+        free(params.last_message);
     if (params.output_filename)
         free(params.output_filename);
     if (params.hash)

----------------------------------------------------------------------
commit 314250a3126243a228249ebf1e6272c0beaec9d6
Author: Sebastian Rasmussen <[email protected]>
Date:   Fri Jun 21 15:02:02 2019 +0200

    jbig2dec: Verify file hashes of test files during testing.
    
    Previously jbig2dec would accept any file with the same name.

diff --git a/jbig2dec/test_jbig2dec.py b/jbig2dec/test_jbig2dec.py
index e6202ab..4ff13fd 100755
--- a/jbig2dec/test_jbig2dec.py
+++ b/jbig2dec/test_jbig2dec.py
@@ -4,6 +4,7 @@
 
 import os, re
 import sys, time
+import hashlib
 
 class SelfTest:
   'generic class for self tests'
@@ -160,11 +161,18 @@ class KnownFileHash(SelfTest):
 
   def runTest(self):
     '''jbig2dec should return proper document hashes for known files'''
+    # verify that the input file hash is correct
+    sha1 = hashlib.sha1()
+    with open(self.file, 'rb') as f:
+      sha1.update(f.read())
+    self.assertEqual(self.file_hash, sha1.hexdigest())
+
     # invoke jbig2dec on our file
     instance = os.popen('./jbig2dec -q -o /dev/null --hash ' + self.file)
     lines = instance.readlines()
     exit_code = instance.close()
     self.failIf(exit_code, 'jbig2dec should exit normally')
+
     # test here for correct hash
     hash_pattern = re.compile('[0-9a-f]{%d}' % len(decode_hash))
     for line in lines:

----------------------------------------------------------------------
commit a9b92d33e7ed5e06d0728d6a1be771d8b464c50e
Author: Sebastian Rasmussen <[email protected]>
Date:   Fri Jun 14 14:49:21 2019 +0200

    jbig2dec: Expect test files to reside inside jbig2dec directory.

diff --git a/jbig2dec/test_jbig2dec.py b/jbig2dec/test_jbig2dec.py
index ddede8f..e6202ab 100755
--- a/jbig2dec/test_jbig2dec.py
+++ b/jbig2dec/test_jbig2dec.py
@@ -66,85 +66,85 @@ class KnownFileHash(SelfTest):
 
   # these are known test files in the form
   # (filename, sha-1(file), sha-1(decoded document)
-  known_hashes = ( ('../ubc/042_1.jb2',
+  known_hashes = ( ('tests/ubc/042_1.jb2',
                         "673e1ee5c55ab241b171e476ba1168a42733ddaa",
                         known_042_DECODED),
-                   ('../ubc/042_2.jb2', 
+                   ('tests/ubc/042_2.jb2', 
                         "9aa2804e2d220952035c16fb3c907547884067c5",
                         known_042_DECODED),
-                   ('../ubc/042_3.jb2',
+                   ('tests/ubc/042_3.jb2',
                         "9663a5f35727f13e61a0a2f0a64207b1f79e7d67",
                         known_042_DECODED),
-                   ('../ubc/042_4.jb2',
+                   ('tests/ubc/042_4.jb2',
                         "014df658c8b99b600c2ceac3f1d53c7cc2b4917c",
                         known_042_DECODED),
-                   ('../ubc/042_5.jb2',
+                   ('tests/ubc/042_5.jb2',
                         "264720a6ccbbf72aa6a2cfb6343f43b8e6f2da4b",
                         known_042_DECODED),
-                   ('../ubc/042_6.jb2',
+                   ('tests/ubc/042_6.jb2',
                         "96f7dc9df4a1b305f9ac082dd136f85ef5b108fe",
                         known_042_DECODED),
-                   ('../ubc/042_7.jb2',
+                   ('tests/ubc/042_7.jb2',
                         "5526371ba9dc2b8743f20ae3e05a7e60b3dcba76",
                         known_042_DECODED),
-                   ('../ubc/042_8.jb2',
+                   ('tests/ubc/042_8.jb2',
                         "4bf0c87dfaf40d67c36f2a083579eeda26d54641",
                         known_042_DECODED),
-                   ('../ubc/042_9.jb2',
+                   ('tests/ubc/042_9.jb2',
                         "53e630e7fe2fe6e1d6164758e15fc93382e07f55",
                         known_042_DECODED),
-                   ('../ubc/042_10.jb2',
+                   ('tests/ubc/042_10.jb2',
                         "5ca1364367e25cb8f642e9dc677a94d5cfed0c8b",
                         known_042_DECODED),
-                   ('../ubc/042_11.jb2',
+                   ('tests/ubc/042_11.jb2',
                         "bc194caf022bc5345fc41259e05cea3c08245216",
                         known_042_DECODED),
-                   ('../ubc/042_12.jb2',
+                   ('tests/ubc/042_12.jb2',
                         "f354df8eb4849bc707f088739e322d1fe3a14ef3",
                         known_042_DECODED),
-                   ('../ubc/042_13.jb2',
+                   ('tests/ubc/042_13.jb2',
                         "7d428bd542f58591b254d9827f554b0552c950a7",
                         known_WHITE_PAGE_DECODED),
-                   ('../ubc/042_14.jb2',
+                   ('tests/ubc/042_14.jb2',
                         "c40fe3a02acb6359baf9b40fc9c49bc0800be589",
                         known_WHITE_PAGE_DECODED),
-                   ('../ubc/042_15.jb2',
+                   ('tests/ubc/042_15.jb2',
                         "a9e39fc1ecb178aec9f05039514d75ea3246246c",
                         known_042_DECODED),
-                   ('../ubc/042_16.jb2',
+                   ('tests/ubc/042_16.jb2',
                         "4008bbca43670f3c90eaee26516293ba95baaf3d",
                         known_042_DECODED),
-                   ('../ubc/042_17.jb2',
+                   ('tests/ubc/042_17.jb2',
                         "0ff95637b64c57d659a41c582da03e25321551fb",
                         known_042_DECODED),
-                   ('../ubc/042_18.jb2',
+                   ('tests/ubc/042_18.jb2',
                         "87381d044f00c4329200e44decbe91bebfa31595",
                         known_042_DECODED),
-                   ('../ubc/042_19.jb2',
+                   ('tests/ubc/042_19.jb2',
                         "387d95a140b456d4742622c788cf5b51cebbf438",
                         known_042_DECODED),
-                   ('../ubc/042_20.jb2',
+                   ('tests/ubc/042_20.jb2',
                         "85c19e9ec42b8ddd6b860a1bebea1c67610e7a59",
                         known_042_DECODED),
-                   ('../ubc/042_21.jb2',
+                   ('tests/ubc/042_21.jb2',
                         "ab535c7d7a61a7b9dc53d546e7419ca78ac7f447",
                         known_042_DECODED),
-                   ('../ubc/042_22.jb2',
+                   ('tests/ubc/042_22.jb2',
                         "a9e2b365be63716dbde74b0661c3c6efd2a6844d",
                         known_042_DECODED),
-                   ('../ubc/042_23.jb2',
+                   ('tests/ubc/042_23.jb2',
                         "8ffa40a05e93e10982b38a2233a8da58c1b5c343",
                         known_042_DECODED),
-                   ('../ubc/042_24.jb2',
+                   ('tests/ubc/042_24.jb2',
                         "2553fe65111c58f6412de51d8cdc71651e778ccf",
                         known_042_DECODED),
-                   ('../ubc/042_25.jb2',
+                   ('tests/ubc/042_25.jb2',
                         "52de4a3b86252d896a8d783ba71dd0699333dd69",
                         known_042_DECODED),
-                   ('../ubc/amb_1.jb2',
+                   ('tests/ubc/amb_1.jb2',
                         "d6d6d1c981dc37a09108c1e3ed990aa5b345fa6a",
                         known_amb_DECODED),
-                   ('../ubc/amb_2.jb2',
+                   ('tests/ubc/amb_2.jb2',
                         "9af6616a89eb03f8934de72626e301a716366c3c",
                         known_amb_DECODED)
                  )

----------------------------------------------------------------------
commit 8b3ffd237746e2bab2867ad460e8635a79cd5916
Author: Sebastian Rasmussen <[email protected]>
Date:   Fri Jun 14 15:18:45 2019 +0200

    jbig2dec: Indent test code by spaces like the rest of the code.

diff --git a/jbig2dec/test_jbig2dec.py b/jbig2dec/test_jbig2dec.py
index 33008e5..ddede8f 100755
--- a/jbig2dec/test_jbig2dec.py
+++ b/jbig2dec/test_jbig2dec.py
@@ -67,85 +67,85 @@ class KnownFileHash(SelfTest):
   # these are known test files in the form
   # (filename, sha-1(file), sha-1(decoded document)
   known_hashes = ( ('../ubc/042_1.jb2',
-			"673e1ee5c55ab241b171e476ba1168a42733ddaa",
-			known_042_DECODED),
+                        "673e1ee5c55ab241b171e476ba1168a42733ddaa",
+                        known_042_DECODED),
                    ('../ubc/042_2.jb2', 
                         "9aa2804e2d220952035c16fb3c907547884067c5",
                         known_042_DECODED),
                    ('../ubc/042_3.jb2',
-			"9663a5f35727f13e61a0a2f0a64207b1f79e7d67",
-			known_042_DECODED),
+                        "9663a5f35727f13e61a0a2f0a64207b1f79e7d67",
+                        known_042_DECODED),
                    ('../ubc/042_4.jb2',
-			"014df658c8b99b600c2ceac3f1d53c7cc2b4917c",
+                        "014df658c8b99b600c2ceac3f1d53c7cc2b4917c",
                         known_042_DECODED),
                    ('../ubc/042_5.jb2',
-			"264720a6ccbbf72aa6a2cfb6343f43b8e6f2da4b",
+                        "264720a6ccbbf72aa6a2cfb6343f43b8e6f2da4b",
                         known_042_DECODED),
                    ('../ubc/042_6.jb2',
-			"96f7dc9df4a1b305f9ac082dd136f85ef5b108fe",
-			known_042_DECODED),
+                        "96f7dc9df4a1b305f9ac082dd136f85ef5b108fe",
+                        known_042_DECODED),
                    ('../ubc/042_7.jb2',
-			"5526371ba9dc2b8743f20ae3e05a7e60b3dcba76",
-			known_042_DECODED),
+                        "5526371ba9dc2b8743f20ae3e05a7e60b3dcba76",
+                        known_042_DECODED),
                    ('../ubc/042_8.jb2',
-			"4bf0c87dfaf40d67c36f2a083579eeda26d54641",
-			known_042_DECODED),
+                        "4bf0c87dfaf40d67c36f2a083579eeda26d54641",
+                        known_042_DECODED),
                    ('../ubc/042_9.jb2',
-			"53e630e7fe2fe6e1d6164758e15fc93382e07f55",
-			known_042_DECODED),
+                        "53e630e7fe2fe6e1d6164758e15fc93382e07f55",
+                        known_042_DECODED),
                    ('../ubc/042_10.jb2',
-			"5ca1364367e25cb8f642e9dc677a94d5cfed0c8b",
-			known_042_DECODED),
+                        "5ca1364367e25cb8f642e9dc677a94d5cfed0c8b",
+                        known_042_DECODED),
                    ('../ubc/042_11.jb2',
-			"bc194caf022bc5345fc41259e05cea3c08245216",
-			known_042_DECODED),
+                        "bc194caf022bc5345fc41259e05cea3c08245216",
+                        known_042_DECODED),
                    ('../ubc/042_12.jb2',
-			"f354df8eb4849bc707f088739e322d1fe3a14ef3",
-			known_042_DECODED),
+                        "f354df8eb4849bc707f088739e322d1fe3a14ef3",
+                        known_042_DECODED),
                    ('../ubc/042_13.jb2',
-			"7d428bd542f58591b254d9827f554b0552c950a7",
-			known_WHITE_PAGE_DECODED),
+                        "7d428bd542f58591b254d9827f554b0552c950a7",
+                        known_WHITE_PAGE_DECODED),
                    ('../ubc/042_14.jb2',
-			"c40fe3a02acb6359baf9b40fc9c49bc0800be589",
-			known_WHITE_PAGE_DECODED),
+                        "c40fe3a02acb6359baf9b40fc9c49bc0800be589",
+                        known_WHITE_PAGE_DECODED),
                    ('../ubc/042_15.jb2',
-			"a9e39fc1ecb178aec9f05039514d75ea3246246c",
-			known_042_DECODED),
+                        "a9e39fc1ecb178aec9f05039514d75ea3246246c",
+                        known_042_DECODED),
                    ('../ubc/042_16.jb2',
-			"4008bbca43670f3c90eaee26516293ba95baaf3d",
-			known_042_DECODED),
+                        "4008bbca43670f3c90eaee26516293ba95baaf3d",
+                        known_042_DECODED),
                    ('../ubc/042_17.jb2',
-			"0ff95637b64c57d659a41c582da03e25321551fb",
-			known_042_DECODED),
+                        "0ff95637b64c57d659a41c582da03e25321551fb",
+                        known_042_DECODED),
                    ('../ubc/042_18.jb2',
-			"87381d044f00c4329200e44decbe91bebfa31595",
-			known_042_DECODED),
+                        "87381d044f00c4329200e44decbe91bebfa31595",
+                        known_042_DECODED),
                    ('../ubc/042_19.jb2',
-			"387d95a140b456d4742622c788cf5b51cebbf438",
-			known_042_DECODED),
+                        "387d95a140b456d4742622c788cf5b51cebbf438",
+                        known_042_DECODED),
                    ('../ubc/042_20.jb2',
-			"85c19e9ec42b8ddd6b860a1bebea1c67610e7a59",
-			known_042_DECODED),
+                        "85c19e9ec42b8ddd6b860a1bebea1c67610e7a59",
+                        known_042_DECODED),
                    ('../ubc/042_21.jb2',
-			"ab535c7d7a61a7b9dc53d546e7419ca78ac7f447",
-			known_042_DECODED),
+                        "ab535c7d7a61a7b9dc53d546e7419ca78ac7f447",
+                        known_042_DECODED),
                    ('../ubc/042_22.jb2',
-			"a9e2b365be63716dbde74b0661c3c6efd2a6844d",
-			known_042_DECODED),
+                        "a9e2b365be63716dbde74b0661c3c6efd2a6844d",
+                        known_042_DECODED),
                    ('../ubc/042_23.jb2',
-			"8ffa40a05e93e10982b38a2233a8da58c1b5c343",
-			known_042_DECODED),
+                        "8ffa40a05e93e10982b38a2233a8da58c1b5c343",
+                        known_042_DECODED),
                    ('../ubc/042_24.jb2',
-			"2553fe65111c58f6412de51d8cdc71651e778ccf",
-			known_042_DECODED),
+                        "2553fe65111c58f6412de51d8cdc71651e778ccf",
+                        known_042_DECODED),
                    ('../ubc/042_25.jb2',
-			"52de4a3b86252d896a8d783ba71dd0699333dd69",
-			known_042_DECODED),
+                        "52de4a3b86252d896a8d783ba71dd0699333dd69",
+                        known_042_DECODED),
                    ('../ubc/amb_1.jb2',
-			"d6d6d1c981dc37a09108c1e3ed990aa5b345fa6a",
+                        "d6d6d1c981dc37a09108c1e3ed990aa5b345fa6a",
                         known_amb_DECODED),
                    ('../ubc/amb_2.jb2',
-			"9af6616a89eb03f8934de72626e301a716366c3c",
+                        "9af6616a89eb03f8934de72626e301a716366c3c",
                         known_amb_DECODED)
                  )
 

----------------------------------------------------------------------
commit 2e957c0b1afc6d2d705c9d075fc55db2de5df854
Author: Sebastian Rasmussen <[email protected]>
Date:   Fri Jun 14 22:18:14 2019 +0200

    jbig2dec: Make tests expect that some test files return white image.
    
    Previously these tests would just error out and jbig2dec would not
    return any output file at all. Now, jbig2dec parses as much as
    possible, while emitting warning/error messages. In the case of a
    few of the test files the end result is a white image.

diff --git a/jbig2dec/test_jbig2dec.py b/jbig2dec/test_jbig2dec.py
index a841438..33008e5 100755
--- a/jbig2dec/test_jbig2dec.py
+++ b/jbig2dec/test_jbig2dec.py
@@ -60,6 +60,7 @@ class KnownFileHash(SelfTest):
 
   # hashes of known test inputs
   known_NOTHING_DECODED = "da39a3ee5e6b4b0d3255bfef95601890afd80709"
+  known_WHITE_PAGE_DECODED = "28a6bd83a8a3a36910fbc1f5ce06c962e4332911"
   known_042_DECODED = "ebfdf6e2fc5ff3ee2271c2fa19de0e52712046e8"
   known_amb_DECODED = "3d4b7992d506894662b53415bd3d0d2a2f8b7953"
 
@@ -103,10 +104,10 @@ class KnownFileHash(SelfTest):
 			known_042_DECODED),
                    ('../ubc/042_13.jb2',
 			"7d428bd542f58591b254d9827f554b0552c950a7",
-			known_NOTHING_DECODED),
+			known_WHITE_PAGE_DECODED),
                    ('../ubc/042_14.jb2',
 			"c40fe3a02acb6359baf9b40fc9c49bc0800be589",
-			known_NOTHING_DECODED),
+			known_WHITE_PAGE_DECODED),
                    ('../ubc/042_15.jb2',
 			"a9e39fc1ecb178aec9f05039514d75ea3246246c",
 			known_042_DECODED),

----------------------------------------------------------------------
commit 1c5c3a1f14c85582d09ab58f55b1fd83435b6562
Author: Sebastian Rasmussen <[email protected]>
Date:   Fri Jun 14 15:15:53 2019 +0200

    jbig2dec: Indent Makefiles with tabs like the rest of the Makefiles.

diff --git a/base/jbig2.mak b/base/jbig2.mak
index eba11f5..6182fdd 100644
--- a/base/jbig2.mak
+++ b/base/jbig2.mak
@@ -43,39 +43,39 @@ JBIG2OBJ=$(JBIG2OBJDIR)$(D)
 libjbig2_OBJS1=\
 	$(JBIG2OBJ)jbig2.$(OBJ) \
 	$(JBIG2OBJ)jbig2_arith.$(OBJ) \
-        $(JBIG2OBJ)jbig2_arith_iaid.$(OBJ) \
-        $(JBIG2OBJ)jbig2_arith_int.$(OBJ) \
-        $(JBIG2OBJ)jbig2_generic.$(OBJ) \
-        $(JBIG2OBJ)jbig2_refinement.$(OBJ) \
-        $(JBIG2OBJ)jbig2_huffman.$(OBJ) \
-        $(JBIG2OBJ)jbig2_image.$(OBJ) \
-        $(JBIG2OBJ)jbig2_mmr.$(OBJ)
+	$(JBIG2OBJ)jbig2_arith_iaid.$(OBJ) \
+	$(JBIG2OBJ)jbig2_arith_int.$(OBJ) \
+	$(JBIG2OBJ)jbig2_generic.$(OBJ) \
+	$(JBIG2OBJ)jbig2_refinement.$(OBJ) \
+	$(JBIG2OBJ)jbig2_huffman.$(OBJ) \
+	$(JBIG2OBJ)jbig2_image.$(OBJ) \
+	$(JBIG2OBJ)jbig2_mmr.$(OBJ)
 
 libjbig2_OBJS2=\
 	$(JBIG2OBJ)jbig2_page.$(OBJ) \
-        $(JBIG2OBJ)jbig2_segment.$(OBJ) \
-        $(JBIG2OBJ)jbig2_symbol_dict.$(OBJ) \
-        $(JBIG2OBJ)jbig2_text.$(OBJ) \
-        $(JBIG2OBJ)jbig2_halftone.$(OBJ) \
-        $(JBIG2_EXTRA_OBJS)
+	$(JBIG2OBJ)jbig2_segment.$(OBJ) \
+	$(JBIG2OBJ)jbig2_symbol_dict.$(OBJ) \
+	$(JBIG2OBJ)jbig2_text.$(OBJ) \
+	$(JBIG2OBJ)jbig2_halftone.$(OBJ) \
+	$(JBIG2_EXTRA_OBJS)
 
 libjbig2_OBJS=$(libjbig2_OBJS1) $(libjbig2_OBJS2)
 
 libjbig2_HDRS=\
-        $(JBIG2SRC)jbig2.h \
-        $(JBIG2SRC)jbig2_arith.h \
-        $(JBIG2SRC)jbig2_arith_iaid.h \
-        $(JBIG2SRC)jbig2_arith_int.h \
-        $(JBIG2SRC)jbig2_generic.h \
-        $(JBIG2SRC)jbig2_huffman.h \
-        $(JBIG2SRC)jbig2_hufftab.h \
-        $(JBIG2SRC)jbig2_image.h \
-        $(JBIG2SRC)jbig2_mmr.h \
-        $(JBIG2SRC)jbig2_priv.h \
-        $(JBIG2SRC)jbig2_symbol_dict.h \
-        $(JBIG2SRC)jbig2_text.h \
-        $(JBIG2SRC)jbig2_halftone.h \
-        $(JBIG2SRC)config_win32.h
+	$(JBIG2SRC)jbig2.h \
+	$(JBIG2SRC)jbig2_arith.h \
+	$(JBIG2SRC)jbig2_arith_iaid.h \
+	$(JBIG2SRC)jbig2_arith_int.h \
+	$(JBIG2SRC)jbig2_generic.h \
+	$(JBIG2SRC)jbig2_huffman.h \
+	$(JBIG2SRC)jbig2_hufftab.h \
+	$(JBIG2SRC)jbig2_image.h \
+	$(JBIG2SRC)jbig2_mmr.h \
+	$(JBIG2SRC)jbig2_priv.h \
+	$(JBIG2SRC)jbig2_symbol_dict.h \
+	$(JBIG2SRC)jbig2_text.h \
+	$(JBIG2SRC)jbig2_halftone.h \
+	$(JBIG2SRC)config_win32.h
 
 jbig2dec_OBJS=$(JBIG2OBJ)getopt.$(OBJ) $(JBIG2OBJ)getopt1.$(OBJ) $(JBIG2OBJ)sha1.$(OBJ)
 jbig2dec_HDRS=$(JBIG2OBJ)getopt.h $(JBIG2OBJ)sha1.h


Summary of changes:
 base/jbig2.mak                                |  56 ++---
 jbig2dec/Makefile.am                          |   2 +-
 jbig2dec/Makefile.unix                        |   6 +-
 jbig2dec/jbig2.c                              |   2 +-
 jbig2dec/jbig2_arith.c                        |   2 +-
 jbig2dec/jbig2_halftone.c                     |   6 +-
 jbig2dec/jbig2_huffman.c                      |   8 +-
 jbig2dec/{jbig2_hufftab.h => jbig2_hufftab.c} |  47 ++--
 jbig2dec/jbig2_hufftab.h                      | 305 ++------------------------
 jbig2dec/jbig2_image.c                        |  14 --
 jbig2dec/jbig2_page.c                         |  17 +-
 jbig2dec/jbig2_symbol_dict.c                  |   2 +-
 jbig2dec/jbig2_text.c                         |   3 +-
 jbig2dec/jbig2dec.c                           |   2 +
 jbig2dec/msvc.mak                             |  12 +-
 jbig2dec/test_jbig2dec.py                     | 160 +++++++-------
 windows/ghostscript.vcproj                    |   4 +
 windows/ghostscript_rt.vcxproj                |   1 +
 18 files changed, 199 insertions(+), 450 deletions(-)
 copy jbig2dec/{jbig2_hufftab.h => jbig2_hufftab.c} (86%)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.