ws-arch2-cab: codecs/compress/Quantum (CAB Quantum: 16-bit arithmetic decoder, the adaptive models with their rescale / re-sort rules, windows 2^10..2^21, one frame per CFDATA; written from the format descriptions) + cab Quantum folders, checked against cabextract on cabinets of a fixture Quantum compressor (tools/fixtures/_quantum.py) and libmspack's mszip_lzx_qtm sample

This commit is contained in:
4DBug committed 2026-10-31 15:50:37 -05:00
1 parent c54c8daff5
commit 9761df1af1
8 files changed
+486 -12

No files matched your search

+9 -2
View File
@@ -3,7 +3,8 @@
-- files cabextract extracts (names, sizes, data CRCs, DOS times read as UTC); cabextract / gcab / 7z extract our
-- writer's output (fixture step) and it round-trips; spanned files are UNSUPPORTED; checksum, truncation and
-- signature errors, libmspack's broken cabinets; LZX (codecs/compress/Lzx) from a fixture compressor whose cabinets
-- cabextract extracts (windows 2^15 .. 2^21, verbatim / aligned / uncompressed blocks, E8); Deflate's preset
-- cabextract extracts (windows 2^15 .. 2^21, verbatim / aligned / uncompressed blocks, E8); Quantum
-- (codecs/compress/Quantum) the same way (windows 2^10 .. 2^21, model rescaling); Deflate's preset
-- dictionary; the fuzz pass. Fixtures: tools/fixtures/cab.py.
local T = require("@tests/T")
local F = require("@formats")
@@ -35,7 +36,7 @@ for _, c in Fx.cases do
t:eq(F.detect(c.data), "cab", c.name .. ": detect")
table.insert(samples, string.sub(c.data, 1, 4000))
end
t:check(methods.store and methods.mszip and methods.lzx, "covers store, mszip and lzx")
t:check(methods.store and methods.mszip and methods.lzx and methods.quantum, "covers store, mszip, lzx and quantum")
-- attributes, UTF-8 names, reserve areas (the builder's two-folder cabinet)
local two = assert(load(Fx.cases[5].data))
@@ -98,6 +99,12 @@ t:check(not Lzx.decode(buffer.create(10), 0, 10, 100, 14), "LZX window 2^14 unsu
t:check(not Lzx.decode(buffer.create(10), 0, 10, 100, 16), "LZX of zeros")
t:check(not Lzx.decode(buffer.create(10), 4, 10, 100, 16), "LZX range past the end")
-- Quantum directly
local Quantum = require("@formats/codecs/compress/Quantum")
t:check(not Quantum.decode(buffer.create(10), {}, 0, 9), "Quantum window 2^9 unsupported")
t:check(not Quantum.decode(buffer.create(10), { { at = 0, len = 10, size = 5 } }, 6, 16), "Quantum sizes must add up")
t:check(not Quantum.decode(buffer.create(10), { { at = 4, len = 10, size = 5 } }, 5, 16), "Quantum range past the end")
-- Deflate's preset dictionary and MSZIP blocks
local block1 = assert(Deflate.compress(string.rep("ab", 50)))
local mszip = buffer.create(buffer.len(block1) + 2)