shithub: jbig2

Download patch

ref: a0531af83d6d29abe2fccb488fa7b741d68cb3fd
parent: 5bbd972edf6b6441248d4201cd61767fa521cc97
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Wed Aug 17 16:03:18 EDT 2005

Hack around the lack of subtree support in jbig2_huffman_table_build() 
by allocating a bigger flat table. This should be fixed the correct
way at some point, but lets us proceed with huffman text region
decoding implementation in the meantime.


git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@430 ded80894-8fb9-0310-811b-c03f3676ab4d

--- a/jbig2_huffman.c
+++ b/jbig2_huffman.c
@@ -262,7 +262,10 @@
   return result;
 }
 
-#define LOG_TABLE_SIZE_MAX 8
+/* TODO: 10 bits here is wasteful of memory here. We have support
+   for sub-trees in jbig2_huffman_get() above, but don't use it here
+   we should, and then revert to 8 bits */
+#define LOG_TABLE_SIZE_MAX 10
 
 /** Build an in-memory representation of a Huffman table from the
  *  set of template params provided by the spec or a table segment
@@ -270,7 +273,7 @@
 Jbig2HuffmanTable *
 jbig2_build_huffman_table (Jbig2Ctx *ctx, const Jbig2HuffmanParams *params)
 {
-  int LENCOUNT[256];
+  int LENCOUNT[1 << LOG_TABLE_SIZE_MAX];
   int LENMAX = -1;
   const Jbig2HuffmanLine *lines = params->lines;
   int n_lines = params->n_lines;