X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Flzx.h;h=5f87076e6a100363a3f98b4c149047ca40189f75;hp=70872abeab68c2d65fb686abdbe93dc88d60922d;hb=3e7f9503cec2df67295fa878f5a6230ad3871160;hpb=9ad70b9c12fb5859ff5be1730672b80197a0d9f9 diff --git a/src/lzx.h b/src/lzx.h index 70872abe..5f87076e 100644 --- a/src/lzx.h +++ b/src/lzx.h @@ -49,10 +49,10 @@ #define LZX_MAINTREE_NUM_SYMBOLS (LZX_NUM_CHARS + \ (LZX_NUM_POSITION_SLOTS << 3)) -#define LZX_MAINTREE_TABLEBITS 12 +#define LZX_MAINTREE_TABLEBITS 11 #define LZX_LENTREE_NUM_SYMBOLS 249 -#define LZX_LENTREE_TABLEBITS 12 +#define LZX_LENTREE_TABLEBITS 10 #define LZX_PRETREE_NUM_SYMBOLS 20 #define LZX_PRETREE_TABLEBITS 6 @@ -70,22 +70,36 @@ * though the blocks themselves are not this size, and the size of the actual * file resource in the WIM file is very likely to be something entirely * different as well. */ -#define LZX_MAGIC_FILESIZE 12000000 +#define LZX_WIM_MAGIC_FILESIZE 12000000 +#define USE_LZX_EXTRA_BITS_ARRAY + +#ifdef USE_LZX_EXTRA_BITS_ARRAY extern const u8 lzx_extra_bits[LZX_NUM_POSITION_SLOTS]; +#endif + +/* Given the number of a LZX position slot, return the number of extra bits that + * are needed to encode the match offset. */ +static inline unsigned +lzx_get_num_extra_bits(unsigned position_slot) +{ +#ifdef USE_LZX_EXTRA_BITS_ARRAY + /* Use a table */ + return lzx_extra_bits[position_slot]; +#else + /* Calculate directly using a shift and subtraction. */ + wimlib_assert(position_slot >= 2 && position_slot <= 37); + return (position_slot >> 1) - 1; +#endif +} + extern const u32 lzx_position_base[LZX_NUM_POSITION_SLOTS]; /* Least-recently used queue for match offsets. */ struct lru_queue { - int R0; - int R1; - int R2; + u32 R0; + u32 R1; + u32 R2; }; -extern int lzx_decompress(const void *compressed_data, uint compressed_len, - void *uncompressed_data, uint uncompressed_len); - -extern int lzx_compress(const void *uncompressed_data, uint uncompressed_len, - void *compressed_data, uint *compressed_len_ret); - #endif /* _WIMLIB_LZX_H */