From dae4d105d5fe6fd99d40f457d5e250a15d66e537 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Mon, 21 Aug 2023 18:13:49 -0700 Subject: [PATCH] lib: if object is only one chunk, write end chunk immediately Improves accuracy --- lib/interleaf.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/interleaf.cpp b/lib/interleaf.cpp index e90a6b1..4e7f07b 100644 --- a/lib/interleaf.cpp +++ b/lib/interleaf.cpp @@ -536,12 +536,26 @@ void Interleaf::InterleaveObjects(FileBase *f, const std::vector &obje } // First, interleave headers - for (size_t i=0; i::iterator it = status.begin(); it != status.end(); ) { + ChunkStatus &s = *it; Object *o = s.object; + + bool proceed = true; + if (!o->data().empty()) { WriteSubChunk(f, 0, o->id(), 0xFFFFFFFF, o->data().front()); s.index++; + + // If we've already reached the end, write the end chunk now + if (o->data().size() == s.index) { + WriteSubChunk(f, MxCh::FLAG_END, o->id(), 0xFFFFFFFF); + it = status.erase(it); + proceed = false; + } + } + + if (proceed) { + it++; } }