Skip to content

Kaitai Struct: data compression algorithms processing routines

License

Notifications You must be signed in to change notification settings

kaitai-io/kaitai_compress

Repository files navigation

Kaitai Struct: compression processing libraries

This package provides custom processing routines to deal with compressed binary data. Implementations are provided for:

  • JavaScript
  • Python
  • Ruby

Note that most implementations are actually wrappers which route calls to well-known implementations for that languages.

Usage

To use these routines, one should add processing instruction into .ksy file and then add relevant language-specific implementations into one's project.

In .ksy file

To use it, just invoke the following in your .ksy:

process: kaitai.compress.PROCESS_NAME(ARGUMENTS)

where PROCESS_NAME and ARGUMENTS should be as described in the table below.

Fully working example:

meta:
  id: example_lz4
seq:
  - id: buf
    size: 50
    process: kaitai.compress.lz4

In JavaScript / Node

Add javascript/ to one's NODE_PATH.

In Python

Add python/ to one's PYTHONPATH.

In Ruby

Add ruby/lib/ to one's $LOAD_PATH.

Supported algorithms

Algorithm Process name Arguments Conforming Test file extension
Brotli brotli None RFC 7932 br
LZ4 lz4 None LZ4 block specification lz4
LZMA lzma_raw None Raw LZMA stream lzma_raw
LZMA lzma_lzma None Legacy .lzma file format (AKA alone) lzma
LZMA lzma_xz None .xz file format xz
DEFLATE (AKA zlib) zlib None RFC 1951 zlib
zstd (AKA zstandard) zstd None Spec & ref implementation zst