GIF: parse terminator

This commit is contained in:
Evan Hahn 2023-11-09 09:20:48 -06:00
parent e0a2a3287b
commit 40c7091386
3 changed files with 15 additions and 0 deletions

View File

@ -43,6 +43,8 @@ const types = [
"unknownExtensionBlock",
"unknownExtensionBlockLabel",
"unknownExtensionBlockData",
"gifTerminator",
].reduce((result, id) => {
result[id] = id;
return result;

View File

@ -298,6 +298,15 @@ const NODE_UI_FNS = {
title: "Unknown Extension Block Data",
description: p("TODO"),
}),
// Terminator
[GifNodeType.gifTerminator]: () => ({
title: "GIF Terminator",
description: p(
"The terminator is a one-byte block indicating the end of our GIF. We're done!",
),
}),
};
/**

View File

@ -315,6 +315,10 @@ export default (bytes) => {
readerFn = readExtensionBlock;
break;
case BLOCK_TYPE_TRAILER:
children.push({
type: GifNodeType.gifTerminator,
bytes: bytes.subarray(offset, offset + 1),
});
break readingBlocks;
default:
throw new Error(`Unknown GIF block type: ${blockType}`);