More BZip documenting

This commit is contained in:
Matt Nadareski
2025-09-30 20:35:40 -04:00
parent ac285c48fe
commit ef9fa562ab
4 changed files with 76 additions and 1 deletions

View File

@@ -0,0 +1,12 @@
namespace SabreTools.Data.Models.BZip2
{
public class Block
{
/// <summary>
/// Block header
/// </summary>
public BlockHeader? Header { get; set; }
// TODO: Implement remaining structures
}
}

View File

@@ -0,0 +1,37 @@
namespace SabreTools.Data.Models.BZip2
{
public class BlockHeader
{
/// <summary>
/// A 48-bit integer value 31 41 59 26 53 59, which
/// is the binary-coded decimal representation of
/// pi. It is used to differentiate the block
/// from the footer.
/// </summary>
/// <remarks>This may not be byte-aligned</remarks>
public byte[]? Magic { get; set; }
/// <summary>
/// The CRC-32 checksum of the uncompressed data contained
/// in <see cref="BlockData"/>. It is the same checksum
/// used in GZip, but is slightly different due to the
/// bit-packing differences.
/// </summary>
public uint Crc32 { get; set; }
/// <summary>
/// Should be 0. Previous versions of BZip2 allowed
/// the input data to be randomized to avoid
/// pathological strings from causing the runtime
/// to be exponential.
/// </summary>
/// <remarks>Actually a 1-bit value</remarks>
public byte Randomized { get; set; }
/// <summary>
/// Contains the origin pointer used in the BWT stage
/// </summary>
/// <remarks>Actually a 24-bit value</remarks>
public uint OrigPtr { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
namespace SabreTools.Data.Models.BZip2
{
public class BlockTrees
{
// TODO: Implement SymMap
/// <summary>
/// Indicates the number of Huffman trees used in
/// the HUFF stage. It must between 2 and 6.
/// </summary>
/// <remarks>Actually a 3-bit value</remarks>
public byte NumTrees { get; set; }
/// <summary>
/// Indicates the number of selectors used in the
/// HUFF stage. There must be at least 1 selector
/// defined.
/// </summary>
/// <remarks>Actually a 15-bit value</remarks>
public ushort NumSels { get; set; }
// TODO: Implement Selectors
// TODO: Implement Trees
}
}

View File

@@ -6,4 +6,4 @@ namespace SabreTools.Data.Models.BZip2
public const string SignatureString = "BZh";
}
}
}