2584 Commits
Author SHA1 Message Date
Timofey Solomko 6cb19dfcfa Merge pull request #61 from analytical-engines/fix-lzma-dictionary-size 2026-05-14 21:31:46 +08:00
nekonyaandTimofey Solomko 735795a7e1 [7-Zip] Fix LZMA dictionary size parsing
The LZMA dictionary size was being read from only 3 bytes (indices 1-3)
instead of the full 4 bytes (indices 1-4) specified in the LZMA format.

This caused decompression to fail with LZMAError.notEnoughToRepeat for
archives using dictionary sizes >= 16MB (e.g., LZMA:24 = 2^24 = 16MB),
because the high byte was not read and the dictionary size defaulted
to the minimum 4096 bytes.

Change: `for i in 1..<4` → `for i in 1..<5`
2026-05-14 21:31:30 +08:00
Timofey Solomko a6419940c1 [CI] Add Swift 6.3, update iOS simulator for Swift 6.2 2026-05-14 13:21:34 +08:00
Timofey Solomko 85c8fd60aa [docs] Update BZip2 docs for multiDecompress functionality 2026-05-14 12:42:02 +08:00
Timofey Solomko cf044550f1 [swcomp] Add --multi-decompress option to bz2 command
This option allows to decompress multiple BZip2 archives concatenated together.
2026-05-14 12:42:02 +08:00
Timofey Solomko 8c389295c4 [Tests] Add tests for BZip2.multiDecompress 2026-05-14 12:42:02 +08:00
Timofey Solomko 75cc406d47 [BZip2] Add multiDecompress public function
This should help with inputs consisting of multiple BZip2 archives concatenated together which were brought up in #59.
2026-05-12 16:06:19 +08:00
Timofey Solomko 2620ed67cf Remove reference to download-bbd-macos command in README 2026-05-12 16:04:53 +08:00
Timofey Solomko e32887084c [Huffman] Change Decoding/Encoding tree to structs
This seems to have a positive impact on the performance of Deflate and BZip2 decompression and compression. It is unclear to me why these two were declared as classes in the first place.
2026-03-01 20:35:22 +08:00
Timofey Solomko 567a5473d1 [GZip] Move bytes left check out of the loop when reading extra fields 2026-03-01 20:35:22 +08:00
Timofey Solomko 5d4b4d2493 [TAR] Fix code comment to refer to TarParser instead of Provider 2026-03-01 20:35:22 +08:00
Timofey Solomko 93e2eef38d [BZip2] Remove redundant check for zero code lengths
Such code lengths are now filtered out during Huffman code construction.
2026-03-01 20:35:22 +08:00
Timofey Solomko 8310b985f2 [Tests] Add tests for all zero code lengths in Deflate dynamic Huffman block
These are related to situation described in issue #57. We should now either properly throw an error, or in rare cases (when only literals are inside the block) produce an output.
2026-03-01 20:35:22 +08:00
Timofey Solomko d8c22c55da [Deflate][Huffman] Filter out zero code lengths only during code construction
This should prevent crashes described in issue #57.
2026-03-01 20:35:21 +08:00
Timofey Solomko 7e6a9fd42c [Deflate] Add a check for correct number of literal/length codes 2026-03-01 20:35:21 +08:00
Timofey Solomko 229c3ec47d [Tests] Add Deflate tests for handling over copying in dynamic Huffman blocks 2026-03-01 20:35:21 +08:00
Timofey Solomko a39011a00b [Deflate] Fix potential crashes in cases of too large copy amount
In a dynamic Huffman block if either previous or zero code length is copied too many times, it could cause a crash or lead to inconsistent state. These situations are checked now.
2026-03-01 20:35:21 +08:00
Timofey Solomko 7f547c20a1 [Huffman] Optimize DecodingTree leaf count 2026-03-01 20:35:21 +08:00
Timofey Solomko 567878fce5 [CI] Update to Xcode 26.3 2026-03-01 20:35:21 +08:00
Timofey Solomko 07d30d6045 [Tests] Add a test for symbol 16 issue in Deflate 2026-03-01 20:35:21 +08:00
Timofey Solomko ccf97c995b [Deflate] Check that 16 is not the first code length symbol
This symbol in the dynamic Huffman block encodes copy of the previous code length. If this symbol is the first, then there is nothing to copy. Previously, this could cause a crash.
2026-02-28 01:26:43 +08:00
Timofey Solomko 3bfb4a1fa2 [Tests] Simplify Deflate truncation test 2026-02-28 01:26:43 +08:00
Timofey Solomko b743b0b7ed [Deflate] Optimize decoding of code lengths for dynamic trees 2026-02-26 00:53:17 +08:00
Timofey Solomko 80177155c8 [Tests] Move deflate truncation testing into a separate file
Also add test files that contain only "deflated" data.
2026-02-26 00:25:24 +08:00
Timofey Solomko 08e10e8c45 [Tests] Add a more comprehensive GZip truncation test 2026-02-25 23:44:41 +08:00
Timofey Solomko fd42e30262 [Tests] Add a more comprehensive Zlib truncation test 2026-02-24 00:59:15 +08:00
Timofey Solomko 52efeef2b8 [Zlib] Improve handling of truncated inputs during decompression 2026-02-24 00:58:49 +08:00
Timofey Solomko 7b366f7df4 [Tests] Add a more comprehensive LZ4 truncation test 2026-02-24 00:50:23 +08:00
Timofey Solomko e8c8ccb3f2 [Tests] Add a test for BZip2 truncation handling
The idea here is that BZip2.decompress should not crash for any possible truncation. It should either throw an error or produce an output (if stars align such that truncated input is still a valid BZip2 "archive").
2026-02-24 00:44:54 +08:00
Timofey Solomko f307a7fb0b [BZip2] Improve handling of truncated inputs during decompression 2026-02-23 18:08:27 +08:00
Timofey Solomko ad73d82367 [BZip2] Slightly rewrite Huffman+RUNA/B+MTF decoding
This piece of the code is now more logical, with less branching, and mirrors encoding counterpart.
2026-02-23 18:08:26 +08:00
Timofey Solomko a0c64f7f9c [Deflate] Optimize creation of uncompressed blocks 2026-02-23 18:08:26 +08:00
Timofey Solomko 51734eb8d3 [swcomp] Remove empty warmupIteration function from comp-ratio benchmarks
These functions weren't called anyway since 5e8f568f64 commit where Benchmark protocol requirement for this function acquired Double return type. In any event, skipping of warmup iteration is better controlled by the corresponding option of "benchmark run" command.
2026-02-23 18:08:26 +08:00
Timofey Solomko 3686067e54 [LZMA] Remove LZMARangeDecoder.isCorrupted property
According to LZMA specification this property is ignored by the reference implementation. In addition, specification suggests that other LZMA decoders should also ignore it. We weren't using this property for anything anyway, so its removal does not really change anything, except for better compliance with LZMA specification.

