(bits)
| 51 | } |
| 52 | |
| 53 | readBits(bits) { |
| 54 | if (bits > 32) |
| 55 | throw new InvalidArgumentException('ExpGolomb: readBits() bits exceeded max 32bits!'); |
| 56 | |
| 57 | if (bits <= this._current_word_bits_left) { |
| 58 | let result = this._current_word >>> (32 - bits); |
| 59 | this._current_word <<= bits; |
| 60 | this._current_word_bits_left -= bits; |
| 61 | return result; |
| 62 | } |
| 63 | |
| 64 | let result = this._current_word_bits_left ? this._current_word : 0; |
| 65 | result = result >>> (32 - this._current_word_bits_left); |
| 66 | let bits_need_left = bits - this._current_word_bits_left; |
| 67 | |
| 68 | this._fillCurrentWord(); |
| 69 | let bits_read_next = Math.min(bits_need_left, this._current_word_bits_left); |
| 70 | |
| 71 | let result2 = this._current_word >>> (32 - bits_read_next); |
| 72 | this._current_word <<= bits_read_next; |
| 73 | this._current_word_bits_left -= bits_read_next; |
| 74 | |
| 75 | result = (result << bits_read_next) | result2; |
| 76 | return result; |
| 77 | } |
| 78 | |
| 79 | readBool() { |
| 80 | return this.readBits(1) === 1; |
no test coverage detected