mirror of https://bitbucket.org/ausocean/av.git
codec/h264/h264dec/bits/bitreader.go: added ReadBool and ReadBitsInt methods
This commit is contained in:
parent
38f5f983e8
commit
16b4d570b6
|
@ -128,6 +128,24 @@ func (br *BitReader) ReadBits(n int) (uint64, error) {
|
|||
return r, nil
|
||||
}
|
||||
|
||||
// ReadBitsInt reads n bits from the source, and returns as an int.
|
||||
func (br *BitReader) ReadBitsInt(n int) (int, error) {
|
||||
b, err := br.ReadBits(n)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return int(b), nil
|
||||
}
|
||||
|
||||
// ReadBool reads a single bit from the source, converts to a bool and returns.
|
||||
func (br *BitReader) ReadBool() (bool, error) {
|
||||
b, err := br.ReadBits(1)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return b == 1, nil
|
||||
}
|
||||
|
||||
// PeekBits provides the next n bits returning them in the least-significant
|
||||
// part of a uint64, without advancing through the source.
|
||||
// For example, with a source as []byte{0x8f,0xe3} (1000 1111, 1110 0011), we
|
||||
|
|
Loading…
Reference in New Issue