From 0c95cfcde45a10016c4bdc35523c75fc308c92e3 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 22 Sep 2023 20:47:29 -0400 Subject: [PATCH] More LZX cleanup --- Compression/LZX/AlignedOffsetBlockData.cs | 12 +++++-- Compression/LZX/Constants.cs | 40 +++++++++-------------- Compression/LZX/VerbatimBlockData.cs | 12 +++++-- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/Compression/LZX/AlignedOffsetBlockData.cs b/Compression/LZX/AlignedOffsetBlockData.cs index 746a0f6..6279f4f 100644 --- a/Compression/LZX/AlignedOffsetBlockData.cs +++ b/Compression/LZX/AlignedOffsetBlockData.cs @@ -77,8 +77,14 @@ namespace SabreTools.Models.Compression.LZX public int[]? PathLengthsLengthTree { get; set; } #endif - // Entry Comments Size - // --------------------------------------------------------------------------------------- - // Token sequence (matches and literals) Specified in section 2.6 Variable + /// + /// Token sequence (matches and literals) + /// + /// Variable +#if NET48 + public byte[] TokenSequence { get; set; } +#else + public byte[]? TokenSequence { get; set; } +#endif } } \ No newline at end of file diff --git a/Compression/LZX/Constants.cs b/Compression/LZX/Constants.cs index a8b1b65..07c0330 100644 --- a/Compression/LZX/Constants.cs +++ b/Compression/LZX/Constants.cs @@ -3,44 +3,36 @@ namespace SabreTools.Models.Compression.LZX public static class Constants { /* some constants defined by the LZX specification */ - public const int LZX_MIN_MATCH = (2); - public const int LZX_MAX_MATCH = (257); - public const int LZX_NUM_CHARS = (256); - - /// - /// also blocktypes 4-7 invalid - /// - public const int LZX_BLOCKTYPE_INVALID = (0); - public const int LZX_BLOCKTYPE_VERBATIM = (1); - public const int LZX_BLOCKTYPE_ALIGNED = (2); - public const int LZX_BLOCKTYPE_UNCOMPRESSED = (3); - public const int LZX_PRETREE_NUM_ELEMENTS = (20); + public const int LZX_MIN_MATCH = 2; + public const int LZX_MAX_MATCH = 257; + public const int LZX_NUM_CHARS = 256; + public const int LZX_PRETREE_NUM_ELEMENTS = 20; /// /// aligned offset tree #elements /// - public const int LZX_ALIGNED_NUM_ELEMENTS = (8); + public const int LZX_ALIGNED_NUM_ELEMENTS = 8; /// /// this one missing from spec! /// - public const int LZX_NUM_PRIMARY_LENGTHS = (7); + public const int LZX_NUM_PRIMARY_LENGTHS = 7; /// /// length tree #elements /// - public const int LZX_NUM_SECONDARY_LENGTHS = (249); + public const int LZX_NUM_SECONDARY_LENGTHS = 249; /* LZX huffman defines: tweak tablebits as desired */ - public const int LZX_PRETREE_MAXSYMBOLS = (LZX_PRETREE_NUM_ELEMENTS); - public const int LZX_PRETREE_TABLEBITS = (6); - public const int LZX_MAINTREE_MAXSYMBOLS = (LZX_NUM_CHARS + 50 * 8); - public const int LZX_MAINTREE_TABLEBITS = (12); - public const int LZX_LENGTH_MAXSYMBOLS = (LZX_NUM_SECONDARY_LENGTHS + 1); - public const int LZX_LENGTH_TABLEBITS = (12); - public const int LZX_ALIGNED_MAXSYMBOLS = (LZX_ALIGNED_NUM_ELEMENTS); - public const int LZX_ALIGNED_TABLEBITS = (7); + public const int LZX_PRETREE_MAXSYMBOLS = LZX_PRETREE_NUM_ELEMENTS; + public const int LZX_PRETREE_TABLEBITS = 6; + public const int LZX_MAINTREE_MAXSYMBOLS = LZX_NUM_CHARS + 50 * 8; + public const int LZX_MAINTREE_TABLEBITS = 12; + public const int LZX_LENGTH_MAXSYMBOLS = LZX_NUM_SECONDARY_LENGTHS + 1; + public const int LZX_LENGTH_TABLEBITS = 12; + public const int LZX_ALIGNED_MAXSYMBOLS = LZX_ALIGNED_NUM_ELEMENTS; + public const int LZX_ALIGNED_TABLEBITS = 7; - public const int LZX_LENTABLE_SAFETY = (64); /* we allow length table decoding overruns */ + public const int LZX_LENTABLE_SAFETY = 64; /* we allow length table decoding overruns */ } } \ No newline at end of file diff --git a/Compression/LZX/VerbatimBlockData.cs b/Compression/LZX/VerbatimBlockData.cs index a2d2c67..e9284e7 100644 --- a/Compression/LZX/VerbatimBlockData.cs +++ b/Compression/LZX/VerbatimBlockData.cs @@ -66,8 +66,14 @@ namespace SabreTools.Models.Compression.LZX public int[]? PathLengthsLengthTree { get; set; } #endif - // Entry Comments Size - // --------------------------------------------------------------------------------------- - // Token sequence (matches and literals) Specified in section 2.6 Variable + /// + /// Token sequence (matches and literals) + /// + /// Variable +#if NET48 + public byte[] TokenSequence { get; set; } +#else + public byte[]? TokenSequence { get; set; } +#endif } } \ No newline at end of file