Expand description
Still decode, orientation, metadata normalisation and derivative generation over
rawshift-image (media feature, implied by native). Feature-gated
rather than native-gated so the codec stack is one manifest edit away from being dropped
from a size-constrained build, and so the wasm32-unknown-unknown sealing surface provably
does not link it. See media.
Still-image decode, orientation, metadata normalisation and derivative generation — the
Capsule-side owner of the media pipeline.
SSoT: Thumbnails and Previews.
§Boundaries
Rawshift owns codecs; this module owns everything Capsule decides. Concretely,
rawshift-image performs format sniffing, pixel decode, and the byte encode, while this
module owns:
- the closed format sets —
StillFormat(what Capsule models as a still) andDerivativeFormat(what a signedDerivativeManifest.formatmay say); - the pixel budget and the panic guard, because a third-party pre-1.0 decoder is fed untrusted bytes on the import path;
- tier sizing and the downscale, because
rawshift-imagehas no resize and because a derivative’s bytes are signed, so the resample must be deterministic; - the metadata strip, because the crate’s own default embeds EXIF (GPS included) into every encode.
Every path above is reached through the re-exports below, and the doc links name them by
their full crate::media::… path deliberately. A bare [`StillFormat`] here does not
resolve under the doc-check-rust gate (cargo doc --no-deps, -D warnings) even though
the type is re-exported a few lines down — while it does resolve when the same command is
given --document-private-items, which is why the failure only appeared in CI. Rather than
guess at which of rustdoc’s resolution rules produces that asymmetry, these links use the
path that resolves under both.
LQIP is not here: it lives in the unconditional crate::lqip module so the import
pipeline, the app FFI and capsule-wasm share one implementation. This
module produces the pixels crate::lqip::Lqip::encode consumes.
§What this build can and cannot do
Every gap is a typed
UnsupportedFormat or a recorded per-format
deferral — never a silent absence, and never a panic.
Decode covers JPEG, PNG, JXL, TIFF and GIF, the ARW and DNG RAW families (issue #589,
through rawshift-image’s RAW pipeline rather than its standard-image one; see
media::decode), plus AVIF under the opt-in media-avif-decode feature, which the CLI
enables (issue #588). AVIF goes through gamut’s container parser and decodes its AV1
codestream only where a hardware decoder is present (VAAPI on Linux today); elsewhere an
AVIF defers like a missing codec until upstream gains a software AV1 fallback
(visualcommons/rawshift#78). An ARW or DNG variant upstream has no decoder for — Sony’s
lossy compressed ARW — defers the same way. Encode writes the AVIF variant through
gamut’s pure-Rust AV1 encoder in every build. The opt-in media-linked-codecs feature, which
the CLI enables and the mobile FFI does not, adds the lossy JXL master (libjxl) and the
preview tier; without it only the thumbnail is encoded, as AVIF alone, and the JXL master is
a recorded deferral.
Embedded previews (extract_embedded_preview)
are read from every RAW family the build decodes through RawFile::thumbnail, under the same
IFD walk and pixel budget, and never developed, uploaded or signed. They are a stand-in on
the render ladder until an encoded tier exists, not a derivative.
HEIC, WebP and the other five RAW families (CR2, CR3, CRW, NEF, RAF) — and AVIF without
media-avif-decode — sniff correctly and refuse to decode. HEIC is refused by decision: libheif and libde265 are LGPL-3.0 and excluded
by policy (rawshift-image’s gamut HEIC decoder needs a hardware HEVC decoder besides, and
is not enabled). WebP is not enabled: rawshift-image’s WebP is now pure-Rust gamut and
compiles everywhere, but enabling it is its own change.
Structs§
- Decoded
Image - A decoded still: upright, opaque, packed RGBA8.
- Derivative
Context - Everything the manifest signer needs that the pixels do not carry: the asset identity, the epoch/authorisation context, and the two signing keys that produce the manifest’s two hybrid signatures.
- Embedded
Preview - A RAW file’s embedded, camera-rendered JPEG, extracted without developing the RAW.
- Generated
Derivative - One generated derivative: the encoded bytes plus its signed manifest.
- Media
Metadata - What a header-only probe can say about a still, normalised onto Capsule’s own types.
- Rawshift
Decoder - The
rawshift-image-backedDecoder— the only production implementation. - Sealed
Derivative - What a derivative’s signed manifest has to commit to about its ciphertext.
- Still
Derivatives - The outcome of one asset’s still-derivative generation.
Enums§
- Derivative
Tier - A derivative tier from the tier table.
- Format
Op - Which direction of a codec a format was needed for. A build can decode a format it cannot encode (every format here except WebP) and the message has to say which half is missing.
- Media
Error - Why the still pipeline could not produce what was asked of it.
- Still
Format - The closed set of still-image formats Capsule models.
Constants§
- MAX_
DECODE_ PIXELS - The decode budget in pixels, refused before the decoder allocates.
- SUPPORTED_
STILL_ FORMATS - Every format this build can read pixels out of — the codec-coverage table, in one place.
Traits§
- Decoder
- The still-decode seam.
- Derivative
Sealer - The encryption seam between
mediaandlifecycle.
Functions§
- capped_
dimensions - The dimensions a
widthxheightframe takes when its long edge is capped atmax_long_edge, preserving aspect ratio. - decode_
embedded_ preview - Decode an
EmbeddedPreviewto upright, packed RGBA8, behind the unwind guard. - decode_
guarded - Run
decoder.decodewith the unwind boundary an import needs. - downscale_
rgba8 - Downscale packed RGBA8 so its long edge is at most
max_long_edge. - extract_
embedded_ preview - Extract the embedded preview of a RAW still, behind the pixel budget and the unwind guard.
- generate_
still_ derivatives - Generate the committed still derivatives for
decodedacrosstiers, signing aDerivativeManifestfor each. - guarded
- Run any fallible step of the still pipeline behind the same unwind boundary.