pub struct HuffTable {
pub dng_bug16: bool,
pub has_diffs: bool,
/* private fields */
}Expand description
A canonical Huffman table with fast lookup.
Fields§
§dng_bug16: boolLossless JPEG/DNG quirk: a length-16 symbol means diff = -32768 with no extra bits.
has_diffs: boolWhether diff bits follow the symbol (false: the symbol value itself is the result).
Implementations§
Source§impl HuffTable
impl HuffTable
Sourcepub fn from_counts(
counts: &[u8],
values: &[u8],
has_diffs: bool,
) -> Result<Self>
pub fn from_counts( counts: &[u8], values: &[u8], has_diffs: bool, ) -> Result<Self>
Build from JPEG-style counts (codes per length 1..=16) and values.
Sourcepub fn from_lengths(lengths: &[(u8, u8)], has_diffs: bool) -> Result<Self>
pub fn from_lengths(lengths: &[(u8, u8)], has_diffs: bool) -> Result<Self>
Build from a list of (code_length, symbol) pairs in canonical order
(helper for vendors that specify tables as code lengths).
Sourcepub fn decode_symbol<B: BitRead>(&self, bits: &mut B) -> Result<u32>
pub fn decode_symbol<B: BitRead>(&self, bits: &mut B) -> Result<u32>
Decode one symbol (no diff handling).
Sourcepub fn decode_diff<B: BitRead>(&self, bits: &mut B) -> Result<i32>
pub fn decode_diff<B: BitRead>(&self, bits: &mut B) -> Result<i32>
Decode a symbol giving a bit length, then read and sign-extend that many diff bits.
Sourcepub fn decode_diff_buffered<B: BitRead>(
&self,
bits: &mut B,
err: &mut bool,
) -> i32
pub fn decode_diff_buffered<B: BitRead>( &self, bits: &mut B, err: &mut bool, ) -> i32
Decode one difference assuming at least 27 bits are buffered (the caller refilled,
e.g. with BitRead::fill_to):
table hits need no refill and no error path. Rare cases (codes longer than the
lookup table, 16-bit differences, invalid codes) fall back to the general decoder;
a corrupt code sets *err and yields 0 so hot loops avoid per-sample Results.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HuffTable
impl RefUnwindSafe for HuffTable
impl Send for HuffTable
impl Sync for HuffTable
impl Unpin for HuffTable
impl UnsafeUnpin for HuffTable
impl UnwindSafe for HuffTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more