1 unstable release

new 0.1.0 Feb 10, 2025
0.0.1 Feb 9, 2025

#466 in Video

46 downloads per month
Used in 5 crates (2 directly)

MIT/Apache

41KB
732 lines

scuffle-expgolomb

[!WARNING]
This crate is under active development and may not be stable.

crates.io docs.rs


A set of helper functions to encode and decode exponential-golomb values.

License

This project is licensed under the MIT or Apache-2.0 license. You can choose between one of them if you use this work.

SPDX-License-Identifier: MIT OR Apache-2.0


lib.rs:

A set of helper functions to encode and decode exponential-golomb values.

This crate extends upon the BitReader and BitWriter from the scuffle-bytes-util crate to provide functionality for reading and writing Exp-Golomb encoded numbers.

use scuffle_expgolomb::{BitReaderExpGolombExt, BitWriterExpGolombExt};
use scuffle_bytes_util::{BitReader, BitWriter};

let mut bit_writer = BitWriter::default();
bit_writer.write_exp_golomb(0)?;
bit_writer.write_exp_golomb(1)?;
bit_writer.write_exp_golomb(2)?;

let data: Vec<u8> = bit_writer.finish()?;

let mut bit_reader = BitReader::new(std::io::Cursor::new(data));

let result = bit_reader.read_exp_golomb()?;
assert_eq!(result, 0);

let result = bit_reader.read_exp_golomb()?;
assert_eq!(result, 1);

let result = bit_reader.read_exp_golomb()?;
assert_eq!(result, 2);

License

This project is licensed under the MIT or Apache-2.0 license. You can choose between one of them if you use this work.

SPDX-License-Identifier: MIT OR Apache-2.0

Dependencies

~220KB