MCPcopy
hub / github.com/bilibili/flv.js / readBits

Method readBits

src/demux/exp-golomb.js:53–77  ·  view source on GitHub ↗
(bits)

Source from the content-addressed store, hash-verified

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;

Callers 4

readBoolMethod · 0.95
readByteMethod · 0.95
readUEGMethod · 0.95
parseSPSMethod · 0.95

Calls 1

_fillCurrentWordMethod · 0.95

Tested by

no test coverage detected