Skip to main content

generate_still_derivatives

Function generate_still_derivatives 

Source
pub fn generate_still_derivatives(
    decoded: &DecodedImage,
    tiers: &[DerivativeTier],
    ctx: &DerivativeContext<'_>,
) -> Result<StillDerivatives, MediaError>
Expand description

Generate the committed still derivatives for decoded across tiers, signing a DerivativeManifest for each.

Per tier:

  • if the tier caps the long edge and the source is not larger than the cap, a single format = "original" manifest is signed as a reference to the original blob (no bytes, nothing encrypted, committing to DerivativeContext::original) — the redundant-derivative sentinel from the contract, never a re-encode;
  • otherwise the frame is downscaled to the tier, encoded to each encodable format of DerivativeFormat::STILL_DELIVERY_ORDER, and encrypted through DerivativeContext::sealer before its manifest is signed over the ciphertext’s address; the formats with no encoder here are recorded as deferrals, and so is any single pair whose encoder refuses or panics on the frame — the tier’s other formats, and the other tiers, still run.

Manifests of the same role are hash-chained in generation order, so a role’s derivative provenance is append-only exactly like the asset’s.

§Errors

  • MediaError::Encode or MediaError::DecoderPanic — a codec refused (or panicked on) the frame for every pair attempted, so no derivative was produced at all; the first such failure is returned. A refusal on some pairs only is a deferral, not an error. “A codec refused the frame” is the only thing Encode means here.
  • MediaError::ZeroDimension — the source frame has a zero dimension.
  • MediaError::Sign — the device signer or the epoch write-tier signer refused, or DerivativeContext::sealer failed (an encryption refusal, or an exhausted nonce-prefix draw).

The split is the contract rather than bookkeeping. The import path degrades the first two to “this asset has no thumbnail” and commits the original anyway; it propagates Sign, because a workspace that cannot author a signed record is broken in a way a missing derivative is not — the same fault would stop the asset’s own manifest.