Skip to main content

Crate blad_codec

Crate blad_codec 

Source
Expand description

Lossless codec backends.

§Byte-oriented by design

Encode and decode take and produce raw sample bytes in the source file’s own byte order, and write through a Write. Materialising an image as Vec<u16> merely to change endianness duplicates the entire frame — ~300 MB on a 51MP file, twice per round trip.

§Why JPEG XL

Measured on real 16-bit files, not chosen by reputation:

  • zstd -19 reaches only 0.72 on a Bayer mosaic; LZ looks for repeated byte sequences and photographic data has 2D correlation instead.
  • AVIF and HEIC cannot participate at all — AV1 tops out at 12 bits per sample.
  • PNG handles 16-bit but is well behind JXL’s modular mode.

libjxl is vendored, so the binary links libjxl.a statically and depends on nothing beyond the platform C/C++ runtime. That also pins the codec version, which keeps benchmarks comparable over time instead of shifting under someone’s package upgrade.

§Effort is non-monotonic

Default is 4, not 9. Measured: on Bayer planes effort 7 encoded larger than 4 and 3.8x slower; on a 51MP RGB frame effort 9 was larger than 7 and 36x slower than 4. Do not raise the default without measuring on both CFA and RGB content.

Structs§

Frame
Everything a codec needs to know about a rectangle of raw samples.
Jxl
JPEG XL via vendored libjxl, in process.

Enums§

Channels
Depth
Bits per sample. Real files mix depths — a 3FR holds a 16-bit sensor mosaic and an 8-bit embedded preview — so this cannot be assumed away.
Error

Traits§

Codec
A lossless image codec operating on raw sample bytes.

Functions§

libjxl_version
libjxl’s own version, e.g. 0.12.0, from the linked library.

Type Aliases§

Result