Lines Matching +full:low +full:-

1 // SPDX-License-Identifier: 0BSD
27 uint64_t low; member
32 /// Number of bytes written out by rc_encode() -> rc_shift_low()
59 rc->low = 0; in rc_reset()
60 rc->cache_size = 1; in rc_reset()
61 rc->range = UINT32_MAX; in rc_reset()
62 rc->cache = 0; in rc_reset()
63 rc->out_total = 0; in rc_reset()
64 rc->count = 0; in rc_reset()
65 rc->pos = 0; in rc_reset()
73 assert(rc->pos == 0); in rc_forget()
74 rc->count = 0; in rc_forget()
81 rc->symbols[rc->count] = bit; in rc_bit()
82 rc->probs[rc->count] = prob; in rc_bit()
83 ++rc->count; in rc_bit()
94 const uint32_t bit = (symbol >> --bit_count) & 1; in rc_bittree()
112 } while (--bit_count != 0); in rc_bittree_reverse()
121 rc->symbols[rc->count++] in rc_direct()
122 = RC_DIRECT_0 + ((value >> --bit_count) & 1); in rc_direct()
131 rc->symbols[rc->count++] = RC_FLUSH; in rc_flush()
139 if ((uint32_t)(rc->low) < (uint32_t)(0xFF000000) in rc_shift_low()
140 || (uint32_t)(rc->low >> 32) != 0) { in rc_shift_low()
145 out[*out_pos] = rc->cache + (uint8_t)(rc->low >> 32); in rc_shift_low()
147 ++rc->out_total; in rc_shift_low()
148 rc->cache = 0xFF; in rc_shift_low()
150 } while (--rc->cache_size != 0); in rc_shift_low()
152 rc->cache = (rc->low >> 24) & 0xFF; in rc_shift_low()
155 ++rc->cache_size; in rc_shift_low()
156 rc->low = (rc->low & 0x00FFFFFF) << RC_SHIFT_BITS; in rc_shift_low()
163 // the dummy version these refer to the size of the whole range-encoded
166 rc_shift_low_dummy(uint64_t *low, uint64_t *cache_size, uint8_t *cache, in rc_shift_low_dummy() argument
169 if ((uint32_t)(*low) < (uint32_t)(0xFF000000) in rc_shift_low_dummy()
170 || (uint32_t)(*low >> 32) != 0) { in rc_shift_low_dummy()
178 } while (--*cache_size != 0); in rc_shift_low_dummy()
180 *cache = (*low >> 24) & 0xFF; in rc_shift_low_dummy()
184 *low = (*low & 0x00FFFFFF) << RC_SHIFT_BITS; in rc_shift_low_dummy()
194 assert(rc->count <= RC_SYMBOLS_MAX); in rc_encode()
196 while (rc->pos < rc->count) { in rc_encode()
198 if (rc->range < RC_TOP_VALUE) { in rc_encode()
202 rc->range <<= RC_SHIFT_BITS; in rc_encode()
206 switch (rc->symbols[rc->pos]) { in rc_encode()
208 probability prob = *rc->probs[rc->pos]; in rc_encode()
209 rc->range = (rc->range >> RC_BIT_MODEL_TOTAL_BITS) in rc_encode()
211 prob += (RC_BIT_MODEL_TOTAL - prob) >> RC_MOVE_BITS; in rc_encode()
212 *rc->probs[rc->pos] = prob; in rc_encode()
217 probability prob = *rc->probs[rc->pos]; in rc_encode()
218 const uint32_t bound = prob * (rc->range in rc_encode()
220 rc->low += bound; in rc_encode()
221 rc->range -= bound; in rc_encode()
222 prob -= prob >> RC_MOVE_BITS; in rc_encode()
223 *rc->probs[rc->pos] = prob; in rc_encode()
228 rc->range >>= 1; in rc_encode()
232 rc->range >>= 1; in rc_encode()
233 rc->low += rc->range; in rc_encode()
238 rc->range = UINT32_MAX; in rc_encode()
244 } while (++rc->pos < rc->count); in rc_encode()
256 ++rc->pos; in rc_encode()
259 rc->count = 0; in rc_encode()
260 rc->pos = 0; in rc_encode()
269 assert(rc->count <= RC_SYMBOLS_MAX); in rc_encode_dummy()
271 uint64_t low = rc->low; in rc_encode_dummy() local
272 uint64_t cache_size = rc->cache_size; in rc_encode_dummy()
273 uint32_t range = rc->range; in rc_encode_dummy()
274 uint8_t cache = rc->cache; in rc_encode_dummy()
275 uint64_t out_pos = rc->out_total; in rc_encode_dummy()
277 size_t pos = rc->pos; in rc_encode_dummy()
282 if (rc_shift_low_dummy(&low, &cache_size, &cache, in rc_encode_dummy()
291 if (pos == rc->count) in rc_encode_dummy()
295 switch (rc->symbols[pos]) { in rc_encode_dummy()
297 probability prob = *rc->probs[pos]; in rc_encode_dummy()
304 probability prob = *rc->probs[pos]; in rc_encode_dummy()
307 low += bound; in rc_encode_dummy()
308 range -= bound; in rc_encode_dummy()
318 low += range; in rc_encode_dummy()
330 // Flush the last bytes. This isn't in rc->symbols[] so we do in rc_encode_dummy()
334 if (rc_shift_low_dummy(&low, &cache_size, in rc_encode_dummy()
346 return rc->cache_size + 5 - 1; in rc_pending()