This commit is contained in:
Adam Hathcock
2025-10-13 17:02:41 +01:00
parent 906baf18d2
commit ee2cbc8051
118 changed files with 3268 additions and 4662 deletions

View File

@@ -45,20 +45,13 @@ public class ArcFilePart : FilePart
);
break;
case CompressionType.RLE90:
compressedStream = new RunLength90Stream(
_stream,
(int)Header.CompressedSize
);
compressedStream = new RunLength90Stream(_stream, (int)Header.CompressedSize);
break;
case CompressionType.Squeezed:
compressedStream = new SqueezeStream(_stream, (int)Header.CompressedSize);
break;
case CompressionType.Crunched:
compressedStream = new ArcLzwStream(
_stream,
(int)Header.CompressedSize,
true
);
compressedStream = new ArcLzwStream(_stream, (int)Header.CompressedSize, true);
break;
default:
throw new NotSupportedException(
@@ -71,4 +64,4 @@ public class ArcFilePart : FilePart
}
internal override Stream? GetRawStream() => _stream;
}
}

View File

@@ -32,4 +32,4 @@ internal class DeltaFilter : Filter
return count;
}
}
}

View File

@@ -61,4 +61,4 @@ public sealed class LzwConstants
public const int INIT_BITS = 9;
private LzwConstants() { }
}
}

View File

@@ -46,7 +46,7 @@ namespace SharpCompress.Compressors.Lzw;
public class LzwStream : Stream, IStreamStack
{
#if DEBUG_STREAMS
long IStreamStack.InstanceId { get; set; }
long IStreamStack.InstanceId { get; set; }
#endif
int IStreamStack.DefaultBufferSize { get; set; }
@@ -112,7 +112,7 @@ public class LzwStream : Stream, IStreamStack
{
this.baseInputStream = baseInputStream;
#if DEBUG_STREAMS
this.DebugConstruct(typeof(LzwStream));
this.DebugConstruct(typeof(LzwStream));
#endif
}
@@ -237,13 +237,13 @@ public class LzwStream : Stream, IStreamStack
// read next code
int pos = lBitPos >> 3;
int code =
(
(
(lData[pos] & 0xFF)
| ((lData[pos + 1] & 0xFF) << 8)
| ((lData[pos + 2] & 0xFF) << 16)
) >> (lBitPos & 0x7)
) & lBitMask;
(
(lData[pos] & 0xFF)
| ((lData[pos + 1] & 0xFF) << 8)
| ((lData[pos + 2] & 0xFF) << 16)
) >> (lBitPos & 0x7)
) & lBitMask;
lBitPos += lNBits;
@@ -251,9 +251,7 @@ public class LzwStream : Stream, IStreamStack
if (lOldCode == -1)
{
if (code >= 256)
throw new IncompleteArchiveException(
"corrupt input: " + code + " > 255"
);
throw new IncompleteArchiveException("corrupt input: " + code + " > 255");
lFinChar = (byte)(lOldCode = code);
buffer[offset++] = lFinChar;
@@ -423,10 +421,10 @@ public class LzwStream : Stream, IStreamStack
{
throw new ArchiveException(
"Stream compressed with "
+ maxBits
+ " bits, but decompression can only handle "
+ LzwConstants.MAX_BITS
+ " bits."
+ maxBits
+ " bits, but decompression can only handle "
+ LzwConstants.MAX_BITS
+ " bits."
);
}
@@ -564,7 +562,7 @@ public class LzwStream : Stream, IStreamStack
{
isClosed = true;
#if DEBUG_STREAMS
this.DebugDispose(typeof(LzwStream));
this.DebugDispose(typeof(LzwStream));
#endif
if (IsStreamOwner)
{

View File

@@ -11,7 +11,7 @@ namespace SharpCompress.Compressors.RLE90;
public class RunLength90Stream : Stream, IStreamStack
{
#if DEBUG_STREAMS
long IStreamStack.InstanceId { get; set; }
long IStreamStack.InstanceId { get; set; }
#endif
int IStreamStack.DefaultBufferSize { get; set; }
@@ -40,14 +40,14 @@ public class RunLength90Stream : Stream, IStreamStack
_stream = stream;
_compressedSize = compressedSize;
#if DEBUG_STREAMS
this.DebugConstruct(typeof(RunLength90Stream));
this.DebugConstruct(typeof(RunLength90Stream));
#endif
}
protected override void Dispose(bool disposing)
{
#if DEBUG_STREAMS
this.DebugDispose(typeof(RunLength90Stream));
this.DebugDispose(typeof(RunLength90Stream));
#endif
base.Dispose(disposing);
}

View File

@@ -12,7 +12,7 @@ namespace SharpCompress.Compressors.Squeezed;
public class SqueezeStream : Stream, IStreamStack
{
#if DEBUG_STREAMS
long IStreamStack.InstanceId { get; set; }
long IStreamStack.InstanceId { get; set; }
#endif
int IStreamStack.DefaultBufferSize { get; set; }
@@ -42,14 +42,14 @@ public class SqueezeStream : Stream, IStreamStack
_stream = stream;
_compressedSize = compressedSize;
#if DEBUG_STREAMS
this.DebugConstruct(typeof(SqueezeStream));
this.DebugConstruct(typeof(SqueezeStream));
#endif
}
protected override void Dispose(bool disposing)
{
#if DEBUG_STREAMS
this.DebugDispose(typeof(SqueezeStream));
this.DebugDispose(typeof(SqueezeStream));
#endif
base.Dispose(disposing);
}

View File

@@ -77,7 +77,7 @@ public class CompressionStream : Stream
#if !NETSTANDARD2_0 && !NETFRAMEWORK
public override async ValueTask DisposeAsync()
#else
public async Task DisposeAsync()
public async Task DisposeAsync()
#endif
{
if (compressor == null)
@@ -149,8 +149,8 @@ public class CompressionStream : Stream
public override void Write(ReadOnlySpan<byte> buffer) =>
WriteInternal(buffer, ZSTD_EndDirective.ZSTD_e_continue);
#else
public void Write(ReadOnlySpan<byte> buffer) =>
WriteInternal(buffer, ZSTD_EndDirective.ZSTD_e_continue);
public void Write(ReadOnlySpan<byte> buffer) =>
WriteInternal(buffer, ZSTD_EndDirective.ZSTD_e_continue);
#endif
private void WriteInternal(ReadOnlySpan<byte> buffer, ZSTD_EndDirective directive)
@@ -172,9 +172,7 @@ public class CompressionStream : Stream
if (written > 0)
innerStream.Write(outputBuffer, 0, written);
} while (
directive == ZSTD_EndDirective.ZSTD_e_continue
? input.pos < input.size
: remaining > 0
directive == ZSTD_EndDirective.ZSTD_e_continue ? input.pos < input.size : remaining > 0
);
}
@@ -185,11 +183,11 @@ public class CompressionStream : Stream
CancellationToken cancellationToken = default
)
#else
private async Task WriteInternalAsync(
ReadOnlyMemory<byte>? buffer,
ZSTD_EndDirective directive,
CancellationToken cancellationToken = default
)
private async Task WriteInternalAsync(
ReadOnlyMemory<byte>? buffer,
ZSTD_EndDirective directive,
CancellationToken cancellationToken = default
)
#endif
{
@@ -213,12 +211,10 @@ public class CompressionStream : Stream
var written = (int)output.pos;
if (written > 0)
await innerStream
.WriteAsync(outputBuffer, 0, written, cancellationToken)
.ConfigureAwait(false);
.WriteAsync(outputBuffer, 0, written, cancellationToken)
.ConfigureAwait(false);
} while (
directive == ZSTD_EndDirective.ZSTD_e_continue
? input.pos < input.size
: remaining > 0
directive == ZSTD_EndDirective.ZSTD_e_continue ? input.pos < input.size : remaining > 0
);
}
@@ -229,8 +225,7 @@ public class CompressionStream : Stream
int offset,
int count,
CancellationToken cancellationToken
) =>
WriteAsync(new ReadOnlyMemory<byte>(buffer, offset, count), cancellationToken).AsTask();
) => WriteAsync(new ReadOnlyMemory<byte>(buffer, offset, count), cancellationToken).AsTask();
public override async ValueTask WriteAsync(
ReadOnlyMemory<byte> buffer,
@@ -240,19 +235,19 @@ public class CompressionStream : Stream
.ConfigureAwait(false);
#else
public override Task WriteAsync(
byte[] buffer,
int offset,
int count,
CancellationToken cancellationToken
) => WriteAsync(new ReadOnlyMemory<byte>(buffer, offset, count), cancellationToken);
public override Task WriteAsync(
byte[] buffer,
int offset,
int count,
CancellationToken cancellationToken
) => WriteAsync(new ReadOnlyMemory<byte>(buffer, offset, count), cancellationToken);
public async Task WriteAsync(
ReadOnlyMemory<byte> buffer,
CancellationToken cancellationToken = default
) =>
await WriteInternalAsync(buffer, ZSTD_EndDirective.ZSTD_e_continue, cancellationToken)
.ConfigureAwait(false);
public async Task WriteAsync(
ReadOnlyMemory<byte> buffer,
CancellationToken cancellationToken = default
) =>
await WriteInternalAsync(buffer, ZSTD_EndDirective.ZSTD_e_continue, cancellationToken)
.ConfigureAwait(false);
#endif
internal unsafe nuint CompressStream(
@@ -267,9 +262,9 @@ public class CompressionStream : Stream
input.src = inputBufferPtr;
output.dst = outputBufferPtr;
return compressor
.NotNull()
.CompressStream(ref input, ref output, directive)
.EnsureZstdSuccess();
.NotNull()
.CompressStream(ref input, ref output, directive)
.EnsureZstdSuccess();
}
}
@@ -285,8 +280,7 @@ public class CompressionStream : Stream
set => throw new NotSupportedException();
}
public override long Seek(long offset, SeekOrigin origin) =>
throw new NotSupportedException();
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();
public override void SetLength(long value) => throw new NotSupportedException();

View File

@@ -62,9 +62,9 @@ public unsafe class Compressor : IDisposable
{
using var cctx = handle.Acquire();
fixed (byte* dictPtr = dict)
Unsafe.Methods
.ZSTD_CCtx_loadDictionary(cctx, dictPtr, (nuint)dict.Length)
.EnsureZstdSuccess();
Unsafe
.Methods.ZSTD_CCtx_loadDictionary(cctx, dictPtr, (nuint)dict.Length)
.EnsureZstdSuccess();
}
public Compressor(int level = DefaultCompressionLevel)
@@ -96,15 +96,15 @@ public unsafe class Compressor : IDisposable
{
using var cctx = handle.Acquire();
return (int)
Unsafe.Methods
.ZSTD_compress2(
cctx,
destPtr,
(nuint)dest.Length,
srcPtr,
(nuint)src.Length
)
.EnsureZstdSuccess();
Unsafe
.Methods.ZSTD_compress2(
cctx,
destPtr,
(nuint)dest.Length,
srcPtr,
(nuint)src.Length
)
.EnsureZstdSuccess();
}
}
@@ -190,9 +190,9 @@ public unsafe class Compressor : IDisposable
fixed (ZSTD_outBuffer_s* outputPtr = &output)
{
using var cctx = handle.Acquire();
return Unsafe.Methods
.ZSTD_compressStream2(cctx, outputPtr, inputPtr, directive)
.EnsureZstdSuccess();
return Unsafe
.Methods.ZSTD_compressStream2(cctx, outputPtr, inputPtr, directive)
.EnsureZstdSuccess();
}
}

View File

@@ -5,4 +5,4 @@ internal class Constants
//NOTE: https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/gcallowverylargeobjects-element#remarks
//NOTE: https://github.com/dotnet/runtime/blob/v5.0.0-rtm.20519.4/src/libraries/System.Private.CoreLib/src/System/Array.cs#L27
public const ulong MaxByteArrayLength = 0x7FFFFFC7;
}
}

View File

@@ -53,13 +53,11 @@ public class DecompressionStream : Stream
this.checkEndOfStream = checkEndOfStream;
inputBufferSize =
bufferSize > 0 ? bufferSize : (int)Unsafe.Methods.ZSTD_DStreamInSize().EnsureZstdSuccess();
bufferSize > 0
? bufferSize
: (int)Unsafe.Methods.ZSTD_DStreamInSize().EnsureZstdSuccess();
inputBuffer = ArrayPool<byte>.Shared.Rent(inputBufferSize);
input = new ZSTD_inBuffer_s
{
pos = (nuint)inputBufferSize,
size = (nuint)inputBufferSize,
};
input = new ZSTD_inBuffer_s { pos = (nuint)inputBufferSize, size = (nuint)inputBufferSize };
}
public void SetParameter(ZSTD_dParameter parameter, int value)
@@ -110,7 +108,7 @@ public class DecompressionStream : Stream
#if !NETSTANDARD2_0 && !NETFRAMEWORK
public override int Read(Span<byte> buffer)
#else
public int Read(Span<byte> buffer)
public int Read(Span<byte> buffer)
#endif
{
EnsureNotDisposed();
@@ -174,17 +172,17 @@ public class DecompressionStream : Stream
)
#else
public override Task<int> ReadAsync(
byte[] buffer,
int offset,
int count,
CancellationToken cancellationToken
) => ReadAsync(new Memory<byte>(buffer, offset, count), cancellationToken);
public override Task<int> ReadAsync(
byte[] buffer,
int offset,
int count,
CancellationToken cancellationToken
) => ReadAsync(new Memory<byte>(buffer, offset, count), cancellationToken);
public async Task<int> ReadAsync(
Memory<byte> buffer,
CancellationToken cancellationToken = default
)
public async Task<int> ReadAsync(
Memory<byte> buffer,
CancellationToken cancellationToken = default
)
#endif
{
EnsureNotDisposed();
@@ -222,8 +220,8 @@ public class DecompressionStream : Stream
if (
(
bytesRead = await innerStream
.ReadAsync(inputBuffer, 0, inputBufferSize, cancellationToken)
.ConfigureAwait(false)
.ReadAsync(inputBuffer, 0, inputBufferSize, cancellationToken)
.ConfigureAwait(false)
) == 0
)
{
@@ -265,8 +263,7 @@ public class DecompressionStream : Stream
public override void Flush() => throw new NotSupportedException();
public override long Seek(long offset, SeekOrigin origin) =>
throw new NotSupportedException();
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();
public override void SetLength(long value) => throw new NotSupportedException();
@@ -280,17 +277,17 @@ public class DecompressionStream : Stream
}
#if NETSTANDARD2_0 || NETFRAMEWORK
public virtual Task DisposeAsync()
public virtual Task DisposeAsync()
{
try
{
try
{
Dispose();
return Task.CompletedTask;
}
catch (Exception exc)
{
return Task.FromException(exc);
}
Dispose();
return Task.CompletedTask;
}
catch (Exception exc)
{
return Task.FromException(exc);
}
}
#endif
}

View File

@@ -36,17 +36,17 @@ public unsafe class Decompressor : IDisposable
{
using var dctx = handle.Acquire();
fixed (byte* dictPtr = dict)
Unsafe.Methods
.ZSTD_DCtx_loadDictionary(dctx, dictPtr, (nuint)dict.Length)
.EnsureZstdSuccess();
Unsafe
.Methods.ZSTD_DCtx_loadDictionary(dctx, dictPtr, (nuint)dict.Length)
.EnsureZstdSuccess();
}
public static ulong GetDecompressedSize(ReadOnlySpan<byte> src)
{
fixed (byte* srcPtr = src)
return Unsafe.Methods
.ZSTD_decompressBound(srcPtr, (nuint)src.Length)
.EnsureContentSizeOk();
return Unsafe
.Methods.ZSTD_decompressBound(srcPtr, (nuint)src.Length)
.EnsureContentSizeOk();
}
public static ulong GetDecompressedSize(ArraySegment<byte> src) =>
@@ -84,15 +84,15 @@ public unsafe class Decompressor : IDisposable
{
using var dctx = handle.Acquire();
return (int)
Unsafe.Methods
.ZSTD_decompressDCtx(
dctx,
destPtr,
(nuint)dest.Length,
srcPtr,
(nuint)src.Length
)
.EnsureZstdSuccess();
Unsafe
.Methods.ZSTD_decompressDCtx(
dctx,
destPtr,
(nuint)dest.Length,
srcPtr,
(nuint)src.Length
)
.EnsureZstdSuccess();
}
}
@@ -168,7 +168,9 @@ public unsafe class Decompressor : IDisposable
fixed (ZSTD_outBuffer_s* outputPtr = &output)
{
using var dctx = handle.Acquire();
return Unsafe.Methods.ZSTD_decompressStream(dctx, outputPtr, inputPtr).EnsureZstdSuccess();
return Unsafe
.Methods.ZSTD_decompressStream(dctx, outputPtr, inputPtr)
.EnsureZstdSuccess();
}
}
}
}

View File

@@ -47,10 +47,7 @@ internal sealed unsafe class SafeCctxHandle : SafeZstdHandle
{
var cctx = Unsafe.Methods.ZSTD_createCCtx();
if (cctx == null)
throw new ZstdException(
ZSTD_ErrorCode.ZSTD_error_GENERIC,
"Failed to create cctx"
);
throw new ZstdException(ZSTD_ErrorCode.ZSTD_error_GENERIC, "Failed to create cctx");
safeHandle.SetHandle((IntPtr)cctx);
success = true;
}
@@ -100,10 +97,7 @@ internal sealed unsafe class SafeDctxHandle : SafeZstdHandle
{
var dctx = Unsafe.Methods.ZSTD_createDCtx();
if (dctx == null)
throw new ZstdException(
ZSTD_ErrorCode.ZSTD_error_GENERIC,
"Failed to create dctx"
);
throw new ZstdException(ZSTD_ErrorCode.ZSTD_error_GENERIC, "Failed to create dctx");
safeHandle.SetHandle((IntPtr)dctx);
success = true;
}

View File

@@ -19,4 +19,4 @@ internal static unsafe class SynchronizationWrapper
public static void PulseAll(void** obj) => Monitor.PulseAll(UnwrapObject(obj));
public static void Wait(void** mutex) => Monitor.Wait(UnwrapObject(mutex));
}
}

View File

@@ -11,4 +11,4 @@ public unsafe struct BIT_CStream_t
public sbyte* startPtr;
public sbyte* ptr;
public sbyte* endPtr;
}
}

View File

@@ -13,4 +13,4 @@ public enum BIT_DStream_status
/* user requested more bits than present in bitstream */
BIT_DStream_overflow = 3,
}
}

View File

