Skip to main content

Module bit_reader

Module bit_reader 

Source
Expand description

Forward, MSB-first bit reader with exp-Golomb decoders.

Used by every codec parser in this crate. Behavior:

  • Bits are consumed MSB first within each byte.
  • read_bits(n) supports 1 <= n <= 32. Larger widths are not meaningful for any codec field in scope.
  • read_ue_v / read_se_v implement H.264/H.265 unsigned and signed exp-Golomb coding. Codes wider than 32 bits return CodecError::GolombOverflow rather than panicking.
  • End-of-stream always returns a structured CodecError::EndOfStream; no panics on arbitrary input. This is the invariant the proptest harness relies on.

Emulation-prevention byte (0x03) removal lives on rbsp_from_ebsp because it is codec-agnostic.

Structs§

BitReader

Functions§

rbsp_from_ebsp
Strip H.264/H.265 emulation-prevention bytes: whenever the encoder emits 0x00 0x00 0x00 or 0x00 0x00 0x01 or 0x00 0x00 0x02 or 0x00 0x00 0x03 in the NAL payload, it inserts a 0x03 byte after the two zeros to distinguish from a start code. Reverse that transformation so the decoder sees the raw RBSP.