예제 #1
0
        private int ApplyDict(int index)
        {
            var dictStart = Math.Max(index - Mem.K64, 0);
            var dictSize  = index - dictStart;

            LZ4_xx.LZ4_setStreamDecode(_context, _outputBuffer + dictStart, dictSize);
            return(index);
        }
예제 #2
0
        /// <summary>Decompresses data from given buffer.</summary>
        /// <param name="source">Input buffer.</param>
        /// <param name="sourceLength">Input buffer length.</param>
        /// <param name="target">Output buffer.</param>
        /// <param name="targetLength">Output buffer length.</param>
        /// <returns>Number of bytes written, or negative value if output buffer is too small.</returns>
        public static unsafe int Decode(
            byte *source, int sourceLength,
            byte *target, int targetLength)
        {
            if (sourceLength <= 0)
            {
                return(0);
            }

            var decoded = LZ4_xx.LZ4_decompress_safe(source, target, sourceLength, targetLength);

            return(decoded <= 0 ? -1 : decoded);
        }
예제 #3
0
 /// <inheritdoc />
 protected override int CopyDict(byte *target, int length) =>
 LZ4_xx.LZ4_saveDict(_context, target, length);
예제 #4
0
 private int DecodeBlock(byte *source, int sourceLength, byte *target, int targetLength) =>
 LZ4_xx.LZ4_decompress_safe_continue(_context, source, target, sourceLength, targetLength);
예제 #5
0
 /// <summary>Maximum size after compression.</summary>
 /// <param name="length">Length of input buffer.</param>
 /// <returns>Maximum length after compression.</returns>
 public static int MaximumOutputSize(int length) =>
 LZ4_xx.LZ4_compressBound(length);