@@ -1,57 +1,57 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static SharpCompress.Compressors.ZStandard.UnsafeHelper;
#if NETCOREAPP3_0_OR_GREATER
using System.Runtime.Intrinsics.X86;
#endif
using static SharpCompress.Compressors.ZStandard.UnsafeHelper;
namespace SharpCompress.Compressors.ZStandard.Unsafe;
public static unsafe partial class Methods
{
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_BIT_mask =>
new uint[32]
{
0,
1,
3,
7,
0xF,
0x1F,
0x3F,
0x7F,
0xFF,
0x1FF,
0x3FF,
0x7FF,
0xFFF,
0x1FFF,
0x3FFF,
0x7FFF,
0xFFFF,
0x1FFFF,
0x3FFFF,
0x7FFFF,
0xFFFFF,
0x1FFFFF,
0x3FFFFF,
0x7FFFFF,
0xFFFFFF,
0x1FFFFFF,
0x3FFFFFF,
0x7FFFFFF,
0xFFFFFFF,
0x1FFFFFFF,
0x3FFFFFFF,
0x7FFFFFFF,
};
private static uint* BIT_mask =>
(uint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_BIT_mask)
);
private static ReadOnlySpan<uint> Span_BIT_mask =>
new uint[32]
{
0,
1,
3,
7,
0xF,
0x1F,
0x3F,
0x7F,
0xFF,
0x1FF,
0x3FF,
0x7FF,
0xFFF,
0x1FFF,
0x3FFF,
0x7FFF,
0xFFFF,
0x1FFFF,
0x3FFFF,
0x7FFFF,
0xFFFFF,
0x1FFFFF,
0x3FFFFF,
0x7FFFFF,
0xFFFFFF,
0x1FFFFFF,
0x3FFFFFF,
0x7FFFFFF,
0xFFFFFFF,
0x1FFFFFFF,
0x3FFFFFFF,
0x7FFFFFFF,
};
private static uint* BIT_mask =>
(uint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_BIT_mask)
);
#else
private static readonly uint* BIT_mask = GetArrayPointer(
@@ -100,11 +100,7 @@ public static unsafe partial class Methods
* @return : 0 if success,
* otherwise an error code (can be tested using ERR_isError()) */
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static nuint BIT_initCStream(
ref BIT_CStream_t bitC,
void* startPtr,
nuint dstCapacity
)
private static nuint BIT_initCStream(ref BIT_CStream_t bitC, void* startPtr, nuint dstCapacity)
{
bitC.bitContainer = 0;
bitC.bitPos = 0;
@@ -121,15 +117,15 @@ public static unsafe partial class Methods
{
assert(nbBits < sizeof(uint) * 32 / sizeof(uint));
#if NETCOREAPP3_1_OR_GREATER
if (Bmi2.X64.IsSupported)
{
return (nuint)Bmi2.X64.ZeroHighBits(bitContainer, nbBits);
}
if (Bmi2.X64.IsSupported)
{
return (nuint)Bmi2.X64.ZeroHighBits(bitContainer, nbBits);
}
if (Bmi2.IsSupported)
{
return Bmi2.ZeroHighBits((uint)bitContainer, nbBits);
}
if (Bmi2.IsSupported)
{
return Bmi2.ZeroHighBits((uint)bitContainer, nbBits);
}
#endif
return bitContainer & BIT_mask[nbBits];
@@ -270,16 +266,13 @@ public static unsafe partial class Methods
switch (srcSize)
{
case 7:
bitD->bitContainer +=
(nuint)((byte*)srcBuffer)[6] << sizeof(nuint) * 8 - 16;
bitD->bitContainer += (nuint)((byte*)srcBuffer)[6] << sizeof(nuint) * 8 - 16;
goto case 6;
case 6:
bitD->bitContainer +=
(nuint)((byte*)srcBuffer)[5] << sizeof(nuint) * 8 - 24;
bitD->bitContainer += (nuint)((byte*)srcBuffer)[5] << sizeof(nuint) * 8 - 24;
goto case 5;
case 5:
bitD->bitContainer +=
(nuint)((byte*)srcBuffer)[4] << sizeof(nuint) * 8 - 32;
bitD->bitContainer += (nuint)((byte*)srcBuffer)[4] << sizeof(nuint) * 8 - 32;
goto case 4;
case 4:
bitD->bitContainer += (nuint)((byte*)srcBuffer)[3] << 24;
@@ -298,9 +291,7 @@ public static unsafe partial class Methods
byte lastByte = ((byte*)srcBuffer)[srcSize - 1];
bitD->bitsConsumed = lastByte != 0 ? 8 - ZSTD_highbit32(lastByte) : 0;
if (lastByte == 0)
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
bitD->bitsConsumed += (uint)((nuint)sizeof(nuint) - srcSize) * 8;
@@ -321,15 +312,15 @@ public static unsafe partial class Methods
uint regMask = (uint)(sizeof(nuint) * 8 - 1);
assert(nbBits < sizeof(uint) * 32 / sizeof(uint));
#if NETCOREAPP3_1_OR_GREATER
if (Bmi2.X64.IsSupported)
{
return (nuint)Bmi2.X64.ZeroHighBits(bitContainer >> (int)(start & regMask), nbBits);
}
if (Bmi2.X64.IsSupported)
{
return (nuint)Bmi2.X64.ZeroHighBits(bitContainer >> (int)(start & regMask), nbBits);
}
if (Bmi2.IsSupported)
{
return Bmi2.ZeroHighBits((uint)(bitContainer >> (int)(start & regMask)), nbBits);
}
if (Bmi2.IsSupported)
{
return Bmi2.ZeroHighBits((uint)(bitContainer >> (int)(start & regMask)), nbBits);
}
#endif
return (nuint)(bitContainer >> (int)(start & regMask) & ((ulong)1 << (int)nbBits) - 1);
@@ -359,8 +350,8 @@ public static unsafe partial class Methods
uint regMask = (uint)(sizeof(nuint) * 8 - 1);
assert(nbBits >= 1);
return bitD->bitContainer
<< (int)(bitD->bitsConsumed & regMask)
>> (int)(regMask + 1 - nbBits & regMask);
<< (int)(bitD->bitsConsumed & regMask)
>> (int)(regMask + 1 - nbBits & regMask);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -423,13 +414,13 @@ public static unsafe partial class Methods
}
#if NET7_0_OR_GREATER
private static ReadOnlySpan<byte> Span_static_zeroFilled =>
new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 };
private static nuint* static_zeroFilled =>
(nuint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_static_zeroFilled)
);
private static ReadOnlySpan<byte> Span_static_zeroFilled =>
new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 };
private static nuint* static_zeroFilled =>
(nuint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_static_zeroFilled)
);
#else
private static readonly nuint* static_zeroFilled = (nuint*)GetArrayPointer(
@@ -485,10 +476,9 @@ public static unsafe partial class Methods
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint BIT_endOfDStream(BIT_DStream_t* DStream)
{
return
DStream->ptr == DStream->start && DStream->bitsConsumed == (uint)(sizeof(nuint) * 8)
? 1U
: 0U;
return DStream->ptr == DStream->start && DStream->bitsConsumed == (uint)(sizeof(nuint) * 8)
? 1U
: 0U;
}
/*-********************************************************
@@ -554,9 +544,7 @@ public static unsafe partial class Methods
byte lastByte = ((byte*)srcBuffer)[srcSize - 1];
bitD.bitsConsumed = lastByte != 0 ? 8 - ZSTD_highbit32(lastByte) : 0;
if (lastByte == 0)
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
bitD.bitsConsumed += (uint)((nuint)sizeof(nuint) - srcSize) * 8;
@@ -572,11 +560,7 @@ public static unsafe partial class Methods
* On 64-bits, maxNbBits==56.
* @return : value extracted */
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static nuint BIT_lookBits(
nuint bitD_bitContainer,
uint bitD_bitsConsumed,
uint nbBits
)
private static nuint BIT_lookBits(nuint bitD_bitContainer, uint bitD_bitsConsumed, uint nbBits)
{
return BIT_getMiddleBits(
bitD_bitContainer,
@@ -597,8 +581,8 @@ public static unsafe partial class Methods
uint regMask = (uint)(sizeof(nuint) * 8 - 1);
assert(nbBits >= 1);
return bitD_bitContainer
<< (int)(bitD_bitsConsumed & regMask)
>> (int)(regMask + 1 - nbBits & regMask);
<< (int)(bitD_bitsConsumed & regMask)
>> (int)(regMask + 1 - nbBits & regMask);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]

View File

@@ -5,4 +5,4 @@ public struct BlockSummary
public nuint nbSequences;
public nuint blockSize;
public nuint litSize;
}
}

View File

@@ -17,4 +17,4 @@ public unsafe struct COVER_best_s
public nuint dictSize;
public ZDICT_cover_params_t parameters;
public nuint compressedSize;
}
}

View File

@@ -16,4 +16,4 @@ public unsafe struct COVER_ctx_t
public uint* freqs;
public uint* dmerAt;
public uint d;
}
}

View File

@@ -6,4 +6,4 @@ public unsafe struct COVER_map_s
public uint sizeLog;
public uint size;
public uint sizeMask;
}
}

View File

@@ -8,4 +8,4 @@ public struct COVER_segment_t
public uint begin;
public uint end;
public uint score;
}
}

View File

@@ -24,11 +24,7 @@ public static unsafe partial class Methods
/**
* Warns the user when their corpus is too small.
*/
private static void COVER_warnOnSmallCorpus(
nuint maxDictSize,
nuint nbDmers,
int displayLevel
)
private static void COVER_warnOnSmallCorpus(nuint maxDictSize, nuint nbDmers, int displayLevel)
{
double ratio = nbDmers / (double)maxDictSize;
if (ratio >= 10)
@@ -100,8 +96,7 @@ public static unsafe partial class Methods
i = parameters.splitPoint < 1 ? nbTrainSamples : 0;
for (; i < nbSamples; ++i)
{
maxSampleSize =
samplesSizes[i] > maxSampleSize ? samplesSizes[i] : maxSampleSize;
maxSampleSize = samplesSizes[i] > maxSampleSize ? samplesSizes[i] : maxSampleSize;
}
dstCapacity = ZSTD_compressBound(maxSampleSize);
@@ -435,11 +430,7 @@ public static unsafe partial class Methods
if (totalCompressedSize <= largestCompressed * regressionTolerance)
{
free(largestDictbuffer);
return setDictSelection(
candidateDictBuffer,
dictContentSize,
totalCompressedSize
);
return setDictSelection(candidateDictBuffer, dictContentSize, totalCompressedSize);
}
dictContentSize *= 2;
@@ -450,4 +441,4 @@ public static unsafe partial class Methods
free(candidateDictBuffer);
return setDictSelection(largestDictbuffer, dictContentSize, totalCompressedSize);
}
}
}

View File

@@ -9,4 +9,4 @@ public struct DTableDesc
public byte tableType;
public byte tableLog;
public byte reserved;
}
}

View File

@@ -10,4 +10,4 @@ public unsafe struct EStats_ress_t
/* must be ZSTD_BLOCKSIZE_MAX allocated */
public void* workPlace;
}
}

View File

@@ -73,9 +73,7 @@ public static unsafe partial class Methods
if (FSE_isError(countSize))
return countSize;
if (countSize > hbSize)
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
return countSize;
}
}
@@ -220,13 +218,7 @@ public static unsafe partial class Methods
nuint hbSize
)
{
return FSE_readNCount_body(
normalizedCounter,
maxSVPtr,
tableLogPtr,
headerBuffer,
hbSize
);
return FSE_readNCount_body(normalizedCounter, maxSVPtr, tableLogPtr, headerBuffer, hbSize);
}
/*! FSE_readNCount_bmi2():
@@ -369,9 +361,7 @@ public static unsafe partial class Methods
for (n = 0; n < oSize; n++)
{
if (huffWeight[n] > 12)
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
rankStats[huffWeight[n]]++;
weightTotal += (uint)(1 << huffWeight[n] >> 1);
}
@@ -390,9 +380,7 @@ public static unsafe partial class Methods
uint verif = (uint)(1 << (int)ZSTD_highbit32(rest));
uint lastWeight = ZSTD_highbit32(rest) + 1;
if (verif != rest)
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
huffWeight[oSize] = (byte)lastWeight;
rankStats[lastWeight]++;
}

View File

@@ -4,4 +4,4 @@ public struct EstimatedBlockSize
{
public nuint estLitSize;
public nuint estBlockSize;
}
}

View File

@@ -16,4 +16,4 @@ public unsafe struct FASTCOVER_ctx_t
public uint d;
public uint f;
public FASTCOVER_accel_t accelParams;
}
}

View File

@@ -9,4 +9,4 @@ public unsafe struct FASTCOVER_tryParameters_data_s
public COVER_best_s* best;
public nuint dictBufferCapacity;
public ZDICT_cover_params_t parameters;
}
}

View File

@@ -5,4 +5,4 @@ public struct FSE_DTableHeader
{
public ushort tableLog;
public ushort fastMode;
}
}

View File

@@ -3,4 +3,4 @@ namespace SharpCompress.Compressors.ZStandard.Unsafe;
public unsafe struct FSE_DecompressWksp
{
public fixed short ncount[256];
}
}

View File

@@ -20,23 +20,22 @@ public static unsafe partial class Methods
return ZSTD_hash8Ptr(p, f);
}
private static readonly FASTCOVER_accel_t* FASTCOVER_defaultAccelParameters =
GetArrayPointer(
new FASTCOVER_accel_t[11]
{
new FASTCOVER_accel_t(finalize: 100, skip: 0),
new FASTCOVER_accel_t(finalize: 100, skip: 0),
new FASTCOVER_accel_t(finalize: 50, skip: 1),
new FASTCOVER_accel_t(finalize: 34, skip: 2),
new FASTCOVER_accel_t(finalize: 25, skip: 3),
new FASTCOVER_accel_t(finalize: 20, skip: 4),
new FASTCOVER_accel_t(finalize: 17, skip: 5),
new FASTCOVER_accel_t(finalize: 14, skip: 6),
new FASTCOVER_accel_t(finalize: 13, skip: 7),
new FASTCOVER_accel_t(finalize: 11, skip: 8),
new FASTCOVER_accel_t(finalize: 10, skip: 9),
}
);
private static readonly FASTCOVER_accel_t* FASTCOVER_defaultAccelParameters = GetArrayPointer(
new FASTCOVER_accel_t[11]
{
new FASTCOVER_accel_t(finalize: 100, skip: 0),
new FASTCOVER_accel_t(finalize: 100, skip: 0),
new FASTCOVER_accel_t(finalize: 50, skip: 1),
new FASTCOVER_accel_t(finalize: 34, skip: 2),
new FASTCOVER_accel_t(finalize: 25, skip: 3),
new FASTCOVER_accel_t(finalize: 20, skip: 4),
new FASTCOVER_accel_t(finalize: 17, skip: 5),
new FASTCOVER_accel_t(finalize: 14, skip: 6),
new FASTCOVER_accel_t(finalize: 13, skip: 7),
new FASTCOVER_accel_t(finalize: 11, skip: 8),
new FASTCOVER_accel_t(finalize: 10, skip: 9),
}
);
/*-*************************************
* Helper functions
@@ -91,11 +90,7 @@ public static unsafe partial class Methods
if (activeSegment.end - activeSegment.begin == dmersInK + 1)
{
/* Get hash value of the dmer to be eliminated from active segment */
nuint delIndex = FASTCOVER_hashPtrToIndex(
ctx->samples + activeSegment.begin,
f,
d
);
nuint delIndex = FASTCOVER_hashPtrToIndex(ctx->samples + activeSegment.begin, f, d);
segmentFreqs[delIndex] -= 1;
if (segmentFreqs[delIndex] == 0)
{
@@ -403,9 +398,7 @@ public static unsafe partial class Methods
parameters,
segmentFreqs
);
uint nbFinalizeSamples = (uint)(
ctx->nbTrainSamples * ctx->accelParams.finalize / 100
);
uint nbFinalizeSamples = (uint)(ctx->nbTrainSamples * ctx->accelParams.finalize / 100);
selection = COVER_selectDict(
dict + tail,
dictBufferCapacity,
@@ -544,10 +537,7 @@ public static unsafe partial class Methods
COVER_warnOnSmallCorpus(dictBufferCapacity, ctx.nbDmers, g_displayLevel);
{
/* Initialize array to keep track of frequency of dmer within activeSegment */
ushort* segmentFreqs = (ushort*)calloc(
(ulong)1 << (int)parameters.f,
sizeof(ushort)
);
ushort* segmentFreqs = (ushort*)calloc((ulong)1 << (int)parameters.f, sizeof(ushort));
nuint tail = FASTCOVER_buildDictionary(
&ctx,
ctx.freqs,
@@ -556,9 +546,7 @@ public static unsafe partial class Methods
coverParams,
segmentFreqs
);
uint nbFinalizeSamples = (uint)(
ctx.nbTrainSamples * ctx.accelParams.finalize / 100
);
uint nbFinalizeSamples = (uint)(ctx.nbTrainSamples * ctx.accelParams.finalize / 100);
nuint dictionarySize = ZDICT_finalizeDictionary(
dict,
dictBufferCapacity,
@@ -706,9 +694,7 @@ public static unsafe partial class Methods
COVER_best_destroy(&best);
FASTCOVER_ctx_destroy(&ctx);
POOL_free(pool);
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_memory_allocation)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_memory_allocation));
}
data->ctx = &ctx;

View File

@@ -51,9 +51,7 @@ public static unsafe partial class Methods
ushort* stateTable = (ushort*)statePtr.stateTable;
uint nbBitsOut = (uint)statePtr.value + symbolTT.deltaNbBits >> 16;
BIT_addBits(ref bitC_bitContainer, ref bitC_bitPos, (nuint)statePtr.value, nbBitsOut);
statePtr.value = stateTable[
(statePtr.value >> (int)nbBitsOut) + symbolTT.deltaFindState
];
statePtr.value = stateTable[(statePtr.value >> (int)nbBitsOut) + symbolTT.deltaFindState];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -105,8 +103,7 @@ public static unsafe partial class Methods
assert(accuracyLog < 31 - tableLog);
{
uint tableSize = (uint)(1 << (int)tableLog);
uint deltaFromThreshold =
threshold - (symbolTT[symbolValue].deltaNbBits + tableSize);
uint deltaFromThreshold = threshold - (symbolTT[symbolValue].deltaNbBits + tableSize);
/* linear interpolation (very approximate) */
uint normalizedDeltaFromThreshold =
deltaFromThreshold << (int)accuracyLog >> (int)tableLog;
@@ -118,19 +115,11 @@ public static unsafe partial class Methods
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void FSE_initDState(
ref FSE_DState_t DStatePtr,
ref BIT_DStream_t bitD,
uint* dt
)
private static void FSE_initDState(ref FSE_DState_t DStatePtr, ref BIT_DStream_t bitD, uint* dt)
{
void* ptr = dt;
FSE_DTableHeader* DTableH = (FSE_DTableHeader*)ptr;
DStatePtr.state = BIT_readBits(
bitD.bitContainer,
ref bitD.bitsConsumed,
DTableH->tableLog
);
DStatePtr.state = BIT_readBits(bitD.bitContainer, ref bitD.bitsConsumed, DTableH->tableLog);
BIT_reloadDStream(
ref bitD.bitContainer,
ref bitD.bitsConsumed,
@@ -206,4 +195,4 @@ public static unsafe partial class Methods
statePtr.symbolTT = ct + 1 + (tableLog != 0 ? 1 << (int)(tableLog - 1) : 1);
statePtr.stateLog = tableLog;
}
}
}

View File

@@ -37,10 +37,7 @@ public static unsafe partial class Methods
assert(((nuint)workSpace & 1) == 0);
if (
sizeof(uint)
* (
(maxSymbolValue + 2 + (1UL << (int)tableLog)) / 2
+ sizeof(ulong) / sizeof(uint)
)
* ((maxSymbolValue + 2 + (1UL << (int)tableLog)) / 2 + sizeof(ulong) / sizeof(uint))
> wkspSize
)
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_tableLog_tooLarge));
@@ -151,8 +148,7 @@ public static unsafe partial class Methods
switch (normalizedCounter[s])
{
case 0:
symbolTT[s].deltaNbBits =
(tableLog + 1 << 16) - (uint)(1 << (int)tableLog);
symbolTT[s].deltaNbBits = (tableLog + 1 << 16) - (uint)(1 << (int)tableLog);
break;
case -1:
case 1:
@@ -164,16 +160,14 @@ public static unsafe partial class Methods
default:
assert(normalizedCounter[s] > 1);
{
uint maxBitsOut =
tableLog - ZSTD_highbit32((uint)normalizedCounter[s] - 1);
uint minStatePlus = (uint)normalizedCounter[s] << (int)maxBitsOut;
symbolTT[s].deltaNbBits = (maxBitsOut << 16) - minStatePlus;
symbolTT[s].deltaFindState = (int)(
total - (uint)normalizedCounter[s]
);
total += (uint)normalizedCounter[s];
}
{
uint maxBitsOut =
tableLog - ZSTD_highbit32((uint)normalizedCounter[s] - 1);
uint minStatePlus = (uint)normalizedCounter[s] << (int)maxBitsOut;
symbolTT[s].deltaNbBits = (maxBitsOut << 16) - minStatePlus;
symbolTT[s].deltaFindState = (int)(total - (uint)normalizedCounter[s]);
total += (uint)normalizedCounter[s];
}
break;
}
@@ -232,9 +226,7 @@ public static unsafe partial class Methods
start += 24;
bitStream += 0xFFFFU << bitCount;
if (writeIsSafe == 0 && @out > oend - 2)
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall));
@out[0] = (byte)bitStream;
@out[1] = (byte)(bitStream >> 8);
@out += 2;
@@ -253,9 +245,7 @@ public static unsafe partial class Methods
if (bitCount > 16)
{
if (writeIsSafe == 0 && @out > oend - 2)
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall));
@out[0] = (byte)bitStream;
@out[1] = (byte)(bitStream >> 8);
@out += 2;
@@ -384,11 +374,7 @@ public static unsafe partial class Methods
dynamically downsize 'tableLog' when conditions are met.
It saves CPU time, by using smaller tables, while preserving or even improving compression ratio.
@return : recommended tableLog (necessarily <= 'maxTableLog') */
private static uint FSE_optimalTableLog(
uint maxTableLog,
nuint srcSize,
uint maxSymbolValue
)
private static uint FSE_optimalTableLog(uint maxTableLog, nuint srcSize, uint maxSymbolValue)
{
return FSE_optimalTableLog_internal(maxTableLog, srcSize, maxSymbolValue, 2);
}
@@ -464,7 +450,7 @@ public static unsafe partial class Methods
probably incompressible data (should have already been detected);
find max, then give all remaining points to max */
uint maxV = 0,
maxC = 0;
maxC = 0;
for (s = 0; s <= maxSymbolValue; s++)
if (count[s] > maxC)
{
@@ -514,13 +500,13 @@ public static unsafe partial class Methods
}
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_rtbTable =>
new uint[8] { 0, 473195, 504333, 520860, 550000, 700000, 750000, 830000 };
private static uint* rtbTable =>
(uint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_rtbTable)
);
private static ReadOnlySpan<uint> Span_rtbTable =>
new uint[8] { 0, 473195, 504333, 520860, 550000, 700000, 750000, 830000 };
private static uint* rtbTable =>
(uint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_rtbTable)
);
#else
private static readonly uint* rtbTable = GetArrayPointer(
@@ -655,7 +641,7 @@ public static unsafe partial class Methods
BIT_CStream_t bitC;
System.Runtime.CompilerServices.Unsafe.SkipInit(out bitC);
FSE_CState_t CState1,
CState2;
CState2;
System.Runtime.CompilerServices.Unsafe.SkipInit(out CState1);
System.Runtime.CompilerServices.Unsafe.SkipInit(out CState2);
if (srcSize <= 2)
@@ -683,12 +669,7 @@ public static unsafe partial class Methods
bitC_endPtr
);
else
BIT_flushBits(
ref bitC_bitContainer,
ref bitC_bitPos,
ref bitC_ptr,
bitC_endPtr
);
BIT_flushBits(ref bitC_bitContainer, ref bitC_bitPos, ref bitC_ptr, bitC_endPtr);
}
else
{
@@ -709,12 +690,7 @@ public static unsafe partial class Methods
bitC_endPtr
);
else
BIT_flushBits(
ref bitC_bitContainer,
ref bitC_bitPos,
ref bitC_ptr,
bitC_endPtr
);
BIT_flushBits(ref bitC_bitContainer, ref bitC_bitPos, ref bitC_ptr, bitC_endPtr);
}
while (ip > istart)
@@ -750,12 +726,7 @@ public static unsafe partial class Methods
bitC_endPtr
);
else
BIT_flushBits(
ref bitC_bitContainer,
ref bitC_bitPos,
ref bitC_ptr,
bitC_endPtr
);
BIT_flushBits(ref bitC_bitContainer, ref bitC_bitPos, ref bitC_ptr, bitC_endPtr);
}
FSE_flushCState(

View File

@@ -102,7 +102,7 @@ public static unsafe partial class Methods
uint tableMask = tableSize - 1;
uint step = (tableSize >> 1) + (tableSize >> 3) + 3;
uint s,
position = 0;
position = 0;
for (s = 0; s < maxSV1; s++)
{
int i;
@@ -213,7 +213,7 @@ public static unsafe partial class Methods
bitD_start,
bitD_limitPtr
) == BIT_DStream_status.BIT_DStream_unfinished
&& op < olimit;
&& op < olimit;
op += 4
)
{
@@ -288,16 +288,8 @@ public static unsafe partial class Methods
{
*op++ =
fast != 0
? FSE_decodeSymbolFast(
ref state2,
bitD_bitContainer,
ref bitD_bitsConsumed
)
: FSE_decodeSymbol(
ref state2,
bitD_bitContainer,
ref bitD_bitsConsumed
);
? FSE_decodeSymbolFast(ref state2, bitD_bitContainer, ref bitD_bitsConsumed)
: FSE_decodeSymbol(ref state2, bitD_bitContainer, ref bitD_bitsConsumed);
break;
}
@@ -319,16 +311,8 @@ public static unsafe partial class Methods
{
*op++ =
fast != 0
? FSE_decodeSymbolFast(
ref state1,
bitD_bitContainer,
ref bitD_bitsConsumed
)
: FSE_decodeSymbol(
ref state1,
bitD_bitContainer,
ref bitD_bitsConsumed
);
? FSE_decodeSymbolFast(ref state1, bitD_bitContainer, ref bitD_bitsConsumed)
: FSE_decodeSymbol(ref state1, bitD_bitContainer, ref bitD_bitsConsumed);
break;
}
}
@@ -394,15 +378,13 @@ public static unsafe partial class Methods
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_tableLog_tooLarge));
assert(
(nuint)(sizeof(FSE_DecompressWksp) + (1 + (1 << (int)tableLog)) * sizeof(uint))
<= wkspSize
<= wkspSize
);
workSpace =
(byte*)workSpace
+ sizeof(FSE_DecompressWksp)
+ (1 + (1 << (int)tableLog)) * sizeof(uint);
wkspSize -= (nuint)(
sizeof(FSE_DecompressWksp) + (1 + (1 << (int)tableLog)) * sizeof(uint)
);
wkspSize -= (nuint)(sizeof(FSE_DecompressWksp) + (1 + (1 << (int)tableLog)) * sizeof(uint));
{
nuint _var_err__ = FSE_buildDTable_internal(
dtable,
@@ -429,14 +411,7 @@ public static unsafe partial class Methods
dtable,
1
);
return FSE_decompress_usingDTable_generic(
dst,
dstCapacity,
ip,
cSrcSize,
dtable,
0
);
return FSE_decompress_usingDTable_generic(dst, dstCapacity, ip, cSrcSize, dtable, 0);
}
}
@@ -484,4 +459,4 @@ public static unsafe partial class Methods
wkspSize
);
}
}
}

