[Zlib-devel] different root table sizes in inflate.c

hzip at linux.vnet.ibm.com hzip at linux.vnet.ibm.com
Tue Feb 12 11:25:57 EST 2013


Greetings,

I am experimenting with different root table sizes than the two  
default 9 and 6 in inflate.
Changed few files as shown below. Have I overlooked any other places  
to change?
Appreciate any advice and pointers. Thank you

B. Abali

===================================================================
--- inflate.c   (revision 490)
+++ inflate.c   (working copy)
@@ -994,8 +994,9 @@
                 values here (9 and 6) without reading the comments in  
inftrees.h
                 concerning the ENOUGH constants, which depend on  
those values */
              state->next = state->codes;
-            state->lencode = (code const FAR *)(state->next);
-            state->lenbits = 9;
+            state->lencode = (code const FAR *)(state->next);
+               // state->lenbits = 9;
+               state->lenbits = 10;
              ret = inflate_table(LENS, state->lens, state->nlen,  
&(state->next),
                                  &(state->lenbits), state->work);
              if (ret) {
@@ -1004,7 +1005,8 @@
                  break;
              }
              state->distcode = (code const FAR *)(state->next);
-            state->distbits = 6;
+               // state->distbits = 6;
+               state->distbits = 7;
              ret = inflate_table(DISTS, state->lens + state->nlen,  
state->ndist,
                              &(state->next), &(state->distbits), state->work);
              if (ret) {
===================================================================
--- inftrees.h  (revision 490)
+++ inftrees.h  (working copy)
@@ -46,8 +46,12 @@
     inflate_table() calls in inflate.c and infback.c.  If the root  
table size is
     changed, then these maximum sizes would be need to be recalculated and
     updated. */
-#define ENOUGH_LENS 852
-#define ENOUGH_DISTS 592
+// #define ENOUGH_LENS 852
+// 10 bit len table 1332 enough 286 10 15
+#define ENOUGH_LENS 1332
+// #define ENOUGH_DISTS 592
+// 7 bit dist table 400  enough 30 7 15
+#define ENOUGH_DISTS 400
  #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)

  /* Type of code to build for inflate_table() */
===================================================================
--- infback.c   (revision 490)
+++ infback.c   (working copy)
@@ -458,7 +458,8 @@
                 concerning the ENOUGH constants, which depend on  
those values */
              state->next = state->codes;
              state->lencode = (code const FAR *)(state->next);
-            state->lenbits = 9;
+            // state->lenbits = 9;
+           state->lenbits = 10;
              ret = inflate_table(LENS, state->lens, state->nlen,  
&(state->next),
                                  &(state->lenbits), state->work);
              if (ret) {
@@ -467,7 +468,8 @@
                  break;
              }
              state->distcode = (code const FAR *)(state->next);
-            state->distbits = 6;
+            // state->distbits = 6;
+            state->distbits = 7;
              ret = inflate_table(DISTS, state->lens + state->nlen,  
state->ndist,
                              &(state->next), &(state->distbits), state->work);
              if (ret) {





More information about the Zlib-devel mailing list