Function
rans_encode_symbol
(state: &mut u32, bitstream: &mut Vec<u8>, start: u32, freq: u32)
Source from the content-addressed store, hash-verified
| 223 | // --------------------------------------------------------------------------- |
| 224 | |
| 225 | fn rans_encode_symbol(state: &mut u32, bitstream: &mut Vec<u8>, start: u32, freq: u32) { |
| 226 | // Renormalize: output bytes until state is in the correct range. |
| 227 | let max_state = ((RANS_L >> PROB_BITS) << 8) * freq; |
| 228 | while *state >= max_state { |
| 229 | bitstream.push((*state & 0xFF) as u8); |
| 230 | *state >>= 8; |
| 231 | } |
| 232 | |
| 233 | // Encode symbol. |
| 234 | *state = ((*state / freq) << PROB_BITS) + (*state % freq) + start; |
| 235 | } |
| 236 | |
| 237 | fn rans_decode_symbol( |
| 238 | state: u32, |
Tested by
no test coverage detected