View File

@@ -4,4 +4,4 @@ public enum HIST_checkInput_e
{
trustInput,
checkMaxSymbolValue,
}
}

View File

@@ -6,4 +6,4 @@ public unsafe struct HUF_CompressWeightsWksp
public fixed uint scratchBuffer[41];
public fixed uint count[13];
public fixed short norm[13];
}
}

View File

@@ -46,4 +46,4 @@ public unsafe struct HUF_DecompressFastArgs
public byte* e2;
public byte* e3;
}
}
}

View File

@@ -7,4 +7,4 @@ public unsafe struct HUF_ReadDTableX1_Workspace
public fixed uint statsWksp[219];
public fixed byte symbols[256];
public fixed byte huffWeight[256];
}
}

View File

@@ -12,11 +12,11 @@ public unsafe struct HUF_ReadDTableX2_Workspace
public fixed uint calleeWksp[219];
#if NET8_0_OR_GREATER
[InlineArray(12)]
public unsafe struct _rankVal_e__FixedBuffer
{
public rankValCol_t e0;
}
[InlineArray(12)]
public unsafe struct _rankVal_e__FixedBuffer
{
public rankValCol_t e0;
}
#else
public unsafe struct _rankVal_e__FixedBuffer
@@ -37,11 +37,11 @@ public unsafe struct HUF_ReadDTableX2_Workspace
#endif
#if NET8_0_OR_GREATER
[InlineArray(256)]
public unsafe struct _sortedSymbol_e__FixedBuffer
{
public sortedSymbol_t e0;
}
[InlineArray(256)]
public unsafe struct _sortedSymbol_e__FixedBuffer
{
public sortedSymbol_t e0;
}
#else
public unsafe struct _sortedSymbol_e__FixedBuffer

View File

@@ -8,11 +8,11 @@ public struct HUF_buildCTable_wksp_tables
public _rankPosition_e__FixedBuffer rankPosition;
#if NET8_0_OR_GREATER
[InlineArray(512)]
public unsafe struct _huffNodeTbl_e__FixedBuffer
{
public nodeElt_s e0;
}
[InlineArray(512)]
public unsafe struct _huffNodeTbl_e__FixedBuffer
{
public nodeElt_s e0;
}
#else
public unsafe struct _huffNodeTbl_e__FixedBuffer
@@ -533,11 +533,11 @@ public struct HUF_buildCTable_wksp_tables
#endif
#if NET8_0_OR_GREATER
[InlineArray(192)]
public unsafe struct _rankPosition_e__FixedBuffer
{
public rankPos e0;
}
[InlineArray(192)]
public unsafe struct _rankPosition_e__FixedBuffer
{
public rankPos e0;
}
#else
public unsafe struct _rankPosition_e__FixedBuffer
@@ -736,4 +736,4 @@ public struct HUF_buildCTable_wksp_tables
public rankPos e191;
}
#endif
}
}

View File

@@ -9,11 +9,11 @@ public unsafe struct HUF_compress_tables_t
public _wksps_e__Union wksps;
#if NET8_0_OR_GREATER
[InlineArray(257)]
public unsafe struct _CTable_e__FixedBuffer
{
public nuint e0;
}
[InlineArray(257)]
public unsafe struct _CTable_e__FixedBuffer
{
public nuint e0;
}
#else
public unsafe struct _CTable_e__FixedBuffer

View File

@@ -157,9 +157,7 @@ public static unsafe partial class Methods
while (Counting1[maxSymbolValue] == 0)
maxSymbolValue--;
if (check != default && maxSymbolValue > *maxSymbolValuePtr)
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_maxSymbolValue_tooSmall)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_maxSymbolValue_tooSmall));
*maxSymbolValuePtr = maxSymbolValue;
memmove(count, Counting1, countSize);
}
@@ -260,12 +258,7 @@ public static unsafe partial class Methods
* or an error code, which can be tested using HIST_isError().
* note : if return == srcSize, there is only one symbol.
*/
private static nuint HIST_count(
uint* count,
uint* maxSymbolValuePtr,
void* src,
nuint srcSize
)
private static nuint HIST_count(uint* count, uint* maxSymbolValuePtr, void* src, nuint srcSize)
{
uint* tmpCounters = stackalloc uint[1024];
return HIST_count_wksp(

View File

@@ -5,11 +5,7 @@ namespace SharpCompress.Compressors.ZStandard.Unsafe;
public static unsafe partial class Methods
{
private static void* HUF_alignUpWorkspace(
void* workspace,
nuint* workspaceSizePtr,
nuint align
)
private static void* HUF_alignUpWorkspace(void* workspace, nuint* workspaceSizePtr, nuint align)
{
nuint mask = align - 1;
nuint rem = (nuint)workspace & mask;
@@ -56,12 +52,7 @@ public static unsafe partial class Methods
return 0;
{
/* never fails */
uint maxCount = HIST_count_simple(
wksp->count,
&maxSymbolValue,
weightTable,
wtSize
);
uint maxCount = HIST_count_simple(wksp->count, &maxSymbolValue, weightTable, wtSize);
if (maxCount == wtSize)
return 1;
if (maxCount == 1)
@@ -289,7 +280,7 @@ public static unsafe partial class Methods
HUF_writeCTableHeader(CTable, tableLog, *maxSymbolValuePtr);
{
uint n,
nextRankStart = 0;
nextRankStart = 0;
for (n = 1; n <= tableLog; n++)
{
uint curr = nextRankStart;
@@ -377,11 +368,7 @@ public static unsafe partial class Methods
* respect targetNbBits.
* @return The maximum number of bits of the Huffman tree after adjustment.
*/
private static uint HUF_setMaxHeight(
nodeElt_s* huffNode,
uint lastNonNull,
uint targetNbBits
)
private static uint HUF_setMaxHeight(nodeElt_s* huffNode, uint lastNonNull, uint targetNbBits)
{
uint largestBits = huffNode[lastNonNull].nbBits;
if (largestBits <= targetNbBits)
@@ -392,9 +379,7 @@ public static unsafe partial class Methods
int n = (int)lastNonNull;
while (huffNode[n].nbBits > targetNbBits)
{
totalCost += (int)(
baseCost - (uint)(1 << (int)(largestBits - huffNode[n].nbBits))
);
totalCost += (int)(baseCost - (uint)(1 << (int)(largestBits - huffNode[n].nbBits)));
huffNode[n].nbBits = (byte)targetNbBits;
n--;
}
@@ -753,11 +738,7 @@ public static unsafe partial class Methods
)
{
HUF_buildCTable_wksp_tables* wksp_tables =
(HUF_buildCTable_wksp_tables*)HUF_alignUpWorkspace(
workSpace,
&wkspSize,
sizeof(uint)
);
(HUF_buildCTable_wksp_tables*)HUF_alignUpWorkspace(workSpace, &wkspSize, sizeof(uint));
nodeElt_s* huffNode0 = &wksp_tables->huffNodeTbl.e0;
nodeElt_s* huffNode = huffNode0 + 1;
int nonNullRank;
@@ -777,11 +758,7 @@ public static unsafe partial class Methods
return maxNbBits;
}
private static nuint HUF_estimateCompressedSize(
nuint* CTable,
uint* count,
uint maxSymbolValue
)
private static nuint HUF_estimateCompressedSize(nuint* CTable, uint* count, uint maxSymbolValue)
{
nuint* ct = CTable + 1;
nuint nbBits = 0;
@@ -820,11 +797,7 @@ public static unsafe partial class Methods
* Initializes the bitstream.
* @returns 0 or an error code.
*/
private static nuint HUF_initCStream(
ref HUF_CStream_t bitC,
void* startPtr,
nuint dstCapacity
)
private static nuint HUF_initCStream(ref HUF_CStream_t bitC, void* startPtr, nuint dstCapacity)
{
bitC = new HUF_CStream_t
{
@@ -937,13 +910,7 @@ public static unsafe partial class Methods
private static nuint HUF_closeCStream(ref HUF_CStream_t bitC)
{
HUF_addBits(ref bitC.bitContainer.e0, ref bitC.bitPos.e0, HUF_endMark(), 0);
HUF_flushBits(
ref bitC.bitContainer.e0,
ref bitC.bitPos.e0,
ref bitC.ptr,
bitC.endPtr,
0
);
HUF_flushBits(ref bitC.bitContainer.e0, ref bitC.bitPos.e0, ref bitC.ptr, bitC.endPtr, 0);
{
nuint nbBits = bitC.bitPos.e0 & 0xFF;
if (bitC.ptr >= bitC.endPtr)
@@ -1006,13 +973,7 @@ public static unsafe partial class Methods
int u;
for (u = 1; u < kUnroll; ++u)
{
HUF_encodeSymbol(
ref bitC_bitContainer_e0,
ref bitC_bitPos_e0,
ip[n - u],
ct,
1
);
HUF_encodeSymbol(ref bitC_bitContainer_e0, ref bitC_bitPos_e0, ip[n - u], ct, 1);
}
HUF_encodeSymbol(
@@ -1039,13 +1000,7 @@ public static unsafe partial class Methods
int u;
for (u = 1; u < kUnroll; ++u)
{
HUF_encodeSymbol(
ref bitC_bitContainer_e0,
ref bitC_bitPos_e0,
ip[n - u],
ct,
1
);
HUF_encodeSymbol(ref bitC_bitContainer_e0, ref bitC_bitPos_e0, ip[n - u], ct, 1);
}
HUF_encodeSymbol(
@@ -1511,12 +1466,12 @@ public static unsafe partial class Methods
byte* dst = (byte*)workSpace + sizeof(HUF_WriteCTableWksp);
nuint dstSize = wkspSize - (nuint)sizeof(HUF_WriteCTableWksp);
nuint hSize,
newSize;
newSize;
uint symbolCardinality = HUF_cardinality(count, maxSymbolValue);
uint minTableLog = HUF_minTableLog(symbolCardinality);
nuint optSize = unchecked((nuint)~0) - 1;
uint optLog = maxTableLog,
optLogGuess;
optLogGuess;
for (optLogGuess = minTableLog; optLogGuess <= maxTableLog; optLogGuess++)
{
{
@@ -1623,10 +1578,7 @@ public static unsafe partial class Methods
);
}
if (
(flags & (int)HUF_flags_e.HUF_flags_suspectUncompressible) != 0
&& srcSize >= 4096 * 10
)
if ((flags & (int)HUF_flags_e.HUF_flags_suspectUncompressible) != 0 && srcSize >= 4096 * 10)
{
nuint largestTotal = 0;
{

View File

@@ -369,8 +369,7 @@ public static unsafe partial class Methods
if (MEM_32bits)
while (
BIT_reloadDStream(bitDPtr) == BIT_DStream_status.BIT_DStream_unfinished
&& p < pEnd
BIT_reloadDStream(bitDPtr) == BIT_DStream_status.BIT_DStream_unfinished && p < pEnd
)
*p++ = HUF_decodeSymbolX1(bitDPtr, dt, dtLog);
while (p < pEnd)
@@ -513,23 +512,19 @@ public static unsafe partial class Methods
*op3++ = HUF_decodeSymbolX1(&bitD3, dt, dtLog);
*op4++ = HUF_decodeSymbolX1(&bitD4, dt, dtLog);
endSignal &=
BIT_reloadDStreamFast(&bitD1)
== BIT_DStream_status.BIT_DStream_unfinished
BIT_reloadDStreamFast(&bitD1) == BIT_DStream_status.BIT_DStream_unfinished
? 1U
: 0U;
endSignal &=
BIT_reloadDStreamFast(&bitD2)
== BIT_DStream_status.BIT_DStream_unfinished
BIT_reloadDStreamFast(&bitD2) == BIT_DStream_status.BIT_DStream_unfinished
? 1U
: 0U;
endSignal &=
BIT_reloadDStreamFast(&bitD3)
== BIT_DStream_status.BIT_DStream_unfinished
BIT_reloadDStreamFast(&bitD3) == BIT_DStream_status.BIT_DStream_unfinished
? 1U
: 0U;
endSignal &=
BIT_reloadDStreamFast(&bitD4)
== BIT_DStream_status.BIT_DStream_unfinished
BIT_reloadDStreamFast(&bitD4) == BIT_DStream_status.BIT_DStream_unfinished
? 1U
: 0U;
}
@@ -552,9 +547,7 @@ public static unsafe partial class Methods
& BIT_endOfDStream(&bitD3)
& BIT_endOfDStream(&bitD4);
if (endCheck == 0)
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
return dstSize;
@@ -569,13 +562,7 @@ public static unsafe partial class Methods
uint* DTable
)
{
return HUF_decompress4X1_usingDTable_internal_body(
dst,
dstSize,
cSrc,
cSrcSize,
DTable
);
return HUF_decompress4X1_usingDTable_internal_body(dst, dstSize, cSrc, cSrcSize, DTable);
}
private static void HUF_decompress4X1_usingDTable_internal_fast_c_loop(
@@ -583,17 +570,17 @@ public static unsafe partial class Methods
)
{
ulong bits0,
bits1,
bits2,
bits3;
bits1,
bits2,
bits3;
byte* ip0,
ip1,
ip2,
ip3;
ip1,
ip2,
ip3;
byte* op0,
op1,
op2,
op3;
op1,
op2,
op3;
ushort* dtable = (ushort*)args->dt;
byte* oend = args->oend;
byte* ilowest = args->ilowest;
@@ -907,14 +894,7 @@ public static unsafe partial class Methods
byte* oend = ZSTD_maybeNullPtrAdd((byte*)dst, (nint)dstSize);
HUF_DecompressFastArgs args;
{
nuint ret = HUF_DecompressFastArgs_init(
&args,
dst,
dstSize,
cSrc,
cSrcSize,
DTable
);
nuint ret = HUF_DecompressFastArgs_init(&args, dst, dstSize, cSrc, cSrcSize, DTable);
{
nuint err_code = ret;
if (ERR_isError(err_code))
@@ -964,9 +944,7 @@ public static unsafe partial class Methods
11
);
if ((&args.op.e0)[i] != segmentEnd)
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
}
@@ -983,13 +961,7 @@ public static unsafe partial class Methods
int flags
)
{
return HUF_decompress1X1_usingDTable_internal_body(
dst,
dstSize,
cSrc,
cSrcSize,
DTable
);
return HUF_decompress1X1_usingDTable_internal_body(dst, dstSize, cSrc, cSrcSize, DTable);
}
private static nuint HUF_decompress4X1_usingDTable_internal(
@@ -1217,16 +1189,16 @@ public static unsafe partial class Methods
memcpy(DTable + 2, &DEltX2, sizeof(ulong));
break;
default:
{
int i;
for (i = 0; i < skipSize; i += 8)
{
memcpy(DTable + i + 0, &DEltX2, sizeof(ulong));
memcpy(DTable + i + 2, &DEltX2, sizeof(ulong));
memcpy(DTable + i + 4, &DEltX2, sizeof(ulong));
memcpy(DTable + i + 6, &DEltX2, sizeof(ulong));
int i;
for (i = 0; i < skipSize; i += 8)
{
memcpy(DTable + i + 0, &DEltX2, sizeof(ulong));
memcpy(DTable + i + 2, &DEltX2, sizeof(ulong));
memcpy(DTable + i + 4, &DEltX2, sizeof(ulong));
memcpy(DTable + i + 6, &DEltX2, sizeof(ulong));
}
}
}
break;
}
@@ -1326,8 +1298,8 @@ public static unsafe partial class Methods
)
{
uint tableLog,
maxW,
nbSymbols;
maxW,
nbSymbols;
DTableDesc dtd = HUF_getDTableDesc(DTable);
uint maxTableLog = dtd.maxTableLog;
nuint iSize;
@@ -1365,7 +1337,7 @@ public static unsafe partial class Methods
{
uint w,
nextRankStart = 0;
nextRankStart = 0;
for (w = 1; w < maxW + 1; w++)
{
uint curr = nextRankStart;
@@ -1667,13 +1639,11 @@ public static unsafe partial class Methods
op2 += HUF_decodeSymbolX2(op2, &bitD2, dt, dtLog);
op2 += HUF_decodeSymbolX2(op2, &bitD2, dt, dtLog);
endSignal &=
BIT_reloadDStreamFast(&bitD1)
== BIT_DStream_status.BIT_DStream_unfinished
BIT_reloadDStreamFast(&bitD1) == BIT_DStream_status.BIT_DStream_unfinished
? 1U
: 0U;
endSignal &=
BIT_reloadDStreamFast(&bitD2)
== BIT_DStream_status.BIT_DStream_unfinished
BIT_reloadDStreamFast(&bitD2) == BIT_DStream_status.BIT_DStream_unfinished
? 1U
: 0U;
if (MEM_64bits)
@@ -1689,13 +1659,11 @@ public static unsafe partial class Methods
op4 += HUF_decodeSymbolX2(op4, &bitD4, dt, dtLog);
op4 += HUF_decodeSymbolX2(op4, &bitD4, dt, dtLog);
endSignal &=
BIT_reloadDStreamFast(&bitD3)
== BIT_DStream_status.BIT_DStream_unfinished
BIT_reloadDStreamFast(&bitD3) == BIT_DStream_status.BIT_DStream_unfinished
? 1U
: 0U;
endSignal &=
BIT_reloadDStreamFast(&bitD4)
== BIT_DStream_status.BIT_DStream_unfinished
BIT_reloadDStreamFast(&bitD4) == BIT_DStream_status.BIT_DStream_unfinished
? 1U
: 0U;
}
@@ -1718,9 +1686,7 @@ public static unsafe partial class Methods
& BIT_endOfDStream(&bitD3)
& BIT_endOfDStream(&bitD4);
if (endCheck == 0)
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
return dstSize;
@@ -1735,13 +1701,7 @@ public static unsafe partial class Methods
uint* DTable
)
{
return HUF_decompress4X2_usingDTable_internal_body(
dst,
dstSize,
cSrc,
cSrcSize,
DTable
);
return HUF_decompress4X2_usingDTable_internal_body(dst, dstSize, cSrc, cSrcSize, DTable);
}
private static void HUF_decompress4X2_usingDTable_internal_fast_c_loop(
@@ -1749,21 +1709,21 @@ public static unsafe partial class Methods
)
{
ulong bits0,
bits1,
bits2,
bits3;
bits1,
bits2,
bits3;
byte* ip0,
ip1,
ip2,
ip3;
ip1,
ip2,
ip3;
byte* op0,
op1,
op2,
op3;
op1,
op2,
op3;
byte* oend0,
oend1,
oend2,
oend3;
oend1,
oend2,
oend3;
HUF_DEltX2* dtable = (HUF_DEltX2*)args->dt;
byte* ilowest = args->ilowest;
bits0 = args->bits[0];
@@ -2126,14 +2086,7 @@ public static unsafe partial class Methods
byte* oend = ZSTD_maybeNullPtrAdd((byte*)dst, (nint)dstSize);
HUF_DecompressFastArgs args;
{
nuint ret = HUF_DecompressFastArgs_init(
&args,
dst,
dstSize,
cSrc,
cSrcSize,
DTable
);
nuint ret = HUF_DecompressFastArgs_init(&args, dst, dstSize, cSrc, cSrcSize, DTable);
{
nuint err_code = ret;
if (ERR_isError(err_code))
@@ -2182,9 +2135,7 @@ public static unsafe partial class Methods
11
);
if ((&args.op.e0)[i] != segmentEnd)
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
}
@@ -2238,13 +2189,7 @@ public static unsafe partial class Methods
int flags
)
{
return HUF_decompress1X2_usingDTable_internal_body(
dst,
dstSize,
cSrc,
cSrcSize,
DTable
);
return HUF_decompress1X2_usingDTable_internal_body(dst, dstSize, cSrc, cSrcSize, DTable);
}
private static nuint HUF_decompress1X2_DCtx_wksp(
@@ -2462,14 +2407,7 @@ public static unsafe partial class Methods
{
DTableDesc dtd = HUF_getDTableDesc(DTable);
return dtd.tableType != 0
? HUF_decompress1X2_usingDTable_internal(
dst,
maxDstSize,
cSrc,
cSrcSize,
DTable,
flags
)
? HUF_decompress1X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, flags)
: HUF_decompress1X1_usingDTable_internal(
dst,
maxDstSize,
@@ -2513,14 +2451,7 @@ public static unsafe partial class Methods
{
DTableDesc dtd = HUF_getDTableDesc(DTable);
return dtd.tableType != 0
? HUF_decompress4X2_usingDTable_internal(
dst,
maxDstSize,
cSrc,
cSrcSize,
DTable,
flags
)
? HUF_decompress4X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, flags)
: HUF_decompress4X1_usingDTable_internal(
dst,
maxDstSize,

View File

@@ -138,7 +138,7 @@ public static unsafe partial class Methods
if (!BitConverter.IsLittleEndian)
{
#if NET8_0_OR_GREATER
val = BinaryPrimitives.ReverseEndianness(val);
val = BinaryPrimitives.ReverseEndianness(val);
#else
val = ReverseEndiannessNative(val);
#endif
@@ -152,7 +152,7 @@ public static unsafe partial class Methods
if (!BitConverter.IsLittleEndian)
{
#if NET8_0_OR_GREATER
val = BinaryPrimitives.ReverseEndianness(val);
val = BinaryPrimitives.ReverseEndianness(val);
#else
val = ReverseEndiannessNative(val);
#endif

View File

@@ -5,4 +5,4 @@ public struct RSyncState_t
public ulong hash;
public ulong hitMask;
public ulong primePower;
}
}

View File

@@ -18,13 +18,7 @@ public unsafe struct RawSeqStore_t
/* The capacity starting from `seq` pointer */
public nuint capacity;
public RawSeqStore_t(
rawSeq* seq,
nuint pos,
nuint posInSequence,
nuint size,
nuint capacity
)
public RawSeqStore_t(rawSeq* seq, nuint pos, nuint posInSequence, nuint size, nuint capacity)
{
this.seq = seq;
this.pos = pos;

View File

@@ -25,4 +25,4 @@ public unsafe struct RoundBuff_t
this.capacity = capacity;
this.pos = pos;
}
}
}

View File

@@ -11,4 +11,4 @@ public struct SeqDef_s
/* mlBase == matchLength - MINMATCH */
public ushort mlBase;
}
}

View File

@@ -7,4 +7,4 @@ public unsafe struct XXH32_canonical_t
{
/*!< Hash bytes, big endian */
public fixed byte digest[4];
}
}

View File

@@ -164,12 +164,7 @@ public static unsafe partial class Methods
* @param align Whether @p input is aligned.
* @return The calculated hash.
*/
private static uint XXH32_endian_align(
byte* input,
nuint len,
uint seed,
XXH_alignment align
)
private static uint XXH32_endian_align(byte* input, nuint len, uint seed, XXH_alignment align)
{
uint h32;
if (len >= 16)
@@ -324,12 +319,7 @@ public static unsafe partial class Methods
}
h32 += state->total_len_32;
return XXH32_finalize(
h32,
(byte*)state->mem32,
state->memsize,
XXH_alignment.XXH_aligned
);
return XXH32_finalize(h32, (byte*)state->mem32, state->memsize, XXH_alignment.XXH_aligned);
}
/*! @ingroup XXH32_family */
@@ -426,9 +416,7 @@ public static unsafe partial class Methods
ulong k1 = XXH64_round(0, XXH_readLE64_align(ptr, align));
ptr += 8;
hash ^= k1;
hash =
BitOperations.RotateLeft(hash, 27) * 0x9E3779B185EBCA87UL
+ 0x85EBCA77C2B2AE63UL;
hash = BitOperations.RotateLeft(hash, 27) * 0x9E3779B185EBCA87UL + 0x85EBCA77C2B2AE63UL;
len -= 8;
}
@@ -436,9 +424,7 @@ public static unsafe partial class Methods
{
hash ^= XXH_readLE32_align(ptr, align) * 0x9E3779B185EBCA87UL;
ptr += 4;
hash =
BitOperations.RotateLeft(hash, 23) * 0xC2B2AE3D27D4EB4FUL
+ 0x165667B19E3779F9UL;
hash = BitOperations.RotateLeft(hash, 23) * 0xC2B2AE3D27D4EB4FUL + 0x165667B19E3779F9UL;
len -= 4;
}
@@ -460,12 +446,7 @@ public static unsafe partial class Methods
* @param align Whether @p input is aligned.
* @return The calculated hash.
*/
private static ulong XXH64_endian_align(
byte* input,
nuint len,
ulong seed,
XXH_alignment align
)
private static ulong XXH64_endian_align(byte* input, nuint len, ulong seed, XXH_alignment align)
{
ulong h64;
if (len >= 32)

View File

@@ -27,4 +27,4 @@ public struct ZDICT_cover_params_t
/* Sets shrinkDictMaxRegression so that a smaller dictionary can be at worse shrinkDictMaxRegression% worse than the max dict size dictionary. */
public uint shrinkDictMaxRegression;
public ZDICT_params_t zParams;
}
}

View File

@@ -8,4 +8,4 @@ public unsafe struct ZSTDMT_bufferPool_s
public uint nbBuffers;
public ZSTD_customMem cMem;
public buffer_s* buffers;
}
}

View File

@@ -27,4 +27,4 @@ public unsafe struct ZSTD_CDict_s
* the same greedy/lazy matchfinder at compression time.
*/
public ZSTD_paramSwitch_e useRowMatchFinder;
}
}

View File

@@ -6,4 +6,4 @@ public unsafe struct ZSTD_DDictHashSet
public ZSTD_DDict_s** ddictPtrTable;
public nuint ddictPtrTableSize;
public nuint ddictPtrCount;
}
}

View File

@@ -12,4 +12,4 @@ public unsafe struct ZSTD_DDict_s
public uint dictID;
public uint entropyPresent;
public ZSTD_customMem cMem;
}
}

View File

@@ -4,4 +4,4 @@ public enum ZSTD_DefaultPolicy_e
{
ZSTD_defaultDisallowed = 0,
ZSTD_defaultAllowed = 1,
}
}

