Class LzmaCodec
LZMA compression matching MAME's chd_lzma_compressor: raw headerless LZMA with
no end marker, properties lc=3/lp=0/pb=2, dictionary size = hunk bytes and
numFastBytes=64 (the LZMA "level 8" profile that chdman configures via
LzmaEncProps; the match-finder cycle count 16 + fb/2 = 48 follows automatically).
Backed by Igor Pavlov's official LZMA SDK C# encoder (public domain, ported into this
project); the encoder never writes the 5-byte property header, so the stream is already
in CHD's raw format; the decoder synthesizes the properties (see CHDSharpLib's
CHDReaders.Lzma). The port matches the C encoder's byte emission: the price table uses
the C's kNumMoveReducingBits/kNumBitPriceShiftBits = 4/4 (the SDK C# line still uses
2/6, which flips near-tie optimal-parser decisions) and the BT4 match finder walks the
btree with maxLen = 3 like MAME's Bt4_MatchFinder_GetMatches. Output is
byte-identical to chdman on the battle-test corpus (verified per-hunk on 1,664 raw
hunks and the cdlz CD hunks).
public sealed class LzmaCodec : IChdCodec
- Inheritance
-
LzmaCodec
- Implements
- Inherited Members
Constructors
LzmaCodec(uint)
Creates an LZMA codec for the given hunk size.
public LzmaCodec(uint hunkBytes)
Parameters
hunkBytesuintHunk size in bytes (becomes the LZMA dictionary size).
Properties
Tag
The four-character codec tag (see CodecTags).
public uint Tag { get; }
Property Value
Methods
Compress(byte[])
Compresses a full hunk. Returns null when the codec does not reduce the size.
public byte[]? Compress(byte[] data)
Parameters
databyte[]
Returns
- byte[]