]> wimlib.net Git - wimlib/commitdiff
Rename raw_match => lz_match
authorEric Biggers <ebiggers3@gmail.com>
Sat, 5 Jul 2014 01:41:53 +0000 (20:41 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 5 Jul 2014 01:41:53 +0000 (20:41 -0500)
include/wimlib/lz.h
include/wimlib/lz_bt.h
src/lz_bt.c
src/lzms-compress.c
src/lzx-compress.c

index 1b84fc47cbd3e467863b2c4d113f65e97d8e3ead..dfba7c2a33d8b7e32638debf8b4ea53873c313aa 100644 (file)
@@ -19,7 +19,7 @@
  *
  * This can alternatively be used to represent a literal byte if @len is less
  * than the minimum match length.  */
  *
  * This can alternatively be used to represent a literal byte if @len is less
  * than the minimum match length.  */
-struct raw_match {
+struct lz_match {
        input_idx_t len;
        input_idx_t offset;
 };
        input_idx_t len;
        input_idx_t offset;
 };
index fec51f15d820d6c940f58270a1a0cf15880635e8..6ce525ae13cdf8f9241f701982eaca5b7186a010 100644 (file)
@@ -37,7 +37,7 @@ struct lz_bt {
        u32 max_search_depth;
 };
 
        u32 max_search_depth;
 };
 
-struct raw_match;
+struct lz_match;
 
 extern u64
 lz_bt_get_needed_memory(lz_bt_pos_t max_window_size);
 
 extern u64
 lz_bt_get_needed_memory(lz_bt_pos_t max_window_size);
@@ -54,7 +54,7 @@ extern void
 lz_bt_load_window(struct lz_bt *mf, const u8 *window, lz_bt_pos_t window_size);
 
 extern lz_bt_len_t
 lz_bt_load_window(struct lz_bt *mf, const u8 *window, lz_bt_pos_t window_size);
 
 extern lz_bt_len_t
-lz_bt_get_matches(struct lz_bt *mf, struct raw_match *matches);
+lz_bt_get_matches(struct lz_bt *mf, struct lz_match *matches);
 
 static inline lz_bt_pos_t
 lz_bt_get_position(const struct lz_bt *mf)
 
 static inline lz_bt_pos_t
 lz_bt_get_position(const struct lz_bt *mf)