In addition, range decoder initialization error is now thrown in accordance with reference implementation.
2026-02-23 18:08:26 +08:00
Timofey Solomko 609eb29791 [BZip2] Change a couple of guard/if-checks to assertions 2026-02-23 18:08:26 +08:00
Timofey Solomko 1e7154474b [BZip2] Use better versions of bit writer functions
First, write(unsignedNumber:) is better than write(number:) when the argument is already UInt, since it does one fewer precondition check and does not do additional integer conversion. Secondly, using write(number:) to write one bit was very inefficient.
2026-02-23 18:08:25 +08:00
Timofey Solomko 7af76764d7 [BZip2] Use UInt8 arrays instead of Data 2026-02-23 18:08:25 +08:00
Timofey Solomko bff411d511 [BZip2] Improve encoding performance of code lengths deltas 2026-02-23 18:08:25 +08:00
Timofey Solomko 273b6ed9e9 Remove redundant imports 2026-02-18 12:21:57 +08:00
Timofey Solomko 5b5b20f582 [Huffman] Remove codes argument label from EncodingTree.init 2026-02-18 00:12:55 +08:00
Timofey Solomko ce1736a2b0 [Huffman] Add HuffmanCodes typealias for clarity 2026-02-18 00:10:29 +08:00
Timofey Solomko f5b8a393ce Cleanup gitignore 2026-02-13 13:23:03 +08:00
Timofey Solomko d76351caa0 [swcomp] Update benchmark run command to use new format 2026-02-12 21:44:42 +08:00
Timofey Solomko 52961ea60d [swcomp] Update benchmark show command to use new format
This allowed to rewrite implementation in a much clearer way. One user-visible change, however, is that NEW/BASE is now always printed with an index even if there is only one (implementation complexity to accommodate empty index is not worth it).
2026-02-12 21:44:42 +08:00
Timofey Solomko 515c11fd0e [swcomp] Support new format in benchmark remove-run command 2026-02-12 21:44:42 +08:00
Timofey Solomko 8847fe92ce [swcomp] SaveFile.load now auto-converts from old format 2026-02-12 21:44:41 +08:00
Timofey Solomko 4ec437e912 [swcomp] Add benchmark convert command
This command converts save file from old format to the new one.
2026-02-12 21:44:35 +08:00
Timofey Solomko 20d33b0966 [swcomp] Add a new benchmark save file format
Ultimately, it turned out that the approach of the old save file format of separating runs metadatas and results only leads to super complicated code. Unfortunately, it didn't help with append-updates to save files (they are still loaded fully, their content is modified in memory, and the actual file is then overwritten).
2026-02-12 21:44:35 +08:00
Timofey Solomko 98b5ee3610 [swcomp] Save results file JSON with keys sorted
This ensures a more stable layout of JSON fields between updates to the same file.
2026-02-12 21:44:35 +08:00
Timofey Solomko 3f5694aeee [swcomp] Rename SaveFile to OldSaveFile 2026-02-12 21:44:35 +08:00