X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=include%2Fwimlib%2Fcompress_common.h;h=7913a138734925aaae2a01a965390e33948fe7f7;hb=acb5c41d2c9be655eca863a0315a22d1f54889e2;hp=14b32f488b488a0084e4a4ac31a72f4769932c5f;hpb=883833a4b3dabec325edf1ca938000f91d587c00;p=wimlib diff --git a/include/wimlib/compress_common.h b/include/wimlib/compress_common.h index 14b32f48..7913a138 100644 --- a/include/wimlib/compress_common.h +++ b/include/wimlib/compress_common.h @@ -9,89 +9,11 @@ #include "wimlib/types.h" -/* Variable type that can represent all possible window positions. */ -#ifndef INPUT_IDX_T_DEFINED -#define INPUT_IDX_T_DEFINED -typedef u32 input_idx_t; -#endif - -/* Structure to keep track of the current state sending bits and bytes to the - * compressed output buffer. */ -struct output_bitstream { - - /* Variable that holds up to 16 bits that haven't yet been flushed to - * the output. */ - u16 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. */ - u8 *output_start; - - /* Position at which to write the next 16 bits. */ - u8 *bit_output; - - /* Next position to write 16 bits, after they are written to bit_output. - * This is after @next_bit_output and may be separated from @bit_output - * by literal bytes. */ - u8 *next_bit_output; - - /* Next position to write literal bytes. This is after @bit_output and - * @next_bit_output, and may be separated from them by literal bytes. - */ - u8 *output; - - /* Number of bytes remaining in the @output buffer. */ - input_idx_t bytes_remaining; - - /* Set to true if the buffer has been exhausted. */ - bool overrun; -}; - -extern void -init_output_bitstream(struct output_bitstream *ostream, - void *data, unsigned num_bytes); - -extern input_idx_t -flush_output_bitstream(struct output_bitstream *ostream); - -extern void -bitstream_put_bits(struct output_bitstream *ostream, - u32 bits, unsigned num_bits); - -extern void -bitstream_put_byte(struct output_bitstream *ostream, u8 n); - -struct lz_params { - unsigned min_match; - unsigned max_match; - unsigned max_offset; - unsigned nice_match; - unsigned good_match; - unsigned max_chain_len; - unsigned max_lazy_match; - unsigned too_far; -}; - -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[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[restrict]); - extern void make_canonical_huffman_code(unsigned num_syms, unsigned max_codeword_len, - const input_idx_t freq_tab[restrict], + const u32 freq_tab[restrict], u8 lens[restrict], - u16 codewords[restrict]); + u32 codewords[restrict]); -#endif /* _WIMLIB_COMPRESS_H */ +#endif /* _WIMLIB_COMPRESS_COMMON_H */