Class ParentMap
Builds the parent-hunk hash map used to create differential (delta) CHDs. The parent CHD
is decompressed once, and every unit-aligned window of its data (one hunk's worth of bytes
starting at each unit boundary) is hashed; during encoding, a child hunk whose full-hunk
(CRC-16, SHA-1) matches a window is emitted as a CompressionParent
reference to that parent unit — mirroring MAME's chd_file_compressor parent walk
(chd.cpp: hashes every parent unit window, then matches child hunks against it).
public sealed class ParentMap : IDisposable
- Inheritance
-
ParentMap
- Implements
- Inherited Members
Remarks
The walk is sequential (the parent's hunks must be decompressed once; each read is cached by the reader). The map itself is read-only after construction, so it is safe to consult from the encoder's single consumer thread during the parallel pipeline.
Constructors
ParentMap(string, uint, uint)
Initializes a new parent map by decompressing and hashing the parent CHD.
public ParentMap(string parentPath, uint hunkBytes, uint unitBytes)
Parameters
parentPathstringPath of the parent CHD file.
hunkBytesuintThe hunk size of the child being created.
unitBytesuintThe unit size of the child being created.
Exceptions
- ArgumentException
parentPathisnullor the parent's hunk/unit sizes do not matchhunkBytes/unitBytes.- IOException
The parent CHD cannot be opened.
Properties
HunkBytes
The hunk size of the parent CHD (equal to the child's).
public uint HunkBytes { get; }
Property Value
HunkCount
The hunk count of the parent CHD.
public uint HunkCount { get; }
Property Value
ParentSha1
The parent's overall SHA-1 (header field), stored in the child's parent-SHA-1 field.
public byte[] ParentSha1 { get; }
Property Value
- byte[]
UnitBytes
The unit size of the parent CHD (equal to the child's).
public uint UnitBytes { get; }
Property Value
UnitsPerHunk
The number of units per hunk.
public uint UnitsPerHunk { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
TryGetParentUnit(ushort, string, out uint)
Looks up a child hunk's (CRC-16, SHA-1) in the parent map.
public bool TryGetParentUnit(ushort crc16, string sha1Hex, out uint parentUnit)
Parameters
crc16ushortCRC-16 of the child hunk's data.
sha1HexstringHexadecimal SHA-1 of the child hunk's data.
parentUnituintWhen
trueis returned, the parent unit index (0-based, in units) whose data matches the child hunk.
Returns
- bool
trueif a matching parent unit exists; otherwisefalse.