From 1bf42f72b07a7d4d0801741de0624ad72fcb43e2 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Thu, 4 Aug 2022 16:32:18 -0700 Subject: [PATCH] lib: insert empty flic frame where necessary --- lib/object.cpp | 7 ++++++- lib/othertypes.h | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/object.cpp b/lib/object.cpp index c2d7233..987a606 100644 --- a/lib/object.cpp +++ b/lib/object.cpp @@ -217,7 +217,12 @@ bool Object::ExtractToFile(FileBase *f) const // Subsequent chunks are FLIC frames with an additional 20 byte header that needs to be stripped const int CUSTOM_HEADER_SZ = 20; for (size_t i=1; iWriteData(data_.at(i).data() + CUSTOM_HEADER_SZ, data_.at(i).size() - CUSTOM_HEADER_SZ); + if (data_.at(i).size() == CUSTOM_HEADER_SZ) { + static const char *empty_hdr = "\x10\x00\x00\x00\xfa\xf1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; + f->WriteData(empty_hdr, 16); + } else { + f->WriteData(data_.at(i).data() + CUSTOM_HEADER_SZ, data_.at(i).size() - CUSTOM_HEADER_SZ); + } } break; } diff --git a/lib/othertypes.h b/lib/othertypes.h index b748d3b..33dfb18 100644 --- a/lib/othertypes.h +++ b/lib/othertypes.h @@ -52,6 +52,18 @@ public: uint8_t reserved3[40]; // Set to zerodesc << " }; +class FLICFrame +{ +public: + uint32_t size; // Size of the chunk, including subchunks + uint16_t type; // Chunk type: 0xF1FA + uint16_t chunks; // Number of subchunks + uint16_t delay; // Delay in milliseconds + int16_t reserved; // Always zero + uint16_t width; // Frame width override (if non-zero) + uint16_t height; // Frame height override (if non-zero) +}; + // Copied from https://wiki.multimedia.cx/index.php/Smacker#Header class SMK2 {