Skip to content

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

License

Notifications You must be signed in to change notification settings

jakubtomsu/odin-lz4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.