]> wimlib.net Git - wimlib/commitdiff
lzx_compress: increase LZX_BIT_COST to 64
authorEric Biggers <ebiggers3@gmail.com>
Sat, 11 Jun 2016 18:28:21 +0000 (13:28 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 11 Jun 2016 19:46:18 +0000 (14:46 -0500)
Increasing the bit cost allows higher precision calculations, with
essentially no disadvantages.  64 is also the value used by the LZMS
compressor.

src/lzx_compress.c

index b31eca735a4005853c0f5b3c50d39a9c8c3d058a..93ee97d45efdb1927fb83f291845084d60ae000b 100644 (file)
  * unknown.  In reality, each token in LZX requires a whole number of bits to
  * output.
  */
-#define LZX_BIT_COST           16
+#define LZX_BIT_COST           64
 
 /*
  * Should the compressor take into account the costs of aligned offset symbols?
@@ -1668,8 +1668,8 @@ lzx_set_default_costs(struct lzx_compressor *c, const u8 *block, u32 block_size)
        bool have_byte[256];
        unsigned num_used_bytes;
 
-       /* The costs below are hard coded to use a scaling factor of 16.  */
-       STATIC_ASSERT(LZX_BIT_COST == 16);
+       /* The costs below are hard coded to use a scaling factor of 64.  */
+       STATIC_ASSERT(LZX_BIT_COST == 64);
 
        /*
         * Heuristics:
@@ -1694,13 +1694,13 @@ lzx_set_default_costs(struct lzx_compressor *c, const u8 *block, u32 block_size)
                num_used_bytes += have_byte[i];
 
        for (i = 0; i < 256; i++)
-               c->costs.main[i] = 140 - (256 - num_used_bytes) / 4;
+               c->costs.main[i] = 560 - (256 - num_used_bytes);
 
        for (; i < c->num_main_syms; i++)
-               c->costs.main[i] = 170;
+               c->costs.main[i] = 680;
 
        for (i = 0; i < LZX_LENCODE_NUM_SYMBOLS; i++)
-               c->costs.len[i] = 103 + (i / 4);
+               c->costs.len[i] = 412 + i;
 
 #if LZX_CONSIDER_ALIGNED_COSTS
        for (i = 0; i < LZX_ALIGNEDCODE_NUM_SYMBOLS; i++)