Rizin
unix-like reverse engineering framework and cli tools
lzma_encoder_private.h
Go to the documentation of this file.
1 //
6 // Authors: Igor Pavlov
7 // Lasse Collin
8 //
9 // This file has been put into the public domain.
10 // You can do whatever you want with this file.
11 //
13 
14 #ifndef LZMA_LZMA_ENCODER_PRIVATE_H
15 #define LZMA_LZMA_ENCODER_PRIVATE_H
16 
17 #include "lz_encoder.h"
18 #include "range_encoder.h"
19 #include "lzma_common.h"
20 #include "lzma_encoder.h"
21 
22 
23 // Macro to compare if the first two bytes in two buffers differ. This is
24 // needed in lzma_lzma_optimum_*() to test if the match is at least
25 // MATCH_LEN_MIN bytes. Unaligned access gives tiny gain so there's no
26 // reason to not use it when it is supported.
27 #ifdef TUKLIB_FAST_UNALIGNED_ACCESS
28 # define not_equal_16(a, b) (read16ne(a) != read16ne(b))
29 #else
30 # define not_equal_16(a, b) \
31  ((a)[0] != (b)[0] || (a)[1] != (b)[1])
32 #endif
33 
34 
35 // Optimal - Number of entries in the optimum array.
36 #define OPTS (1 << 12)
37 
38 
39 typedef struct {
45 
49 
51 
52 
53 typedef struct {
55 
57  bool prev_2;
58 
61 
63  uint32_t pos_prev; // pos_next;
65 
66  uint32_t backs[REPS];
67 
68 } lzma_optimal;
69 
70 
74 
77 
80 
83 
86 
90 
92  bool fast_mode;
93 
97 
101 
105 
106  // These are the same as in lzma_decoder.c. See comments there.
117 
118  // These are the same as in lzma_decoder.c except that the encoders
119  // include also price tables.
122 
123  // Price tables
128 
131 
132  // Optimal
136 };
137 
138 
139 extern void lzma_lzma_optimum_fast(
141  uint32_t *restrict back_res, uint32_t *restrict len_res);
142 
144  lzma_mf *restrict mf, uint32_t *restrict back_res,
145  uint32_t *restrict len_res, uint32_t position);
146 
147 #endif
#define restrict
LZ in window and match finder API.
Private definitions common to LZMA encoder and decoder.
#define MATCH_LEN_MAX
Definition: lzma_common.h:168
#define LEN_SYMBOLS
Definition: lzma_common.h:164
lzma_lzma_state
Definition: lzma_common.h:56
#define LEN_LOW_SYMBOLS
Definition: lzma_common.h:159
#define LITERAL_CODER_SIZE
Definition: lzma_common.h:115
#define REPS
Definition: lzma_common.h:223
#define DIST_STATES
Definition: lzma_common.h:179
#define LEN_MID_SYMBOLS
Definition: lzma_common.h:161
#define FULL_DISTANCES
Definition: lzma_common.h:213
#define ALIGN_SIZE
Definition: lzma_common.h:218
#define POS_STATES_MAX
Definition: lzma_common.h:28
#define DIST_SLOTS
Definition: lzma_common.h:190
#define DIST_MODEL_END
Definition: lzma_common.h:209
#define LEN_HIGH_SYMBOLS
Definition: lzma_common.h:163
#define STATES
Total number of states.
Definition: lzma_common.h:73
#define LITERAL_CODERS_MAX
Maximum number of literal coders.
Definition: lzma_common.h:118
LZMA encoder API.
#define OPTS
void lzma_lzma_optimum_normal(lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf, uint32_t *restrict back_res, uint32_t *restrict len_res, uint32_t position)
void lzma_lzma_optimum_fast(lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf, uint32_t *restrict back_res, uint32_t *restrict len_res)
uint16_t probability
Type of probabilities used with range coder.
Definition: range_common.h:69
Range Encoder.
unsigned int uint32_t
Definition: sftypes.h:29
uint32_t reps[REPS]
The four most recent match distances.
lzma_match matches[MATCH_LEN_MAX+1]
Array of match candidates.
probability literal[LITERAL_CODERS_MAX][LITERAL_CODER_SIZE]
probability is_rep0_long[STATES][POS_STATES_MAX]
probability is_rep1[STATES]
uint32_t pos_mask
(1 << pos_bits) - 1
lzma_range_encoder rc
Range encoder.
probability is_rep0[STATES]
bool fast_mode
True if using getoptimumfast.
probability is_rep2[STATES]
probability dist_special[FULL_DISTANCES - DIST_MODEL_END]
uint32_t align_prices[ALIGN_SIZE]
lzma_optimal opts[OPTS]
probability is_rep[STATES]
lzma_length_encoder match_len_encoder
uint32_t dist_prices[DIST_STATES][FULL_DISTANCES]
probability dist_slot[DIST_STATES][DIST_SLOTS]
lzma_lzma_state state
State.
uint32_t dist_slot_prices[DIST_STATES][DIST_SLOTS]
uint32_t matches_count
Number of match candidates in matches[].
probability dist_align[ALIGN_SIZE]
probability is_match[STATES][POS_STATES_MAX]
lzma_length_encoder rep_len_encoder
lzma_lzma_state state