View File

@@ -56,4 +56,4 @@ public enum ZSTD_ErrorCode
/* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */
ZSTD_error_maxCode = 120,
}
}

View File

@@ -4,4 +4,4 @@ public enum ZSTD_OptPrice_e
{
zop_dynamic = 0,
zop_predef,
}
}

View File

@@ -10,4 +10,4 @@ public struct ZSTD_SequencePosition
/* Number of bytes given by sequences provided so far */
public nuint posInSrc;
}
}

View File

@@ -9,4 +9,4 @@ public enum ZSTD_buffered_policy_e
{
ZSTDb_not_buffered,
ZSTDb_buffered,
}
}

View File

@@ -5,4 +5,4 @@ public enum ZSTD_cStreamStage
zcss_init = 0,
zcss_load,
zcss_flush,
}
}

View File

@@ -11,4 +11,4 @@ public enum ZSTD_compResetPolicy_e
{
ZSTDcrp_makeClean,
ZSTDcrp_leaveDirty,
}
}

View File

@@ -9,4 +9,4 @@ public enum ZSTD_compressionStage_e
ZSTDcs_init,
ZSTDcs_ongoing,
ZSTDcs_ending,
}
}

View File

@@ -12,4 +12,4 @@ public unsafe struct ZSTD_customMem
this.customFree = customFree;
this.opaque = opaque;
}
}
}

View File

@@ -9,4 +9,4 @@ public enum ZSTD_cwksp_static_alloc_e
{
ZSTD_cwksp_dynamic_alloc,
ZSTD_cwksp_static_alloc,
}
}

View File

@@ -7,4 +7,4 @@ public enum ZSTD_dStreamStage
zdss_read,
zdss_load,
zdss_flush,
}
}

View File

@@ -10,4 +10,4 @@ public enum ZSTD_dictContentType_e
/* refuses to load a dictionary if it does not respect Zstandard's specification, starting with ZSTD_MAGIC_DICTIONARY */
ZSTD_dct_fullDict = 2,
}
}

View File

@@ -10,4 +10,4 @@ public enum ZSTD_dictUses_e
/* Use the dictionary once and set to ZSTD_dont_use */
ZSTD_use_once = 1,
}
}

View File

@@ -19,11 +19,11 @@ public unsafe struct ZSTD_entropyDTables_t
public fixed uint workspace[157];
#if NET8_0_OR_GREATER
[InlineArray(513)]
public unsafe struct _LLTable_e__FixedBuffer
{
public ZSTD_seqSymbol e0;
}
[InlineArray(513)]
public unsafe struct _LLTable_e__FixedBuffer
{
public ZSTD_seqSymbol e0;
}
#else
public unsafe struct _LLTable_e__FixedBuffer
@@ -545,11 +545,11 @@ public unsafe struct ZSTD_entropyDTables_t
#endif
#if NET8_0_OR_GREATER
[InlineArray(257)]
public unsafe struct _OFTable_e__FixedBuffer
{
public ZSTD_seqSymbol e0;
}
[InlineArray(257)]
public unsafe struct _OFTable_e__FixedBuffer
{
public ZSTD_seqSymbol e0;
}
#else
public unsafe struct _OFTable_e__FixedBuffer
@@ -815,11 +815,11 @@ public unsafe struct ZSTD_entropyDTables_t
#endif
#if NET8_0_OR_GREATER
[InlineArray(513)]
public unsafe struct _MLTable_e__FixedBuffer
{
public ZSTD_seqSymbol e0;
}
[InlineArray(513)]
public unsafe struct _MLTable_e__FixedBuffer
{
public ZSTD_seqSymbol e0;
}
#else
public unsafe struct _MLTable_e__FixedBuffer
@@ -1339,4 +1339,4 @@ public unsafe struct ZSTD_entropyDTables_t
public ZSTD_seqSymbol e512;
}
#endif
}
}

View File

@@ -5,4 +5,4 @@ public enum ZSTD_forceIgnoreChecksum_e
/* Note: this enum controls ZSTD_d_forceIgnoreChecksum */
ZSTD_d_validateChecksum = 0,
ZSTD_d_ignoreChecksum = 1,
}
}

View File

@@ -18,4 +18,4 @@ public struct ZSTD_frameHeader
public uint checksumFlag;
public uint _reserved1;
public uint _reserved2;
}
}

View File

@@ -19,4 +19,4 @@ public struct ZSTD_frameProgression
/* MT only : nb of workers actively compressing at probe time */
public uint nbActiveWorkers;
}
}

View File

@@ -4,4 +4,4 @@ public enum ZSTD_frameType_e
{
ZSTD_frame,
ZSTD_skippableFrame,
}
}

View File

@@ -8,4 +8,4 @@ public unsafe struct ZSTD_fseCTables_t
public FSE_repeat offcode_repeatMode;
public FSE_repeat matchlength_repeatMode;
public FSE_repeat litlength_repeatMode;
}
}

View File

@@ -8,11 +8,11 @@ public unsafe struct ZSTD_hufCTables_t
public HUF_repeat repeatMode;
#if NET8_0_OR_GREATER
[InlineArray(257)]
public unsafe struct _CTable_e__FixedBuffer
{
public nuint e0;
}
[InlineArray(257)]
public unsafe struct _CTable_e__FixedBuffer
{
public nuint e0;
}
#else
public unsafe struct _CTable_e__FixedBuffer

View File

@@ -13,4 +13,4 @@ public unsafe struct ZSTD_inBuffer_s
/**< position where reading stopped. Will be updated. Necessarily 0 <= pos <= size */
public nuint pos;
}
}

View File

@@ -9,4 +9,4 @@ public enum ZSTD_indexResetPolicy_e
{
ZSTDirp_continue,
ZSTDirp_reset,
}
}

View File

@@ -7,4 +7,4 @@ public unsafe struct ZSTD_localDict
public nuint dictSize;
public ZSTD_dictContentType_e dictContentType;
public ZSTD_CDict_s* cdict;
}
}

View File

@@ -11,4 +11,4 @@ public enum ZSTD_longLengthType_e
/* represents a long match */
ZSTD_llt_matchLength = 2,
}
}

View File

@@ -10,4 +10,4 @@ public struct ZSTD_match_t
/* Raw length of match */
public uint len;
}
}

View File

@@ -10,4 +10,4 @@ public unsafe struct ZSTD_outBuffer_s
/**< position where writing stopped. Will be updated. Necessarily 0 <= pos <= size */
public nuint pos;
}
}

View File

@@ -4,4 +4,4 @@ public struct ZSTD_parameters
{
public ZSTD_compressionParameters cParams;
public ZSTD_frameParameters fParams;
}
}

View File

@@ -4,4 +4,4 @@ public enum ZSTD_resetTarget_e
{
ZSTD_resetTarget_CDict,
ZSTD_resetTarget_CCtx,
}
}

View File

@@ -14,4 +14,4 @@ public struct ZSTD_seqSymbol
this.nbBits = nbBits;
this.baseValue = baseValue;
}
}
}

View File

@@ -7,4 +7,4 @@ public enum ZSTD_sequenceFormat_e
/* ZSTD_Sequence[] contains explicit block delimiters */
ZSTD_sf_explicitBlockDelimiters = 1,
}
}

View File

@@ -4,4 +4,4 @@ public enum ZSTD_tableFillPurpose_e
{
ZSTD_tfp_forCCtx,
ZSTD_tfp_forCDict,
}
}

View File

