diff --git a/BurnOutSharp.Compression/LZX.cs b/BurnOutSharp.Compression/LZX.cs deleted file mode 100644 index b557ccd6..00000000 --- a/BurnOutSharp.Compression/LZX.cs +++ /dev/null @@ -1,9 +0,0 @@ -using BurnOutSharp.Models.Compression.LZX; - -namespace BurnOutSharp.Compression -{ - public class LZX - { - // TODO: Implement LZX decompression - } -} \ No newline at end of file diff --git a/BurnOutSharp.Compression/LZX/Bits.cs b/BurnOutSharp.Compression/LZX/Bits.cs new file mode 100644 index 00000000..89fa42f4 --- /dev/null +++ b/BurnOutSharp.Compression/LZX/Bits.cs @@ -0,0 +1,12 @@ +namespace BurnOutSharp.Compression.LZX +{ + /// + public class Bits + { + public uint BitBuffer; + + public int BitLength; + + public int InitialPosition; //byte* + } +} \ No newline at end of file diff --git a/BurnOutSharp.Compression/LZX/State.cs b/BurnOutSharp.Compression/LZX/State.cs new file mode 100644 index 00000000..529d6c9f --- /dev/null +++ b/BurnOutSharp.Compression/LZX/State.cs @@ -0,0 +1,83 @@ +using static BurnOutSharp.Models.Compression.LZX.Constants; + +namespace BurnOutSharp.Compression.LZX +{ + /// + public class State + { + /// + /// the actual decoding window + /// + public byte[] window; + + /// + /// window size (32Kb through 2Mb) + /// + public uint window_size; + + /// + /// window size when it was first allocated + /// + public uint actual_size; + + /// + /// current offset within the window + /// + public uint window_posn; + + /// + /// for the LRU offset system + /// + public uint R0, R1, R2; + + /// + /// number of main tree elements + /// + public ushort main_elements; + + /// + /// have we started decoding at all yet? + /// + public int header_read; + + /// + /// type of this block + /// + public ushort block_type; + + /// + /// uncompressed length of this block + /// + public uint block_length; + + /// + /// uncompressed bytes still left to decode + /// + public uint block_remaining; + + /// + /// the number of CFDATA blocks processed + /// + public uint frames_read; + + /// + /// magic header value used for transform + /// + public int intel_filesize; + + /// + /// current offset in transform space + /// + public int intel_curpos; + + /// + /// have we seen any translatable data yet? + /// + public int intel_started; + + public ushort[] tblPRETREE_table = new ushort[(1 << LZX_PRETREE_TABLEBITS) + (LZX_PRETREE_MAXSYMBOLS << 1)]; + public ushort[] tblMAINTREE_table = new ushort[(1 << LZX_MAINTREE_TABLEBITS) + (LZX_MAINTREE_MAXSYMBOLS << 1)]; + public ushort[] tblLENGTH_table = new ushort[(1 << LZX_LENGTH_TABLEBITS) + (LZX_LENGTH_MAXSYMBOLS << 1)]; + public ushort[] tblALIGNED_table = new ushort[(1 << LZX_ALIGNED_TABLEBITS) + (LZX_ALIGNED_MAXSYMBOLS << 1)]; + } +} \ No newline at end of file diff --git a/BurnOutSharp.Models/Compression/LZX/Constants.cs b/BurnOutSharp.Models/Compression/LZX/Constants.cs new file mode 100644 index 00000000..a3921030 --- /dev/null +++ b/BurnOutSharp.Models/Compression/LZX/Constants.cs @@ -0,0 +1,46 @@ +namespace BurnOutSharp.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); + + /// + /// aligned offset tree #elements + /// + public const int LZX_ALIGNED_NUM_ELEMENTS = (8); + + /// + /// this one missing from spec! + /// + public const int LZX_NUM_PRIMARY_LENGTHS = (7); + + /// + /// length tree #elements + /// + 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_LENTABLE_SAFETY = (64); /* we allow length table decoding overruns */ + } +} \ No newline at end of file diff --git a/BurnOutSharp.Wrappers/MicrosoftCabinet.fdi.cs b/BurnOutSharp.Wrappers/MicrosoftCabinet.fdi.cs index d4379c81..35295869 100644 --- a/BurnOutSharp.Wrappers/MicrosoftCabinet.fdi.cs +++ b/BurnOutSharp.Wrappers/MicrosoftCabinet.fdi.cs @@ -1102,74 +1102,6 @@ // /* MSZIP stuff */ -// /// -// /// window size -// /// -// public const ushort ZIPWSIZE = 0x8000; - -// /// -// /// bits in base literal/length lookup table -// /// -// public const int ZIPLBITS = 9; - -// /// -// /// bits in base distance lookup table -// /// -// public const int ZIPDBITS = 6; - -// /// -// /// maximum bit length of any code -// /// -// public const int ZIPBMAX = 16; - -// /// -// /// maximum number of codes in any set -// /// -// public const int ZIPN_MAX = 288; - -// /* LZX stuff */ - -// /* 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); - -// /// -// /// aligned offset tree #elements -// /// -// public const int LZX_ALIGNED_NUM_ELEMENTS = (8); - -// /// -// /// this one missing from spec! -// /// -// public const int LZX_NUM_PRIMARY_LENGTHS = (7); - -// /// -// /// length tree #elements -// /// -// 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_LENTABLE_SAFETY = (64); /* we allow length table decoding overruns */ - // /* CAB data blocks are <= 32768 bytes in uncompressed form. Uncompressed // * blocks have zero growth. MSZIP guarantees that it won't grow above // * uncompressed size by more than 12 bytes. LZX guarantees it won't grow @@ -1183,97 +1115,6 @@ // public const uint EXTRACT_EXTRACTFILES = 0x00000002; // } -// /* LZX stuff */ - -// /// -// internal class LZXstate -// { -// /// -// /// the actual decoding window -// /// -// public byte[] window; - -// /// -// /// window size (32Kb through 2Mb) -// /// -// public uint window_size; - -// /// -// /// window size when it was first allocated -// /// -// public uint actual_size; - -// /// -// /// current offset within the window -// /// -// public uint window_posn; - -// /// -// /// for the LRU offset system -// /// -// public uint R0, R1, R2; - -// /// -// /// number of main tree elements -// /// -// public ushort main_elements; - -// /// -// /// have we started decoding at all yet? -// /// -// public int header_read; - -// /// -// /// type of this block -// /// -// public ushort block_type; - -// /// -// /// uncompressed length of this block -// /// -// public uint block_length; - -// /// -// /// uncompressed bytes still left to decode -// /// -// public uint block_remaining; - -// /// -// /// the number of CFDATA blocks processed -// /// -// public uint frames_read; - -// /// -// /// magic header value used for transform -// /// -// public int intel_filesize; - -// /// -// /// current offset in transform space -// /// -// public int intel_curpos; - -// /// -// /// have we seen any translatable data yet? -// /// -// public int intel_started; - -// public ushort[] tblPRETREE_table = new ushort[(1 << LZX_PRETREE_TABLEBITS) + (LZX_PRETREE_MAXSYMBOLS << 1)]; -// public ushort[] tblMAINTREE_table = new ushort[(1 << LZX_MAINTREE_TABLEBITS) + (LZX_MAINTREE_MAXSYMBOLS << 1)]; -// public ushort[] tblLENGTH_table = new ushort[(1 << LZX_LENGTH_TABLEBITS) + (LZX_LENGTH_MAXSYMBOLS << 1)]; -// public ushort[] tblALIGNED_table = new ushort[(1 << LZX_ALIGNED_TABLEBITS) + (LZX_ALIGNED_MAXSYMBOLS << 1)]; -// } - -// /// -// internal class lzx_bits -// { -// public uint bb; - -// public int bl; - -// public byte* ip; -// } - // /****************************************************************************/ // /// @@ -1480,7 +1321,7 @@ // public Compression.MSZIP.State zip; // public Compression.Quantum.State qtm; -// public LZXstate lzx; +// public Compression.LZX.State lzx; // #endregion // } @@ -1811,7 +1652,7 @@ // public Compression.MSZIP.State zip; // public Compression.Quantum.State qtm; -// public LZXstate lzx; +// public Compression.LZX.State lzx; // #endregion