]> wimlib.net Git - wimlib/commitdiff
lzx_compress: update lzx_update_costs() with codeword limits
authorEric Biggers <ebiggers3@gmail.com>
Sun, 20 Sep 2015 21:01:02 +0000 (16:01 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 20 Sep 2015 21:49:30 +0000 (16:49 -0500)
src/lzx_compress.c

index ec11727bfab4ea58f32491ec36dfac4f6f3b605c..dff0f5103c0dbe0671053055a931623f211a3ee7 100644 (file)
@@ -1792,15 +1792,24 @@ lzx_update_costs(struct lzx_compressor *c)
        unsigned i;
        const struct lzx_lens *lens = &c->codes[c->codes_index].lens;
 
-       for (i = 0; i < c->num_main_syms; i++)
-               c->costs.main[i].cost = (lens->main[i] ? lens->main[i] : 15) * LZX_BIT_COST;
+       for (i = 0; i < c->num_main_syms; i++) {
+               c->costs.main[i].cost =
+                       (lens->main[i] ? lens->main[i] :
+                                        MAIN_CODEWORD_LIMIT) * LZX_BIT_COST;
+       }
 
-       for (i = 0; i < LZX_LENCODE_NUM_SYMBOLS; i++)
-               c->costs.len[i].cost = (lens->len[i] ? lens->len[i] : 15) * LZX_BIT_COST;
+       for (i = 0; i < LZX_LENCODE_NUM_SYMBOLS; i++) {
+               c->costs.len[i].cost =
+                       (lens->len[i] ? lens->len[i] :
+                                       LENGTH_CODEWORD_LIMIT) * LZX_BIT_COST;
+       }
 
 #if LZX_CONSIDER_ALIGNED_COSTS
-       for (i = 0; i < LZX_ALIGNEDCODE_NUM_SYMBOLS; i++)
-               c->costs.aligned[i].cost = (lens->aligned[i] ? lens->aligned[i] : 7) * LZX_BIT_COST;
+       for (i = 0; i < LZX_ALIGNEDCODE_NUM_SYMBOLS; i++) {
+               c->costs.aligned[i].cost =
+                       (lens->aligned[i] ? lens->aligned[i] :
+                                           ALIGNED_CODEWORD_LIMIT) * LZX_BIT_COST;
+       }
 #endif
 
        lzx_compute_match_costs(c);