mirror of
https://github.com/koush/scrypted.git
synced 2026-02-03 14:13:28 +00:00
rebroadcast: remove some bit shifting in favor of read/write uintbe
This commit is contained in:
@@ -29,11 +29,8 @@ export function createAUHeader(
|
||||
// Combine size and index into a single value
|
||||
const combinedValue = (frameSize << indexLength) | auIndex;
|
||||
|
||||
// Convert to bytes (little-endian within the multi-byte value)
|
||||
const header = new Buffer(totalBytes);
|
||||
for (let i = 0; i < totalBytes; i++) {
|
||||
header[i] = (combinedValue >> ((totalBytes - 1 - i) * 8)) & 0xFF;
|
||||
}
|
||||
const header = Buffer.alloc(totalBytes);
|
||||
header.writeUintBE(combinedValue, 0, totalBytes);
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
@@ -224,10 +224,7 @@ function parseNALUUnits(buffer: Buffer, offset: number, length: number, naluLeng
|
||||
}
|
||||
|
||||
while (pos + naluLengthSize <= offset + length) {
|
||||
let naluLength = 0;
|
||||
for (let i = 0; i < naluLengthSize; i++) {
|
||||
naluLength = (naluLength << 8) | buffer[pos + i];
|
||||
}
|
||||
const naluLength = buffer.readUintBE(pos, naluLengthSize);
|
||||
pos += naluLengthSize;
|
||||
|
||||
if (naluLength === 0) {
|
||||
|
||||
Reference in New Issue
Block a user