From d7670ae685e9f4278e80086d4837799d80a8ea5f Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 23 Sep 2023 00:32:08 -0400 Subject: [PATCH] Add a little more Quantum decoding --- Quantum/Decompressor.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Quantum/Decompressor.cs b/Quantum/Decompressor.cs index 2db8a9a..312cc5d 100644 --- a/Quantum/Decompressor.cs +++ b/Quantum/Decompressor.cs @@ -186,7 +186,7 @@ namespace SabreTools.Compression.Quantum // Loop until the end of the stream var bytes = new List(); - while (true) + while (_bitStream.Position < _bitStream.Length) { // Determine the selector to use int selector = GetSymbol(_selector); @@ -247,13 +247,19 @@ namespace SabreTools.Compression.Quantum throw new ArgumentOutOfRangeException(); } - // TODO: Finish implementation: - // - Copy data from the offsets to the lengths - // - Return the decoded byte array + // Copy the previous data + int copyIndex = bytes.Count - offset; + while (length-- > 0) + { + bytes.Add(bytes[copyIndex++]); + } + + // TODO: Add MS-CAB specific padding + // TODO: Add Cinematronics specific checksum } } - throw new NotImplementedException(); + return bytes.ToArray(); } ///