From 40c7091386bd141d7165571c1a0e3403ab32fc10 Mon Sep 17 00:00:00 2001 From: Evan Hahn Date: Thu, 9 Nov 2023 09:20:48 -0600 Subject: [PATCH] GIF: parse terminator --- public/gif/constants.js | 2 ++ public/gif/getNodeUi.js | 9 +++++++++ public/gif/parseGif.js | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/public/gif/constants.js b/public/gif/constants.js index 7912516..c0bc867 100644 --- a/public/gif/constants.js +++ b/public/gif/constants.js @@ -43,6 +43,8 @@ const types = [ "unknownExtensionBlock", "unknownExtensionBlockLabel", "unknownExtensionBlockData", + + "gifTerminator", ].reduce((result, id) => { result[id] = id; return result; diff --git a/public/gif/getNodeUi.js b/public/gif/getNodeUi.js index c82117f..614c1f3 100644 --- a/public/gif/getNodeUi.js +++ b/public/gif/getNodeUi.js @@ -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!", + ), + }), }; /** diff --git a/public/gif/parseGif.js b/public/gif/parseGif.js index 3c173ac..d4ae67d 100644 --- a/public/gif/parseGif.js +++ b/public/gif/parseGif.js @@ -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}`);