| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
#ifndef LZMA_LZMA_ENCODER_PRIVATE_H |
| 14 |
#define LZMA_LZMA_ENCODER_PRIVATE_H |
| 15 |
|
| 16 |
#include "lz_encoder.h" |
| 17 |
#include "range_encoder.h" |
| 18 |
#include "lzma_common.h" |
| 19 |
#include "lzma_encoder.h" |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#ifdef TUKLIB_FAST_UNALIGNED_ACCESS |
| 27 |
# define not_equal_16(a, b) (read16ne(a) != read16ne(b)) |
| 28 |
#else |
| 29 |
# define not_equal_16(a, b) \ |
| 30 |
((a)[0] != (b)[0] || (a)[1] != (b)[1]) |
| 31 |
#endif |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
#define OPTS (1 << 12) |
| 36 |
|
| 37 |
|
| 38 |
typedef struct { |
| 39 |
probability choice; |
| 40 |
probability choice2; |
| 41 |
probability low[POS_STATES_MAX][LEN_LOW_SYMBOLS]; |
| 42 |
probability mid[POS_STATES_MAX][LEN_MID_SYMBOLS]; |
| 43 |
probability high[LEN_HIGH_SYMBOLS]; |
| 44 |
|
| 45 |
uint32_t prices[POS_STATES_MAX][LEN_SYMBOLS]; |
| 46 |
uint32_t table_size; |
| 47 |
uint32_t counters[POS_STATES_MAX]; |
| 48 |
|
| 49 |
} lzma_length_encoder; |
| 50 |
|
| 51 |
|
| 52 |
typedef struct { |
| 53 |
lzma_lzma_state state; |
| 54 |
|
| 55 |
bool prev_1_is_literal; |
| 56 |
bool prev_2; |
| 57 |
|
| 58 |
uint32_t pos_prev_2; |
| 59 |
uint32_t back_prev_2; |
| 60 |
|
| 61 |
uint32_t price; |
| 62 |
uint32_t pos_prev; |
| 63 |
uint32_t back_prev; |
| 64 |
|
| 65 |
uint32_t backs[REPS]; |
| 66 |
|
| 67 |
} lzma_optimal; |
| 68 |
|
| 69 |
|
| 70 |
struct lzma_lzma1_encoder_s { |
| 71 |
|
| 72 |
lzma_range_encoder rc; |
| 73 |
|
| 74 |
|
| 75 |
uint64_t uncomp_size; |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
uint64_t out_limit; |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
uint64_t *uncomp_size_ptr; |
| 85 |
|
| 86 |
|
| 87 |
lzma_lzma_state state; |
| 88 |
|
| 89 |
|
| 90 |
uint32_t reps[REPS]; |
| 91 |
|
| 92 |
|
| 93 |
lzma_match matches[MATCH_LEN_MAX + 1]; |
| 94 |
|
| 95 |
|
| 96 |
uint32_t matches_count; |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
uint32_t longest_match_length; |
| 101 |
|
| 102 |
|
| 103 |
bool fast_mode; |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
bool is_initialized; |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
bool is_flushed; |
| 112 |
|
| 113 |
|
| 114 |
bool use_eopm; |
| 115 |
|
| 116 |
uint32_t pos_mask; |
| 117 |
uint32_t literal_context_bits; |
| 118 |
uint32_t literal_mask; |
| 119 |
|
| 120 |
|
| 121 |
probability literal[LITERAL_CODERS_MAX * LITERAL_CODER_SIZE]; |
| 122 |
probability is_match[STATES][POS_STATES_MAX]; |
| 123 |
probability is_rep[STATES]; |
| 124 |
probability is_rep0[STATES]; |
| 125 |
probability is_rep1[STATES]; |
| 126 |
probability is_rep2[STATES]; |
| 127 |
probability is_rep0_long[STATES][POS_STATES_MAX]; |
| 128 |
probability dist_slot[DIST_STATES][DIST_SLOTS]; |
| 129 |
probability dist_special[FULL_DISTANCES - DIST_MODEL_END]; |
| 130 |
probability dist_align[ALIGN_SIZE]; |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
lzma_length_encoder match_len_encoder; |
| 135 |
lzma_length_encoder rep_len_encoder; |
| 136 |
|
| 137 |
|
| 138 |
uint32_t dist_slot_prices[DIST_STATES][DIST_SLOTS]; |
| 139 |
uint32_t dist_prices[DIST_STATES][FULL_DISTANCES]; |
| 140 |
uint32_t dist_table_size; |
| 141 |
uint32_t match_price_count; |
| 142 |
|
| 143 |
uint32_t align_prices[ALIGN_SIZE]; |
| 144 |
uint32_t align_price_count; |
| 145 |
|
| 146 |
|
| 147 |
uint32_t opts_end_index; |
| 148 |
uint32_t opts_current_index; |
| 149 |
lzma_optimal opts[OPTS]; |
| 150 |
}; |
| 151 |
|
| 152 |
|
| 153 |
extern void lzma_lzma_optimum_fast( |
| 154 |
lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf, |
| 155 |
uint32_t *restrict back_res, uint32_t *restrict len_res); |
| 156 |
|
| 157 |
extern void lzma_lzma_optimum_normal(lzma_lzma1_encoder *restrict coder, |
| 158 |
lzma_mf *restrict mf, uint32_t *restrict back_res, |
| 159 |
uint32_t *restrict len_res, uint32_t position); |
| 160 |
|
| 161 |
#endif |