Skip to content

Commit

Permalink
get rid of DECODE_TABLE_SIZE macro
Browse files Browse the repository at this point in the history
  • Loading branch information
maharmstone committed Mar 22, 2023
1 parent 3bcd29a commit 8fa185b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
9 changes: 0 additions & 9 deletions src/ebiggers/decompress_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,6 @@ read_huffsym(struct input_bitstream *is, const u16 decode_table[],
((num_syms) == 799 && (table_bits) == 11 && (max_codeword_len) == 15) ? 2854 : \
-1)

/* Wrapper around DECODE_TABLE_ENOUGH() that does additional compile-time
* validation. */
#define DECODE_TABLE_SIZE(num_syms, table_bits, max_codeword_len) ( \
/* Finally, make the macro evaluate to the needed maximum
* number of decode table entries. */ \
DECODE_TABLE_ENOUGH((num_syms), (table_bits), \
(max_codeword_len)) \
)

extern int
make_huffman_decode_table(u16 decode_table[], unsigned num_syms,
unsigned table_bits, const u8 lens[],
Expand Down
8 changes: 4 additions & 4 deletions src/ebiggers/lzx_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@
#define LZX_READ_LENS_MAX_OVERRUN 50

struct lzx_decompressor {
u16 maincode_decode_table[DECODE_TABLE_SIZE(LZX_MAINCODE_MAX_NUM_SYMBOLS, LZX_MAINCODE_TABLEBITS, LZX_MAX_MAIN_CODEWORD_LEN)] _aligned_attribute(DECODE_TABLE_ALIGNMENT);
u16 maincode_decode_table[DECODE_TABLE_ENOUGH(LZX_MAINCODE_MAX_NUM_SYMBOLS, LZX_MAINCODE_TABLEBITS, LZX_MAX_MAIN_CODEWORD_LEN)] _aligned_attribute(DECODE_TABLE_ALIGNMENT);
u8 maincode_lens[LZX_MAINCODE_MAX_NUM_SYMBOLS + LZX_READ_LENS_MAX_OVERRUN];

u16 lencode_decode_table[DECODE_TABLE_SIZE(LZX_LENCODE_NUM_SYMBOLS, LZX_LENCODE_TABLEBITS, LZX_MAX_LEN_CODEWORD_LEN)] _aligned_attribute(DECODE_TABLE_ALIGNMENT);
u16 lencode_decode_table[DECODE_TABLE_ENOUGH(LZX_LENCODE_NUM_SYMBOLS, LZX_LENCODE_TABLEBITS, LZX_MAX_LEN_CODEWORD_LEN)] _aligned_attribute(DECODE_TABLE_ALIGNMENT);
u8 lencode_lens[LZX_LENCODE_NUM_SYMBOLS + LZX_READ_LENS_MAX_OVERRUN];

union {
u16 alignedcode_decode_table[DECODE_TABLE_SIZE(LZX_ALIGNEDCODE_NUM_SYMBOLS, LZX_ALIGNEDCODE_TABLEBITS, LZX_MAX_ALIGNED_CODEWORD_LEN)] _aligned_attribute(DECODE_TABLE_ALIGNMENT);
u16 alignedcode_decode_table[DECODE_TABLE_ENOUGH(LZX_ALIGNEDCODE_NUM_SYMBOLS, LZX_ALIGNEDCODE_TABLEBITS, LZX_MAX_ALIGNED_CODEWORD_LEN)] _aligned_attribute(DECODE_TABLE_ALIGNMENT);
u8 alignedcode_lens[LZX_ALIGNEDCODE_NUM_SYMBOLS];
};

union {
u16 precode_decode_table[DECODE_TABLE_SIZE(LZX_PRECODE_NUM_SYMBOLS, LZX_PRECODE_TABLEBITS, LZX_MAX_PRE_CODEWORD_LEN)] _aligned_attribute(DECODE_TABLE_ALIGNMENT);
u16 precode_decode_table[DECODE_TABLE_ENOUGH(LZX_PRECODE_NUM_SYMBOLS, LZX_PRECODE_TABLEBITS, LZX_MAX_PRE_CODEWORD_LEN)] _aligned_attribute(DECODE_TABLE_ALIGNMENT);
u8 precode_lens[LZX_PRECODE_NUM_SYMBOLS];
u8 extra_offset_bits[LZX_MAX_OFFSET_SLOTS];
};
Expand Down
2 changes: 1 addition & 1 deletion src/ebiggers/xpress_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

struct xpress_decompressor {
union {
u16 decode_table[DECODE_TABLE_SIZE(XPRESS_NUM_SYMBOLS, XPRESS_TABLEBITS, XPRESS_MAX_CODEWORD_LEN)] _aligned_attribute(DECODE_TABLE_ALIGNMENT);
u16 decode_table[DECODE_TABLE_ENOUGH(XPRESS_NUM_SYMBOLS, XPRESS_TABLEBITS, XPRESS_MAX_CODEWORD_LEN)] _aligned_attribute(DECODE_TABLE_ALIGNMENT);
u8 lens[XPRESS_NUM_SYMBOLS];
};
u16 working_space[2 * (XPRESS_MAX_CODEWORD_LEN + 1) + XPRESS_NUM_SYMBOLS]
Expand Down

0 comments on commit 8fa185b

Please sign in to comment.