Skip to content

Architecture

YadeWira edited this page Sep 3, 2026 · 1 revision

Architecture

Moved here from the README (2026-09-03).

nz_recon CLI
├── sfx_archive.cpp    — core: archive format, dispatcher, native decoders
├── sfx_cli.cpp        — CLI parsing (l/t/x/a/s + switches)
├── lzpf_arith.cpp     — lzpf arith primitives (BitReader, Huffman, LZ77 A/B)
├── nz_cm.cpp          — CM decoder: ported from nzdec_v0 NZ_CM.cpp (context mixer, range coder, all tables)
├── nz_lzhd.cpp        — lzhd decoder: ported from nzdec_v0 NZ_LZ.cpp (DecLZ, PAQ context mixer, 12-bit arith)
├── nz_optimum_lz.cpp  — real -co (nz_optimum1) LZ/CM engine
├── nz_optimum2_lz.cpp — real -cO (nz_optimum2) LZ/CM engine
├── linux32_cm_map.cpp — cm context-mixer vtable mapping (linux32 ELF offsets)
└── include/
    ├── lzpf_arith.h
    ├── nz_cm.h        — CM decoder public API
    ├── nz_lzhd.h      — lzhd decoder public API
    └── nz_sfx/        — internal headers

One decode layer: the native C++ reconstruction. A multi-threaded archive (the -pN container the original writes for anything above ~8 MB) has its worker streams decoded concurrently, one thread per stream up to the CPU count (-t<n> caps it); the streams are independent by construction and each writes its own slice of the output, which is checked to tile the file without overlap before any thread starts. There is no bridge to the original binary of any kind — not for decoding, not for unknown switches, not for compression. What the native decoders decline is reported as Archive corrupted. Error decoding (code 100), exactly as the original reports its own failures.

Newer files not in the tree above: nz_bwt.cpp (BWT entropy layer, inverse transform, params 14/15), nz_postfilter.cpp, nz_text_transform*.cpp, nz_exefilter.cpp, nz_audio.cpp (audio and image models), nz_cd_tokens.cpp (-cd/-cD chunk decoder), nz_lzhds.cpp (-cD literal model), nz_lzhd.cpp (reference port, not reached by real archives), include/nz_trace.h (NZ_TRACE_CONSTRUCTS).

Clone this wiki locally