/// <inheritdoc /> public override void Flush() { var action = _encoder.FlushAndEncode( _buffer, 0, _buffer.Length, true, out var encoded); WriteBlock(encoded, action); _inner.Flush(); }
private void CloseFrame() { if (_encoder == null) { return; } try { var action = _encoder.FlushAndEncode( _buffer, 0, _buffer.Length, true, out var encoded); WriteBlock(encoded, action); Stash32(0); FlushStash(); if (_descriptor.ContentChecksum) { throw NotImplemented("ContentChecksum"); } _buffer = null; _encoder.Dispose(); } finally { _encoder = null; } }
private void CloseFrame() { if (_encoder == null) return; try { EncoderAction action = _encoder.FlushAndEncode(_buffer, 0, _buffer.Length, true, out int encoded); WriteBlock(encoded, action); Write32(0); Flush16(); if (_descriptor.ContentChecksum) throw new NotImplementedException(string.Format(RS.FeatureNotImplementedInType, "Content Checksum", GetType().Name)); _buffer = null; _encoder.Dispose(); } finally { _encoder = null; } }
public void CloseFrame() { if (_encoder == null) { return; } try { var action = _encoder.FlushAndEncode( _buffer, 0, _buffer.Length, true, out var encoded); WriteBlock(encoded, action); Write32(0); Flush16(); if (_frameInfo.ContentChecksum) { throw NotImplemented("ContentChecksum"); } _buffer = null; _encoder.Dispose(); } finally { _encoder = null; } }
/// <summary> /// Encoded remaining bytes in the encoder. /// </summary> /// <param name="encoder">The encoder instance.</param> /// <param name="target">Target buffer.</param> /// <param name="targetOffset">Offset within target buffer.</param> /// <param name="targetLength">Target buffer length.</param> /// <param name="allowCopy">Allows to copy bytes if compression was not possible.</param> /// <param name="encoded">Number if bytes encoded or copied. Value is 0 if no encoding was done.</param> /// <returns> /// An <see cref="EncoderAction"/> indicating the action performed. /// </returns> public static unsafe EncoderAction FlushAndEncode(this ILZ4Encoder encoder, byte[] target, int targetOffset, int targetLength, bool allowCopy, out int encoded) { fixed(byte *targetPtr = target) { return(encoder.FlushAndEncode(targetPtr + targetOffset, targetLength, true, allowCopy, 0, out encoded)); } }
/// <summary>Encoded remaining bytes in encoder.</summary> /// <param name="encoder">Encoder.</param> /// <param name="target">Target buffer.</param> /// <param name="allowCopy">Allows to copy bytes if compression was not possible.</param> /// <param name="encoded">Number if bytes encoded or copied. /// Value is 0 if no encoding was done.</param> /// <returns>Action performed.</returns> public static unsafe EncoderAction FlushAndEncode( this ILZ4Encoder encoder, Span <byte> target, bool allowCopy, out int encoded) { fixed(byte *targetP = target) return(encoder.FlushAndEncode( targetP, target.Length, true, allowCopy, 0, out encoded)); }
/// <summary> /// Tops encoder and encodes content. /// </summary> /// <param name="encoder">The encoder instance.</param> /// <param name="source">Source buffer (used to top up from).</param> /// <param name="sourceLength">Source buffer length.</param> /// <param name="target">Target buffer (used to encode into).</param> /// <param name="targetLength">Target buffer length.</param> /// <param name="forceEncode">Forces encoding even if encoder is not full.</param> /// <param name="allowCopy">Allows to copy bytes if compression was not possible.</param> /// <param name="loaded">Number of bytes loaded (topped up).</param> /// <param name="encoded">Number if bytes encoded or copied. Value is 0 if no encoding was done.</param> /// <returns> /// An <see cref="EncoderAction"/> indicating the action performed. /// </returns> public static unsafe EncoderAction TopupAndEncode(this ILZ4Encoder encoder, byte *source, int sourceLength, byte *target, int targetLength, bool forceEncode, bool allowCopy, out int loaded, out int encoded) { loaded = 0; encoded = 0; if (sourceLength > 0) { loaded = encoder.Topup(source, sourceLength); } return(encoder.FlushAndEncode(target, targetLength, forceEncode, allowCopy, loaded, out encoded)); }
private BlockInfo FlushAndEncode() { var action = _encoder.FlushAndEncode( _buffer.AsSpan(), true, out var encoded); try { _encoder.Dispose(); return(new BlockInfo(_buffer, action, encoded)); } finally { _encoder = null; _buffer = null; } }
/// <summary>Encoded remaining bytes in encoder.</summary> /// <param name="encoder">Encoder.</param> /// <param name="target">Target buffer.</param> /// <param name="targetLength">Target buffer length.</param> /// <param name="allowCopy">Allows to copy bytes if compression was not possible.</param> /// <param name="encoded">Number if bytes encoded or copied. /// Value is 0 if no encoding was done.</param> /// <returns>Action performed.</returns> public static unsafe EncoderAction FlushAndEncode( this ILZ4Encoder encoder, byte *target, int targetLength, bool allowCopy, out int encoded) => encoder.FlushAndEncode(target, targetLength, true, allowCopy, 0, out encoded);