13#ifndef LZMA_RANGE_ENCODER_H
14#define LZMA_RANGE_ENCODER_H
23#define RC_SYMBOLS_MAX 53
89 uint32_t bit_count, uint32_t symbol)
91 uint32_t model_index = 1;
94 const uint32_t bit = (symbol >> --bit_count) & 1;
95 rc_bit(rc, &probs[model_index], bit);
96 model_index = (model_index << 1) + bit;
97 }
while (bit_count != 0);
103 uint32_t bit_count, uint32_t symbol)
105 uint32_t model_index = 1;
108 const uint32_t bit = symbol & 1;
110 rc_bit(rc, &probs[model_index], bit);
111 model_index = (model_index << 1) + bit;
112 }
while (--bit_count != 0);
118 uint32_t value, uint32_t bit_count)
122 = RC_DIRECT_0 + ((value >> --bit_count) & 1);
123 }
while (bit_count != 0);
130 for (
size_t i = 0;
i < 5; ++
i)
137 uint8_t *out,
size_t *
out_pos,
size_t out_size)
139 if ((uint32_t)(rc->
low) < (uint32_t)(0xFF000000)
140 || (uint32_t)(rc->
low >> 32) != 0) {
166rc_shift_low_dummy(uint64_t *low, uint64_t *cache_size, uint8_t *cache,
167 uint64_t *
out_pos, uint64_t out_size)
169 if ((uint32_t)(*low) < (uint32_t)(0xFF000000)
170 || (uint32_t)(*low >> 32) != 0) {
178 }
while (--*cache_size != 0);
180 *cache = (*low >> 24) & 0xFF;
192 uint8_t *out,
size_t *
out_pos,
size_t out_size)
199 if (rc_shift_low(rc, out,
out_pos, out_size))
218 const uint32_t bound = prob * (rc->
range
242 if (rc_shift_low(rc, out,
out_pos, out_size))
271 uint64_t low = rc->
low;
273 uint32_t range = rc->
range;
274 uint8_t cache = rc->
cache;
277 size_t pos = rc->
pos;
282 if (rc_shift_low_dummy(&low, &cache_size, &cache,
291 if (pos == rc->
count)
305 const uint32_t bound = prob * (range
333 for (pos = 0; pos < 5; ++pos) {
334 if (rc_shift_low_dummy(&low, &cache_size,
343static 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
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
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
Probability price calculation.
Common things for range encoder and decoder.