Microsoft.Protocols.TestTools.StackSdk.Compression.Mppc.Compressor.Compress C# (CSharp) Method

Compress() public method

compress the input data
public Compress ( byte input, CompressMode &compressMode ) : byte[]
input byte the input data
compressMode CompressMode the compress mode of this compress
return byte[]
        public byte[] Compress(byte[] input, out CompressMode compressMode)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            compressMode = CompressMode.Compressed;
            if (input.Length > (window8k - slidingWindow.Count))
            {
                compressMode = compressMode | CompressMode.SetToFront;
                hashTable.Clear();
                slidingWindow.Clear();
            }

            CompressCore(input);

            byte[] ret = new byte[outputStream.Length];
            outputStream.Position = 0;
            outputStream.Read(ret, 0, ret.Length);

            //put stream position to 0 for next round compress
            outputStream.SetLength(0);

            if (ret.Length > input.Length)
            {
                compressMode = CompressMode.Flush;
                hashTable.Clear();
                slidingWindow.Clear();
                return input;
            }

            return ret;
        }