/// <summary>Compresses data from one buffer into another.</summary> /// <param name="source">Input buffer.</param> /// <param name="sourceLength">Length of input buffer.</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> private static unsafe int Encode( byte *source, int sourceLength, byte *target, int targetLength) { if (sourceLength <= 0) { return(0); } var encoded = LZ4_64.LZ4_compress_default(source, target, sourceLength, targetLength); return(encoded <= 0 ? -1 : encoded); }
/// <summary>Compresses data from one buffer into another.</summary> /// <param name="source">Input buffer.</param> /// <param name="sourceLength">Length of input buffer.</param> /// <param name="target">Output buffer.</param> /// <param name="targetLength">Output buffer length.</param> /// <param name="level">Compression level.</param> /// <returns>Number of bytes written, or negative value if output buffer is too small.</returns> public static unsafe int Encode( byte *source, int sourceLength, byte *target, int targetLength, LZ4Level level = LZ4Level.L00_FAST) { if (sourceLength <= 0) { return(0); } var encoded = level == LZ4Level.L00_FAST ? LZ4_64.LZ4_compress_default(source, target, sourceLength, targetLength) : LZ4_64_HC.LZ4_compress_HC( source, target, sourceLength, targetLength, (int)level); return(encoded <= 0 ? -1 : encoded); }
public static unsafe int Encode(byte *source, byte *target, int sourceLength, int targetLength) { return(LZ4_64.LZ4_compress_default(source, target, sourceLength, targetLength)); }
public static unsafe int Encode(byte[] source, byte[] target) { fixed(byte *sourceP = source) fixed(byte *targetP = target) return(LZ4_64.LZ4_compress_default(sourceP, targetP, source.Length, target.Length)); }