index ec0342cad0c3cc03a69b66a73de59d460571c754..30250054f733f5574203f3f6bdabdddd8e50cb05 100644 (file)
@@ -242,7 +242,7 @@ do_search(const u8 window[restrict],
          const u32 max_depth,
          lz_bt_pos_t child_tab[restrict],
          lz_bt_pos_t cur_match,
          const u32 max_depth,
          lz_bt_pos_t child_tab[restrict],
          lz_bt_pos_t cur_match,
-         struct raw_match matches[restrict])
+         struct lz_match matches[restrict])
 {
        /*
         * Here's my explanation of how this code actually works.  Beware: this
 {
        /*
         * Here's my explanation of how this code actually works.  Beware: this
@@ -427,7 +427,7 @@ do_search(const u8 window[restrict],
                        if (len > longest_match_len) {
                                longest_match_len = len;
 
                        if (len > longest_match_len) {
                                longest_match_len = len;
 
-                               matches[num_matches++] = (struct raw_match) {
+                               matches[num_matches++] = (struct lz_match) {
                                        .len = len,
                                        .offset = cur_window_pos - cur_match,
                                };
                                        .len = len,
                                        .offset = cur_window_pos - cur_match,
                                };
@@ -474,7 +474,7 @@ do_search(const u8 window[restrict],
  * in the window.
  */
 lz_bt_len_t
  * in the window.
  */
 lz_bt_len_t
-lz_bt_get_matches(struct lz_bt *mf, struct raw_match matches[])
+lz_bt_get_matches(struct lz_bt *mf, struct lz_match matches[])
 {
        lz_bt_pos_t bytes_remaining;
        lz_bt_len_t num_matches;
 {
        lz_bt_pos_t bytes_remaining;
        lz_bt_len_t num_matches;
@@ -514,7 +514,7 @@ lz_bt_get_matches(struct lz_bt *mf, struct raw_match matches[])
                if (cur_match != 0 && mf->cur_window[cur_match + 2] !=
                                      mf->cur_window[mf->cur_window_pos + 2])
                {
                if (cur_match != 0 && mf->cur_window[cur_match + 2] !=
                                      mf->cur_window[mf->cur_window_pos + 2])
                {
-                       matches[num_matches++] = (struct raw_match) {
+                       matches[num_matches++] = (struct lz_match) {
                                .len = 2,
                                .offset = mf->cur_window_pos - cur_match,
                        };
                                .len = 2,
                                .offset = mf->cur_window_pos - cur_match,
                        };
index 7c103f7b42150695b366ef69170b161a9160b432..0567ea392fd46ea9ad23ef9739aa619764f22a2a 100644 (file)
@@ -175,7 +175,7 @@ struct lzms_compressor {
        struct lz_bt mf;
 
        /* Temporary space to store found matches.  */
        struct lz_bt mf;
 
        /* Temporary space to store found matches.  */
-       struct raw_match *matches;
+       struct lz_match *matches;
 
        /* Match-chooser data.  */
        struct lzms_mc_pos_data *optimum;
 
        /* Match-chooser data.  */
        struct lzms_mc_pos_data *optimum;
@@ -744,7 +744,7 @@ lzms_get_length_cost(const struct lzms_huffman_encoder *enc, u32 length)
 }
 
 static u32
 }
 
 static u32
-lzms_get_matches(struct lzms_compressor *ctx, struct raw_match **matches_ret)
+lzms_get_matches(struct lzms_compressor *ctx, struct lz_match **matches_ret)
 {
        *matches_ret = ctx->matches;
        return lz_bt_get_matches(&ctx->mf, ctx->matches);
 {
        *matches_ret = ctx->matches;
        return lz_bt_get_matches(&ctx->mf, ctx->matches);
@@ -834,7 +834,7 @@ lzms_get_lz_match_cost(struct lzms_compressor *ctx,
               lzms_get_length_cost(&ctx->length_encoder, length);
 }
 
               lzms_get_length_cost(&ctx->length_encoder, length);
 }
 
-static struct raw_match
+static struct lz_match
 lzms_match_chooser_reverse_list(struct lzms_compressor *ctx, unsigned cur_pos)
 {
        unsigned prev_link, saved_prev_link;
 lzms_match_chooser_reverse_list(struct lzms_compressor *ctx, unsigned cur_pos)
 {
        unsigned prev_link, saved_prev_link;
@@ -860,7 +860,7 @@ lzms_match_chooser_reverse_list(struct lzms_compressor *ctx, unsigned cur_pos)
 
        ctx->optimum_cur_idx = ctx->optimum[0].next.link;
 
 
        ctx->optimum_cur_idx = ctx->optimum[0].next.link;
 
-       return (struct raw_match)
+       return (struct lz_match)
                { .len = ctx->optimum_cur_idx,
                  .offset = ctx->optimum[0].next.match_offset,
                };
                { .len = ctx->optimum_cur_idx,
                  .offset = ctx->optimum[0].next.match_offset,
                };
@@ -868,12 +868,12 @@ lzms_match_chooser_reverse_list(struct lzms_compressor *ctx, unsigned cur_pos)
 
 /* This is similar to lzx_get_near_optimal_match() in lzx-compress.c.
  * Read that one if you want to understand it.  */
 
 /* This is similar to lzx_get_near_optimal_match() in lzx-compress.c.
  * Read that one if you want to understand it.  */
-static struct raw_match
+static struct lz_match
 lzms_get_near_optimal_match(struct lzms_compressor *ctx)
 {
        u32 num_matches;
 lzms_get_near_optimal_match(struct lzms_compressor *ctx)
 {
        u32 num_matches;
-       struct raw_match *matches;
-       struct raw_match match;
+       struct lz_match *matches;
+       struct lz_match match;
        u32 longest_len;
        u32 longest_rep_len;
        u32 longest_rep_offset;
        u32 longest_len;
        u32 longest_rep_len;
        u32 longest_rep_offset;
@@ -913,7 +913,7 @@ lzms_get_near_optimal_match(struct lzms_compressor *ctx)
 
        if (longest_rep_len >= ctx->params.nice_match_length) {
                lzms_skip_bytes(ctx, longest_rep_len);
 
        if (longest_rep_len >= ctx->params.nice_match_length) {
                lzms_skip_bytes(ctx, longest_rep_len);
-               return (struct raw_match) {
+               return (struct lz_match) {
                        .len = longest_rep_len,
                        .offset = longest_rep_offset,
                };
                        .len = longest_rep_len,
                        .offset = longest_rep_offset,
                };
@@ -1131,7 +1131,7 @@ lzms_get_near_optimal_match(struct lzms_compressor *ctx)
 static void
 lzms_encode(struct lzms_compressor *ctx)
 {
 static void
 lzms_encode(struct lzms_compressor *ctx)
 {
-       struct raw_match match;
+       struct lz_match match;
 
        /* Load window into the binary tree match-finder.  */
        lz_bt_load_window(&ctx->mf, ctx->window, ctx->window_size);
 
        /* Load window into the binary tree match-finder.  */
        lz_bt_load_window(&ctx->mf, ctx->window, ctx->window_size);
index 190a729303fc041e18b43a51a1ac5e60ed52a37c..fbe255688f5004cda4e2d5d477464caeae0152af 100644 (file)
 #define LZX_CACHE_PER_POS      8
 
 #define LZX_CACHE_LEN (LZX_DIV_BLOCK_SIZE * (LZX_CACHE_PER_POS + 1))
 #define LZX_CACHE_PER_POS      8
 
 #define LZX_CACHE_LEN (LZX_DIV_BLOCK_SIZE * (LZX_CACHE_PER_POS + 1))
-#define LZX_CACHE_SIZE (LZX_CACHE_LEN * sizeof(struct raw_match))
+#define LZX_CACHE_SIZE (LZX_CACHE_LEN * sizeof(struct lz_match))
 #define LZX_MAX_MATCHES_PER_POS (LZX_MAX_MATCH_LEN - LZX_MIN_MATCH_LEN + 1)
 
 /* Codewords for the LZX main, length, and aligned offset Huffman codes  */
 #define LZX_MAX_MATCHES_PER_POS (LZX_MAX_MATCH_LEN - LZX_MIN_MATCH_LEN + 1)
 
 /* Codewords for the LZX main, length, and aligned offset Huffman codes  */
@@ -414,10 +414,10 @@ struct lzx_compressor {
         * subsequent passes.  This is suboptimal because different matches may
         * be preferred with different cost models, but seems to be a worthwhile
         * speedup.  */
         * subsequent passes.  This is suboptimal because different matches may
         * be preferred with different cost models, but seems to be a worthwhile
         * speedup.  */
-       struct raw_match *cached_matches;
-       struct raw_match *cache_ptr;
+       struct lz_match *cached_matches;
+       struct lz_match *cache_ptr;
        bool matches_cached;
        bool matches_cached;
-       struct raw_match *cache_limit;
+       struct lz_match *cache_limit;
 
        /* Match-chooser state.
         * When matches have been chosen, optimum_cur_idx is set to the position
 
        /* Match-chooser state.
         * When matches have been chosen, optimum_cur_idx is set to the position
@@ -1248,10 +1248,10 @@ lzx_set_costs(struct lzx_compressor * ctx, const struct lzx_lens * lens)
  * value is the number of matches found.  */
 static unsigned
 lzx_get_matches(struct lzx_compressor *ctx,
  * value is the number of matches found.  */
 static unsigned
 lzx_get_matches(struct lzx_compressor *ctx,
-               const struct raw_match **matches_ret)
+               const struct lz_match **matches_ret)
 {
 {
-       struct raw_match *cache_ptr;
-       struct raw_match *matches;
+       struct lz_match *cache_ptr;
+       struct lz_match *matches;
        unsigned num_matches;
 
        LZX_ASSERT(ctx->match_window_pos < ctx->match_window_end);
        unsigned num_matches;
 
        LZX_ASSERT(ctx->match_window_pos < ctx->match_window_end);
@@ -1324,7 +1324,7 @@ lzx_get_matches(struct lzx_compressor *ctx,
 static void
 lzx_skip_bytes(struct lzx_compressor *ctx, unsigned n)
 {
 static void
 lzx_skip_bytes(struct lzx_compressor *ctx, unsigned n)
 {
-       struct raw_match *cache_ptr;
+       struct lz_match *cache_ptr;
 
        LZX_ASSERT(n <= ctx->match_window_end - ctx->match_window_pos);
 
 
        LZX_ASSERT(n <= ctx->match_window_end - ctx->match_window_pos);
 
@@ -1349,7 +1349,7 @@ lzx_skip_bytes(struct lzx_compressor *ctx, unsigned n)
  *
  * Returns the first match in the list.
  */
  *
  * Returns the first match in the list.
  */
-static struct raw_match
+static struct lz_match
 lzx_match_chooser_reverse_list(struct lzx_compressor *ctx, unsigned cur_pos)
 {
        unsigned prev_link, saved_prev_link;
 lzx_match_chooser_reverse_list(struct lzx_compressor *ctx, unsigned cur_pos)
 {
        unsigned prev_link, saved_prev_link;
@@ -1375,7 +1375,7 @@ lzx_match_chooser_reverse_list(struct lzx_compressor *ctx, unsigned cur_pos)
 
        ctx->optimum_cur_idx = ctx->optimum[0].next.link;
 
 
        ctx->optimum_cur_idx = ctx->optimum[0].next.link;
 
-       return (struct raw_match)
+       return (struct lz_match)
                { .len = ctx->optimum_cur_idx,
                  .offset = ctx->optimum[0].next.match_offset,
                };
                { .len = ctx->optimum_cur_idx,
                  .offset = ctx->optimum[0].next.match_offset,
                };
@@ -1443,12 +1443,12 @@ lzx_match_chooser_reverse_list(struct lzx_compressor *ctx, unsigned cur_pos)
  * The return value is a (length, offset) pair specifying the match or literal
  * chosen.  For literals, the length is 0 or 1 and the offset is meaningless.
  */
  * The return value is a (length, offset) pair specifying the match or literal
  * chosen.  For literals, the length is 0 or 1 and the offset is meaningless.
  */
-static struct raw_match
+static struct lz_match
 lzx_get_near_optimal_match(struct lzx_compressor *ctx)
 {
        unsigned num_matches;
 lzx_get_near_optimal_match(struct lzx_compressor *ctx)
 {
        unsigned num_matches;
-       const struct raw_match *matches;
-       struct raw_match match;
+       const struct lz_match *matches;
+       struct lz_match match;
        unsigned longest_len;
        unsigned longest_rep_len;
        u32 longest_rep_offset;
        unsigned longest_len;
        unsigned longest_rep_len;
        u32 longest_rep_offset;
@@ -1493,7 +1493,7 @@ lzx_get_near_optimal_match(struct lzx_compressor *ctx)
        /* If there's a long match with a recent offset, take it.  */
        if (longest_rep_len >= ctx->params.alg_params.slow.nice_match_length) {
                lzx_skip_bytes(ctx, longest_rep_len);
        /* If there's a long match with a recent offset, take it.  */
        if (longest_rep_len >= ctx->params.alg_params.slow.nice_match_length) {
                lzx_skip_bytes(ctx, longest_rep_len);
-               return (struct raw_match) {
+               return (struct lz_match) {
                        .len = longest_rep_len,
                        .offset = longest_rep_offset,
                };
                        .len = longest_rep_len,
                        .offset = longest_rep_offset,
                };
@@ -1860,7 +1860,7 @@ lzx_optimize_block(struct lzx_compressor *ctx, struct lzx_block_spec *spec,
        const u8 *window_ptr;
        const u8 *window_end;
        struct lzx_item *next_chosen_match;
        const u8 *window_ptr;
        const u8 *window_end;
        struct lzx_item *next_chosen_match;
-       struct raw_match raw_match;
+       struct lz_match lz_match;
        struct lzx_item lzx_item;
 
        LZX_ASSERT(num_passes >= 1);
        struct lzx_item lzx_item;
 
        LZX_ASSERT(num_passes >= 1);
@@ -1885,15 +1885,15 @@ lzx_optimize_block(struct lzx_compressor *ctx, struct lzx_block_spec *spec,
 
                while (window_ptr != window_end) {
 
 
                while (window_ptr != window_end) {
 
-                       raw_match = lzx_get_near_optimal_match(ctx);
+                       lz_match = lzx_get_near_optimal_match(ctx);
 
 
-                       LZX_ASSERT(!(raw_match.len == LZX_MIN_MATCH_LEN &&
-                                    raw_match.offset == ctx->max_window_size -
+                       LZX_ASSERT(!(lz_match.len == LZX_MIN_MATCH_LEN &&
+                                    lz_match.offset == ctx->max_window_size -
                                                         LZX_MIN_MATCH_LEN));
                                                         LZX_MIN_MATCH_LEN));
-                       if (raw_match.len >= LZX_MIN_MATCH_LEN) {
-                               lzx_tally_match(raw_match.len, raw_match.offset,
+                       if (lz_match.len >= LZX_MIN_MATCH_LEN) {
+                               lzx_tally_match(lz_match.len, lz_match.offset,
                                                &freqs, &ctx->queue);
                                                &freqs, &ctx->queue);
-                               window_ptr += raw_match.len;
+                               window_ptr += lz_match.len;
                        } else {
                                lzx_tally_literal(*window_ptr, &freqs);
                                window_ptr += 1;
                        } else {
                                lzx_tally_literal(*window_ptr, &freqs);
                                window_ptr += 1;
@@ -1915,16 +1915,16 @@ lzx_optimize_block(struct lzx_compressor *ctx, struct lzx_block_spec *spec,
        next_chosen_match = spec->chosen_items;
 
        while (window_ptr != window_end) {
        next_chosen_match = spec->chosen_items;
 
        while (window_ptr != window_end) {
-               raw_match = lzx_get_near_optimal_match(ctx);
+               lz_match = lzx_get_near_optimal_match(ctx);
 
 
-               LZX_ASSERT(!(raw_match.len == LZX_MIN_MATCH_LEN &&
-                            raw_match.offset == ctx->max_window_size -
+               LZX_ASSERT(!(lz_match.len == LZX_MIN_MATCH_LEN &&
+                            lz_match.offset == ctx->max_window_size -
                                                 LZX_MIN_MATCH_LEN));
                                                 LZX_MIN_MATCH_LEN));
-               if (raw_match.len >= LZX_MIN_MATCH_LEN) {
-                       lzx_item.data = lzx_tally_match(raw_match.len,
-                                                        raw_match.offset,
+               if (lz_match.len >= LZX_MIN_MATCH_LEN) {
+                       lzx_item.data = lzx_tally_match(lz_match.len,
+                                                        lz_match.offset,
                                                         &freqs, &ctx->queue);
                                                         &freqs, &ctx->queue);
-                       window_ptr += raw_match.len;
+                       window_ptr += lz_match.len;
                } else {
                        lzx_item.data = lzx_tally_literal(*window_ptr, &freqs);
                        window_ptr += 1;
                } else {
                        lzx_item.data = lzx_tally_literal(*window_ptr, &freqs);
                        window_ptr += 1;