#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 */
* 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. */
/* The high bit of the 32-bit intermediate representation
* indicates whether the item is an actual LZ-style match (1) or
/* The high bit of the 32-bit intermediate representation
* indicates whether the item is an actual LZ-style match (1) or
- struct lzx_match * chosen_matches,
- unsigned num_chosen_matches,
+ struct lzx_item * chosen_items,
+ unsigned num_chosen_items,
const struct lzx_codes * codes,
const struct lzx_codes * prev_codes,
struct output_bitstream * ostream)
const struct lzx_codes * codes,
const struct lzx_codes * prev_codes,
struct output_bitstream * ostream)
/* Write the actual matches and literals. */
lzx_write_matches_and_literals(ostream, block_type,
/* Write the actual matches and literals. */
lzx_write_matches_and_literals(ostream, block_type,
for (unsigned i = 0; i < ctx->num_blocks; i++) {
const struct lzx_block_spec *spec = &ctx->block_specs[i];
for (unsigned i = 0; i < ctx->num_blocks; i++) {
const struct lzx_block_spec *spec = &ctx->block_specs[i];
- LZX_DEBUG("Writing block %u/%u (type=%d, size=%u, num_chosen_matches=%u)...",
+ LZX_DEBUG("Writing block %u/%u (type=%d, size=%u, num_chosen_items=%u)...",
freqs->aligned[position_footer & 7]++;
/* Pack the position slot, position footer, and match length into an
freqs->aligned[position_footer & 7]++;
/* Pack the position slot, position footer, and match length into an
*/
LZX_ASSERT(LZX_MAX_POSITION_SLOTS <= 64);
LZX_ASSERT(lzx_get_num_extra_bits(LZX_MAX_POSITION_SLOTS - 1) <= 17);
*/
LZX_ASSERT(LZX_MAX_POSITION_SLOTS <= 64);
LZX_ASSERT(lzx_get_num_extra_bits(LZX_MAX_POSITION_SLOTS - 1) <= 17);
* 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,
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;
{ .len = ctx->optimum_cur_idx,
.offset = ctx->optimum[0].next.match_offset,
};
{ .len = ctx->optimum_cur_idx,
.offset = ctx->optimum[0].next.match_offset,
};
* 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.
*/
/* 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);
- struct lzx_match *next_chosen_match;
- struct raw_match raw_match;
- struct lzx_match lzx_match;
+ struct lzx_item *next_chosen_match;
+ struct lz_match lz_match;
+ struct lzx_item lzx_item;
- 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,
- spec->chosen_matches = &ctx->chosen_matches[spec->window_pos];
- next_chosen_match = spec->chosen_matches;
+ spec->chosen_items = &ctx->chosen_items[spec->window_pos];
+ next_chosen_match = spec->chosen_items;
- if (raw_match.len >= LZX_MIN_MATCH_LEN) {
- lzx_match.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,
lzx_make_huffman_codes(&freqs, &spec->codes, ctx->num_main_syms);
spec->block_type = lzx_choose_verbatim_or_aligned(&freqs, &spec->codes);
}
lzx_make_huffman_codes(&freqs, &spec->codes, ctx->num_main_syms);
spec->block_type = lzx_choose_verbatim_or_aligned(&freqs, &spec->codes);
}
/* Initialize symbol frequencies and match offset LRU queue. */
memset(&record_ctx.freqs, 0, sizeof(struct lzx_freqs));
lzx_lru_queue_init(&record_ctx.queue);
/* Initialize symbol frequencies and match offset LRU queue. */
memset(&record_ctx.freqs, 0, sizeof(struct lzx_freqs));
lzx_lru_queue_init(&record_ctx.queue);
/* Determine series of matches/literals to output. */
lz_analyze_block(ctx->window,
/* Determine series of matches/literals to output. */
lz_analyze_block(ctx->window,
- spec->num_chosen_matches = (record_ctx.matches - ctx->chosen_matches);
- spec->chosen_matches = ctx->chosen_matches;
+ spec->num_chosen_items = (record_ctx.matches - ctx->chosen_items);
+ spec->chosen_items = ctx->chosen_items;
- ctx->chosen_matches = MALLOC(window_size * sizeof(ctx->chosen_matches[0]));
- if (ctx->chosen_matches == NULL)
+ ctx->chosen_items = MALLOC(window_size * sizeof(ctx->chosen_items[0]));
+ if (ctx->chosen_items == NULL)
sizeof(((struct lzx_compressor*)0)->block_specs[0]);
if (params->algorithm == WIMLIB_LZX_ALGORITHM_SLOW) {
sizeof(((struct lzx_compressor*)0)->block_specs[0]);
if (params->algorithm == WIMLIB_LZX_ALGORITHM_SLOW) {
size += lz_bt_get_needed_memory(max_block_size);
size += (LZX_OPTIM_ARRAY_SIZE +
min(params->alg_params.slow.nice_match_length,
size += lz_bt_get_needed_memory(max_block_size);
size += (LZX_OPTIM_ARRAY_SIZE +
min(params->alg_params.slow.nice_match_length,