Fix LZ4F compression for KSA
This commit is contained in:
parent
a43e00ff5d
commit
cba330d41d
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -54,10 +54,10 @@ namespace Switch_Toolbox.Library.IO
|
||||
}
|
||||
if (extension == ".cmp")
|
||||
{
|
||||
FileIsCompressed = true;
|
||||
CompressionType = CompressionType.Lz4f;
|
||||
}
|
||||
|
||||
|
||||
if (EnableDialog && FileIsCompressed)
|
||||
{
|
||||
DialogResult save = MessageBox.Show($"Compress file with {CompressionType}?", "File Save", MessageBoxButtons.YesNo);
|
||||
@ -449,25 +449,14 @@ namespace Switch_Toolbox.Library.IO
|
||||
}
|
||||
public static byte[] Compress(byte[] data)
|
||||
{
|
||||
LZ4EncoderSettings settings = new LZ4EncoderSettings();
|
||||
settings.ChainBlocks = false;
|
||||
// settings.BlockSize = K4os.Compression.LZ4.Internal.Mem.M1;
|
||||
|
||||
using (MemoryStream mem = new MemoryStream())
|
||||
var stream = new MemoryStream();
|
||||
using (var writer = new FileWriter(stream))
|
||||
{
|
||||
var encodeSettings = new LZ4EncoderSettings();
|
||||
using (var source = LZ4Stream.Encode(mem, settings))
|
||||
{
|
||||
source.Write(data, 0, data.Length);
|
||||
|
||||
var newMem = new MemoryStream();
|
||||
BinaryWriter writer = new BinaryWriter(newMem);
|
||||
writer.Write((uint)data.Length);
|
||||
writer.Write(mem.ToArray());
|
||||
writer.Write((uint)973407368);
|
||||
return newMem.ToArray();
|
||||
}
|
||||
writer.Write(data.Length);
|
||||
byte[] buffer = LZ4.Frame.LZ4Frame.Compress(new MemoryStream(data), LZ4.Frame.LZ4MaxBlockSize.Auto, true, true, false, false, true);
|
||||
writer.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
public class Type_LZ4
|
||||
|
@ -77,6 +77,9 @@
|
||||
<HintPath>..\packages\lz4net.1.0.15.93\lib\net4-client\LZ4.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="LZ4.Frame">
|
||||
<HintPath>..\Toolbox\Lib\LZ4.Frame.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="NAudio, Version=1.8.4.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
BIN
Toolbox/Lib/Extensions.Data.xxHash.dll
Normal file
BIN
Toolbox/Lib/Extensions.Data.xxHash.dll
Normal file
Binary file not shown.
BIN
Toolbox/Lib/LZ4.Frame.dll
Normal file
BIN
Toolbox/Lib/LZ4.Frame.dll
Normal file
Binary file not shown.
68
Toolbox/Lib/LZ4.Frame.xml
Normal file
68
Toolbox/Lib/LZ4.Frame.xml
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>LZ4.Frame</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:LZ4.Frame.LZ4MaxBlockSize">
|
||||
<summary>
|
||||
Max size for each LZ4 block
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:LZ4.Frame.LZ4MaxBlockSize.Auto">
|
||||
<summary>
|
||||
4MB by default
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:LZ4.Frame.LZ4MaxBlockSize.KB64">
|
||||
<summary>
|
||||
64 KB
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:LZ4.Frame.LZ4MaxBlockSize.KB256">
|
||||
<summary>
|
||||
256 KB
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:LZ4.Frame.LZ4MaxBlockSize.MB1">
|
||||
<summary>
|
||||
1 MB
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:LZ4.Frame.LZ4MaxBlockSize.MB4">
|
||||
<summary>
|
||||
4 MB
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:LZ4.Frame.LZ4Frame">
|
||||
<summary>
|
||||
LZ4 Frame Compression
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:LZ4.Frame.LZ4Frame.MAGIC">
|
||||
<summary>
|
||||
LZ4 Frame Header Signature
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:LZ4.Frame.LZ4Frame.Compress(System.IO.Stream,LZ4.Frame.LZ4MaxBlockSize,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Boolean)">
|
||||
<summary>
|
||||
LZ4 Frame Compress
|
||||
</summary>
|
||||
<param name="input">stream to be compressed (won't be closed)</param>
|
||||
<param name="blockSizeType">max size (before compress) per block</param>
|
||||
<param name="useIndependenceBlock">only True works</param>
|
||||
<param name="useUncompressedBlock">If a block is better not to compress, will use original data</param>
|
||||
<param name="useBlockChecksum">Checksum for every block, not recommended</param>
|
||||
<param name="useContentChecksum">Checksum for whole content, recommended</param>
|
||||
<param name="useContentSize">If content size can be get, there's no reason to set it to False</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:LZ4.Frame.LZ4Frame.Decompress(System.IO.Stream)">
|
||||
<summary>
|
||||
LZ4 Frame Decompress
|
||||
</summary>
|
||||
<param name="input">stream to be decompressed (won't be closed)</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
@ -271,6 +271,9 @@
|
||||
<Content Include="Lib\EditorCoreCommon.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Lib\Extensions.Data.xxHash.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Lib\FirstPlugin.Plg.dll" />
|
||||
<Content Include="Lib\GL_Core.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
@ -309,6 +312,9 @@
|
||||
<Content Include="Lib\LZ4.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Lib\LZ4.Frame.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Lib\NAudio.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
Loading…
x
Reference in New Issue
Block a user