img_core/bits.rs#
Source: lib/img_core/bits.rs
bits -- the bit readers of the codecs (MSB-first and LSB-first) [ASMLIB/inc/img_int.inc]
BrM (MSB first: JPEG entropy data without stuffing, HEVC, AV1 headers, JXR)
BrL (LSB first: deflate, VP8L, JPEG XL)
r = BrX::new(data, pos); r.refill(); r.get(n) / r.peek(n) / r.skip(n); r.overrun()
The state of the assembly macros: a 64-bit buffer, a bit count and a byte position that
keeps counting past the end of the data (zero bytes are shifted in there, nothing is
read). After refill() at least 56 bits are available. overrun() is BRx_OVERRUN: more
zero padding bytes consumed than bits are left. Values of n: 1..56 (get / peek / skip).
struct BrM<'a>MSB-first reader (BRM_*)data: &'a [u8]buf: u64cnt: u32pos: usize-- may pass data.len()
impl<'a> BrM<'a>
fn new(data: &'a [u8], pos: usize) -> SelfBRM_INIT with the byte position posfn refill(&mut self)BRM_REFILL: at least 56 bits in the bufferfn peek(&self, n: u32) -> u64BRM_PEEK: the next n bitsfn skip(&mut self, n: u32)BRM_SKIPfn get(&mut self, n: u32) -> u64BRM_GET / BRM_GETVfn overrun(&self) -> boolBRM_OVERRUN: true when more padding bytes were consumed than bits are leftstruct BrL<'a>LSB-first reader (BRL_*)data: &'a [u8]buf: u64cnt: u32pos: usize-- may pass data.len()
impl<'a> BrL<'a>
fn new(data: &'a [u8], pos: usize) -> SelfBRL_INIT with the byte position posfn refill(&mut self)BRL_REFILL: at least 56 bits in the bufferfn peek(&self, n: u32) -> u64BRL_PEEK: the next n bitsfn skip(&mut self, n: u32)BRL_SKIPfn get(&mut self, n: u32) -> u64BRL_GET / BRL_GETVfn overrun(&self) -> boolBRL_OVERRUN