4 * Header for compression code shared by multiple compression formats.
6 * The author dedicates this file to the public domain.
7 * You can do whatever you want with this file.
10 #ifndef _WIMLIB_COMPRESS_COMMON_H
11 #define _WIMLIB_COMPRESS_COMMON_H
13 #include "wimlib/types.h"
15 /* Structure to keep track of the current state sending bits and bytes to the
16 * compressed output buffer. */
17 struct output_bitstream {
19 /* Variable that holds up to 16 bits that haven't yet been flushed to
23 /* Number of free bits in @bitbuf; that is, 16 minus the number of valid
27 /* Pointer to the start of the output buffer. */
30 /* Position at which to write the next 16 bits. */
33 /* Next position to write 16 bits, after they are written to bit_output.
34 * This is after @next_bit_output and may be separated from @bit_output
35 * by literal bytes. */
38 /* Next position to write literal bytes. This is after @bit_output and
39 * @next_bit_output, and may be separated from them by literal bytes.
43 /* Number of bytes remaining in the @output buffer. */
46 /* Set to true if the buffer has been exhausted. */
51 init_output_bitstream(struct output_bitstream *ostream,
52 void *data, unsigned num_bytes);
55 flush_output_bitstream(struct output_bitstream *ostream);
58 bitstream_put_bits(struct output_bitstream *ostream,
59 u32 bits, unsigned num_bits);
62 bitstream_put_byte(struct output_bitstream *ostream, u8 n);
65 make_canonical_huffman_code(unsigned num_syms,
66 unsigned max_codeword_len,
67 const u32 freq_tab[restrict],
69 u32 codewords[restrict]);
71 #endif /* _WIMLIB_COMPRESS_COMMON_H */