BitReader
- class BitReader(*args, **kwargs)
BitReader
provides a bit reader that can read any number of bits
from a memory buffer. It provides functions for reading any number of bits
into 8, 16, 32 and 64 bit variables.
Methods
- class BitReader
-
- get_bits_uint16(nbits: int) tuple[bool, int]
Read
nbits
bits intoval
and update the current position.- Parameters:
nbits – number of bits to read
- get_bits_uint32(nbits: int) tuple[bool, int]
Read
nbits
bits intoval
and update the current position.- Parameters:
nbits – number of bits to read
- get_bits_uint64(nbits: int) tuple[bool, int]
Read
nbits
bits intoval
and update the current position.- Parameters:
nbits – number of bits to read
- get_bits_uint8(nbits: int) tuple[bool, int]
Read
nbits
bits intoval
and update the current position.- Parameters:
nbits – number of bits to read
- init(data: Sequence[int]) None
Initializes a
BitReader
instance to read fromdata
. This function can be called on already initialized instances.- Parameters:
data – data from which the bit reader should read
- peek_bits_uint16(nbits: int) tuple[bool, int]
Read
nbits
bits intoval
but keep the current position.- Parameters:
nbits – number of bits to read
- peek_bits_uint32(nbits: int) tuple[bool, int]
Read
nbits
bits intoval
but keep the current position.- Parameters:
nbits – number of bits to read
- peek_bits_uint64(nbits: int) tuple[bool, int]
Read
nbits
bits intoval
but keep the current position.- Parameters:
nbits – number of bits to read
- peek_bits_uint8(nbits: int) tuple[bool, int]
Read
nbits
bits intoval
but keep the current position.- Parameters:
nbits – number of bits to read
- set_pos(pos: int) bool
Sets the new position of a
BitReader
instance topos
in bits.- Parameters:
pos – The new position in bits