mirror of
https://github.com/SabreTools/SabreTools.Models.git
synced 2026-02-07 13:54:36 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4be402052 | ||
|
|
182c9bc756 | ||
|
|
cc62b3ffae | ||
|
|
7d34f486cd | ||
|
|
9c68cfc0c1 |
41
Compression/MSZIP/Block.cs
Normal file
41
Compression/MSZIP/Block.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
namespace SabreTools.Models.Compression.MSZIP
|
||||
{
|
||||
/// <summary>
|
||||
/// Each MSZIP block MUST consist of a 2-byte MSZIP signature and one or more RFC 1951 blocks. The
|
||||
/// 2-byte MSZIP signature MUST consist of the bytes 0x43 and 0x4B. The MSZIP signature MUST be
|
||||
/// the first 2 bytes in the MSZIP block. The MSZIP signature is shown in the following packet diagram.
|
||||
///
|
||||
/// Each MSZIP block is the result of a single deflate compression operation, as defined in [RFC1951].
|
||||
/// The compressor that performs the compression operation MUST generate one or more RFC 1951
|
||||
/// blocks, as defined in [RFC1951]. The number, deflation mode, and type of RFC 1951 blocks in each
|
||||
/// MSZIP block is determined by the compressor, as defined in [RFC1951]. The last RFC 1951 block in
|
||||
/// each MSZIP block MUST be marked as the "end" of the stream(1), as defined by [RFC1951]
|
||||
/// section 3.2.3. Decoding trees MUST be discarded after each RFC 1951 block, but the history buffer
|
||||
/// MUST be maintained.Each MSZIP block MUST represent no more than 32 KB of uncompressed data.
|
||||
///
|
||||
/// The maximum compressed size of each MSZIP block is 32 KB + 12 bytes. This enables the MSZIP
|
||||
/// block to contain 32 KB of data split between two noncompressed RFC 1951 blocks, each of which
|
||||
/// has a value of BTYPE = 00.
|
||||
/// </summary>
|
||||
/// <see href="https://interoperability.blob.core.windows.net/files/MS-MCI/%5bMS-MCI%5d.pdf"/>
|
||||
public class Block
|
||||
{
|
||||
/// <summary>
|
||||
/// Block header
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public BlockHeader BlockHeader { get; set; }
|
||||
#else
|
||||
public BlockHeader? BlockHeader { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Compressed blocks
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public DeflateBlock[] CompressedBlocks { get; set; }
|
||||
#else
|
||||
public DeflateBlock[]? CompressedBlocks { get; set; }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -4,18 +4,6 @@ namespace SabreTools.Models.Compression.MSZIP
|
||||
/// Each MSZIP block MUST consist of a 2-byte MSZIP signature and one or more RFC 1951 blocks. The
|
||||
/// 2-byte MSZIP signature MUST consist of the bytes 0x43 and 0x4B. The MSZIP signature MUST be
|
||||
/// the first 2 bytes in the MSZIP block. The MSZIP signature is shown in the following packet diagram.
|
||||
///
|
||||
/// Each MSZIP block is the result of a single deflate compression operation, as defined in [RFC1951].
|
||||
/// The compressor that performs the compression operation MUST generate one or more RFC 1951
|
||||
/// blocks, as defined in [RFC1951]. The number, deflation mode, and type of RFC 1951 blocks in each
|
||||
/// MSZIP block is determined by the compressor, as defined in [RFC1951]. The last RFC 1951 block in
|
||||
/// each MSZIP block MUST be marked as the "end" of the stream(1), as defined by [RFC1951]
|
||||
/// section 3.2.3. Decoding trees MUST be discarded after each RFC 1951 block, but the history buffer
|
||||
/// MUST be maintained.Each MSZIP block MUST represent no more than 32 KB of uncompressed data.
|
||||
///
|
||||
/// The maximum compressed size of each MSZIP block is 32 KB + 12 bytes. This enables the MSZIP
|
||||
/// block to contain 32 KB of data split between two noncompressed RFC 1951 blocks, each of which
|
||||
/// has a value of BTYPE = 00.
|
||||
/// </summary>
|
||||
/// <see href="https://interoperability.blob.core.windows.net/files/MS-MCI/%5bMS-MCI%5d.pdf"/>
|
||||
public class BlockHeader
|
||||
|
||||
28
Compression/MSZIP/CompressedBlockHeader.cs
Normal file
28
Compression/MSZIP/CompressedBlockHeader.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace SabreTools.Models.Compression.MSZIP
|
||||
{
|
||||
/// <summary>
|
||||
/// Compression with Huffman codes (BTYPE=01 or BTYPE=02)
|
||||
/// </summary>
|
||||
/// <see href="https://interoperability.blob.core.windows.net/files/MS-MCI/%5bMS-MCI%5d.pdf"/>
|
||||
/// <see href="https://www.rfc-editor.org/rfc/rfc1951"/>
|
||||
public abstract class CompressedDataHeader : DataHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// Huffman code lengths for the literal / length alphabet
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public virtual uint[] LiteralLengths { get; set; }
|
||||
#else
|
||||
public virtual uint[]? LiteralLengths { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Huffman distance codes for the literal / length alphabet
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public virtual uint[] DistanceCodes { get; set; }
|
||||
#else
|
||||
public virtual uint[]? DistanceCodes { get; set; }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Compression/MSZIP/DataHeader.cs
Normal file
11
Compression/MSZIP/DataHeader.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace SabreTools.Models.Compression.MSZIP
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for all data headers (BTYPE=00, BTYPE=01, or BTYPE=02)
|
||||
/// </summary>
|
||||
/// <see href="https://www.rfc-editor.org/rfc/rfc1951"/>
|
||||
public abstract class DataHeader
|
||||
{
|
||||
// No common fields between all data headers
|
||||
}
|
||||
}
|
||||
47
Compression/MSZIP/DeflateBlock.cs
Normal file
47
Compression/MSZIP/DeflateBlock.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
namespace SabreTools.Models.Compression.MSZIP
|
||||
{
|
||||
/// <summary>
|
||||
/// Each MSZIP block is the result of a single deflate compression operation, as defined in [RFC1951].
|
||||
/// The compressor that performs the compression operation MUST generate one or more RFC 1951
|
||||
/// blocks, as defined in [RFC1951]. The number, deflation mode, and type of RFC 1951 blocks in each
|
||||
/// MSZIP block is determined by the compressor, as defined in [RFC1951]. The last RFC 1951 block in
|
||||
/// each MSZIP block MUST be marked as the "end" of the stream(1), as defined by [RFC1951]
|
||||
/// section 3.2.3. Decoding trees MUST be discarded after each RFC 1951 block, but the history buffer
|
||||
/// MUST be maintained.Each MSZIP block MUST represent no more than 32 KB of uncompressed data.
|
||||
/// </summary>
|
||||
/// <see href="https://interoperability.blob.core.windows.net/files/MS-MCI/%5bMS-MCI%5d.pdf"/>
|
||||
public class DeflateBlock
|
||||
{
|
||||
/// <summary>
|
||||
/// Deflate block (RFC-1951) header
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public DeflateBlockHeader Header { get; set; }
|
||||
#else
|
||||
public DeflateBlockHeader? Header { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Compression-specific data header
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public DataHeader DataHeader { get; set; }
|
||||
#else
|
||||
public DataHeader? DataHeader { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// MSZIP data
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Depending on the implementation of these models, this property could either be
|
||||
/// compressed or uncompressed data. Keep this in mind when using the built
|
||||
/// versions of this model.
|
||||
/// </remarks>
|
||||
#if NET48
|
||||
public byte[] Data { get; set; }
|
||||
#else
|
||||
public byte[]? Data { get; set; }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Compression/MSZIP/DynamicCompressedDataHeader.cs
Normal file
11
Compression/MSZIP/DynamicCompressedDataHeader.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace SabreTools.Models.Compression.MSZIP
|
||||
{
|
||||
/// <summary>
|
||||
/// Compression with dynamic Huffman codes (BTYPE=10)
|
||||
/// </summary>
|
||||
/// <see href="https://www.rfc-editor.org/rfc/rfc1951"/>
|
||||
public class DynamicCompressedDataHeader : CompressedDataHeader
|
||||
{
|
||||
// Codes are provided externally
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
namespace SabreTools.Models.Compression.MSZIP
|
||||
{
|
||||
/// <summary>
|
||||
/// Compression with dynamic Huffman codes (BTYPE=10)
|
||||
/// </summary>
|
||||
/// <see href="https://www.rfc-editor.org/rfc/rfc1951"/>
|
||||
public class DynamicHuffmanCompressedBlockHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// Huffman code lengths for the literal / length alphabet
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public int[] LiteralLengths { get; set; }
|
||||
#else
|
||||
public int[]? LiteralLengths { get; set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Huffman distance codes for the literal / length alphabet
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public int[] DistanceCodes { get; set; }
|
||||
#else
|
||||
public int[]? DistanceCodes { get; set; }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace SabreTools.Models.Compression.MSZIP
|
||||
/// </summary>
|
||||
/// <see href="https://interoperability.blob.core.windows.net/files/MS-MCI/%5bMS-MCI%5d.pdf"/>
|
||||
/// <see href="https://www.rfc-editor.org/rfc/rfc1951"/>
|
||||
public class FixedHuffmanCompressedBlockHeader
|
||||
public class FixedCompressedDataHeader : CompressedDataHeader
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace SabreTools.Models.Compression.MSZIP
|
||||
/// Huffman code lengths for the literal / length alphabet
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public uint[] LiteralLengths
|
||||
public override uint[] LiteralLengths
|
||||
#else
|
||||
public uint[]? LiteralLengths
|
||||
public override uint[]? LiteralLengths
|
||||
#endif
|
||||
{
|
||||
get
|
||||
@@ -57,9 +57,9 @@ namespace SabreTools.Models.Compression.MSZIP
|
||||
/// Huffman distance codes for the literal / length alphabet
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public uint[] DistanceCodes
|
||||
public override uint[] DistanceCodes
|
||||
#else
|
||||
public uint[]? DistanceCodes
|
||||
public override uint[]? DistanceCodes
|
||||
#endif
|
||||
{
|
||||
get
|
||||
@@ -4,7 +4,7 @@ namespace SabreTools.Models.Compression.MSZIP
|
||||
/// Non-compressed blocks (BTYPE=00)
|
||||
/// </summary>
|
||||
/// <see href="https://www.rfc-editor.org/rfc/rfc1951"/>
|
||||
public class NonCompressedBlockHeader
|
||||
public class NonCompressedBlockHeader : DataHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of data bytes in the block
|
||||
@@ -4,7 +4,7 @@
|
||||
<!-- Assembly Properties -->
|
||||
<TargetFrameworks>net48;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x86;win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
|
||||
<Version>1.1.2</Version>
|
||||
<Version>1.1.3</Version>
|
||||
|
||||
<!-- Package Properties -->
|
||||
<Authors>Matt Nadareski</Authors>
|
||||
|
||||
Reference in New Issue
Block a user