#coding #exp #codec #bit #wikipedia #pattern #exponential-golomb

exp-golomb

Utilities for Exponential-Golomb coding

1 unstable release

0.1.0 Feb 10, 2023

#6 in #exp

Download history 8/week @ 2024-05-06 22/week @ 2024-05-20 33/week @ 2024-06-03 41/week @ 2024-07-01 10/week @ 2024-07-08 24/week @ 2024-07-15 1/week @ 2024-07-22 34/week @ 2024-07-29 32/week @ 2024-08-05 24/week @ 2024-08-19

90 downloads per month

MIT/Apache

18KB
242 lines

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));
}

lib.rs:

Utilities for Exponential-Golomb coding.

No runtime deps