public Lz4FrameInfo(byte flags) { int version = flags >> 6; if (version != 1) { throw Lz4Compressor.InvalidData(); } IndependentBlocks = 0 != (flags & 0x20); HasBlockChecksum = 0 != (flags & 0x10); HasContentLength = 0 != (flags & 8); HasContentChecksum = 0 != (flags & 4); HasDictionary = 0 != (flags & 1); }
void ReadNextBlock() { if (4 != BaseStream.Read(m_block_header, 0, 4)) { throw new EndOfStreamException(); } int block_size = LittleEndian.ToInt32(m_block_header, 0); if (0 == block_size) { m_eof = true; m_data_size = 0; if (m_info.HasContentChecksum) { ReadChecksum(); } } else if (block_size < 0) { m_data_size = block_size & 0x7FFFFFFF; if (m_data_size > m_data.Length) { m_data = new byte[m_data_size]; } m_data_size = BaseStream.Read(m_data, 0, m_data_size); if (m_info.HasBlockChecksum) { ReadChecksum(); } } else { m_block_size = block_size; if (null == m_block || m_block_size > m_block.Length) { m_block = new byte[m_block_size]; } if (m_block_size != BaseStream.Read(m_block, 0, m_block_size)) { throw new EndOfStreamException(); } m_data_size = Lz4Compressor.DecompressBlock(m_block, m_block_size, m_data, m_data.Length); if (m_info.HasBlockChecksum) { ReadChecksum(); } } m_data_pos = 0; }
public void SetBlockSize(int code) { switch ((code >> 4) & 7) { case 4: BlockSize = 0x10000; break; case 5: BlockSize = 0x40000; break; case 6: BlockSize = 0x100000; break; case 7: BlockSize = 0x400000; break; default: throw Lz4Compressor.InvalidData(); } }