]> wimlib.net Git - wimlib/blobdiff - src/lzx-decompress.c
Remove unused 'num_syms' argument to read_huffsym()
[wimlib] / src / lzx-decompress.c
index f7f6661649cb78fae376ad7c3a4e29c63c11df70..e1c0160cdfef246ab8e2eba26c2054dc5ea490d0 100644 (file)
@@ -151,22 +151,18 @@ struct lzx_decompressor {
  */
 static inline u16
 read_huffsym_using_pretree(struct input_bitstream *istream,
-                          const u16 pretree_decode_table[],
-                          const u8 pretree_lens[])
+                          const u16 pretree_decode_table[])
 {
-       return read_huffsym(istream, pretree_decode_table, pretree_lens,
-                           LZX_PRECODE_NUM_SYMBOLS, LZX_PRECODE_TABLEBITS,
-                           LZX_MAX_PRE_CODEWORD_LEN);
+       return read_huffsym(istream, pretree_decode_table,
+                           LZX_PRECODE_TABLEBITS, LZX_MAX_PRE_CODEWORD_LEN);
 }
 
 /* Reads a Huffman-encoded symbol using the main tree. */
 static inline u16
 read_huffsym_using_maintree(struct input_bitstream *istream,
-                           const struct lzx_tables *tables,
-                           unsigned num_main_syms)
+                           const struct lzx_tables *tables)
 {
        return read_huffsym(istream, tables->maintree_decode_table,
-                           tables->maintree_lens, num_main_syms,
                            LZX_MAINCODE_TABLEBITS, LZX_MAX_MAIN_CODEWORD_LEN);
 }
 
@@ -176,7 +172,6 @@ read_huffsym_using_lentree(struct input_bitstream *istream,
                           const struct lzx_tables *tables)
 {
        return read_huffsym(istream, tables->lentree_decode_table,
-                           tables->lentree_lens, LZX_LENCODE_NUM_SYMBOLS,
                            LZX_LENCODE_TABLEBITS, LZX_MAX_LEN_CODEWORD_LEN);
 }
 
@@ -186,10 +181,7 @@ read_huffsym_using_alignedtree(struct input_bitstream *istream,
                               const struct lzx_tables *tables)
 {
        return read_huffsym(istream, tables->alignedtree_decode_table,
-                           tables->alignedtree_lens,
-                           LZX_ALIGNEDCODE_NUM_SYMBOLS,
-                           LZX_ALIGNEDCODE_TABLEBITS,
-                           LZX_MAX_ALIGNED_CODEWORD_LEN);
+                           LZX_ALIGNEDCODE_TABLEBITS, LZX_MAX_ALIGNED_CODEWORD_LEN);
 }
 
 /*
@@ -250,8 +242,7 @@ lzx_read_code_lens(struct input_bitstream *istream, u8 lens[],
                signed char value;
 
                tree_code = read_huffsym_using_pretree(istream,
-                                                      pretree_decode_table,
-                                                      pretree_lens);
+                                                      pretree_decode_table);
                switch (tree_code) {
                case 17: /* Run of 0's */
                        num_zeroes = bitstream_read_bits(istream, 4);
@@ -275,8 +266,7 @@ lzx_read_code_lens(struct input_bitstream *istream, u8 lens[],
                        num_same = bitstream_read_bits(istream, 1);
                        num_same += 4;
                        code = read_huffsym_using_pretree(istream,
-                                                         pretree_decode_table,
-                                                         pretree_lens);
+                                                         pretree_decode_table);
                        value = (signed char)*lens - (signed char)code;
                        if (value < 0)
                                value += 17;
@@ -672,15 +662,20 @@ undo_call_insn_translation(u32 *call_insn_target, s32 input_pos)
        s32 rel_offset;
 
        abs_offset = le32_to_cpu(*call_insn_target);
-       if (abs_offset >= -input_pos && abs_offset < LZX_WIM_MAGIC_FILESIZE) {
-               if (abs_offset >= 0) {
+       if (abs_offset >= 0) {
+               if (abs_offset < LZX_WIM_MAGIC_FILESIZE) {
                        /* "good translation" */
                        rel_offset = abs_offset - input_pos;
-               } else {
+
+                       *call_insn_target = cpu_to_le32(rel_offset);
+               }
+       } else {
+               if (abs_offset >= -input_pos) {
                        /* "compensating translation" */
                        rel_offset = abs_offset + LZX_WIM_MAGIC_FILESIZE;
+
+                       *call_insn_target = cpu_to_le32(rel_offset);
                }
-               *call_insn_target = cpu_to_le32(rel_offset);
        }
 }
 
@@ -810,7 +805,6 @@ undo_call_insn_preprocessing(u8 *uncompressed_data, size_t uncompressed_size)
  * @block_type:        The type of the block (LZX_BLOCKTYPE_VERBATIM or
  *             LZX_BLOCKTYPE_ALIGNED)
  * @block_size:        The size of the block, in bytes.
- * @num_main_syms:     Number of symbols in the main alphabet.
  * @window:    Pointer to the decompression window.
  * @window_pos:        The current position in the window.  Will be 0 for the first
  *                     block.
@@ -821,7 +815,6 @@ undo_call_insn_preprocessing(u8 *uncompressed_data, size_t uncompressed_size)
  */
 static int
 lzx_decompress_block(int block_type, unsigned block_size,
-                    unsigned num_main_syms,
                     u8 *window,
                     unsigned window_pos,
                     const struct lzx_tables *tables,
@@ -834,8 +827,7 @@ lzx_decompress_block(int block_type, unsigned block_size,
 
        end = window_pos + block_size;
        while (window_pos < end) {
-               main_element = read_huffsym_using_maintree(istream, tables,
-                                                          num_main_syms);
+               main_element = read_huffsym_using_maintree(istream, tables);
                if (main_element < LZX_NUM_CHARS) {
                        /* literal: 0 to LZX_NUM_CHARS - 1 */
                        window[window_pos++] = main_element;
@@ -928,7 +920,6 @@ lzx_decompress(const void *compressed_data, size_t compressed_size,
                                LZX_DEBUG("LZX_BLOCKTYPE_ALIGNED");
                        ret = lzx_decompress_block(block_type,
                                                   block_size,
-                                                  ctx->num_main_syms,
                                                   uncompressed_data,
                                                   window_pos,
                                                   &ctx->tables,