[−][src]Module compress::entropy::ari
Arithmetic encoder/decoder using the Range encoder underneath. Requires entropy
feature, enabled by default
Can be used in a general case of entropy coding stage. Supposed to be fast.
Links
http://en.wikipedia.org/wiki/Arithmetic_coding http://en.wikipedia.org/wiki/Range_encoding
Example
use std::io::{BufWriter, BufReader, Read, Write}; use compress::entropy::ari; // Encode some text let text = "some text"; let mut e = ari::ByteEncoder::new(BufWriter::new(Vec::new())); e.write_all(text.as_bytes()).unwrap(); let (encoded, _) = e.finish(); let inner = encoded.into_inner().unwrap(); // Decode the encoded text let mut d = ari::ByteDecoder::new(BufReader::new(&inner[..])); let mut decoded = Vec::new(); d.read_to_end(&mut decoded).unwrap();
Credit
This is an original implementation.
Re-exports
pub use self::table::ByteDecoder; |
pub use self::table::ByteEncoder; |
Modules
apm | Adaptive Probability Models |
bin | Binary models for the arithmetic coder. The simplicity of the domain allows for normalized updates in place using bit shifts. |
table | Frequency table models for the arithmetic coder. The module also implements Reader/Writer using simple byte coding. |
Structs
Decoder | An arithmetic decoder helper |
Encoder | An arithmetic encoder helper |
RangeEncoder | Range Encoder basic primitive Gets probability ranges on the input, produces whole bytes of code on the output, where the code is an arbitrary fixed-ppoint value inside the resulting probability range. |
Constants
RANGE_DEFAULT_THRESHOLD |
Traits
Model | An abstract model to produce probability ranges Can be a table, a mix of tables, or just a smart function. |
Type Definitions
Border | |
Symbol |