Add conformant LZC compression and NuFX LZC threads - #131
Open
Hawkynt wants to merge 1 commit into
Open
Conversation
UNIX compress does not use a continuous variable-width LZW bitstream: codes are buffered in groups of eight and a width change or CLEAR discards the rest of the old group. Implement that framing once in Core, route the standalone .Z format through it, and enable NuFX LZC-12/LZC-16 threads without silently changing their compression method on replacement. Add fixed byte vectors, CLEAR/alignment, width-transition, malformed-stream, standalone-format and NuFX round-trip coverage. Refresh the generated Core package API documentation for the new public building block.
Hawkynt
force-pushed
the
fix/lzc-block-packing
branch
from
August 31, 2026 08:40
226c1b3 to
d86bef7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
LzcCodecfor native UNIXcompress/.Zstreams;LzcBuildingBlockto the existing source-generated building-block registry surface;FileFormat.Compressthrough the conformant LZC primitive instead of the generic continuous-bit LZW helper;1F 9D.Zframing inside the NuFX thread;Design decisions
The existing generic
LzwEncoder/LzwDecoderremains unchanged. LZC's group flush/alignment behavior is wire-format semantics, not merely another bit-order option, so forcing it into the continuous-bit helper would make that abstraction misleading.The encoder emits valid block-mode streams without adaptive ratio-based CLEAR heuristics. Once the dictionary fills it remains fixed at the configured maximum width; the decoder accepts CLEAR codes from adaptive encoders. This keeps the implementation deterministic while remaining interoperable.
Native
.Zhas no expanded-length field. The benchmarkableIBuildingBlockenvelope therefore prefixes a 32-bit little-endian length before the otherwise-native 16-bit block-mode stream; the concreteLzcCodecAPI operates on true.Zbytes.NuFX LZC threads deliberately retain the three-byte
.Zheader. NufxLib writes and reads that framing for LZC; this differs from NuFX Squeeze threads, where the standalone Squeeze header is omitted.No new package, native library, P/Invoke, unsafe code, or external executable dependency is introduced.
Validation
Added NUnit coverage for:
TOBEORNOTTOBEORTOBEORNOT;CompressStreaminteroperability/alignment regression coverage;The fixed
.Zvectors and generated width-transition/block/non-block streams were checked with GNUgzip -cdas an independent decoder oracle. This environment does not provide the .NET SDK, so repository compilation/test execution is delegated to PR CI rather than claimed locally.References and licensing
Consulted:
.Zheader fields, variable-width coding, eight-code group packing, width-change/CLEAR alignment, and NuFX usage;Lzc.c/Compress.cfor NuFX format identifiers and confirmation that LZC threads carry native.Zframing;NufxLib is BSD-licensed and the legacy compress implementation it incorporates identifies the relevant historical code as public domain, but this change does not copy or closely translate that source. The implementation is independently written from the documented behavior and validated with external byte-level oracles.