コード例 #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);