Crate ultrahdr

Crate ultrahdr 

Source
Expand description

Safe Rust bindings for Google’s libultrahdr, the reference implementation of UltraHDR gain-map JPEG encoding/decoding.

The crate exposes a small, stateful API that mirrors the C library while handling memory ownership and validation for you:

  • Decoder reads JPEGs, exposes gain-map metadata (if present), and produces packed pixel views.
  • Encoder writes UltraHDR or plain JPEGs from packed pixel buffers or compressed inputs.
  • RawImage, CompressedImage, and DecodedPackedView describe image buffers without requiring you to depend on sys directly.

For a higher-level walkthrough, see examples/ultrahdr_app.rs in this crate and the CLI in the companion ultrahdr-bake package.

Re-exports§

pub use ultrahdr_sys as sys;

Structs§

CompressedImage
Borrowed descriptor over a caller-provided compressed JPEG buffer.
DecodedPacked
Owned packed pixels plus metadata returned by a [Decoder].
DecodedPackedView
Borrowed view over packed pixels owned by a [Decoder].
Decoder
UltraHDR JPEG decoder. Owns the underlying uhdr_codec_private_t and provides safe access to decoded pixel buffers and gain-map metadata.
EncodedImage
Owned compressed JPEG (and optional gain-map) returned by an [Encoder].
EncodedView
Borrowed view over an encoded stream owned by an [Encoder] or [Decoder].
Encoder
UltraHDR JPEG encoder. Owns the underlying uhdr_codec_private_t and can be reused across multiple encodes by calling reset.
Error
Error produced by the safe wrappers around libultrahdr.
GainMapMetadata
Parsed metadata describing an embedded gain map.
OwnedPackedImage
Owns a packed raw buffer and exposes it as uhdr_raw_image.
RawImage
Borrowed descriptor over a caller-provided packed pixel buffer.

Constants§

SDR_WHITE_NITS
Nominal SDR diffuse white used by libultrahdr for capacity math (ISO/TS 22028-5).

Functions§

bytes_per_pixel
Bytes-per-pixel helper for the supported packed formats.

Type Aliases§

Codec
Output codec to write.
ColorGamut
Scene-referred color gamut.
ColorRange
Chroma sample range.
ColorTransfer
Transfer function describing the relationship between encoded values and scene light.
EncPreset
Encoder tuning preset.
ErrorCode
Error codes returned by the underlying C API.
ImgFormat
Pixel layout for packed buffers accepted/returned by libultrahdr.
ImgLabel
Whether an image is the base view or the gain map.
Result
Result alias used throughout the crate.