init initializes and resets the bit reader.
(in []byte)
| 25 | |
| 26 | // init initializes and resets the bit reader. |
| 27 | func (b *bitReader) init(in []byte) error { |
| 28 | if len(in) < 1 { |
| 29 | return errors.New("corrupt stream: too short") |
| 30 | } |
| 31 | b.in = in |
| 32 | // The highest bit of the last byte indicates where to start |
| 33 | v := in[len(in)-1] |
| 34 | if v == 0 { |
| 35 | return errors.New("corrupt stream, did not find end of stream") |
| 36 | } |
| 37 | b.cursor = len(in) |
| 38 | b.bitsRead = 64 |
| 39 | b.value = 0 |
| 40 | if len(in) >= 8 { |
| 41 | b.fillFastStart() |
| 42 | } else { |
| 43 | b.fill() |
| 44 | b.fill() |
| 45 | } |
| 46 | b.bitsRead += 8 - uint8(highBits(uint32(v))) |
| 47 | return nil |
| 48 | } |
| 49 | |
| 50 | // getBits will return n bits. n can be 0. |
| 51 | func (b *bitReader) getBits(n uint8) int { |
nothing calls this directly
no test coverage detected