Make Matroska block decoding lazy

This commit is contained in:
Vanilagy
2025-09-18 10:00:03 +02:00
parent f13a81bee3
commit 407dd05953
7 changed files with 72 additions and 49 deletions
+5 -4
View File
@@ -6,7 +6,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { assert, clamp, MaybePromise, toDataView } from './misc';
import { assert, clamp, getUint24, MaybePromise, toDataView } from './misc';
import { Source } from './source';
export class Reader {
@@ -157,9 +157,10 @@ export const readU16Be = (slice: FileSlice) => {
};
export const readU24Be = (slice: FileSlice) => {
const high = readU16Be(slice);
const low = readU8(slice);
return high * 0x100 + low;
const value = getUint24(slice.view, slice.bufferPos, false);
slice.bufferPos += 3;
return value;
};
export const readI16Be = (slice: FileSlice) => {