Esempio n. 1
0
        public static int Encode64(
            ref byte *input,
            ref byte *output,
            int inputLength,
            int outputLength,
            int outputBlockLength,
            int acceleration = ACCELERATION_DEFAULT)
        {
            if (acceleration < 1)
            {
                acceleration = ACCELERATION_DEFAULT;
            }

            Lz4StreamTInternal ctx = new Lz4StreamTInternal();
            int wrote    = 0;
            var inputEnd = input + inputLength;

            if (outputLength >= MaximumOutputLength(inputLength))
            {
                if (inputLength < LZ4_64_KLIMIT)
                {
                    while (wrote < outputLength)
                    {
                        wrote += LZ4_compress_generic <NotLimited, ByU16, NoDict, NoDictIssue>(&ctx, ref input, ref output, (int)(inputEnd - input), outputBlockLength, acceleration);
                    }
                }
                else
                {
                    return(LZ4_compress_generic <NotLimited, ByU32, NoDict, NoDictIssue>(&ctx, ref input, ref output, (int)(inputEnd - input), 0, acceleration));
                }
            }
            else
            {
                if (inputLength < LZ4_64_KLIMIT)
                {
                    while (input < inputEnd)
                    {
                        wrote += LZ4_compress_generic <LimitedOutput, ByU16, NoDict, NoDictIssue>(&ctx, ref input, ref output, (int)(inputEnd - input), outputBlockLength, acceleration);
                    }
                }
                else
                {
                    return(LZ4_compress_generic <LimitedOutput, ByU32, NoDict, NoDictIssue>(&ctx, ref input, ref output, inputLength, outputLength, acceleration));
                }
            }

            return(wrote);
        }
Esempio n. 2
0
        public static int Encode64(
            ref byte *input,
            ref byte *output,
            int inputLength,
            int outputLength,
            int acceleration = ACCELERATION_DEFAULT)
        {
            if (acceleration < 1)
            {
                acceleration = ACCELERATION_DEFAULT;
            }

            Lz4StreamTInternal ctx = new Lz4StreamTInternal();

            if (outputLength >= MaximumOutputLength(inputLength))
            {
                if (inputLength < LZ4_64_KLIMIT)
                {
                    return(LZ4_compress_generic <NotLimited, ByU16, NoDict, NoDictIssue>(&ctx, ref input, ref output, inputLength, 0, acceleration));
                }
                else
                {
                    return(LZ4_compress_generic <NotLimited, ByU32, NoDict, NoDictIssue>(&ctx, ref input, ref output, inputLength, 0, acceleration));
                }
            }
            else
            {
                if (inputLength < LZ4_64_KLIMIT)
                {
                    return(LZ4_compress_generic <LimitedOutput, ByU16, NoDict, NoDictIssue>(&ctx, ref input, ref output, inputLength, outputLength, acceleration));
                }
                else
                {
                    return(LZ4_compress_generic <LimitedOutput, ByU32, NoDict, NoDictIssue>(&ctx, ref input, ref output, inputLength, outputLength, acceleration));
                }
            }
        }