X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=include%2Fwimlib%2Fcompress.h;h=fcd3c4119f16c9e37298a87760ddbd99b56186b3;hb=35ff480326a41f7f74fe0a497c636a811922f276;hp=eaa6ea0e1afca354c0f1f0b34110618f910f37d4;hpb=49a63aa13cdeb4c1348697ccd92207a1a65ec7b0;p=wimlib diff --git a/include/wimlib/compress.h b/include/wimlib/compress.h index eaa6ea0e..fcd3c411 100644 --- a/include/wimlib/compress.h +++ b/include/wimlib/compress.h @@ -7,26 +7,24 @@ #ifndef _WIMLIB_COMPRESS_H #define _WIMLIB_COMPRESS_H -#include "wimlib/endianness.h" #include "wimlib/types.h" -typedef u16 output_bitbuf_t; - /* Variable type that can represent all possible window positions. */ -typedef u32 freq_t; #ifndef INPUT_IDX_T_DEFINED #define INPUT_IDX_T_DEFINED typedef u32 input_idx_t; #endif -/* Structure to keep track of the current position in the compressed output. */ +/* Structure to keep track of the current state sending bits and bytes to the + * compressed output buffer. */ struct output_bitstream { - /* A variable to buffer writing bits to the output and is flushed to the - * compressed output when full. */ - output_bitbuf_t bitbuf; + /* Variable that holds up to 16 bits that haven't yet been flushed to + * the output. */ + u16 bitbuf; - /* Number of free bits in @bitbuf */ + /* Number of free bits in @bitbuf; that is, 16 minus the number of valid + * bits in @bitbuf. */ unsigned free_bits; /* Pointer to the start of the output buffer. */ @@ -45,7 +43,7 @@ struct output_bitstream { */ u8 *output; - /* Bytes remaining in @output buffer. */ + /* Number of bytes remaining in the @output buffer. */ input_idx_t bytes_remaining; /* Set to true if the buffer has been exhausted. */ @@ -61,7 +59,7 @@ flush_output_bitstream(struct output_bitstream *ostream); extern void bitstream_put_bits(struct output_bitstream *ostream, - output_bitbuf_t bits, unsigned num_bits); + u32 bits, unsigned num_bits); extern void bitstream_put_byte(struct output_bitstream *ostream, u8 n); @@ -81,18 +79,18 @@ typedef void (*lz_record_match_t)(unsigned len, unsigned offset, void *ctx); typedef void (*lz_record_literal_t)(u8 lit, void *ctx); extern void -lz_analyze_block(const u8 window[], +lz_analyze_block(const u8 window[restrict], input_idx_t window_size, lz_record_match_t record_match, lz_record_literal_t record_literal, void *record_ctx, const struct lz_params *params, - input_idx_t prev_tab[]); + input_idx_t prev_tab[restrict]); extern void make_canonical_huffman_code(unsigned num_syms, unsigned max_codeword_len, - const freq_t freq_tab[restrict], + const input_idx_t freq_tab[restrict], u8 lens[restrict], u16 codewords[restrict]);