@@ -172,13 +172,13 @@ public static unsafe partial class Methods
};
ZSTD_parameters @params;
uint u,
huffLog = 11,
Offlog = 8,
mlLog = 9,
llLog = 9,
total;
huffLog = 11,
Offlog = 8,
mlLog = 9,
llLog = 9,
total;
nuint pos = 0,
errorCode;
errorCode;
nuint eSize = 0;
nuint totalSrcSize = ZDICT_totalSampleSize(fileSizes, nbFiles);
nuint averageSampleSize = totalSrcSize / (nbFiles + (uint)(nbFiles == 0 ? 1 : 0));
@@ -186,9 +186,7 @@ public static unsafe partial class Methods
uint* wksp = stackalloc uint[1216];
if (offcodeMax > 30)
{
eSize = unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dictionaryCreation_failed)
);
eSize = unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dictionaryCreation_failed));
goto _cleanup;
}
@@ -285,14 +283,7 @@ public static unsafe partial class Methods
total = 0;
for (u = 0; u <= offcodeMax; u++)
total += offcodeCount[u];
errorCode = FSE_normalizeCount(
offcodeNCount,
Offlog,
offcodeCount,
total,
offcodeMax,
1
);
errorCode = FSE_normalizeCount(offcodeNCount, Offlog, offcodeCount, total, offcodeMax, 1);
if (ERR_isError(errorCode))
{
eSize = errorCode;
@@ -303,14 +294,7 @@ public static unsafe partial class Methods
total = 0;
for (u = 0; u <= 52; u++)
total += matchLengthCount[u];
errorCode = FSE_normalizeCount(
matchLengthNCount,
mlLog,
matchLengthCount,
total,
52,
1
);
errorCode = FSE_normalizeCount(matchLengthNCount, mlLog, matchLengthCount, total, 52, 1);
if (ERR_isError(errorCode))
{
eSize = errorCode;
@@ -653,4 +637,4 @@ public static unsafe partial class Methods
@params
);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -12,10 +12,7 @@ public static unsafe partial class Methods
* indicated by longLengthPos and longLengthType, and adds MINMATCH back to matchLength.
*/
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static ZSTD_SequenceLength ZSTD_getSequenceLength(
SeqStore_t* seqStore,
SeqDef_s* seq
)
private static ZSTD_SequenceLength ZSTD_getSequenceLength(SeqStore_t* seqStore, SeqDef_s* seq)
{
ZSTD_SequenceLength seqLen;
seqLen.litLength = seq->litLength;
@@ -44,79 +41,79 @@ public static unsafe partial class Methods
capacity: 0
);
#if NET7_0_OR_GREATER
private static ReadOnlySpan<byte> Span_LL_Code =>
new byte[64]
{
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
16,
17,
17,
18,
18,
19,
19,
20,
20,
20,
20,
21,
21,
21,
21,
22,
22,
22,
22,
22,
22,
22,
22,
23,
23,
23,
23,
23,
23,
23,
23,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
};
private static byte* LL_Code =>
(byte*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_LL_Code)
);
private static ReadOnlySpan<byte> Span_LL_Code =>
new byte[64]
{
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
16,
17,
17,
18,
18,
19,
19,
20,
20,
20,
20,
21,
21,
21,
21,
22,
22,
22,
22,
22,
22,
22,
22,
23,
23,
23,
23,
23,
23,
23,
23,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
24,
};
private static byte* LL_Code =>
(byte*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_LL_Code)
);
#else
private static readonly byte* LL_Code = GetArrayPointer(
@@ -198,143 +195,143 @@ public static unsafe partial class Methods
}
#if NET7_0_OR_GREATER
private static ReadOnlySpan<byte> Span_ML_Code =>
new byte[128]
{
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
32,
33,
33,
34,
34,
35,
35,
36,
36,
36,
36,
37,
37,
37,
37,
38,
38,
38,
38,
38,
38,
38,
38,
39,
39,
39,
39,
39,
39,
39,
39,
40,
40,
40,
40,
40,
40,
40,
40,
40,
40,
40,
40,
40,
40,
40,
40,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
};
private static byte* ML_Code =>
(byte*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_ML_Code)
);
private static ReadOnlySpan<byte> Span_ML_Code =>
new byte[128]
{
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
32,
33,
33,
34,
34,
35,
35,
36,
36,
36,
36,
37,
37,
37,
37,
38,
38,
38,
38,
38,
38,
38,
38,
39,
39,
39,
39,
39,
39,
39,
39,
40,
40,
40,
40,
40,
40,
40,
40,
40,
40,
40,
40,
40,
40,
40,
40,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
41,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
42,
};
private static byte* ML_Code =>
(byte*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_ML_Code)
);
#else
private static readonly byte* ML_Code = GetArrayPointer(
@@ -501,12 +498,7 @@ public static unsafe partial class Methods
* @return index >= lowLimit ? candidate : backup,
* tries to force branchless codegen. */
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static byte* ZSTD_selectAddr(
uint index,
uint lowLimit,
byte* candidate,
byte* backup
)
private static byte* ZSTD_selectAddr(uint index, uint lowLimit, byte* candidate, byte* backup)
{
return index >= lowLimit ? candidate : backup;
}
@@ -523,8 +515,7 @@ public static unsafe partial class Methods
uint lastBlock
)
{
uint cBlockHeader24 =
lastBlock + ((uint)blockType_e.bt_raw << 1) + (uint)(srcSize << 3);
uint cBlockHeader24 = lastBlock + ((uint)blockType_e.bt_raw << 1) + (uint)(srcSize << 3);
if (srcSize + ZSTD_blockHeaderSize > dstCapacity)
{
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall));
@@ -584,8 +575,8 @@ public static unsafe partial class Methods
return
cctxParams->cParams.strategy == ZSTD_strategy.ZSTD_fast
&& cctxParams->cParams.targetLength > 0
? 1
: 0;
? 1
: 0;
}
}
@@ -623,8 +614,7 @@ public static unsafe partial class Methods
)
{
assert(
(nuint)(seqStorePtr->sequences - seqStorePtr->sequencesStart)
< seqStorePtr->maxNbSeq
(nuint)(seqStorePtr->sequences - seqStorePtr->sequencesStart) < seqStorePtr->maxNbSeq
);
assert(litLength <= 1 << 17);
if (litLength > 0xFFFF)
@@ -676,8 +666,7 @@ public static unsafe partial class Methods
byte* litLimit_w = litLimit - 32;
byte* litEnd = literals + litLength;
assert(
(nuint)(seqStorePtr->sequences - seqStorePtr->sequencesStart)
< seqStorePtr->maxNbSeq
(nuint)(seqStorePtr->sequences - seqStorePtr->sequencesStart) < seqStorePtr->maxNbSeq
);
assert(seqStorePtr->maxNbLit <= 128 * (1 << 10));
assert(seqStorePtr->lit + litLength <= seqStorePtr->litStart + seqStorePtr->maxNbLit);
@@ -1052,10 +1041,9 @@ public static unsafe partial class Methods
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint ZSTD_window_isEmpty(ZSTD_window_t window)
{
return
window.dictLimit == 2 && window.lowLimit == 2 && window.nextSrc - window.@base == 2
? 1U
: 0U;
return window.dictLimit == 2 && window.lowLimit == 2 && window.nextSrc - window.@base == 2
? 1U
: 0U;
}
/**
@@ -1079,9 +1067,9 @@ public static unsafe partial class Methods
return ZSTD_window_hasExtDict(ms->window) != 0 ? ZSTD_dictMode_e.ZSTD_extDict
: ms->dictMatchState != null
? ms->dictMatchState->dedicatedDictSearch != 0
? ZSTD_dictMode_e.ZSTD_dedicatedDictSearch
? ZSTD_dictMode_e.ZSTD_dedicatedDictSearch
: ZSTD_dictMode_e.ZSTD_dictMatchState
: ZSTD_dictMode_e.ZSTD_noDict;
: ZSTD_dictMode_e.ZSTD_noDict;
}
/**
@@ -1305,12 +1293,12 @@ public static unsafe partial class Methods
}
#if NET7_0_OR_GREATER
private static ReadOnlySpan<byte> Span_stringToByte_20_00 => new byte[] { 32, 0 };
private static byte* stringToByte_20_00 =>
(byte*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_stringToByte_20_00)
);
private static ReadOnlySpan<byte> Span_stringToByte_20_00 => new byte[] { 32, 0 };
private static byte* stringToByte_20_00 =>
(byte*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_stringToByte_20_00)
);
#else
private static readonly byte* stringToByte_20_00 = GetArrayPointer(new byte[] { 32, 0 });
@@ -1385,11 +1373,7 @@ public static unsafe partial class Methods
* Returns the lowest allowed match index. It may either be in the ext-dict or the prefix.
*/
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint ZSTD_getLowestMatchIndex(
ZSTD_MatchState_t* ms,
uint curr,
uint windowLog
)
private static uint ZSTD_getLowestMatchIndex(ZSTD_MatchState_t* ms, uint curr, uint windowLog)
{
uint maxDistance = 1U << (int)windowLog;
uint lowestValid = ms->window.lowLimit;
@@ -1407,11 +1391,7 @@ public static unsafe partial class Methods
* Returns the lowest allowed match index in the prefix.
*/
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static uint ZSTD_getLowestPrefixIndex(
ZSTD_MatchState_t* ms,
uint curr,
uint windowLog
)
private static uint ZSTD_getLowestPrefixIndex(ZSTD_MatchState_t* ms, uint curr, uint windowLog)
{
uint maxDistance = 1U << (int)windowLog;
uint lowestValid = ms->window.dictLimit;

View File

@@ -110,10 +110,7 @@ public static unsafe partial class Methods
* for literal compression to even be attempted.
* Minimum is made tighter as compression strategy increases.
*/
private static nuint ZSTD_minLiteralsToCompress(
ZSTD_strategy strategy,
HUF_repeat huf_repeat
)
private static nuint ZSTD_minLiteralsToCompress(ZSTD_strategy strategy, HUF_repeat huf_repeat)
{
assert((int)strategy >= 0);
assert((int)strategy <= 9);
@@ -276,40 +273,36 @@ public static unsafe partial class Methods
assert(srcSize >= 6);
#endif
{
uint lhc =
(uint)hType
+ ((singleStream == 0 ? 1U : 0U) << 2)
+ ((uint)srcSize << 4)
+ ((uint)cLitSize << 14);
MEM_writeLE24(ostart, lhc);
break;
}
{
uint lhc =
(uint)hType
+ ((singleStream == 0 ? 1U : 0U) << 2)
+ ((uint)srcSize << 4)
+ ((uint)cLitSize << 14);
MEM_writeLE24(ostart, lhc);
break;
}
case 4:
assert(srcSize >= 6);
{
uint lhc =
(uint)(hType + (2 << 2))
+ ((uint)srcSize << 4)
+ ((uint)cLitSize << 18);
MEM_writeLE32(ostart, lhc);
break;
}
{
uint lhc =
(uint)(hType + (2 << 2)) + ((uint)srcSize << 4) + ((uint)cLitSize << 18);
MEM_writeLE32(ostart, lhc);
break;
}
case 5:
assert(srcSize >= 6);
{
uint lhc =
(uint)(hType + (3 << 2))
+ ((uint)srcSize << 4)
+ ((uint)cLitSize << 22);
MEM_writeLE32(ostart, lhc);
ostart[4] = (byte)(cLitSize >> 10);
break;
}
{
uint lhc =
(uint)(hType + (3 << 2)) + ((uint)srcSize << 4) + ((uint)cLitSize << 22);
MEM_writeLE32(ostart, lhc);
ostart[4] = (byte)(cLitSize >> 10);
break;
}
default:
assert(0 != 0);
@@ -318,4 +311,4 @@ public static unsafe partial class Methods
return lhSize + cLitSize;
}
}
}

View File

@@ -7,271 +7,271 @@ namespace SharpCompress.Compressors.ZStandard.Unsafe;
public static unsafe partial class Methods
{
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_kInverseProbabilityLog256 =>
new uint[256]
{
0,
2048,
1792,
1642,
1536,
1453,
1386,
1329,
1280,
1236,
1197,
1162,
1130,
1100,
1073,
1047,
1024,
1001,
980,
960,
941,
923,
906,
889,
874,
859,
844,
830,
817,
804,
791,
779,
768,
756,
745,
734,
724,
714,
704,
694,
685,
676,
667,
658,
650,
642,
633,
626,
618,
610,
603,
595,
588,
581,
574,
567,
561,
554,
548,
542,
535,
529,
523,
517,
512,
506,
500,
495,
489,
484,
478,
473,
468,
463,
458,
453,
448,
443,
438,
434,
429,
424,
420,
415,
411,
407,
402,
398,
394,
390,
386,
382,
377,
373,
370,
366,
362,
358,
354,
350,
347,
343,
339,
336,
332,
329,
325,
322,
318,
315,
311,
308,
305,
302,
298,
295,
292,
289,
286,
282,
279,
276,
273,
270,
267,
264,
261,
258,
256,
253,
250,
247,
244,
241,
239,
236,
233,
230,
228,
225,
222,
220,
217,
215,
212,
209,
207,
204,
202,
199,
197,
194,
192,
190,
187,
185,
182,
180,
178,
175,
173,
171,
168,
166,
164,
162,
159,
157,
155,
153,
151,
149,
146,
144,
142,
140,
138,
136,
134,
132,
130,
128,
126,
123,
121,
119,
117,
115,
114,
112,
110,
108,
106,
104,
102,
100,
98,
96,
94,
93,
91,
89,
87,
85,
83,
82,
80,
78,
76,
74,
73,
71,
69,
67,
66,
64,
62,
61,
59,
57,
55,
54,
52,
50,
49,
47,
46,
44,
42,
41,
39,
37,
36,
34,
33,
31,
30,
28,
26,
25,
23,
22,
20,
19,
17,
16,
14,
13,
11,
10,
8,
7,
5,
4,
2,
1,
};
private static uint* kInverseProbabilityLog256 =>
(uint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_kInverseProbabilityLog256)
);
private static ReadOnlySpan<uint> Span_kInverseProbabilityLog256 =>
new uint[256]
{
0,
2048,
1792,
1642,
1536,
1453,
1386,
1329,
1280,
1236,
1197,
1162,
1130,
1100,
1073,
1047,
1024,
1001,
980,
960,
941,
923,
906,
889,
874,
859,
844,
830,
817,
804,
791,
779,
768,
756,
745,
734,
724,
714,
704,
694,
685,
676,
667,
658,
650,
642,
633,
626,
618,
610,
603,
595,
588,
581,
574,
567,
561,
554,
548,
542,
535,
529,
523,
517,
512,
506,
500,
495,
489,
484,
478,
473,
468,
463,
458,
453,
448,
443,
438,
434,
429,
424,
420,
415,
411,
407,
402,
398,
394,
390,
386,
382,
377,
373,
370,
366,
362,
358,
354,
350,
347,
343,
339,
336,
332,
329,
325,
322,
318,
315,
311,
308,
305,
302,
298,
295,
292,
289,
286,
282,
279,
276,
273,
270,
267,
264,
261,
258,
256,
253,
250,
247,
244,
241,
239,
236,
233,
230,
228,
225,
222,
220,
217,
215,
212,
209,
207,
204,
202,
199,
197,
194,
192,
190,
187,
185,
182,
180,
178,
175,
173,
171,
168,
166,
164,
162,
159,
157,
155,
153,
151,
149,
146,
144,
142,
140,
138,
136,
134,
132,
130,
128,
126,
123,
121,
119,
117,
115,
114,
112,
110,
108,
106,
104,
102,
100,
98,
96,
94,
93,
91,
89,
87,
85,
83,
82,
80,
78,
76,
74,
73,
71,
69,
67,
66,
64,
62,
61,
59,
57,
55,
54,
52,
50,
49,
47,
46,
44,
42,
41,
39,
37,
36,
34,
33,
31,
30,
28,
26,
25,
23,
22,
20,
19,
17,
16,
14,
13,
11,
10,
8,
7,
5,
4,
2,
1,
};
private static uint* kInverseProbabilityLog256 =>
(uint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_kInverseProbabilityLog256)
);
#else
private static readonly uint* kInverseProbabilityLog256 = GetArrayPointer(
@@ -641,12 +641,7 @@ public static unsafe partial class Methods
* table described by norm. The max symbol support by norm is assumed >= max.
* norm must be valid for every symbol with non-zero probability in count.
*/
private static nuint ZSTD_crossEntropyCost(
short* norm,
uint accuracyLog,
uint* count,
uint max
)
private static nuint ZSTD_crossEntropyCost(short* norm, uint accuracyLog, uint* count, uint max)
{
uint shift = 8 - accuracyLog;
nuint cost = 0;
@@ -732,16 +727,12 @@ public static unsafe partial class Methods
if (isDefaultAllowed != default)
{
assert(!ERR_isError(basicCost));
assert(
!(*repeatMode == FSE_repeat.FSE_repeat_valid && ERR_isError(repeatCost))
);
assert(!(*repeatMode == FSE_repeat.FSE_repeat_valid && ERR_isError(repeatCost)));
}
#endif
assert(!ERR_isError(NCountCost));
assert(
compressedCost < unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_maxCode))
);
assert(compressedCost < unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_maxCode)));
if (basicCost <= repeatCost && basicCost <= compressedCost)
{
assert(isDefaultAllowed != default);
@@ -786,13 +777,13 @@ public static unsafe partial class Methods
switch (type)
{
case SymbolEncodingType_e.set_rle:
{
nuint err_code = FSE_buildCTable_rle(nextCTable, (byte)max);
if (ERR_isError(err_code))
{
return err_code;
nuint err_code = FSE_buildCTable_rle(nextCTable, (byte)max);
if (ERR_isError(err_code))
{
return err_code;
}
}
}
if (dstCapacity == 0)
{
@@ -805,21 +796,21 @@ public static unsafe partial class Methods
memcpy(nextCTable, prevCTable, (uint)prevCTableSize);
return 0;
case SymbolEncodingType_e.set_basic:
{
/* note : could be pre-calculated */
nuint err_code = FSE_buildCTable_wksp(
nextCTable,
defaultNorm,
defaultMax,
defaultNormLog,
entropyWorkspace,
entropyWorkspaceSize
);
if (ERR_isError(err_code))
{
return err_code;
/* note : could be pre-calculated */
nuint err_code = FSE_buildCTable_wksp(
nextCTable,
defaultNorm,
defaultMax,
defaultNormLog,
entropyWorkspace,
entropyWorkspaceSize
);
if (ERR_isError(err_code))
{
return err_code;
}
}
}
return 0;
case SymbolEncodingType_e.set_compressed:

View File

@@ -61,7 +61,7 @@ public static unsafe partial class Methods
assert(litSize > 0);
assert(
hufMetadata->hType == SymbolEncodingType_e.set_compressed
|| hufMetadata->hType == SymbolEncodingType_e.set_repeat
|| hufMetadata->hType == SymbolEncodingType_e.set_repeat
);
if (writeEntropy != 0 && hufMetadata->hType == SymbolEncodingType_e.set_compressed)
{
@@ -105,9 +105,7 @@ public static unsafe partial class Methods
if (
lhSize
< (nuint)(
3
+ (cLitSize >= 1 * (1 << 10) ? 1 : 0)
+ (cLitSize >= 16 * (1 << 10) ? 1 : 0)
3 + (cLitSize >= 1 * (1 << 10) ? 1 : 0) + (cLitSize >= 16 * (1 << 10) ? 1 : 0)
)
)
{
@@ -131,16 +129,14 @@ public static unsafe partial class Methods
case 4:
{
uint lhc =
(uint)(hType + (2 << 2)) + ((uint)litSize << 4) + ((uint)cLitSize << 18);
uint lhc = (uint)(hType + (2 << 2)) + ((uint)litSize << 4) + ((uint)cLitSize << 18);
MEM_writeLE32(ostart, lhc);
break;
}
case 5:
{
uint lhc =
(uint)(hType + (3 << 2)) + ((uint)litSize << 4) + ((uint)cLitSize << 22);
uint lhc = (uint)(hType + (3 << 2)) + ((uint)litSize << 4) + ((uint)cLitSize << 22);
MEM_writeLE32(ostart, lhc);
ostart[4] = (byte)(cLitSize >> 10);
break;
@@ -617,7 +613,7 @@ public static unsafe partial class Methods
private static nuint countLiterals(SeqStore_t* seqStore, SeqDef_s* sp, nuint seqCount)
{
nuint n,
total = 0;
total = 0;
assert(sp != null);
for (n = 0; n < seqCount; n++)
{
@@ -637,8 +633,8 @@ public static unsafe partial class Methods
)
{
nuint n,
budget = 0,
inSize = 0;
budget = 0,
inSize = 0;
/* generous estimate */
nuint headerSize = (nuint)firstSubBlock * 120 * 256;
assert(firstSubBlock == 0 || firstSubBlock == 1);
@@ -730,8 +726,8 @@ public static unsafe partial class Methods
? (ebs.estBlockSize + targetCBlockSize / 2) / targetCBlockSize
: 1;
nuint n,
avgBlockBudget,
blockBudgetSupp = 0;
avgBlockBudget,
blockBudgetSupp = 0;
avgBlockBudget = ebs.estBlockSize * 256 / nbSubBlocks;
if (ebs.estBlockSize > srcSize)
return 0;
@@ -977,4 +973,4 @@ public static unsafe partial class Methods
zc->tmpWkspSize
);
}
}
}

View File

@@ -448,7 +448,7 @@ public static unsafe partial class Methods
private static nuint ZSTD_cwksp_used(ZSTD_cwksp* ws)
{
return (nuint)((byte*)ws->tableEnd - (byte*)ws->workspace)
+ (nuint)((byte*)ws->workspaceEnd - (byte*)ws->allocStart);
+ (nuint)((byte*)ws->workspaceEnd - (byte*)ws->allocStart);
}
/**
@@ -486,12 +486,7 @@ public static unsafe partial class Methods
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_memory_allocation));
}
ZSTD_cwksp_init(
ws,
workspace,
size,
ZSTD_cwksp_static_alloc_e.ZSTD_cwksp_dynamic_alloc
);
ZSTD_cwksp_init(ws, workspace, size, ZSTD_cwksp_static_alloc_e.ZSTD_cwksp_dynamic_alloc);
return 0;
}
@@ -533,8 +528,8 @@ public static unsafe partial class Methods
return
estimatedSpace - ZSTD_cwksp_slack_space_required() <= ZSTD_cwksp_used(ws)
&& ZSTD_cwksp_used(ws) <= estimatedSpace
? 1
: 0;
? 1
: 0;
}
/*-*************************************
@@ -564,8 +559,8 @@ public static unsafe partial class Methods
return
ZSTD_cwksp_check_too_large(ws, additionalNeededSpace) != 0
&& ws->workspaceOversizedDuration > 128
? 1
: 0;
? 1
: 0;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -583,4 +578,4 @@ public static unsafe partial class Methods
ws->workspaceOversizedDuration = 0;
}
}
}
}

View File

@@ -75,17 +75,13 @@ public static unsafe partial class Methods
if (magic != 0xEC30A437)
{
if (dictContentType == ZSTD_dictContentType_e.ZSTD_dct_fullDict)
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dictionary_corrupted)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dictionary_corrupted));
return 0;
}
}
ddict->dictID = MEM_readLE32((sbyte*)ddict->dictContent + 4);
if (
ERR_isError(ZSTD_loadDEntropy(&ddict->entropy, ddict->dictContent, ddict->dictSize))
)
if (ERR_isError(ZSTD_loadDEntropy(&ddict->entropy, ddict->dictContent, ddict->dictSize)))
{
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dictionary_corrupted));
}
@@ -102,11 +98,7 @@ public static unsafe partial class Methods
ZSTD_dictContentType_e dictContentType
)
{
if (
dictLoadMethod == ZSTD_dictLoadMethod_e.ZSTD_dlm_byRef
|| dict == null
|| dictSize == 0
)
if (dictLoadMethod == ZSTD_dictLoadMethod_e.ZSTD_dlm_byRef || dict == null || dictSize == 0)
{
ddict->dictBuffer = null;
ddict->dictContent = dict;
@@ -145,10 +137,7 @@ public static unsafe partial class Methods
ZSTD_customMem customMem
)
{
if (
((customMem.customAlloc == null ? 1 : 0) ^ (customMem.customFree == null ? 1 : 0))
!= 0
)
if (((customMem.customAlloc == null ? 1 : 0) ^ (customMem.customFree == null ? 1 : 0)) != 0)
return null;
{
ZSTD_DDict_s* ddict = (ZSTD_DDict_s*)ZSTD_customMalloc(
@@ -277,13 +266,10 @@ public static unsafe partial class Methods
/*! ZSTD_estimateDDictSize() :
* Estimate amount of memory that will be needed to create a dictionary for decompression.
* Note : dictionary created by reference using ZSTD_dlm_byRef are smaller */
public static nuint ZSTD_estimateDDictSize(
nuint dictSize,
ZSTD_dictLoadMethod_e dictLoadMethod
)
public static nuint ZSTD_estimateDDictSize(nuint dictSize, ZSTD_dictLoadMethod_e dictLoadMethod)
{
return (nuint)sizeof(ZSTD_DDict_s)
+ (dictLoadMethod == ZSTD_dictLoadMethod_e.ZSTD_dlm_byRef ? 0 : dictSize);
+ (dictLoadMethod == ZSTD_dictLoadMethod_e.ZSTD_dlm_byRef ? 0 : dictSize);
}
public static nuint ZSTD_sizeof_DDict(ZSTD_DDict_s* ddict)

View File

@@ -91,10 +91,7 @@ public static unsafe partial class Methods
/* Fetches a DDict with the given dictID
* Returns the ZSTD_DDict* with the requested dictID. If it doesn't exist, then returns NULL.
*/
private static ZSTD_DDict_s* ZSTD_DDictHashSet_getDDict(
ZSTD_DDictHashSet* hashSet,
uint dictID
)
private static ZSTD_DDict_s* ZSTD_DDictHashSet_getDDict(ZSTD_DDictHashSet* hashSet, uint dictID)
{
nuint idx = ZSTD_DDictHashSet_getIndex(hashSet, dictID);
nuint idxRangeMask = hashSet->ddictPtrTableSize - 1;
@@ -145,10 +142,7 @@ public static unsafe partial class Methods
/* Frees the table of ZSTD_DDict* within a hashset, then frees the hashset itself.
* Note: The ZSTD_DDict* within the table are NOT freed.
*/
private static void ZSTD_freeDDictHashSet(
ZSTD_DDictHashSet* hashSet,
ZSTD_customMem customMem
)
private static void ZSTD_freeDDictHashSet(ZSTD_DDictHashSet* hashSet, ZSTD_customMem customMem)
{
if (hashSet != null && hashSet->ddictPtrTable != null)
{
@@ -198,9 +192,9 @@ public static unsafe partial class Methods
if (dctx == null)
return 0;
return (nuint)sizeof(ZSTD_DCtx_s)
+ ZSTD_sizeof_DDict(dctx->ddictLocal)
+ dctx->inBuffSize
+ dctx->outBuffSize;
+ ZSTD_sizeof_DDict(dctx->ddictLocal)
+ dctx->inBuffSize
+ dctx->outBuffSize;
}
public static nuint ZSTD_estimateDCtxSize()
@@ -212,8 +206,7 @@ public static unsafe partial class Methods
{
nuint startingInputLength = (nuint)(format == ZSTD_format_e.ZSTD_f_zstd1 ? 5 : 1);
assert(
format == ZSTD_format_e.ZSTD_f_zstd1
|| format == ZSTD_format_e.ZSTD_f_zstd1_magicless
format == ZSTD_format_e.ZSTD_f_zstd1 || format == ZSTD_format_e.ZSTD_f_zstd1_magicless
);
return startingInputLength;
}
@@ -264,10 +257,7 @@ public static unsafe partial class Methods
private static ZSTD_DCtx_s* ZSTD_createDCtx_internal(ZSTD_customMem customMem)
{
if (
((customMem.customAlloc == null ? 1 : 0) ^ (customMem.customFree == null ? 1 : 0))
!= 0
)
if (((customMem.customAlloc == null ? 1 : 0) ^ (customMem.customFree == null ? 1 : 0)) != 0)
return null;
{
ZSTD_DCtx_s* dctx = (ZSTD_DCtx_s*)ZSTD_customMalloc(
@@ -419,10 +409,10 @@ public static unsafe partial class Methods
uint singleSegment = (uint)(fhd >> 5 & 1);
uint fcsId = (uint)(fhd >> 6);
return minInputSize
+ (nuint)(singleSegment == 0 ? 1 : 0)
+ ZSTD_did_fieldSize[dictID]
+ ZSTD_fcs_fieldSize[fcsId]
+ (nuint)(singleSegment != 0 && fcsId == 0 ? 1 : 0);
+ (nuint)(singleSegment == 0 ? 1 : 0)
+ ZSTD_did_fieldSize[dictID]
+ ZSTD_fcs_fieldSize[fcsId]
+ (nuint)(singleSegment != 0 && fcsId == 0 ? 1 : 0);
}
}
@@ -477,9 +467,7 @@ public static unsafe partial class Methods
memcpy(hbuf, src, (uint)toCopy);
if ((MEM_readLE32(hbuf) & 0xFFFFFFF0) != 0x184D2A50)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_prefix_unknown)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_prefix_unknown));
}
}
}
@@ -643,9 +631,7 @@ public static unsafe partial class Methods
sizeU32 = MEM_readLE32((byte*)src + 4);
if (sizeU32 + 8 < sizeU32)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_frameParameter_unsupported)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_frameParameter_unsupported));
}
{
@@ -778,12 +764,7 @@ public static unsafe partial class Methods
* @return : 0 if success, or an error code, which can be tested using ZSTD_isError() */
private static nuint ZSTD_decodeFrameHeader(ZSTD_DCtx_s* dctx, void* src, nuint headerSize)
{
nuint result = ZSTD_getFrameHeader_advanced(
&dctx->fParams,
src,
headerSize,
dctx->format
);
nuint result = ZSTD_getFrameHeader_advanced(&dctx->fParams, src, headerSize, dctx->format);
if (ERR_isError(result))
return result;
if (result > 0)
@@ -838,8 +819,7 @@ public static unsafe partial class Methods
{
frameSizeInfo.compressedSize = readSkippableFrameSize(src, srcSize);
assert(
ERR_isError(frameSizeInfo.compressedSize)
|| frameSizeInfo.compressedSize <= srcSize
ERR_isError(frameSizeInfo.compressedSize) || frameSizeInfo.compressedSize <= srcSize
);
return frameSizeInfo;
}
@@ -997,8 +977,7 @@ public static unsafe partial class Methods
margin += zfh.headerSize;
margin += (nuint)(zfh.checksumFlag != 0 ? 4 : 0);
margin += 3 * frameSizeInfo.nbBlocks;
maxBlockSize =
maxBlockSize > zfh.blockSizeMax ? maxBlockSize : zfh.blockSizeMax;
maxBlockSize = maxBlockSize > zfh.blockSizeMax ? maxBlockSize : zfh.blockSizeMax;
}
else
{
@@ -1024,12 +1003,7 @@ public static unsafe partial class Methods
return blockSize;
}
private static nuint ZSTD_copyRawBlock(
void* dst,
nuint dstCapacity,
void* src,
nuint srcSize
)
private static nuint ZSTD_copyRawBlock(void* dst, nuint dstCapacity, void* src, nuint srcSize)
{
if (srcSize > dstCapacity)
{
@@ -1174,9 +1148,7 @@ public static unsafe partial class Methods
break;
case blockType_e.bt_reserved:
default:
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
{
@@ -1539,17 +1511,17 @@ public static unsafe partial class Methods
assert(src != null);
memcpy(dctx->headerBuffer + (dctx->headerSize - srcSize), src, (uint)srcSize);
{
nuint err_code = ZSTD_decodeFrameHeader(
dctx,
dctx->headerBuffer,
dctx->headerSize
);
if (ERR_isError(err_code))
{
return err_code;
nuint err_code = ZSTD_decodeFrameHeader(
dctx,
dctx->headerBuffer,
dctx->headerSize
);
if (ERR_isError(err_code))
{
return err_code;
}
}
}
dctx->expected = ZSTD_blockHeaderSize;
dctx->stage = ZSTD_dStage.ZSTDds_decodeBlockHeader;
@@ -1562,9 +1534,7 @@ public static unsafe partial class Methods
return cBlockSize;
if (cBlockSize > dctx->fParams.blockSizeMax)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
dctx->expected = cBlockSize;
@@ -1623,13 +1593,13 @@ public static unsafe partial class Methods
assert(srcSize <= dctx->expected);
rSize = ZSTD_copyRawBlock(dst, dstCapacity, src, srcSize);
{
nuint err_code = rSize;
if (ERR_isError(err_code))
{
return err_code;
nuint err_code = rSize;
if (ERR_isError(err_code))
{
return err_code;
}
}
}
assert(rSize == srcSize);
dctx->expected -= rSize;
@@ -1655,9 +1625,7 @@ public static unsafe partial class Methods
if (rSize > dctx->fParams.blockSizeMax)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
dctx->decodedSize += rSize;
@@ -1705,24 +1673,24 @@ public static unsafe partial class Methods
case ZSTD_dStage.ZSTDds_checkChecksum:
assert(srcSize == 4);
{
if (dctx->validateChecksum != 0)
{
uint h32 = (uint)ZSTD_XXH64_digest(&dctx->xxhState);
uint check32 = MEM_readLE32(src);
if (check32 != h32)
if (dctx->validateChecksum != 0)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_checksum_wrong)
);
uint h32 = (uint)ZSTD_XXH64_digest(&dctx->xxhState);
uint check32 = MEM_readLE32(src);
if (check32 != h32)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_checksum_wrong)
);
}
}
}
ZSTD_DCtx_trace_end(dctx, dctx->decodedSize, dctx->processedCSize, 1);
dctx->expected = 0;
dctx->stage = ZSTD_dStage.ZSTDds_getFrameHeaderSize;
return 0;
}
ZSTD_DCtx_trace_end(dctx, dctx->decodedSize, dctx->processedCSize, 1);
dctx->expected = 0;
dctx->stage = ZSTD_dStage.ZSTDds_getFrameHeaderSize;
return 0;
}
case ZSTD_dStage.ZSTDds_decodeSkippableHeader:
assert(src != null);
@@ -1797,7 +1765,7 @@ public static unsafe partial class Methods
{
short* offcodeNCount = stackalloc short[32];
uint offcodeMaxValue = 31,
offcodeLog;
offcodeLog;
nuint offcodeHeaderSize = FSE_readNCount(
offcodeNCount,
&offcodeMaxValue,
@@ -1837,7 +1805,7 @@ public static unsafe partial class Methods
{
short* matchlengthNCount = stackalloc short[53];
uint matchlengthMaxValue = 52,
matchlengthLog;
matchlengthLog;
nuint matchlengthHeaderSize = FSE_readNCount(
matchlengthNCount,
&matchlengthMaxValue,
@@ -1877,7 +1845,7 @@ public static unsafe partial class Methods
{
short* litlengthNCount = stackalloc short[36];
uint litlengthMaxValue = 35,
litlengthLog;
litlengthLog;
nuint litlengthHeaderSize = FSE_readNCount(
litlengthNCount,
&litlengthMaxValue,
@@ -1928,9 +1896,7 @@ public static unsafe partial class Methods
dictPtr += 4;
if (rep == 0 || rep > dictContentSize)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dictionary_corrupted)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dictionary_corrupted));
}
entropy->rep[i] = rep;
@@ -2463,11 +2429,7 @@ public static unsafe partial class Methods
* @return : 0, or an error code (which can be tested using ZSTD_isError()). */
public static nuint ZSTD_DCtx_setFormat(ZSTD_DCtx_s* dctx, ZSTD_format_e format)
{
return ZSTD_DCtx_setParameter(
dctx,
ZSTD_dParameter.ZSTD_d_experimentalParam1,
(int)format
);
return ZSTD_DCtx_setParameter(dctx, ZSTD_dParameter.ZSTD_d_experimentalParam1, (int)format);
}
/*! ZSTD_dParam_getBounds() :
@@ -2519,9 +2481,7 @@ public static unsafe partial class Methods
break;
}
bounds.error = unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_parameter_unsupported)
);
bounds.error = unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_parameter_unsupported));
return bounds;
}
@@ -2545,11 +2505,7 @@ public static unsafe partial class Methods
* and store it into int* value.
* @return : 0, or an error code (which can be tested with ZSTD_isError()).
*/
public static nuint ZSTD_DCtx_getParameter(
ZSTD_DCtx_s* dctx,
ZSTD_dParameter param,
int* value
)
public static nuint ZSTD_DCtx_getParameter(ZSTD_DCtx_s* dctx, ZSTD_dParameter param, int* value)
{
switch (param)
{
@@ -2588,11 +2544,7 @@ public static unsafe partial class Methods
* Setting a parameter is only possible during frame initialization (before starting decompression).
* @return : 0, or an error code (which can be tested using ZSTD_isError()).
*/
public static nuint ZSTD_DCtx_setParameter(
ZSTD_DCtx_s* dctx,
ZSTD_dParameter dParam,
int value
)
public static nuint ZSTD_DCtx_setParameter(ZSTD_DCtx_s* dctx, ZSTD_dParameter dParam, int value)
{
if (dctx->streamStage != ZSTD_dStreamStage.zdss_init)
{
@@ -2605,85 +2557,74 @@ public static unsafe partial class Methods
if (value == 0)
value = 27;
{
if (
ZSTD_dParam_withinBounds(ZSTD_dParameter.ZSTD_d_windowLogMax, value)
== 0
)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_parameter_outOfBound)
);
if (ZSTD_dParam_withinBounds(ZSTD_dParameter.ZSTD_d_windowLogMax, value) == 0)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_parameter_outOfBound)
);
}
}
}
dctx->maxWindowSize = (nuint)1 << value;
return 0;
case ZSTD_dParameter.ZSTD_d_experimentalParam1:
{
if (
ZSTD_dParam_withinBounds(
ZSTD_dParameter.ZSTD_d_experimentalParam1,
value
) == 0
)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_parameter_outOfBound)
);
if (
ZSTD_dParam_withinBounds(ZSTD_dParameter.ZSTD_d_experimentalParam1, value)
== 0
)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_parameter_outOfBound)
);
}
}
}
dctx->format = (ZSTD_format_e)value;
return 0;
case ZSTD_dParameter.ZSTD_d_experimentalParam2:
{
if (
ZSTD_dParam_withinBounds(
ZSTD_dParameter.ZSTD_d_experimentalParam2,
value
) == 0
)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_parameter_outOfBound)
);
if (
ZSTD_dParam_withinBounds(ZSTD_dParameter.ZSTD_d_experimentalParam2, value)
== 0
)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_parameter_outOfBound)
);
}
}
}
dctx->outBufferMode = (ZSTD_bufferMode_e)value;
return 0;
case ZSTD_dParameter.ZSTD_d_experimentalParam3:
{
if (
ZSTD_dParam_withinBounds(
ZSTD_dParameter.ZSTD_d_experimentalParam3,
value
) == 0
)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_parameter_outOfBound)
);
if (
ZSTD_dParam_withinBounds(ZSTD_dParameter.ZSTD_d_experimentalParam3, value)
== 0
)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_parameter_outOfBound)
);
}
}
}
dctx->forceIgnoreChecksum = (ZSTD_forceIgnoreChecksum_e)value;
return 0;
case ZSTD_dParameter.ZSTD_d_experimentalParam4:
{
if (
ZSTD_dParam_withinBounds(
ZSTD_dParameter.ZSTD_d_experimentalParam4,
value
) == 0
)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_parameter_outOfBound)
);
if (
ZSTD_dParam_withinBounds(ZSTD_dParameter.ZSTD_d_experimentalParam4, value)
== 0
)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_parameter_outOfBound)
);
}
}
}
if (dctx->staticSize != 0)
{
@@ -2695,19 +2636,17 @@ public static unsafe partial class Methods
dctx->refMultipleDDicts = (ZSTD_refMultipleDDicts_e)value;
return 0;
case ZSTD_dParameter.ZSTD_d_experimentalParam5:
{
if (
ZSTD_dParam_withinBounds(
ZSTD_dParameter.ZSTD_d_experimentalParam5,
value
) == 0
)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_parameter_outOfBound)
);
if (
ZSTD_dParam_withinBounds(ZSTD_dParameter.ZSTD_d_experimentalParam5, value)
== 0
)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_parameter_outOfBound)
);
}
}
}
dctx->disableHufAsm = value != 0 ? 1 : 0;
return 0;
@@ -2715,10 +2654,8 @@ public static unsafe partial class Methods
if (value != 0)
{
if (
ZSTD_dParam_withinBounds(
ZSTD_dParameter.ZSTD_d_experimentalParam6,
value
) == 0
ZSTD_dParam_withinBounds(ZSTD_dParameter.ZSTD_d_experimentalParam6, value)
== 0
)
{
return unchecked(
@@ -2881,11 +2818,7 @@ public static unsafe partial class Methods
return 0;
if (zds->streamStage == ZSTD_dStreamStage.zdss_init)
return 0;
if (
expect.dst == output->dst
&& expect.pos == output->pos
&& expect.size == output->size
)
if (expect.dst == output->dst && expect.pos == output->pos && expect.size == output->size)
return 0;
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstBuffer_wrong));
}
@@ -3021,78 +2954,75 @@ public static unsafe partial class Methods
zds->expectedOutBuffer = *output;
goto case ZSTD_dStreamStage.zdss_loadHeader;
case ZSTD_dStreamStage.zdss_loadHeader:
{
nuint hSize = ZSTD_getFrameHeader_advanced(
&zds->fParams,
zds->headerBuffer,
zds->lhSize,
zds->format
);
if (zds->refMultipleDDicts != default && zds->ddictSet != null)
{
ZSTD_DCtx_selectFrameDDict(zds);
}
if (ERR_isError(hSize))
{
return hSize;
}
if (hSize != 0)
{
/* if hSize!=0, hSize > zds->lhSize */
nuint toLoad = hSize - zds->lhSize;
nuint remainingInput = (nuint)(iend - ip);
assert(iend >= ip);
if (toLoad > remainingInput)
nuint hSize = ZSTD_getFrameHeader_advanced(
&zds->fParams,
zds->headerBuffer,
zds->lhSize,
zds->format
);
if (zds->refMultipleDDicts != default && zds->ddictSet != null)
{
if (remainingInput > 0)
{
memcpy(
zds->headerBuffer + zds->lhSize,
ip,
(uint)remainingInput
);
zds->lhSize += remainingInput;
}
input->pos = input->size;
{
/* check first few bytes */
nuint err_code = ZSTD_getFrameHeader_advanced(
&zds->fParams,
zds->headerBuffer,
zds->lhSize,
zds->format
);
if (ERR_isError(err_code))
{
return err_code;
}
}
return (
(nuint)(
zds->format == ZSTD_format_e.ZSTD_f_zstd1 ? 6 : 2
) > hSize
? (nuint)(
zds->format == ZSTD_format_e.ZSTD_f_zstd1
? 6
: 2
)
: hSize
)
- zds->lhSize
+ ZSTD_blockHeaderSize;
ZSTD_DCtx_selectFrameDDict(zds);
}
assert(ip != null);
memcpy(zds->headerBuffer + zds->lhSize, ip, (uint)toLoad);
zds->lhSize = hSize;
ip += toLoad;
break;
if (ERR_isError(hSize))
{
return hSize;
}
if (hSize != 0)
{
/* if hSize!=0, hSize > zds->lhSize */
nuint toLoad = hSize - zds->lhSize;
nuint remainingInput = (nuint)(iend - ip);
assert(iend >= ip);
if (toLoad > remainingInput)
{
if (remainingInput > 0)
{
memcpy(
zds->headerBuffer + zds->lhSize,
ip,
(uint)remainingInput
);
zds->lhSize += remainingInput;
}
input->pos = input->size;
{
/* check first few bytes */
nuint err_code = ZSTD_getFrameHeader_advanced(
&zds->fParams,
zds->headerBuffer,
zds->lhSize,
zds->format
);
if (ERR_isError(err_code))
{
return err_code;
}
}
return (
(nuint)(zds->format == ZSTD_format_e.ZSTD_f_zstd1 ? 6 : 2)
> hSize
? (nuint)(
zds->format == ZSTD_format_e.ZSTD_f_zstd1 ? 6 : 2
)
: hSize
)
- zds->lhSize
+ ZSTD_blockHeaderSize;
}
assert(ip != null);
memcpy(zds->headerBuffer + zds->lhSize, ip, (uint)toLoad);
zds->lhSize = hSize;
ip += toLoad;
break;
}
}
}
if (
zds->fParams.frameContentSize != unchecked(0UL - 1)
@@ -3135,21 +3065,16 @@ public static unsafe partial class Methods
&& (nuint)(oend - op) < zds->fParams.frameContentSize
)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall));
}
{
nuint err_code = ZSTD_decompressBegin_usingDDict(
zds,
ZSTD_getDDict(zds)
);
if (ERR_isError(err_code))
{
return err_code;
nuint err_code = ZSTD_decompressBegin_usingDDict(zds, ZSTD_getDDict(zds));
if (ERR_isError(err_code))
{
return err_code;
}
}
}
if (
zds->format == ZSTD_format_e.ZSTD_f_zstd1
@@ -3182,9 +3107,7 @@ public static unsafe partial class Methods
if (zds->fParams.windowSize > zds->maxWindowSize)
{
return unchecked(
(nuint)(
-(int)ZSTD_ErrorCode.ZSTD_error_frameParameter_windowTooLarge
)
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_frameParameter_windowTooLarge)
);
}
@@ -3194,112 +3117,103 @@ public static unsafe partial class Methods
? zds->fParams.blockSizeMax
: (uint)zds->maxBlockSizeParam;
{
/* frame checksum */
nuint neededInBuffSize =
zds->fParams.blockSizeMax > 4 ? zds->fParams.blockSizeMax : 4;
nuint neededOutBuffSize =
zds->outBufferMode == ZSTD_bufferMode_e.ZSTD_bm_buffered
? ZSTD_decodingBufferSize_internal(
zds->fParams.windowSize,
zds->fParams.frameContentSize,
zds->fParams.blockSizeMax
)
: 0;
ZSTD_DCtx_updateOversizedDuration(
zds,
neededInBuffSize,
neededOutBuffSize
);
{
int tooSmall =
zds->inBuffSize < neededInBuffSize
|| zds->outBuffSize < neededOutBuffSize
? 1
: 0;
int tooLarge = ZSTD_DCtx_isOversizedTooLong(zds);
if (tooSmall != 0 || tooLarge != 0)
{
nuint bufferSize = neededInBuffSize + neededOutBuffSize;
if (zds->staticSize != 0)
{
assert(zds->staticSize >= (nuint)sizeof(ZSTD_DCtx_s));
if (
bufferSize
> zds->staticSize - (nuint)sizeof(ZSTD_DCtx_s)
/* frame checksum */
nuint neededInBuffSize =
zds->fParams.blockSizeMax > 4 ? zds->fParams.blockSizeMax : 4;
nuint neededOutBuffSize =
zds->outBufferMode == ZSTD_bufferMode_e.ZSTD_bm_buffered
? ZSTD_decodingBufferSize_internal(
zds->fParams.windowSize,
zds->fParams.frameContentSize,
zds->fParams.blockSizeMax
)
{
return unchecked(
(nuint)(
-(int)
ZSTD_ErrorCode.ZSTD_error_memory_allocation
)
);
}
}
else
: 0;
ZSTD_DCtx_updateOversizedDuration(zds, neededInBuffSize, neededOutBuffSize);
{
int tooSmall =
zds->inBuffSize < neededInBuffSize
|| zds->outBuffSize < neededOutBuffSize
? 1
: 0;
int tooLarge = ZSTD_DCtx_isOversizedTooLong(zds);
if (tooSmall != 0 || tooLarge != 0)
{
ZSTD_customFree(zds->inBuff, zds->customMem);
zds->inBuffSize = 0;
zds->outBuffSize = 0;
zds->inBuff = (sbyte*)ZSTD_customMalloc(
bufferSize,
zds->customMem
);
if (zds->inBuff == null)
nuint bufferSize = neededInBuffSize + neededOutBuffSize;
if (zds->staticSize != 0)
{
return unchecked(
(nuint)(
-(int)
ZSTD_ErrorCode.ZSTD_error_memory_allocation
)
);
assert(zds->staticSize >= (nuint)sizeof(ZSTD_DCtx_s));
if (bufferSize > zds->staticSize - (nuint)sizeof(ZSTD_DCtx_s))
{
return unchecked(
(nuint)(
-(int)ZSTD_ErrorCode.ZSTD_error_memory_allocation
)
);
}
}
else
{
ZSTD_customFree(zds->inBuff, zds->customMem);
zds->inBuffSize = 0;
zds->outBuffSize = 0;
zds->inBuff = (sbyte*)ZSTD_customMalloc(
bufferSize,
zds->customMem
);
if (zds->inBuff == null)
{
return unchecked(
(nuint)(
-(int)ZSTD_ErrorCode.ZSTD_error_memory_allocation
)
);
}
}
}
zds->inBuffSize = neededInBuffSize;
zds->outBuff = zds->inBuff + zds->inBuffSize;
zds->outBuffSize = neededOutBuffSize;
zds->inBuffSize = neededInBuffSize;
zds->outBuff = zds->inBuff + zds->inBuffSize;
zds->outBuffSize = neededOutBuffSize;
}
}
}
}
zds->streamStage = ZSTD_dStreamStage.zdss_read;
goto case ZSTD_dStreamStage.zdss_read;
case ZSTD_dStreamStage.zdss_read:
{
nuint neededInSize = ZSTD_nextSrcSizeToDecompressWithInputSize(
zds,
(nuint)(iend - ip)
);
if (neededInSize == 0)
{
zds->streamStage = ZSTD_dStreamStage.zdss_init;
someMoreWork = 0;
break;
}
if ((nuint)(iend - ip) >= neededInSize)
{
nuint neededInSize = ZSTD_nextSrcSizeToDecompressWithInputSize(
zds,
(nuint)(iend - ip)
);
if (neededInSize == 0)
{
nuint err_code = ZSTD_decompressContinueStream(
zds,
&op,
oend,
ip,
neededInSize
);
if (ERR_isError(err_code))
{
return err_code;
}
zds->streamStage = ZSTD_dStreamStage.zdss_init;
someMoreWork = 0;
break;
}
assert(ip != null);
ip += neededInSize;
break;
if ((nuint)(iend - ip) >= neededInSize)
{
{
nuint err_code = ZSTD_decompressContinueStream(
zds,
&op,
oend,
ip,
neededInSize
);
if (ERR_isError(err_code))
{
return err_code;
}
}
assert(ip != null);
ip += neededInSize;
break;
}
}
}
if (ip == iend)
{
@@ -3317,10 +3231,7 @@ public static unsafe partial class Methods
nuint loadedSize;
assert(
neededInSize
== ZSTD_nextSrcSizeToDecompressWithInputSize(
zds,
(nuint)(iend - ip)
)
== ZSTD_nextSrcSizeToDecompressWithInputSize(zds, (nuint)(iend - ip))
);
if (isSkipFrame != 0)
{
@@ -3374,30 +3285,30 @@ public static unsafe partial class Methods
}
case ZSTD_dStreamStage.zdss_flush:
{
nuint toFlushSize = zds->outEnd - zds->outStart;
nuint flushedSize = ZSTD_limitCopy(
op,
(nuint)(oend - op),
zds->outBuff + zds->outStart,
toFlushSize
);
op = op != null ? op + flushedSize : op;
zds->outStart += flushedSize;
if (flushedSize == toFlushSize)
{
zds->streamStage = ZSTD_dStreamStage.zdss_read;
if (
zds->outBuffSize < zds->fParams.frameContentSize
&& zds->outStart + zds->fParams.blockSizeMax > zds->outBuffSize
)
nuint toFlushSize = zds->outEnd - zds->outStart;
nuint flushedSize = ZSTD_limitCopy(
op,
(nuint)(oend - op),
zds->outBuff + zds->outStart,
toFlushSize
);
op = op != null ? op + flushedSize : op;
zds->outStart += flushedSize;
if (flushedSize == toFlushSize)
{
zds->outStart = zds->outEnd = 0;
}
zds->streamStage = ZSTD_dStreamStage.zdss_read;
if (
zds->outBuffSize < zds->fParams.frameContentSize
&& zds->outStart + zds->fParams.blockSizeMax > zds->outBuffSize
)
{
zds->outStart = zds->outEnd = 0;
}
break;
break;
}
}
}
someMoreWork = 0;
break;
@@ -3468,9 +3379,7 @@ public static unsafe partial class Methods
nextSrcSizeHint +=
ZSTD_blockHeaderSize
* (nuint)(
ZSTD_nextInputType(zds) == ZSTD_nextInputType_e.ZSTDnit_block ? 1 : 0
);
* (nuint)(ZSTD_nextInputType(zds) == ZSTD_nextInputType_e.ZSTDnit_block ? 1 : 0);
assert(zds->inPos <= nextSrcSizeHint);
nextSrcSizeHint -= zds->inPos;
return nextSrcSizeHint;
@@ -3508,4 +3417,4 @@ public static unsafe partial class Methods
return cErr;
}
}
}
}

