16 #define change_pair(small_dist, big_dist) \
17 (((big_dist) >> 7) > (small_dist))
25 const uint32_t nice_len = mf->nice_len;
29 if (mf->read_ahead == 0) {
30 len_main =
mf_find(mf, &matches_count, coder->matches);
32 assert(mf->read_ahead == 1);
33 len_main = coder->longest_match_length;
34 matches_count = coder->matches_count;
53 const uint8_t *
const buf_back =
buf - coder->reps[
i] - 1;
63 buf, buf_back, 2, buf_avail);
67 if (
len >= nice_len) {
82 if (len_main >= nice_len) {
83 *back_res = coder->matches[matches_count - 1].dist +
REPS;
91 back_main = coder->matches[matches_count - 1].dist;
93 while (matches_count > 1 && len_main ==
94 coder->matches[matches_count - 2].len + 1) {
96 matches_count - 2].dist,
101 len_main = coder->matches[matches_count - 1].len;
102 back_main = coder->matches[matches_count - 1].dist;
105 if (len_main == 2 && back_main >= 0x80)
110 if (rep_len + 1 >= len_main
111 || (rep_len + 2 >= len_main
113 || (rep_len + 3 >= len_main
114 && back_main > (
UINT32_C(1) << 15))) {
115 *back_res = rep_index;
122 if (len_main < 2 || buf_avail <= 2) {
130 coder->longest_match_length =
mf_find(mf,
131 &coder->matches_count, coder->matches);
133 if (coder->longest_match_length >= 2) {
134 const uint32_t new_dist = coder->matches[
135 coder->matches_count - 1].dist;
137 if ((coder->longest_match_length >= len_main
138 && new_dist < back_main)
139 || (coder->longest_match_length == len_main + 1
141 || (coder->longest_match_length > len_main + 1)
142 || (coder->longest_match_length + 1 >= len_main
159 if (memcmp(
buf,
buf - coder->reps[
i] - 1,
limit) == 0) {
166 *back_res = back_main +
REPS;
static uint32_t mf_avail(const lzma_mf *mf)
Get the number of bytes that haven't been ran through the match finder yet.
static const uint8_t * mf_ptr(const lzma_mf *mf)
Get pointer to the first byte not ran through the match finder.
static void mf_skip(lzma_mf *mf, uint32_t amount)
#define mf_find
Since everything else begins with mf_, use it also for lzma_mf_find().
#define change_pair(small_dist, big_dist)
void lzma_lzma_optimum_fast(lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf, uint32_t *restrict back_res, uint32_t *restrict len_res)
Private definitions for LZMA encoder.
#define not_equal_16(a, b)
Optimized comparison of two buffers.
assert(limit<=UINT32_MAX/2)
static uint32_t const uint8_t uint32_t uint32_t limit