14#ifndef LZMA_RANGE_ENCODER_H
15#define LZMA_RANGE_ENCODER_H
24#define RC_SYMBOLS_MAX 53
90 uint32_t bit_count, uint32_t symbol)
92 uint32_t model_index = 1;
95 const uint32_t bit = (symbol >> --bit_count) & 1;
96 rc_bit(rc, &probs[model_index], bit);
97 model_index = (model_index << 1) + bit;
98 }
while (bit_count != 0);
104 uint32_t bit_count, uint32_t symbol)
106 uint32_t model_index = 1;
109 const uint32_t bit = symbol & 1;
111 rc_bit(rc, &probs[model_index], bit);
112 model_index = (model_index << 1) + bit;
113 }
while (--bit_count != 0);
119 uint32_t value, uint32_t bit_count)
123 = RC_DIRECT_0 + ((value >> --bit_count) & 1);
124 }
while (bit_count != 0);
131 for (
size_t i = 0;
i < 5; ++
i)
138 uint8_t *out,
size_t *
out_pos,
size_t out_size)
140 if ((uint32_t)(rc->
low) < (uint32_t)(0xFF000000)
141 || (uint32_t)(rc->
low >> 32) != 0) {
167rc_shift_low_dummy(uint64_t *low, uint64_t *cache_size, uint8_t *cache,
168 uint64_t *
out_pos, uint64_t out_size)
170 if ((uint32_t)(*low) < (uint32_t)(0xFF000000)
171 || (uint32_t)(*low >> 32) != 0) {
179 }
while (--*cache_size != 0);
181 *cache = (*low >> 24) & 0xFF;
193 uint8_t *out,
size_t *
out_pos,
size_t out_size)
200 if (rc_shift_low(rc, out,
out_pos, out_size))
219 const uint32_t bound = prob * (rc->
range
243 if (rc_shift_low(rc, out,
out_pos, out_size))
272 uint64_t low = rc->
low;
274 uint32_t range = rc->
range;
275 uint8_t cache = rc->
cache;
278 size_t pos = rc->
pos;
283 if (rc_shift_low_dummy(&low, &cache_size, &cache,
292 if (pos == rc->
count)
306 const uint32_t bound = prob * (range
334 for (pos = 0; pos < 5; ++pos) {
335 if (rc_shift_low_dummy(&low, &cache_size,
344static inline uint64_t
#define RC_BIT_1(p, prob)
Definition LzmaEnc.c:808
#define RC_BIT_0(p, prob)
Definition LzmaEnc.c:804
#define assert(condition)
Definition lz4.c:273
Definition range_encoder.h:27
probability * probs[RC_SYMBOLS_MAX]
Probabilities associated with RC_BIT_0 or RC_BIT_1.
Definition range_encoder.h:52
uint64_t cache_size
Definition range_encoder.h:29
size_t pos
rc_encode()'s position in the tables
Definition range_encoder.h:40
uint32_t range
Definition range_encoder.h:30
enum lzma_range_encoder::@106 symbols[RC_SYMBOLS_MAX]
Symbols to encode.
uint8_t cache
Definition range_encoder.h:31
size_t count
Number of symbols in the tables.
Definition range_encoder.h:37
uint64_t out_total
Number of bytes written out by rc_encode() -> rc_shift_low()
Definition range_encoder.h:34
uint64_t low
Definition range_encoder.h:28
@ RC_BIT_1
Definition range_encoder.h:45
@ RC_BIT_0
Definition range_encoder.h:44
@ RC_FLUSH
Definition range_encoder.h:48
@ RC_DIRECT_0
Definition range_encoder.h:46
@ RC_DIRECT_1
Definition range_encoder.h:47
const lzma_allocator const uint8_t size_t uint8_t size_t * out_pos
Definition block.h:528
const lzma_allocator const uint8_t size_t uint8_t * out
Definition block.h:528
lzma_index ** i
Definition index.h:629
#define UINT32_MAX
Definition lzma.h:158
Probability price calculation.
Common things for range encoder and decoder.
uint16_t probability
Type of probabilities used with range coder.
Definition range_common.h:69
#define RC_BIT_MODEL_TOTAL_BITS
Definition range_common.h:27
#define RC_MOVE_BITS
Definition range_common.h:29
#define RC_SHIFT_BITS
Definition range_common.h:24
#define RC_TOP_VALUE
Definition range_common.h:26
#define RC_BIT_MODEL_TOTAL
Definition range_common.h:28
#define rc_direct(dest, seq)
Decode a bit without using a probability.
Definition range_decoder.h:171
#define rc_bit(prob, action0, action1, seq)
Definition range_decoder.h:154
#define rc_reset(range_decoder)
Resets the range decoder structure.
Definition range_decoder.h:69
#define RC_SYMBOLS_MAX
Definition range_encoder.h:24