Skip to main content

expected_color_authority

Function expected_color_authority 

Source
pub fn expected_color_authority(
    format: ImageFormat,
    has_cicp: bool,
    has_icc: bool,
) -> Option<ColorAuthority>
Expand description

The [ColorAuthority] a format’s specification assigns, given which colour fields the decoder actually read back.

This is the shared answer key behind check_source_color_authority — the “what does the spec say” half of the audit in zencodec issue #11 (Table 4), so every codec crate asserts the same rule instead of re-deriving it:

formatrule
PNGcICP outranks iCCP (PNG 3rd ed.): Cicp when CICP was read, else Icc
JXLcodestream colour encoding outranks an embedded ICC: Cicp when read, else Icc
HEICnclx is the primary colour authority (ISO 23008-12): Cicp when read, else Icc
AVIFMIAF order: an ICC colr outranks nclx — Icc when an ICC was read, else Cicp when CICP was read, else Icc
Radiance HDRscene-linear BT.709 has no ICC carrier: Cicp when the codec expressed it as CICP, else Icc
JPEG, WebP, GIF, TIFF, BMP, ICO, PNM, Farbfeld, QOI, TGA, DNG, RAW, PDFICC (or an sRGB assumption): always Icc

Returns None where no rule is recorded — Custom, Unknown, and the formats the audit did not cover (EXR, JPEG 2000, SVG) — so a check over those passes rather than inventing a rule. Cicp is never expected when no CICP was read (the enum’s own invariant: codecs only set Cicp when cicp is populated).