From bf0c3a319c621a0fbe57f69e7ca56a790393c72f Mon Sep 17 00:00:00 2001 From: Koji Arai Date: Wed, 10 Sep 2008 12:53:45 +0900 Subject: [PATCH] maketree2() should refer the tree1 info at first. --- src/pm2tree.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/pm2tree.c b/src/pm2tree.c index 8ce0511..76d388b 100644 --- a/src/pm2tree.c +++ b/src/pm2tree.c @@ -21,12 +21,13 @@ static void tree_rebuild(struct tree *t, unsigned char bound, unsigned char *table); static void tree_setsingle(struct tree *t, unsigned char value); +static unsigned char tree1bound; +static unsigned char mindepth; + void maketree1() { int i, nbits, x; - unsigned char tree1bound; - unsigned char mindepth; unsigned char table1[32]; tree1bound = getbits(5); @@ -52,6 +53,18 @@ maketree2(int tree2bound) /* in use: 5 <= tree2bound <= 8 */ int i, count, index; unsigned char table2[8]; + + if (tree1bound < 10) + /* tree1bound=1..8: character only, offset value is no needed. */ + /* tree1bound=9: offset value is not encoded by Huffman tree */ + return; + + if (tree1bound == 29 && mindepth == 0) + /* the length value is just 256 and offset value is just 0 */ + return; + + /* need to build tree2 for offset value */ + for (i = 0; i < 8; i++) table2[i] = 0; for (i = 0; i < tree2bound; i++) -- 2.11.0