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:
1 parent
c54c8daff5
commit
9761df1af1
8 files changed
+486
-12
No files matched your search
+27
-2
@@ -14,8 +14,11 @@ _s.loader.exec_module(A)
|
||||
_s = importlib.util.spec_from_file_location("_lzx", os.path.join(os.path.dirname(os.path.abspath(__file__)), "_lzx.py"))
|
||||
L = importlib.util.module_from_spec(_s)
|
||||
_s.loader.exec_module(L)
|
||||
_s = importlib.util.spec_from_file_location("_quantum", os.path.join(os.path.dirname(os.path.abspath(__file__)), "_quantum.py"))
|
||||
Q = importlib.util.module_from_spec(_s)
|
||||
_s.loader.exec_module(Q)
|
||||
|
||||
INPUTS = ["tools/fixtures/_arch2.py", "tools/fixtures/_lzx.py"]
|
||||
INPUTS = ["tools/fixtures/_arch2.py", "tools/fixtures/_lzx.py", "tools/fixtures/_quantum.py"]
|
||||
ENV = dict(os.environ, TZ="UTC")
|
||||
|
||||
|
||||
@@ -99,6 +102,13 @@ def lzx(wbits, e8size=0, seed=1, plan=None):
|
||||
return enc
|
||||
|
||||
|
||||
def quantum(wbits):
|
||||
def enc(stream):
|
||||
frames = Q.compress(stream, wbits)
|
||||
return [(f, min(32768, len(stream) - i * 32768)) for i, f in enumerate(frames)]
|
||||
return enc
|
||||
|
||||
|
||||
LIST = re.compile(r"^\s*(\d+) \| (\d\d)\.(\d\d)\.(\d{4}) (\d\d):(\d\d):(\d\d) \| (.*)$")
|
||||
|
||||
|
||||
@@ -185,13 +195,28 @@ def generate(ctx):
|
||||
if {e["name"]: e["crc"] for e in ents} != want:
|
||||
raise RuntimeError("cabextract does not extract the fixture LZX cabinet " + label)
|
||||
cases.append({"name": label, "data": c, "entries": ents})
|
||||
# Quantum (our fixture compressor, checked by cabextract): windows 2^10 .. 2^21, model rescaling and re-sorting
|
||||
quantum_cases = [
|
||||
("quantum 2^10 text", 10, [(b"q.txt", text[:20000])]),
|
||||
("quantum 2^16 mixed", 16, [(b"a.txt", text[:60000]), (b"b.bin", rand[:20000]), (b"c.bin", x86[:30000])]),
|
||||
("quantum 2^21 big", 21, [(b"big.bin", big)]),
|
||||
]
|
||||
for i, (label, wb, fl) in enumerate(quantum_cases):
|
||||
c = build([(2 | (4 << 4) | (wb << 8), [(n, d, 0x20, 1700000000) for n, d in fl], quantum(wb))])
|
||||
p = os.path.join(tmp, "qtm%d.cab" % i)
|
||||
open(p, "wb").write(c)
|
||||
ents = reference(p, tmp, "qtm%d" % i)
|
||||
want = {n.decode(): zlib.crc32(d) for n, d in fl}
|
||||
if {e["name"]: e["crc"] for e in ents} != want:
|
||||
raise RuntimeError("cabextract does not extract the fixture Quantum cabinet " + label)
|
||||
cases.append({"name": label, "data": c, "entries": ents})
|
||||
# the libmspack test cabinets
|
||||
ms = os.path.join(tmp, "ms")
|
||||
os.makedirs(ms)
|
||||
subprocess.run(["tar", "xzf", mspack_cabs(), "-C", ms, "--wildcards", "*/test/test_files/cabd/*.cab"], check=True)
|
||||
cabd = os.path.join(ms, os.listdir(ms)[0], "test", "test_files", "cabd")
|
||||
for n in ("normal_2files_1folder", "normal_2files_2folders", "normal_255c_filename", "reserve_---", "reserve_--D",
|
||||
"reserve_-F-", "reserve_-FD", "reserve_H--", "reserve_H-D", "reserve_HF-", "reserve_HFD"):
|
||||
"reserve_-F-", "reserve_-FD", "reserve_H--", "reserve_H-D", "reserve_HF-", "reserve_HFD", "mszip_lzx_qtm"):
|
||||
add("libmspack " + n, os.path.join(cabd, n + ".cab"))
|
||||
spanned = [{"name": n, "data": open(os.path.join(cabd, n + ".cab"), "rb").read()}
|
||||
for n in ("multi_basic_pt1", "multi_basic_pt2", "multi_basic_pt3")]
|
||||
|
||||
Reference in new issue
Block a user