exp-golomb

Crates.ioexp-golomb
lib.rsexp-golomb
version0.1.0
sourcesrc
created_at2023-02-10 15:21:29.904153
updated_at2023-02-10 15:21:29.904153
descriptionUtilities for Exponential-Golomb coding
homepagehttps://github.com/JRF63/exp-golomb
repositoryhttps://github.com/JRF63/exp-golomb
max_upload_size
id781917
size18,906
Joseph Rafael Ferrer (JRF63)

documentation

README

exp-golomb

Encoder/decoder for Exponential-Golomb coding.

Using the Wikipedia example:

Number Bit pattern
0 1
1 010
2 011
3 00100
4 00101
5 00110
6 00111
7 0001000
8 000100
use exp_golomb::{ExpGolombDecoder, ExpGolombEncoder};

let mut buf = [0u8; 6];
let mut writer = ExpGolombEncoder::new(&mut buf, 0).unwrap();
for i in 0..=8 {
    writer.put_unsigned(i).unwrap();
}
writer.close();
    
assert_eq!(
    buf,
    [0b10100110, 0b01000010, 0b10011000, 0b11100010, 0b00000100, 0b10000000]
);

let mut reader = ExpGolombDecoder::new(&buf, 0).unwrap();
for i in 0..=8 {
    assert_eq!(reader.next_unsigned(), Some(i));
}
Commit count: 2

cargo fmt