]> wimlib.net Git - wimlib/blobdiff - src/lzx-compress.c
lzx_prepare_block_fast(): Increase max_offset
[wimlib] / src / lzx-compress.c
index e34b320456e72325b95dbbc2adef7d6155603242..c72fd460c84d47a4612fde0214499acad1d17f5c 100644 (file)
 
 #include "wimlib.h"
 #include "wimlib/compress.h"
+#include "wimlib/endianness.h"
 #include "wimlib/error.h"
 #include "wimlib/lzx.h"
 #include "wimlib/util.h"
@@ -249,9 +250,9 @@ struct lzx_codes {
 
 /* Tables for tallying symbol frequencies in the three LZX alphabets  */
 struct lzx_freqs {
-       freq_t main[LZX_MAINCODE_MAX_NUM_SYMBOLS];
-       freq_t len[LZX_LENCODE_NUM_SYMBOLS];
-       freq_t aligned[LZX_ALIGNEDCODE_NUM_SYMBOLS];
+       input_idx_t main[LZX_MAINCODE_MAX_NUM_SYMBOLS];
+       input_idx_t len[LZX_LENCODE_NUM_SYMBOLS];
+       input_idx_t aligned[LZX_ALIGNEDCODE_NUM_SYMBOLS];
 };
 
 /* LZX intermediate match/literal format  */
@@ -654,7 +655,7 @@ static unsigned
 lzx_build_precode(const u8 lens[restrict],
                  const u8 prev_lens[restrict],
                  const unsigned num_syms,
-                 freq_t precode_freqs[restrict LZX_PRECODE_NUM_SYMBOLS],
+                 input_idx_t precode_freqs[restrict LZX_PRECODE_NUM_SYMBOLS],
                  u8 output_syms[restrict num_syms],
                  u8 precode_lens[restrict LZX_PRECODE_NUM_SYMBOLS],
                  u16 precode_codewords[restrict LZX_PRECODE_NUM_SYMBOLS],
@@ -813,7 +814,7 @@ lzx_write_compressed_code(struct output_bitstream *out,
                          const u8 prev_lens[restrict],
                          unsigned num_syms)
 {
-       freq_t precode_freqs[LZX_PRECODE_NUM_SYMBOLS];
+       input_idx_t precode_freqs[LZX_PRECODE_NUM_SYMBOLS];
        u8 output_syms[num_syms];
        u8 precode_lens[LZX_PRECODE_NUM_SYMBOLS];
        u16 precode_codewords[LZX_PRECODE_NUM_SYMBOLS];
@@ -984,9 +985,9 @@ lzx_write_compressed_block(int block_type,
                bitstream_put_bits(ostream, 0, 1);
 
                if (max_window_size >= 65536)
-                       bitstream_put_bits(ostream, (block_size >> 16) & 0xff, 8);
+                       bitstream_put_bits(ostream, block_size >> 16, 8);
 
-               bitstream_put_bits(ostream, block_size & 0xffff, 16);
+               bitstream_put_bits(ostream, block_size, 16);
        }
 
        /* Write out lengths of the main code. Note that the LZX specification
@@ -2142,7 +2143,7 @@ lzx_prepare_block_fast(struct lzx_compressor * ctx)
                 * aren't worth choosing when using greedy or lazy parsing.  */
                .min_match      = 3,
                .max_match      = LZX_MAX_MATCH_LEN,
-               .max_offset     = 32768,
+               .max_offset     = LZX_MAX_WINDOW_SIZE,
                .good_match     = LZX_MAX_MATCH_LEN,
                .nice_match     = LZX_MAX_MATCH_LEN,
                .max_chain_len  = LZX_MAX_MATCH_LEN,