From 6d6361c153d627a3b9686ada4e18781eeddbbddb Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 22 Sep 2023 20:40:22 -0400 Subject: [PATCH] Start making LZX models better --- ...fsetBlock.cs => AlignedOffsetBlockData.cs} | 11 +------ Compression/LZX/Block.cs | 32 +++++++++++++++++++ Compression/LZX/BlockData.cs | 8 +++++ Compression/LZX/BlockHeader.cs | 11 ++----- ...essedBlock.cs => UncompressedBlockData.cs} | 11 +------ ...{VerbatimBlock.cs => VerbatimBlockData.cs} | 11 +------ 6 files changed, 46 insertions(+), 38 deletions(-) rename Compression/LZX/{AlignedOffsetBlock.cs => AlignedOffsetBlockData.cs} (91%) create mode 100644 Compression/LZX/Block.cs create mode 100644 Compression/LZX/BlockData.cs rename Compression/LZX/{UncompressedBlock.cs => UncompressedBlockData.cs} (91%) rename Compression/LZX/{VerbatimBlock.cs => VerbatimBlockData.cs} (90%) diff --git a/Compression/LZX/AlignedOffsetBlock.cs b/Compression/LZX/AlignedOffsetBlockData.cs similarity index 91% rename from Compression/LZX/AlignedOffsetBlock.cs rename to Compression/LZX/AlignedOffsetBlockData.cs index 483621e..746a0f6 100644 --- a/Compression/LZX/AlignedOffsetBlock.cs +++ b/Compression/LZX/AlignedOffsetBlockData.cs @@ -5,17 +5,8 @@ namespace SabreTools.Models.Compression.LZX /// tree preceding the other trees. /// /// - public class AlignedOffsetBlock + public class AlignedOffsetBlockData : BlockData { - /// - /// Generic block header - /// -#if NET48 - public BlockHeader Header { get; set; } -#else - public BlockHeader? Header { get; set; } -#endif - /// /// Aligned offset tree /// diff --git a/Compression/LZX/Block.cs b/Compression/LZX/Block.cs new file mode 100644 index 0000000..f6da385 --- /dev/null +++ b/Compression/LZX/Block.cs @@ -0,0 +1,32 @@ +namespace SabreTools.Models.Compression.LZX +{ + /// + /// An LZXD block represents a sequence of compressed data that is encoded with the same set of + /// Huffman trees, or a sequence of uncompressed data. There can be one or more LZXD blocks in a + /// compressed stream, each with its own set of Huffman trees. Blocks do not have to start or end on a + /// chunk boundary; blocks can span multiple chunks, or a single chunk can contain multiple blocks. The + /// number of chunks is related to the size of the data being compressed, while the number of blocks is + /// related to how well the data is compressed. + /// + /// + public class Block + { + /// + /// Block header + /// +#if NET48 + public BlockHeader Header { get; set; } +#else + public BlockHeader? Header { get; set; } +#endif + + /// + /// Block data + /// +#if NET48 + public BlockData BlockData { get; set; } +#else + public BlockData? BlockData { get; set; } +#endif + } +} \ No newline at end of file diff --git a/Compression/LZX/BlockData.cs b/Compression/LZX/BlockData.cs new file mode 100644 index 0000000..939f9c9 --- /dev/null +++ b/Compression/LZX/BlockData.cs @@ -0,0 +1,8 @@ +namespace SabreTools.Models.Compression.LZX +{ + /// + public abstract class BlockData + { + // No common fields between all block data + } +} \ No newline at end of file diff --git a/Compression/LZX/BlockHeader.cs b/Compression/LZX/BlockHeader.cs index aa34495..bd10219 100644 --- a/Compression/LZX/BlockHeader.cs +++ b/Compression/LZX/BlockHeader.cs @@ -1,14 +1,9 @@ namespace SabreTools.Models.Compression.LZX { /// - /// An LZXD block represents a sequence of compressed data that is encoded with the same set of - /// Huffman trees, or a sequence of uncompressed data. There can be one or more LZXD blocks in a - /// compressed stream, each with its own set of Huffman trees. Blocks do not have to start or end on a - /// chunk boundary; blocks can span multiple chunks, or a single chunk can contain multiple blocks. The - /// number of chunks is related to the size of the data being compressed, while the number of blocks is - /// related to how well the data is compressed. The Block Type field, as specified in section 2.3.1.1, - /// indicates which type of block follows, and the Block Size field, as specified in section 2.3.1.2, - /// indicates the number of uncompressed bytes represented by the block. Following the generic block + /// The Block Type field, as specified in section 2.3.1.1, indicates which type of block follows, + /// and the Block Size field, as specified in section 2.3.1.2, indicates the number of + /// uncompressed bytes represented by the block. Following the generic block /// header is a type-specific header that describes the remainder of the block. /// /// diff --git a/Compression/LZX/UncompressedBlock.cs b/Compression/LZX/UncompressedBlockData.cs similarity index 91% rename from Compression/LZX/UncompressedBlock.cs rename to Compression/LZX/UncompressedBlockData.cs index 6b418d2..b3fafa5 100644 --- a/Compression/LZX/UncompressedBlock.cs +++ b/Compression/LZX/UncompressedBlockData.cs @@ -14,17 +14,8 @@ namespace SabreTools.Models.Compression.LZX /// subsequent compressed block if present. /// /// - public class UncompressedBlock + public class UncompressedBlockData : BlockData { - /// - /// Generic block header - /// -#if NET48 - public BlockHeader Header { get; set; } -#else - public BlockHeader? Header { get; set; } -#endif - /// /// Padding to align following field on 16-bit boundary /// diff --git a/Compression/LZX/VerbatimBlock.cs b/Compression/LZX/VerbatimBlockData.cs similarity index 90% rename from Compression/LZX/VerbatimBlock.cs rename to Compression/LZX/VerbatimBlockData.cs index aa901f6..a2d2c67 100644 --- a/Compression/LZX/VerbatimBlock.cs +++ b/Compression/LZX/VerbatimBlockData.cs @@ -4,17 +4,8 @@ namespace SabreTools.Models.Compression.LZX /// The fields of a verbatim block that follow the generic block header /// /// - public class VerbatimBlock + public class VerbatimBlockData : BlockData { - /// - /// Generic block header - /// -#if NET48 - public BlockHeader Header { get; set; } -#else - public BlockHeader? Header { get; set; } -#endif - /// /// Pretree for first 256 elements of main tree ///