X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Flz77.c;h=2d85ae8f23609b6bb62014baed5e1dbe90eb2a55;hb=48fbbd68e82d879e2cb6f384c1440e81373338c7;hp=d279874627aa1b2577fbeac0d9283d3f08c4471d;hpb=39f955331c7d8a5c3ff4ae44711f62581568f579;p=wimlib diff --git a/src/lz77.c b/src/lz77.c index d2798746..2d85ae8f 100644 --- a/src/lz77.c +++ b/src/lz77.c @@ -7,7 +7,7 @@ */ /* - * Copyright (C) 2012 Eric Biggers + * Copyright (C) 2012, 2013 Eric Biggers * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler * * This file is part of wimlib, a library for working with WIM files. @@ -26,7 +26,13 @@ * along with wimlib; if not, see http://www.gnu.org/licenses/. */ -#include "compress.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "wimlib/compress.h" +#include "wimlib/util.h" + #include #define LZ_MIN_MATCH 3 @@ -52,7 +58,8 @@ * The AND operation guarantees that only 3 characters will affect the hash * value, so every identical 3-character string will have the same hash value. */ -static inline unsigned update_hash(unsigned hash, u8 c) +static inline unsigned +update_hash(unsigned hash, u8 c) { return ((hash << HASH_SHIFT) ^ c) & HASH_MASK; } @@ -70,9 +77,10 @@ static inline unsigned update_hash(unsigned hash, u8 c) * to walk through the hash chain, until the special index `0' is reached, * indicating the end of the hash chain. */ -static inline unsigned insert_string(u16 hash_tab[], u16 prev_tab[], - const u8 window[], unsigned str_pos, - unsigned hash) +static inline unsigned +insert_string(u16 hash_tab[], u16 prev_tab[], + const u8 window[], unsigned str_pos, + unsigned hash) { hash = update_hash(hash, window[str_pos + LZ_MIN_MATCH - 1]); prev_tab[str_pos] = hash_tab[hash]; @@ -102,11 +110,12 @@ static inline unsigned insert_string(u16 hash_tab[], u16 prev_tab[], * * Returns the length of the match that was found. */ -static unsigned longest_match(const u8 window[], unsigned bytes_remaining, - unsigned strstart, const u16 prev_tab[], - unsigned cur_match, unsigned prev_len, - unsigned *match_start_ret, - const struct lz_params *params) +static unsigned +longest_match(const u8 window[], unsigned bytes_remaining, + unsigned strstart, const u16 prev_tab[], + unsigned cur_match, unsigned prev_len, + unsigned *match_start_ret, + const struct lz_params *params) { unsigned chain_len = params->max_chain_len; @@ -210,15 +219,16 @@ static unsigned longest_match(const u8 window[], unsigned bytes_remaining, * is the number of slots in @match_tab that have been filled with the * intermediate representation of a match or literal byte. */ -unsigned lz_analyze_block(const u8 uncompressed_data[], - unsigned uncompressed_len, - u32 match_tab[], - lz_record_match_t record_match, - lz_record_literal_t record_literal, - void *record_match_arg1, - void *record_match_arg2, - void *record_literal_arg, - const struct lz_params *params) +unsigned +lz_analyze_block(const u8 uncompressed_data[], + unsigned uncompressed_len, + u32 match_tab[], + lz_record_match_t record_match, + lz_record_literal_t record_literal, + void *record_match_arg1, + void *record_match_arg2, + void *record_literal_arg, + const struct lz_params *params) { unsigned cur_match_pos = 0; unsigned cur_input_pos = 0;