Documentation
¶
Overview ¶
Package bits provides an MSB-first bit reader matching the bit-position and overrun semantics of minimp3's bs_t/get_bits (see minimp3.h, CC0-1.0), which every decode unit in this package reads its bitstream through.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is an MSB-first bit reader. Position and limit are tracked in bits, not bytes, mirroring upstream bs_t.
func NewReader ¶
NewReader creates a Reader over buf with the limit set to the full buffer length in bits (8*len(buf)), mirroring upstream bs_init.
func NewReaderBits ¶
NewReaderBits creates a Reader over buf starting at posBits with an explicit bit limit, for callers that seek into a shared buffer (e.g. the bit reservoir) rather than starting at byte 0.
func (*Reader) Bits ¶
Bits reads the next n bits (n in [0,24]) MSB-first and advances the position, porting upstream get_bits exactly: the position always advances by n first, and a read that pushes it past the limit returns 0 and latches Overrun. Since pos never moves backward on its own, every read after that also lands past the limit and returns 0 too.