jakubtomsu / odin-lz4

Odin bindings for LZ4 (https://github.com/lz4/lz4) - an extremely fast lossless compression algorithm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

odin-lz4

Odin bindings for the LZ4 library.

LZ4 is lossless compression algorithm, providing compression speed > 500 MB/s per core, scalable with multi-cores CPU. It features an extremely fast decoder, with speed in multiple GB/s per core, typically reaching RAM speed limits on multi-core systems.

Usage

Import the packages:

import "project:lz4"
import "project:lz4hc"

Compress data:

data := [?]byte{1, 2, 3, 4, 5}
compressed := lz4.compress_slice(data) or_return
// HC is _much_ slower to compress, but very fast to decompress.
hc_compressed := lz4hc.compress_slice(data) or_return

Decompress data:

decompressed_buf := mem.alloc_bytes(orig_size) // You need to store the original size separately.
// Decompress data from LZ4 or LZ4HC
decompressed := lz4.decompress(compressed, decompressed_buf) or_return

Features

  • LZ4
    • simple functions
    • advanced functions
    • streaming functions (WIP: implemented but not fully tested!)
  • LZ4HC
    • block compression
    • streaming compression (WIP: implemented but not fully tested!)

Frame and file support isn't implemented. I might implement them if ever need them.

Contributing

All contributions are welcome! I will merge any pull requests with meaningful work, whether that is small bug fixes, odin helpers or missing API implementation.

About

Odin bindings for LZ4 (https://github.com/lz4/lz4) - an extremely fast lossless compression algorithm

License:BSD 2-Clause "Simplified" License


Languages

Language:C 87.3%Language:Odin 12.5%Language:Batchfile 0.2%