/// <summary>Creates new instance of block decoder.</summary> /// <param name="blockSize">Block size. Must be equal or greater to one used for compression.</param> public LZ4BlockDecoder(int blockSize) { blockSize = Mem.RoundUp(Math.Max(blockSize, Mem.K1), Mem.K1); _blockSize = blockSize; _outputLength = _blockSize + 8; _outputIndex = 0; _outputBuffer = (byte *)Mem.Alloc(_outputLength + 8); }
/// <summary>Creates new instance of encoder.</summary> /// <param name="chaining">Needs to be <c>true</c> if using dependent blocks.</param> /// <param name="blockSize">Block size.</param> /// <param name="extraBlocks">Number of extra blocks.</param> protected LZ4EncoderBase(bool chaining, int blockSize, int extraBlocks) { blockSize = Mem.RoundUp(Math.Max(blockSize, Mem.K1), Mem.K1); extraBlocks = Math.Max(extraBlocks, 0); var dictSize = chaining ? Mem.K64 : 0; _blockSize = blockSize; _inputLength = dictSize + (1 + extraBlocks) * blockSize + 8; _inputIndex = _inputPointer = 0; _inputBuffer = (byte *)Mem.Alloc(_inputLength + 8); }
/// <summary>Creates new instance of <see cref="LZ4ChainDecoder"/>.</summary> /// <param name="blockSize">Block size.</param> /// <param name="extraBlocks">Number of extra blocks.</param> public LZ4ChainDecoder(int blockSize, int extraBlocks) { blockSize = Mem.RoundUp(Math.Max(blockSize, Mem.K1), Mem.K1); extraBlocks = Math.Max(extraBlocks, 0); _blockSize = blockSize; _outputLength = Mem.K64 + (1 + extraBlocks) * _blockSize + 8; _outputIndex = 0; _outputBuffer = (byte *)Mem.Alloc(_outputLength + 8); _context = (LZ4Context *)Mem.AllocZero(sizeof(LZ4Context)); }