Lz4

object Lz4

LZ4: block format (the LZ77 token codec) + frame format (.lz4, magic 0x184D2204). Pure-Kotlin, with no entropy stage, so it is fast and cheap.

Decoder reads any conformant frame (skipping/honoring the optional block and content xxHash32 checks). Encoder writes a minimal frame (block-independent, 4 MiB max block, no checksums) with a real greedy hash-chain block compressor and a stored-block fallback when a block doesn't shrink.

Functions

Link copied to clipboard

Greedy LZ4 block compressor. Always produces a conformant block.

Link copied to clipboard
fun blockDecompress(src: ByteArray, sOff: Int, sEnd: Int, expectedSize: Int = -1): ByteArray

Decompress one LZ4 block in src[sOff, sEnd).

Link copied to clipboard

Compress data into a complete LZ4 frame (no checksums, 4 MiB blocks).

Link copied to clipboard
fun frameDecompress(input: ByteArray, limits: ArchiveLimits = ArchiveLimits.DEFAULT): ByteArray

Decompress an LZ4 frame, enforcing limits.