|
|
|
@ -108,11 +108,12 @@ export class MonoDisplayFile implements MonoFormatFile { |
|
|
|
(section.flags.clearBuffer ?? false ? 0x04 : 0); |
|
|
|
(section.flags.clearBuffer ?? false ? 0x04 : 0); |
|
|
|
|
|
|
|
|
|
|
|
const encodedEls = section.elements.map(el => this.#encodeElement(el)); |
|
|
|
const encodedEls = section.elements.map(el => this.#encodeElement(el)); |
|
|
|
const sectionDataSize = 4 + encodedEls.reduce((s, e) => s + e.byteLength, 0); |
|
|
|
// sub-header: flags(2) + numElements(2) + startTimestamp(8) + endTimestamp(8) = 20 bytes
|
|
|
|
|
|
|
|
const sectionDataSize = 20 + encodedEls.reduce((s, e) => s + e.byteLength, 0); |
|
|
|
// sectionSize (in header) = 4 (header) + sectionDataSize
|
|
|
|
// sectionSize (in header) = 4 (header) + sectionDataSize
|
|
|
|
const sectionSize = 4 + sectionDataSize; |
|
|
|
const sectionSize = 4 + sectionDataSize; |
|
|
|
|
|
|
|
|
|
|
|
const hdr = new Uint8Array(4 + 5*4); // section header (4) + section sub-header (4)
|
|
|
|
const hdr = new Uint8Array(4 + 20); // section header (4) + sub-header (20)
|
|
|
|
const v = new DataView(hdr.buffer); |
|
|
|
const v = new DataView(hdr.buffer); |
|
|
|
v.setUint8(0, section.sectionType); |
|
|
|
v.setUint8(0, section.sectionType); |
|
|
|
v.setUint8(1, sectionSize & 0xFF); |
|
|
|
v.setUint8(1, sectionSize & 0xFF); |
|
|
|
@ -121,12 +122,12 @@ export class MonoDisplayFile implements MonoFormatFile { |
|
|
|
v.setUint16(4, flagBits, true); // flags
|
|
|
|
v.setUint16(4, flagBits, true); // flags
|
|
|
|
v.setUint16(6, section.elements.length, true); // numElements
|
|
|
|
v.setUint16(6, section.elements.length, true); // numElements
|
|
|
|
|
|
|
|
|
|
|
|
// section.startTimestamp.valueOf()
|
|
|
|
const start = section.startTimestamp ?? 0n; |
|
|
|
const startTimestampLow = 0, startTimestampHigh = 0, endTimestampLow = 0, endTimestampHigh = 0; |
|
|
|
const end = section.endTimestamp ?? 0n; |
|
|
|
v.setUint32(8, startTimestampLow, true); // flags
|
|
|
|
v.setUint32( 8, Number(start & 0xFFFFFFFFn), true); |
|
|
|
v.setUint32(12, startTimestampHigh, true); // numElements
|
|
|
|
v.setUint32(12, Number((start >> 32n) & 0xFFFFFFFFn), true); |
|
|
|
v.setUint32(16, endTimestampLow, true); // numElements
|
|
|
|
v.setUint32(16, Number(end & 0xFFFFFFFFn), true); |
|
|
|
v.setUint32(20, endTimestampHigh, true); // numElements
|
|
|
|
v.setUint32(20, Number((end >> 32n) & 0xFFFFFFFFn), true); |
|
|
|
|
|
|
|
|
|
|
|
return this.#concat(hdr, ...encodedEls); |
|
|
|
return this.#concat(hdr, ...encodedEls); |
|
|
|
} |
|
|
|
} |
|
|
|
|