Skip to content

v0.1.20

Choose a tag to compare

@lilith lilith released this 21 Apr 08:06
· 24 commits to main since this release

Added

  • ISO_21496_1_URN: &[u8; 28] — the ISO-defined namespace URN for gain-map payloads in URN-namespaced containers (most notably JPEG APP2). Byte-identical to libultrahdr's kIsoNameSpace.
  • ISO_21496_1_PRIMARY_APP2_BODY: &[u8; 32] — the full JPEG APP2 body (URN + min_version=0, writer_version=0) that the primary image of a canonical Ultra HDR JPEG carries to advertise ISO 21496-1 awareness. Goes directly inside the APP2 segment after the FF E2 marker + length header; detected by exact bytes match.
  • Iso21496Format::JxlJhgm — canonical name for the bare ISO 21496-1 payload (no URN, no version byte). Naming parallels AvifTmap: each variant names the container that consumes exactly those bytes.
  • Iso21496Format::JpegApp2BodyWithUrn — full JPEG APP2 body (URN + bare payload), handled in one parse_iso21496_fmt / serialize_iso21496_fmt call. Does NOT include the JPEG FF E2 marker or u16 BE length word (those stay with the caller as JPEG syntax).
  • Iso21496Format discriminants pinned with explicit = 0..3 values plus a const _: () = assert!(...) block, so accidental reorders/removals trip at compile time instead of silently shifting as u8 results.
  • gainmap::serialize_iso21496_fmt_into(params, format, &mut Vec<u8>) — append-to-buffer partner for serialize_iso21496_fmt, lets callers embed the ISO payload inside a larger buffer (e.g., a JPEG APP2 marker + length + body) in one allocation.
  • GainMapParseError::UrnMismatch — returned when parsing under Iso21496Format::JpegApp2BodyWithUrn and the input does not begin with ISO_21496_1_URN.

Deprecated

  • Iso21496Format::JpegApp2 — misleading name. The bytes it produces are the bare ISO 21496-1 payload (no URN), not a standalone JPEG APP2 body. Use JxlJhgm for the same bytes under a clearer name, or JpegApp2BodyWithUrn for the full APP2 body including the URN. Kept at its original discriminant 0 so existing as u8 casts keep working; it and JxlJhgm are distinct variants that serialize to identical bytes (Rust does not allow two variants to share a discriminant).

Fixed

  • Formatting fixup so cargo fmt --check is clean (41f7162).

Why

The URN is ISO-defined, not JPEG-defined, and belongs next to Iso21496Format rather than duplicated across codec crates. Folding URN framing into the format enum collapses the API surface to one parse/serialize pair and each variant now names the container that consumes exactly those bytes. The FF E2 + u16 BE length envelope remains pure JPEG syntax and stays in zenjpeg.

Full changelog: https://github.com/imazen/zencodec/blob/v0.1.20/CHANGELOG.md#0120---2026-04-21