|
|
@ -49,6 +49,11 @@ func (r *Reader) ReadBits(bits uint) (n uint64) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// discards up to bits bits. returns a bool indicating wheter any errors occured.
|
|
|
|
|
|
|
|
func (r *Reader) DiscardBits(n int) {
|
|
|
|
|
|
|
|
r.ReadBits(uint(n))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ReadByte reads a single byte, regardless of alignment.
|
|
|
|
// ReadByte reads a single byte, regardless of alignment.
|
|
|
|
func (r *Reader) ReadByte() (byte, error) {
|
|
|
|
func (r *Reader) ReadByte() (byte, error) {
|
|
|
|
if r.bits == 0 {
|
|
|
|
if r.bits == 0 {
|
|
|
@ -73,6 +78,17 @@ func (r *Reader) Read(buf []byte) (int, error) {
|
|
|
|
return len(buf), nil
|
|
|
|
return len(buf), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// discards N byte of data on the reader or until EOF
|
|
|
|
|
|
|
|
func (r *Reader) DiscardBytes(n int) {
|
|
|
|
|
|
|
|
for i := 0; i < n; i++ {
|
|
|
|
|
|
|
|
_, err := r.ReadByte()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
r.err = err
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ReadUbitVar reads a prefixed uint value. A prefix is 2 bits wide, followed
|
|
|
|
// ReadUbitVar reads a prefixed uint value. A prefix is 2 bits wide, followed
|
|
|
|
// by the 4 least-significant bits, then a variable number of most-significant
|
|
|
|
// by the 4 least-significant bits, then a variable number of most-significant
|
|
|
|
// bits based on the prefix.
|
|
|
|
// bits based on the prefix.
|
|
|
|