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

Method writeBits

src/misc.ts:443–457  ·  view source on GitHub ↗
(n: number, value: number)

Source from the content-addressed store, hash-verified

441 }
442
443 writeBits(n: number, value: number) {
444 const end = this.pos + n;
445
446 for (let i = this.pos; i < end; i++) {
447 const byteIndex = Math.floor(i / 8);
448 let byte = this.bytes[byteIndex];
449 const bitIndex = 0b111 - (i & 0b111);
450
451 byte &= ~(1 << bitIndex);
452 byte |= ((value & (1 << (end - i - 1))) >> (end - i - 1)) << bitIndex;
453 this.bytes[byteIndex] = byte;
454 }
455
456 this.pos = end;
457 };
458
459 readAlignedByte() {
460 // Ensure we're byte-aligned

Callers 1

aacToAdtsFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected