MCPcopy Create free account
hub / github.com/Vanilagy/webcodecs-polyfill / readLeb128

Function readLeb128

src/codec_data.ts:1193–1217  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1191 const bitstream = new Bitstream(packet);
1192
1193 const readLeb128 = (): number | null => {
1194 let value = 0;
1195
1196 for (let i = 0; i < 8; i++) {
1197 const byte = bitstream.readAlignedByte();
1198
1199 value |= ((byte & 0x7f) << (i * 7));
1200
1201 if (!(byte & 0x80)) {
1202 break;
1203 }
1204
1205 // Spec requirement
1206 if (i === 7 && (byte & 0x80)) {
1207 return null;
1208 }
1209 }
1210
1211 // Spec requirement
1212 if (value >= 2 ** 32 - 1) {
1213 return null;
1214 }
1215
1216 return value;
1217 };
1218
1219 while (bitstream.getBitsLeft() >= 8) {
1220 // Parse OBU header

Callers 1

codec_data.tsFile · 0.85

Calls 1

readAlignedByteMethod · 0.80

Tested by

no test coverage detected