Пример #1
0
 /// <summary>
 /// Tops encoder up with some data.
 /// </summary>
 /// <param name="encoder">The encoder instance.</param>
 /// <param name="source">The buffer data.</param>
 /// <param name="offset">Offset in the buffer.</param>
 /// <param name="length">Length of buffer.</param>
 /// <returns>
 /// Number of bytes actually loaded.
 /// </returns>
 public static unsafe int Topup(this ILZ4Encoder encoder, byte[] source, int offset, int length)
 {
     fixed(byte *sourcePtr = source)
     {
         return(encoder.Topup(sourcePtr + offset, length));
     }
 }
Пример #2
0
        /// <summary>
        /// Tops encoder up with some data.
        /// </summary>
        /// <param name="encoder">The encoder instance.</param>
        /// <param name="source">The buffer data.</param>
        /// <param name="offset">Buffer offset, will be increased after operation by the number of bytes actually loaded.</param>
        /// <param name="length">Length of buffer.</param>
        /// <returns>`true` if buffer was topped up; or `false` if no bytes were loaded.</returns>
        public static bool Topup(this ILZ4Encoder encoder, byte[] source, ref int offset, int length)
        {
            int loaded = encoder.Topup(source, offset, length);

            offset += loaded;
            return(loaded != 0);
        }
Пример #3
0
        /// <summary>
        /// Tops encoder up with some data.
        /// </summary>
        /// <param name="encoder">The encoder instance.</param>
        /// <param name="source">Buffer pointer, will be shifted after operation by the number of bytes actually loaded.</param>
        /// <param name="length">Length of buffer.</param>
        /// <returns>`true` if buffer was topped up; or `false` if no bytes were loaded.</returns>
        public static unsafe bool Topup(this ILZ4Encoder encoder, ref byte *source, int length)
        {
            int loaded = encoder.Topup(source, length);

            source += loaded;
            return(loaded != 0);
        }
        public static bool Topup(
            this ILZ4Encoder encoder, byte[] source, ref int index, int length)
        {
            var loaded = encoder.Topup(source, index, length);

            index += loaded;
            return(loaded != 0);
        }
Пример #5
0
        /// <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));
        }
 public static unsafe int Topup(
     this ILZ4Encoder encoder, byte[] source, int index, int length)
 {
     fixed(byte *sourceP = source)
     return(encoder.Topup(sourceP + index, length));
 }
Пример #7
0
 public unsafe int Topup(byte *source, int length) =>
 _encoder.Topup(source, length);