View File

@@ -20,8 +20,7 @@ public static unsafe partial class Methods
***************************************************************/
private static nuint ZSTD_blockSizeMax(ZSTD_DCtx_s* dctx)
{
nuint blockSizeMax =
dctx->isFrameDecompression != 0 ? dctx->fParams.blockSizeMax : 1 << 17;
nuint blockSizeMax = dctx->isFrameDecompression != 0 ? dctx->fParams.blockSizeMax : 1 << 17;
assert(blockSizeMax <= 1 << 17);
return blockSizeMax;
}
@@ -65,9 +64,7 @@ public static unsafe partial class Methods
{
nuint blockSizeMax = ZSTD_blockSizeMax(dctx);
assert(litSize <= blockSizeMax);
assert(
dctx->isFrameDecompression != 0 || streaming == streaming_operation.not_streaming
);
assert(dctx->isFrameDecompression != 0 || streaming == streaming_operation.not_streaming);
assert(expectedWriteSize <= blockSizeMax);
if (
streaming == streaming_operation.not_streaming
@@ -148,206 +145,194 @@ public static unsafe partial class Methods
);
}
{
nuint lhSize,
litSize,
litCSize;
uint singleStream = 0;
uint lhlCode = (uint)(istart[0] >> 2 & 3);
uint lhc = MEM_readLE32(istart);
nuint hufSuccess;
nuint expectedWriteSize =
blockSizeMax < dstCapacity ? blockSizeMax : dstCapacity;
int flags =
0
| (
ZSTD_DCtx_get_bmi2(dctx) != 0
? (int)HUF_flags_e.HUF_flags_bmi2
: 0
)
| (
dctx->disableHufAsm != 0
? (int)HUF_flags_e.HUF_flags_disableAsm
: 0
);
switch (lhlCode)
{
case 0:
case 1:
default:
singleStream = lhlCode == 0 ? 1U : 0U;
lhSize = 3;
litSize = lhc >> 4 & 0x3FF;
litCSize = lhc >> 14 & 0x3FF;
break;
case 2:
lhSize = 4;
litSize = lhc >> 4 & 0x3FFF;
litCSize = lhc >> 18;
break;
case 3:
lhSize = 5;
litSize = lhc >> 4 & 0x3FFFF;
litCSize = (lhc >> 22) + ((nuint)istart[4] << 10);
break;
}
nuint lhSize,
litSize,
litCSize;
uint singleStream = 0;
uint lhlCode = (uint)(istart[0] >> 2 & 3);
uint lhc = MEM_readLE32(istart);
nuint hufSuccess;
nuint expectedWriteSize =
blockSizeMax < dstCapacity ? blockSizeMax : dstCapacity;
int flags =
0
| (ZSTD_DCtx_get_bmi2(dctx) != 0 ? (int)HUF_flags_e.HUF_flags_bmi2 : 0)
| (
dctx->disableHufAsm != 0 ? (int)HUF_flags_e.HUF_flags_disableAsm : 0
);
switch (lhlCode)
{
case 0:
case 1:
default:
singleStream = lhlCode == 0 ? 1U : 0U;
lhSize = 3;
litSize = lhc >> 4 & 0x3FF;
litCSize = lhc >> 14 & 0x3FF;
break;
case 2:
lhSize = 4;
litSize = lhc >> 4 & 0x3FFF;
litCSize = lhc >> 18;
break;
case 3:
lhSize = 5;
litSize = lhc >> 4 & 0x3FFFF;
litCSize = (lhc >> 22) + ((nuint)istart[4] << 10);
break;
}
if (litSize > 0 && dst == null)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall)
);
}
if (litSize > blockSizeMax)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
}
if (singleStream == 0)
if (litSize < 6)
if (litSize > 0 && dst == null)
{
return unchecked(
(nuint)(
-(int)ZSTD_ErrorCode.ZSTD_error_literals_headerWrong
)
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall)
);
}
if (litCSize + lhSize > srcSize)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
}
if (expectedWriteSize < litSize)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall)
);
}
ZSTD_allocateLiteralsBuffer(
dctx,
dst,
dstCapacity,
litSize,
streaming,
expectedWriteSize,
0
);
if (dctx->ddictIsCold != 0 && litSize > 768)
{
sbyte* _ptr = (sbyte*)dctx->HUFptr;
const nuint _size = sizeof(uint) * 4097;
nuint _pos;
for (_pos = 0; _pos < _size; _pos += 64)
if (litSize > blockSizeMax)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
}
if (singleStream == 0)
if (litSize < 6)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_literals_headerWrong)
);
}
if (litCSize + lhSize > srcSize)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
}
if (expectedWriteSize < litSize)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall)
);
}
ZSTD_allocateLiteralsBuffer(
dctx,
dst,
dstCapacity,
litSize,
streaming,
expectedWriteSize,
0
);
if (dctx->ddictIsCold != 0 && litSize > 768)
{
sbyte* _ptr = (sbyte*)dctx->HUFptr;
const nuint _size = sizeof(uint) * 4097;
nuint _pos;
for (_pos = 0; _pos < _size; _pos += 64)
{
#if NETCOREAPP3_0_OR_GREATER
if (System.Runtime.Intrinsics.X86.Sse.IsSupported)
{
System.Runtime.Intrinsics.X86.Sse.Prefetch1(_ptr + _pos);
}
if (System.Runtime.Intrinsics.X86.Sse.IsSupported)
{
System.Runtime.Intrinsics.X86.Sse.Prefetch1(_ptr + _pos);
}
#endif
}
}
}
if (litEncType == SymbolEncodingType_e.set_repeat)
{
if (singleStream != 0)
if (litEncType == SymbolEncodingType_e.set_repeat)
{
hufSuccess = HUF_decompress1X_usingDTable(
dctx->litBuffer,
litSize,
istart + lhSize,
litCSize,
dctx->HUFptr,
flags
);
if (singleStream != 0)
{
hufSuccess = HUF_decompress1X_usingDTable(
dctx->litBuffer,
litSize,
istart + lhSize,
litCSize,
dctx->HUFptr,
flags
);
}
else
{
assert(litSize >= 6);
hufSuccess = HUF_decompress4X_usingDTable(
dctx->litBuffer,
litSize,
istart + lhSize,
litCSize,
dctx->HUFptr,
flags
);
}
}
else
{
assert(litSize >= 6);
hufSuccess = HUF_decompress4X_usingDTable(
dctx->litBuffer,
litSize,
istart + lhSize,
litCSize,
dctx->HUFptr,
flags
);
if (singleStream != 0)
{
hufSuccess = HUF_decompress1X1_DCtx_wksp(
dctx->entropy.hufTable,
dctx->litBuffer,
litSize,
istart + lhSize,
litCSize,
dctx->workspace,
sizeof(uint) * 640,
flags
);
}
else
{
hufSuccess = HUF_decompress4X_hufOnly_wksp(
dctx->entropy.hufTable,
dctx->litBuffer,
litSize,
istart + lhSize,
litCSize,
dctx->workspace,
sizeof(uint) * 640,
flags
);
}
}
}
else
{
if (singleStream != 0)
if (dctx->litBufferLocation == ZSTD_litLocation_e.ZSTD_split)
{
hufSuccess = HUF_decompress1X1_DCtx_wksp(
dctx->entropy.hufTable,
assert(litSize > 1 << 16);
memcpy(dctx->litExtraBuffer, dctx->litBufferEnd - (1 << 16), 1 << 16);
memmove(
dctx->litBuffer + (1 << 16) - 32,
dctx->litBuffer,
litSize,
istart + lhSize,
litCSize,
dctx->workspace,
sizeof(uint) * 640,
flags
litSize - (1 << 16)
);
dctx->litBuffer += (1 << 16) - 32;
dctx->litBufferEnd -= 32;
assert(dctx->litBufferEnd <= (byte*)dst + blockSizeMax);
}
else
if (ERR_isError(hufSuccess))
{
hufSuccess = HUF_decompress4X_hufOnly_wksp(
dctx->entropy.hufTable,
dctx->litBuffer,
litSize,
istart + lhSize,
litCSize,
dctx->workspace,
sizeof(uint) * 640,
flags
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
}
}
if (dctx->litBufferLocation == ZSTD_litLocation_e.ZSTD_split)
{
assert(litSize > 1 << 16);
memcpy(
dctx->litExtraBuffer,
dctx->litBufferEnd - (1 << 16),
1 << 16
);
memmove(
dctx->litBuffer + (1 << 16) - 32,
dctx->litBuffer,
litSize - (1 << 16)
);
dctx->litBuffer += (1 << 16) - 32;
dctx->litBufferEnd -= 32;
assert(dctx->litBufferEnd <= (byte*)dst + blockSizeMax);
dctx->litPtr = dctx->litBuffer;
dctx->litSize = litSize;
dctx->litEntropy = 1;
if (litEncType == SymbolEncodingType_e.set_compressed)
dctx->HUFptr = dctx->entropy.hufTable;
return litCSize + lhSize;
}
if (ERR_isError(hufSuccess))
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
}
dctx->litPtr = dctx->litBuffer;
dctx->litSize = litSize;
dctx->litEntropy = 1;
if (litEncType == SymbolEncodingType_e.set_compressed)
dctx->HUFptr = dctx->entropy.hufTable;
return litCSize + lhSize;
}
case SymbolEncodingType_e.set_basic:
{
nuint litSize,
lhSize;
lhSize;
uint lhlCode = (uint)(istart[0] >> 2 & 3);
nuint expectedWriteSize =
blockSizeMax < dstCapacity ? blockSizeMax : dstCapacity;
@@ -378,9 +363,7 @@ public static unsafe partial class Methods
if (litSize > 0 && dst == null)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall));
}
if (litSize > blockSizeMax)
@@ -392,9 +375,7 @@ public static unsafe partial class Methods
if (expectedWriteSize < litSize)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall));
}
ZSTD_allocateLiteralsBuffer(
@@ -417,11 +398,7 @@ public static unsafe partial class Methods
if (dctx->litBufferLocation == ZSTD_litLocation_e.ZSTD_split)
{
memcpy(
dctx->litBuffer,
istart + lhSize,
(uint)(litSize - (1 << 16))
);
memcpy(dctx->litBuffer, istart + lhSize, (uint)(litSize - (1 << 16)));
memcpy(
dctx->litExtraBuffer,
istart + lhSize + litSize - (1 << 16),
@@ -449,7 +426,7 @@ public static unsafe partial class Methods
{
uint lhlCode = (uint)(istart[0] >> 2 & 3);
nuint litSize,
lhSize;
lhSize;
nuint expectedWriteSize =
blockSizeMax < dstCapacity ? blockSizeMax : dstCapacity;
switch (lhlCode)
@@ -486,9 +463,7 @@ public static unsafe partial class Methods
if (litSize > 0 && dst == null)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall));
}
if (litSize > blockSizeMax)
@@ -500,9 +475,7 @@ public static unsafe partial class Methods
if (expectedWriteSize < litSize)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_dstSize_tooSmall));
}
ZSTD_allocateLiteralsBuffer(
@@ -530,9 +503,7 @@ public static unsafe partial class Methods
}
default:
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
}
}
@@ -635,94 +606,34 @@ public static unsafe partial class Methods
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 6, nbBits: 4, baseValue: 61),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 9, nbBits: 5, baseValue: 509),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 15, nbBits: 5, baseValue: 32765),
new ZSTD_seqSymbol(
nextState: 0,
nbAdditionalBits: 21,
nbBits: 5,
baseValue: 2097149
),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 21, nbBits: 5, baseValue: 2097149),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 3, nbBits: 5, baseValue: 5),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 7, nbBits: 4, baseValue: 125),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 12, nbBits: 5, baseValue: 4093),
new ZSTD_seqSymbol(
nextState: 0,
nbAdditionalBits: 18,
nbBits: 5,
baseValue: 262141
),
new ZSTD_seqSymbol(
nextState: 0,
nbAdditionalBits: 23,
nbBits: 5,
baseValue: 8388605
),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 18, nbBits: 5, baseValue: 262141),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 23, nbBits: 5, baseValue: 8388605),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 5, nbBits: 5, baseValue: 29),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 8, nbBits: 4, baseValue: 253),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 14, nbBits: 5, baseValue: 16381),
new ZSTD_seqSymbol(
nextState: 0,
nbAdditionalBits: 20,
nbBits: 5,
baseValue: 1048573
),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 20, nbBits: 5, baseValue: 1048573),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 2, nbBits: 5, baseValue: 1),
new ZSTD_seqSymbol(nextState: 16, nbAdditionalBits: 7, nbBits: 4, baseValue: 125),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 11, nbBits: 5, baseValue: 2045),
new ZSTD_seqSymbol(
nextState: 0,
nbAdditionalBits: 17,
nbBits: 5,
baseValue: 131069
),
new ZSTD_seqSymbol(
nextState: 0,
nbAdditionalBits: 22,
nbBits: 5,
baseValue: 4194301
),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 17, nbBits: 5, baseValue: 131069),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 22, nbBits: 5, baseValue: 4194301),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 4, nbBits: 5, baseValue: 13),
new ZSTD_seqSymbol(nextState: 16, nbAdditionalBits: 8, nbBits: 4, baseValue: 253),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 13, nbBits: 5, baseValue: 8189),
new ZSTD_seqSymbol(
nextState: 0,
nbAdditionalBits: 19,
nbBits: 5,
baseValue: 524285
),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 19, nbBits: 5, baseValue: 524285),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 1, nbBits: 5, baseValue: 1),
new ZSTD_seqSymbol(nextState: 16, nbAdditionalBits: 6, nbBits: 4, baseValue: 61),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 10, nbBits: 5, baseValue: 1021),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 16, nbBits: 5, baseValue: 65533),
new ZSTD_seqSymbol(
nextState: 0,
nbAdditionalBits: 28,
nbBits: 5,
baseValue: 268435453
),
new ZSTD_seqSymbol(
nextState: 0,
nbAdditionalBits: 27,
nbBits: 5,
baseValue: 134217725
),
new ZSTD_seqSymbol(
nextState: 0,
nbAdditionalBits: 26,
nbBits: 5,
baseValue: 67108861
),
new ZSTD_seqSymbol(
nextState: 0,
nbAdditionalBits: 25,
nbBits: 5,
baseValue: 33554429
),
new ZSTD_seqSymbol(
nextState: 0,
nbAdditionalBits: 24,
nbBits: 5,
baseValue: 16777213
),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 28, nbBits: 5, baseValue: 268435453),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 27, nbBits: 5, baseValue: 134217725),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 26, nbBits: 5, baseValue: 67108861),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 25, nbBits: 5, baseValue: 33554429),
new ZSTD_seqSymbol(nextState: 0, nbAdditionalBits: 24, nbBits: 5, baseValue: 16777213),
}
);
private static readonly ZSTD_seqSymbol* ML_defaultDTable = GetArrayPointer(
@@ -796,11 +707,7 @@ public static unsafe partial class Methods
}
);
private static void ZSTD_buildSeqTable_rle(
ZSTD_seqSymbol* dt,
uint baseValue,
byte nbAddBits
)
private static void ZSTD_buildSeqTable_rle(ZSTD_seqSymbol* dt, uint baseValue, byte nbAddBits)
{
void* ptr = dt;
ZSTD_seqSymbol_header* DTableH = (ZSTD_seqSymbol_header*)ptr;
@@ -916,7 +823,7 @@ public static unsafe partial class Methods
uint tableMask = tableSize - 1;
uint step = (tableSize >> 1) + (tableSize >> 3) + 3;
uint s,
position = 0;
position = 0;
for (s = 0; s < maxSV1; s++)
{
int i;
@@ -1039,17 +946,15 @@ public static unsafe partial class Methods
if (*(byte*)src > max)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
{
uint symbol = *(byte*)src;
uint baseline = baseValue[symbol];
byte nbBits = nbAdditionalBits[symbol];
ZSTD_buildSeqTable_rle(DTableSpace, baseline, nbBits);
}
{
uint symbol = *(byte*)src;
uint baseline = baseValue[symbol];
byte nbBits = nbAdditionalBits[symbol];
ZSTD_buildSeqTable_rle(DTableSpace, baseline, nbBits);
}
*DTablePtr = DTableSpace;
return 1;
@@ -1059,9 +964,7 @@ public static unsafe partial class Methods
case SymbolEncodingType_e.set_repeat:
if (flagRepeatTable == 0)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
if (ddictIsCold != 0 && nbSeq > 24)
@@ -1075,10 +978,10 @@ public static unsafe partial class Methods
for (_pos = 0; _pos < _size; _pos += 64)
{
#if NETCOREAPP3_0_OR_GREATER
if (System.Runtime.Intrinsics.X86.Sse.IsSupported)
{
System.Runtime.Intrinsics.X86.Sse.Prefetch1(_ptr + _pos);
}
if (System.Runtime.Intrinsics.X86.Sse.IsSupported)
{
System.Runtime.Intrinsics.X86.Sse.Prefetch1(_ptr + _pos);
}
#endif
}
}
@@ -1092,16 +995,12 @@ public static unsafe partial class Methods
nuint headerSize = FSE_readNCount(norm, &max, &tableLog, src, srcSize);
if (ERR_isError(headerSize))
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
if (tableLog > maxLog)
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
ZSTD_buildFSETable(
@@ -1215,9 +1114,7 @@ public static unsafe partial class Methods
);
if (ERR_isError(llhSize))
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
ip += llhSize;
@@ -1244,9 +1141,7 @@ public static unsafe partial class Methods
);
if (ERR_isError(ofhSize))
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
ip += ofhSize;
@@ -1273,9 +1168,7 @@ public static unsafe partial class Methods
);
if (ERR_isError(mlhSize))
{
return unchecked(
(nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected)
);
return unchecked((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_corruption_detected));
}
ip += mlhSize;
@@ -1286,12 +1179,12 @@ public static unsafe partial class Methods
}
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_dec32table => new uint[8] { 0, 1, 2, 1, 4, 4, 4, 4 };
private static uint* dec32table =>
(uint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_dec32table)
);
private static ReadOnlySpan<uint> Span_dec32table => new uint[8] { 0, 1, 2, 1, 4, 4, 4, 4 };
private static uint* dec32table =>
(uint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_dec32table)
);
#else
private static readonly uint* dec32table = GetArrayPointer(
@@ -1299,12 +1192,12 @@ public static unsafe partial class Methods
);
#endif
#if NET7_0_OR_GREATER
private static ReadOnlySpan<int> Span_dec64table => new int[8] { 8, 8, 8, 7, 8, 9, 10, 11 };
private static int* dec64table =>
(int*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_dec64table)
);
private static ReadOnlySpan<int> Span_dec64table => new int[8] { 8, 8, 8, 7, 8, 9, 10, 11 };
private static int* dec64table =>
(int*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_dec64table)
);
#else
private static readonly int* dec64table = GetArrayPointer(
@@ -1365,9 +1258,8 @@ public static unsafe partial class Methods
nint diff = (nint)(op - ip);
byte* oend = op + length;
assert(
ovtype == ZSTD_overlap_e.ZSTD_no_overlap
&& (diff <= -8 || diff >= 8 || op >= oend_w)
|| ovtype == ZSTD_overlap_e.ZSTD_overlap_src_before_dst && diff >= 0
ovtype == ZSTD_overlap_e.ZSTD_no_overlap && (diff <= -8 || diff >= 8 || op >= oend_w)
|| ovtype == ZSTD_overlap_e.ZSTD_overlap_src_before_dst && diff >= 0
);
if (length < 8)
{
@@ -1672,12 +1564,7 @@ public static unsafe partial class Methods
assert(sequence_matchLength >= 1);
if (sequence_offset >= 16)
{
ZSTD_wildcopy(
op,
match,
(nint)sequence_matchLength,
ZSTD_overlap_e.ZSTD_no_overlap
);
ZSTD_wildcopy(op, match, (nint)sequence_matchLength, ZSTD_overlap_e.ZSTD_no_overlap);
return sequenceLength;
}
@@ -1783,12 +1670,7 @@ public static unsafe partial class Methods
assert(sequence.matchLength >= 1);
if (sequence.offset >= 16)
{
ZSTD_wildcopy(
op,
match,
(nint)sequence.matchLength,
ZSTD_overlap_e.ZSTD_no_overlap
);
ZSTD_wildcopy(op, match, (nint)sequence.matchLength, ZSTD_overlap_e.ZSTD_no_overlap);
return sequenceLength;
}
@@ -2189,10 +2071,8 @@ public static unsafe partial class Methods
{
uint i;
for (i = 0; i < 3; i++)
System.Runtime.CompilerServices.Unsafe.Add(
ref seqState.prevOffset.e0,
(int)i
) = dctx->entropy.rep[i];
System.Runtime.CompilerServices.Unsafe.Add(ref seqState.prevOffset.e0, (int)i) =
dctx->entropy.rep[i];
}
if (ERR_isError(BIT_initDStream(ref seqState.DStream, ip, (nuint)(iend - ip))))
@@ -2298,11 +2178,10 @@ public static unsafe partial class Methods
ref seqState.prevOffset.e0,
(int)ll0
);
seqState.prevOffset.e1 =
System.Runtime.CompilerServices.Unsafe.Add(
ref seqState.prevOffset.e0,
ll0 == 0 ? 1 : 0
);
seqState.prevOffset.e1 = System.Runtime.CompilerServices.Unsafe.Add(
ref seqState.prevOffset.e0,
ll0 == 0 ? 1 : 0
);
seqState.prevOffset.e0 = offset;
}
else
@@ -2631,11 +2510,11 @@ public static unsafe partial class Methods
(nint)sequence.offset
);
#if NETCOREAPP3_0_OR_GREATER
if (System.Runtime.Intrinsics.X86.Sse.IsSupported)
{
System.Runtime.Intrinsics.X86.Sse.Prefetch0(match);
System.Runtime.Intrinsics.X86.Sse.Prefetch0(match + 64);
}
if (System.Runtime.Intrinsics.X86.Sse.IsSupported)
{
System.Runtime.Intrinsics.X86.Sse.Prefetch0(match);
System.Runtime.Intrinsics.X86.Sse.Prefetch0(match + 64);
}
#endif
}
@@ -2788,12 +2667,7 @@ public static unsafe partial class Methods
);
if (ERR_isError(oneSeqSize))
return oneSeqSize;
prefetchPos = ZSTD_prefetchMatch(
prefetchPos,
sequence,
prefixStart,
dictEnd
);
prefetchPos = ZSTD_prefetchMatch(prefetchPos, sequence, prefixStart, dictEnd);
sequences[seqNb & 8 - 1] = sequence;
op += oneSeqSize;
}
@@ -3027,11 +2901,7 @@ public static unsafe partial class Methods
*/
private static ZSTD_OffsetInfo ZSTD_getOffsetInfo(ZSTD_seqSymbol* offTable, int nbSeq)
{
ZSTD_OffsetInfo info = new ZSTD_OffsetInfo
{
longOffsetShare = 0,
maxNbAdditionalBits = 0,
};
ZSTD_OffsetInfo info = new ZSTD_OffsetInfo { longOffsetShare = 0, maxNbAdditionalBits = 0 };
if (nbSeq != 0)
{
void* ptr = offTable;
@@ -3290,11 +3160,7 @@ public static unsafe partial class Methods
{
void* ptr = dt;
ZSTD_seqSymbol_header* DTableH = (ZSTD_seqSymbol_header*)ptr;
DStatePtr.state = BIT_readBits(
bitD.bitContainer,
ref bitD.bitsConsumed,
DTableH->tableLog
);
DStatePtr.state = BIT_readBits(bitD.bitContainer, ref bitD.bitsConsumed, DTableH->tableLog);
BIT_reloadDStream(
ref bitD.bitContainer,
ref bitD.bitsConsumed,
@@ -3349,4 +3215,4 @@ public static unsafe partial class Methods
op += 8;
assert(op - ip >= 8);
}
}
}

View File

@@ -8,51 +8,51 @@ namespace SharpCompress.Compressors.ZStandard.Unsafe;
public static unsafe partial class Methods
{
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_LL_base =>
new uint[36]
{
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
18,
20,
22,
24,
28,
32,
40,
48,
64,
0x80,
0x100,
0x200,
0x400,
0x800,
0x1000,
0x2000,
0x4000,
0x8000,
0x10000,
};
private static uint* LL_base =>
(uint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_LL_base)
);
private static ReadOnlySpan<uint> Span_LL_base =>
new uint[36]
{
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
18,
20,
22,
24,
28,
32,
40,
48,
64,
0x80,
0x100,
0x200,
0x400,
0x800,
0x1000,
0x2000,
0x4000,
0x8000,
0x10000,
};
private static uint* LL_base =>
(uint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_LL_base)
);
#else
private static readonly uint* LL_base = GetArrayPointer(
@@ -98,47 +98,47 @@ public static unsafe partial class Methods
);
#endif
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_OF_base =>
new uint[32]
{
0,
1,
1,
5,
0xD,
0x1D,
0x3D,
0x7D,
0xFD,
0x1FD,
0x3FD,
0x7FD,
0xFFD,
0x1FFD,
0x3FFD,
0x7FFD,
0xFFFD,
0x1FFFD,
0x3FFFD,
0x7FFFD,
0xFFFFD,
0x1FFFFD,
0x3FFFFD,
0x7FFFFD,
0xFFFFFD,
0x1FFFFFD,
0x3FFFFFD,
0x7FFFFFD,
0xFFFFFFD,
0x1FFFFFFD,
0x3FFFFFFD,
0x7FFFFFFD,
};
private static uint* OF_base =>
(uint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_OF_base)
);
private static ReadOnlySpan<uint> Span_OF_base =>
new uint[32]
{
0,
1,
1,
5,
0xD,
0x1D,
0x3D,
0x7D,
0xFD,
0x1FD,
0x3FD,
0x7FD,
0xFFD,
0x1FFD,
0x3FFD,
0x7FFD,
0xFFFD,
0x1FFFD,
0x3FFFD,
0x7FFFD,
0xFFFFD,
0x1FFFFD,
0x3FFFFD,
0x7FFFFD,
0xFFFFFD,
0x1FFFFFD,
0x3FFFFFD,
0x7FFFFFD,
0xFFFFFFD,
0x1FFFFFFD,
0x3FFFFFFD,
0x7FFFFFFD,
};
private static uint* OF_base =>
(uint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_OF_base)
);
#else
private static readonly uint* OF_base = GetArrayPointer(
@@ -180,47 +180,47 @@ public static unsafe partial class Methods
);
#endif
#if NET7_0_OR_GREATER
private static ReadOnlySpan<byte> Span_OF_bits =>
new byte[32]
{
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
};
private static byte* OF_bits =>
(byte*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_OF_bits)
);
private static ReadOnlySpan<byte> Span_OF_bits =>
new byte[32]
{
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
};
private static byte* OF_bits =>
(byte*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_OF_bits)
);
#else
private static readonly byte* OF_bits = GetArrayPointer(
@@ -262,68 +262,68 @@ public static unsafe partial class Methods
);
#endif
#if NET7_0_OR_GREATER
private static ReadOnlySpan<uint> Span_ML_base =>
new uint[53]
{
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
37,
39,
41,
43,
47,
51,
59,
67,
83,
99,
0x83,
0x103,
0x203,
0x403,
0x803,
0x1003,
0x2003,
0x4003,
0x8003,
0x10003,
};
private static uint* ML_base =>
(uint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_ML_base)
);
private static ReadOnlySpan<uint> Span_ML_base =>
new uint[53]
{
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
37,
39,
41,
43,
47,
51,
59,
67,
83,
99,
0x83,
0x103,
0x203,
0x403,
0x803,
0x1003,
0x2003,
0x4003,
0x8003,
0x10003,
};
private static uint* ML_base =>
(uint*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_ML_base)
);
#else
private static readonly uint* ML_base = GetArrayPointer(

View File

@@ -99,13 +99,13 @@ public static unsafe partial class Methods
}
#if NET7_0_OR_GREATER
private static ReadOnlySpan<byte> Span_dummy =>
new byte[10] { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0xe2, 0xb4 };
private static byte* dummy =>
(byte*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_dummy)
);
private static ReadOnlySpan<byte> Span_dummy =>
new byte[10] { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0xe2, 0xb4 };
private static byte* dummy =>
(byte*)
System.Runtime.CompilerServices.Unsafe.AsPointer(
ref MemoryMarshal.GetReference(Span_dummy)
);
#else
private static readonly byte* dummy = GetArrayPointer(
@@ -138,9 +138,9 @@ public static unsafe partial class Methods
byte* iend = istart + srcSize;
byte* ilimit = iend - 8;
uint offset_1 = rep[0],
offset_2 = rep[1];
offset_2 = rep[1];
uint offsetSaved1 = 0,
offsetSaved2 = 0;
offsetSaved2 = 0;
nuint mLength;
uint offset;
uint curr;
@@ -252,11 +252,11 @@ public static unsafe partial class Methods
if (ip1 >= nextStep)
{
#if NETCOREAPP3_0_OR_GREATER
if (System.Runtime.Intrinsics.X86.Sse.IsSupported)
{
System.Runtime.Intrinsics.X86.Sse.Prefetch0(ip1 + 64);
System.Runtime.Intrinsics.X86.Sse.Prefetch0(ip1 + 128);
}
if (System.Runtime.Intrinsics.X86.Sse.IsSupported)
{
System.Runtime.Intrinsics.X86.Sse.Prefetch0(ip1 + 64);
System.Runtime.Intrinsics.X86.Sse.Prefetch0(ip1 + 128);
}
#endif
step++;
@@ -319,9 +319,7 @@ public static unsafe partial class Methods
hashSmall[ZSTD_hashPtr(ip - 1, hBitsS, mls)] = (uint)(ip - 1 - @base);
}
while (
ip <= ilimit && offset_2 > 0 && MEM_read32(ip) == MEM_read32(ip - offset_2)
)
while (ip <= ilimit && offset_2 > 0 && MEM_read32(ip) == MEM_read32(ip - offset_2))
{
/* store sequence */
nuint rLength = ZSTD_count(ip + 4, ip + 4 - offset_2, iend) + 4;
@@ -368,7 +366,7 @@ public static unsafe partial class Methods
byte* iend = istart + srcSize;
byte* ilimit = iend - 8;
uint offset_1 = rep[0],
offset_2 = rep[1];
offset_2 = rep[1];
ZSTD_MatchState_t* dms = ms->dictMatchState;
ZSTD_compressionParameters* dictCParams = &dms->cParams;
uint* dictHashLong = dms->hashTable;
@@ -393,10 +391,10 @@ public static unsafe partial class Methods
for (_pos = 0; _pos < _size; _pos += 64)
{
#if NETCOREAPP3_0_OR_GREATER
if (System.Runtime.Intrinsics.X86.Sse.IsSupported)
{
System.Runtime.Intrinsics.X86.Sse.Prefetch1(_ptr + _pos);
}
if (System.Runtime.Intrinsics.X86.Sse.IsSupported)
{
System.Runtime.Intrinsics.X86.Sse.Prefetch1(_ptr + _pos);
}
#endif
}
}
@@ -408,10 +406,10 @@ public static unsafe partial class Methods
for (_pos = 0; _pos < _size; _pos += 64)
{
#if NETCOREAPP3_0_OR_GREATER
if (System.Runtime.Intrinsics.X86.Sse.IsSupported)
{
System.Runtime.Intrinsics.X86.Sse.Prefetch1(_ptr + _pos);
}
if (System.Runtime.Intrinsics.X86.Sse.IsSupported)
{
System.Runtime.Intrinsics.X86.Sse.Prefetch1(_ptr + _pos);
}
#endif
}
}
@@ -450,13 +448,8 @@ public static unsafe partial class Methods
{
byte* repMatchEnd = repIndex < prefixLowestIndex ? dictEnd : iend;
mLength =
ZSTD_count_2segments(
ip + 1 + 4,
repMatch + 4,
iend,
repMatchEnd,
prefixLowest
) + 4;
ZSTD_count_2segments(ip + 1 + 4, repMatch + 4, iend, repMatchEnd, prefixLowest)
+ 4;
ip++;
assert(1 >= 1);
assert(1 <= 3);
@@ -486,13 +479,8 @@ public static unsafe partial class Methods
if (dictMatchL > dictStart && MEM_read64(dictMatchL) == MEM_read64(ip))
{
mLength =
ZSTD_count_2segments(
ip + 8,
dictMatchL + 8,
iend,
dictEnd,
prefixLowest
) + 8;
ZSTD_count_2segments(ip + 8, dictMatchL + 8, iend, dictEnd, prefixLowest)
+ 8;
offset = curr - dictMatchIndexL - dictIndexDelta;
while (ip > anchor && dictMatchL > dictStart && ip[-1] == dictMatchL[-1])
{
@@ -538,10 +526,7 @@ public static unsafe partial class Methods
);
byte* matchL3 = @base + matchIndexL3;
hashLong[hl3] = curr + 1;
if (
matchIndexL3 >= prefixLowestIndex
&& MEM_read64(matchL3) == MEM_read64(ip + 1)
)
if (matchIndexL3 >= prefixLowestIndex && MEM_read64(matchL3) == MEM_read64(ip + 1))
{
mLength = ZSTD_count(ip + 9, matchL3 + 8, iend) + 8;
ip++;
@@ -561,10 +546,7 @@ public static unsafe partial class Methods
uint dictMatchIndexL3 = dictMatchIndexAndTagL3 >> 8;
byte* dictMatchL3 = dictBase + dictMatchIndexL3;
assert(dictMatchL3 < dictEnd);
if (
dictMatchL3 > dictStart
&& MEM_read64(dictMatchL3) == MEM_read64(ip + 1)
)
if (dictMatchL3 > dictStart && MEM_read64(dictMatchL3) == MEM_read64(ip + 1))
{
mLength =
ZSTD_count_2segments(
@@ -576,9 +558,7 @@ public static unsafe partial class Methods
) + 8;
ip++;
offset = curr + 1 - dictMatchIndexL3 - dictIndexDelta;
while (
ip > anchor && dictMatchL3 > dictStart && ip[-1] == dictMatchL3[-1]
)
while (ip > anchor && dictMatchL3 > dictStart && ip[-1] == dictMatchL3[-1])
{
ip--;
dictMatchL3--;
@@ -592,8 +572,7 @@ public static unsafe partial class Methods
if (matchIndexS < prefixLowestIndex)
{
mLength =
ZSTD_count_2segments(ip + 4, match + 4, iend, dictEnd, prefixLowest) + 4;
mLength = ZSTD_count_2segments(ip + 4, match + 4, iend, dictEnd, prefixLowest) + 4;
offset = curr - matchIndexS;
while (ip > anchor && match > dictStart && ip[-1] == match[-1])
{
@@ -647,13 +626,8 @@ public static unsafe partial class Methods
{
byte* repEnd2 = repIndex2 < prefixLowestIndex ? dictEnd : iend;
nuint repLength2 =
ZSTD_count_2segments(
ip + 4,
repMatch2 + 4,
iend,
repEnd2,
prefixLowest
) + 4;
ZSTD_count_2segments(ip + 4, repMatch2 + 4, iend, repEnd2, prefixLowest)
+ 4;
/* swap offset_2 <=> offset_1 */
uint tmpOffset = offset_2;
offset_2 = offset_1;
@@ -894,7 +868,7 @@ public static unsafe partial class Methods
byte* dictStart = dictBase + dictStartIndex;
byte* dictEnd = dictBase + prefixStartIndex;
uint offset_1 = rep[0],
offset_2 = rep[1];
offset_2 = rep[1];
if (prefixStartIndex == dictStartIndex)
return ZSTD_compressBlock_doubleFast(ms, seqStore, rep, src, srcSize);
while (ip < ilimit)
@@ -924,13 +898,8 @@ public static unsafe partial class Methods
{
byte* repMatchEnd = repIndex < prefixStartIndex ? dictEnd : iend;
mLength =
ZSTD_count_2segments(
ip + 1 + 4,
repMatch + 4,
iend,
repMatchEnd,
prefixStart
) + 4;
ZSTD_count_2segments(ip + 1 + 4, repMatch + 4, iend, repMatchEnd, prefixStart)
+ 4;
ip++;
assert(1 >= 1);
assert(1 <= 3);
@@ -941,8 +910,7 @@ public static unsafe partial class Methods
if (matchLongIndex > dictStartIndex && MEM_read64(matchLong) == MEM_read64(ip))
{
byte* matchEnd = matchLongIndex < prefixStartIndex ? dictEnd : iend;
byte* lowMatchPtr =
matchLongIndex < prefixStartIndex ? dictStart : prefixStart;
byte* lowMatchPtr = matchLongIndex < prefixStartIndex ? dictStart : prefixStart;
uint offset;
mLength =
ZSTD_count_2segments(ip + 8, matchLong + 8, iend, matchEnd, prefixStart)
@@ -975,22 +943,14 @@ public static unsafe partial class Methods
byte* match3 = match3Base + matchIndex3;
uint offset;
hashLong[h3] = curr + 1;
if (
matchIndex3 > dictStartIndex
&& MEM_read64(match3) == MEM_read64(ip + 1)
)
if (matchIndex3 > dictStartIndex && MEM_read64(match3) == MEM_read64(ip + 1))
{
byte* matchEnd = matchIndex3 < prefixStartIndex ? dictEnd : iend;
byte* lowMatchPtr =
matchIndex3 < prefixStartIndex ? dictStart : prefixStart;
mLength =
ZSTD_count_2segments(
ip + 9,
match3 + 8,
iend,
matchEnd,
prefixStart
) + 8;
ZSTD_count_2segments(ip + 9, match3 + 8, iend, matchEnd, prefixStart)
+ 8;
ip++;
offset = curr + 1 - matchIndex3;
while (ip > anchor && match3 > lowMatchPtr && ip[-1] == match3[-1])
@@ -1003,8 +963,7 @@ public static unsafe partial class Methods
else
{
byte* matchEnd = matchIndex < prefixStartIndex ? dictEnd : iend;
byte* lowMatchPtr =
matchIndex < prefixStartIndex ? dictStart : prefixStart;
byte* lowMatchPtr = matchIndex < prefixStartIndex ? dictStart : prefixStart;
mLength =
ZSTD_count_2segments(ip + 4, match + 4, iend, matchEnd, prefixStart)
+ 4;
@@ -1064,13 +1023,8 @@ public static unsafe partial class Methods
{
byte* repEnd2 = repIndex2 < prefixStartIndex ? dictEnd : iend;
nuint repLength2 =
ZSTD_count_2segments(
ip + 4,
repMatch2 + 4,
iend,
repEnd2,
prefixStart
) + 4;
ZSTD_count_2segments(ip + 4, repMatch2 + 4, iend, repEnd2, prefixStart)
+ 4;
/* swap offset_2 <=> offset_1 */
uint tmpOffset = offset_2;
offset_2 = offset_1;
@@ -1103,14 +1057,7 @@ public static unsafe partial class Methods
nuint srcSize
)
{
return ZSTD_compressBlock_doubleFast_extDict_generic(
ms,
seqStore,
rep,
src,
srcSize,
4
);
return ZSTD_compressBlock_doubleFast_extDict_generic(ms, seqStore, rep, src, srcSize, 4);
}
private static nuint ZSTD_compressBlock_doubleFast_extDict_5(
@@ -1121,14 +1068,7 @@ public static unsafe partial class Methods
nuint srcSize
)
{
return ZSTD_compressBlock_doubleFast_extDict_generic(
ms,
seqStore,
rep,
src,
srcSize,
5
);
return ZSTD_compressBlock_doubleFast_extDict_generic(ms, seqStore, rep, src, srcSize, 5);
}
private static nuint ZSTD_compressBlock_doubleFast_extDict_6(
@@ -1139,14 +1079,7 @@ public static unsafe partial class Methods
nuint srcSize
)
{
return ZSTD_compressBlock_doubleFast_extDict_generic(
ms,
seqStore,
rep,
src,
srcSize,
6
);
return ZSTD_compressBlock_doubleFast_extDict_generic(ms, seqStore, rep, src, srcSize, 6);
}
private static nuint ZSTD_compressBlock_doubleFast_extDict_7(
@@ -1157,14 +1090,7 @@ public static unsafe partial class Methods
nuint srcSize
)
{
return ZSTD_compressBlock_doubleFast_extDict_generic(
ms,
seqStore,
rep,
src,
srcSize,
7
);
return ZSTD_compressBlock_doubleFast_extDict_generic(ms, seqStore, rep, src, srcSize, 7);
}
private static nuint ZSTD_compressBlock_doubleFast_extDict(

View File

@@ -216,7 +216,7 @@ public static unsafe partial class Methods
uint rep_offset1 = rep[0];
uint rep_offset2 = rep[1];
uint offsetSaved1 = 0,
offsetSaved2 = 0;
offsetSaved2 = 0;
/* hash for ip0 */
nuint hash0;
/* hash for ip1 */
@@ -564,7 +564,7 @@ public static unsafe partial class Methods
byte* iend = istart + srcSize;
byte* ilimit = iend - 8;
uint offset_1 = rep[0],
offset_2 = rep[1];
offset_2 = rep[1];
ZSTD_MatchState_t* dms = ms->dictMatchState;
ZSTD_compressionParameters* dictCParams = &dms->cParams;
uint* dictHashTable = dms->hashTable;
@@ -653,10 +653,7 @@ public static unsafe partial class Methods
/* Found a possible dict match */
uint dictMatchIndex = dictMatchIndexAndTag >> 8;
byte* dictMatch = dictBase + dictMatchIndex;
if (
dictMatchIndex > dictStartIndex
&& MEM_read32(dictMatch) == MEM_read32(ip0)
)
if (dictMatchIndex > dictStartIndex && MEM_read32(dictMatch) == MEM_read32(ip0))
{
if (matchIndex <= prefixStartIndex)
{
@@ -670,9 +667,7 @@ public static unsafe partial class Methods
prefixStart
) + 4;
while (
ip0 > anchor
&& dictMatch > dictStart
&& ip0[-1] == dictMatch[-1]
ip0 > anchor && dictMatch > dictStart && ip0[-1] == dictMatch[-1]
)
{
ip0--;
@@ -762,13 +757,8 @@ public static unsafe partial class Methods
{
byte* repEnd2 = repIndex2 < prefixStartIndex ? dictEnd : iend;
nuint repLength2 =
ZSTD_count_2segments(
ip0 + 4,
repMatch2 + 4,
iend,
repEnd2,
prefixStart
) + 4;
ZSTD_count_2segments(ip0 + 4, repMatch2 + 4, iend, repEnd2, prefixStart)
+ 4;
/* swap offset_2 <=> offset_1 */
uint tmpOffset = offset_2;
offset_2 = offset_1;
@@ -886,37 +876,13 @@ public static unsafe partial class Methods
{
default:
case 4:
return ZSTD_compressBlock_fast_dictMatchState_4_0(
ms,
seqStore,
rep,
src,
srcSize
);
return ZSTD_compressBlock_fast_dictMatchState_4_0(ms, seqStore, rep, src, srcSize);
case 5:
return ZSTD_compressBlock_fast_dictMatchState_5_0(
ms,
seqStore,
rep,
src,
srcSize
);
return ZSTD_compressBlock_fast_dictMatchState_5_0(ms, seqStore, rep, src, srcSize);
case 6:
return ZSTD_compressBlock_fast_dictMatchState_6_0(
ms,
seqStore,
rep,
src,
srcSize
);
return ZSTD_compressBlock_fast_dictMatchState_6_0(ms, seqStore, rep, src, srcSize);
case 7:
return ZSTD_compressBlock_fast_dictMatchState_7_0(
ms,
seqStore,
rep,
src,
srcSize
);
return ZSTD_compressBlock_fast_dictMatchState_7_0(ms, seqStore, rep, src, srcSize);
}
}
@@ -950,9 +916,9 @@ public static unsafe partial class Methods
byte* iend = istart + srcSize;
byte* ilimit = iend - 8;
uint offset_1 = rep[0],
offset_2 = rep[1];
offset_2 = rep[1];
uint offsetSaved1 = 0,
offsetSaved2 = 0;
offsetSaved2 = 0;
byte* ip0 = istart;
byte* ip1;
byte* ip2;
@@ -1043,8 +1009,7 @@ public static unsafe partial class Methods
}
{
uint mval =
idx >= dictStartIndex ? MEM_read32(idxBase + idx) : MEM_read32(ip0) ^ 1;
uint mval = idx >= dictStartIndex ? MEM_read32(idxBase + idx) : MEM_read32(ip0) ^ 1;
if (MEM_read32(ip0) == mval)
{
goto _offset;
@@ -1061,8 +1026,7 @@ public static unsafe partial class Methods
current0 = (uint)(ip0 - @base);
hashTable[hash0] = current0;
{
uint mval =
idx >= dictStartIndex ? MEM_read32(idxBase + idx) : MEM_read32(ip0) ^ 1;
uint mval = idx >= dictStartIndex ? MEM_read32(idxBase + idx) : MEM_read32(ip0) ^ 1;
if (MEM_read32(ip0) == mval)
{
goto _offset;
@@ -1143,10 +1107,8 @@ public static unsafe partial class Methods
byte* repMatch2 =
repIndex2 < prefixStartIndex ? dictBase + repIndex2 : @base + repIndex2;
if (
(
ZSTD_index_overlap_check(prefixStartIndex, repIndex2)
& (offset_2 > 0 ? 1 : 0)
) != 0
(ZSTD_index_overlap_check(prefixStartIndex, repIndex2) & (offset_2 > 0 ? 1 : 0))
!= 0
&& MEM_read32(repMatch2) == MEM_read32(ip0)
)
{
@@ -1244,4 +1206,4 @@ public static unsafe partial class Methods
return ZSTD_compressBlock_fast_extDict_7_0(ms, seqStore, rep, src, srcSize);
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More