feat(color): minimal cross-codec CICP/ICC emission policy#19
Closed
lilith wants to merge 1 commit into
Closed
Conversation
This was referenced Jun 1, 2026
Member
Author
|
Superseded by #21 — the unified scenario-driven encode-emit model replaces this scenario-blind |
lilith
added a commit
that referenced
this pull request
Jun 2, 2026
A pure no_std color-carrier policy: resolve_color_emit(&SourceColor,
&EncodeCapabilities, ColorPolicy) -> ColorPlan{cicp, icc} — no CMS, no codec deps.
Replaces the over-built EmitFacts/EmitIntent/EmitPlan "scenario" model and the
TranscodeEncoder trait, which a 5-codec dogfood + adversarial review + a full
read of zenpixels/zenpipe showed (a) nothing in the pipeline produces the facts
for (decode attaches no color to the buffer; the carrier is a flat Metadata), and
(b) would have forced every codec to depend on every other. The grounded surface
is the shipped #19 shape + the four surviving red-team fixes.
- ColorPolicy { Compatibility, Balanced(default), Compact, Verbatim, Custom };
ColorPlan { cicp, icc: IccDisposition{KeepSource, SynthesizeFrom, Drop} }.
- EncodeCapabilities: cicp_is_valid_carrier (standardized carrier incl. PNG cICP),
cicp_safe_sole_carrier (JXL only). IccRetention +DropIfCicpRepresentable,
+DropIfCicpSafeSoleCarrier. ColorFields::new makes Custom constructible.
- No redundant SynthesizeFrom(sRGB). Lowers to zenpixels_convert::
finalize_for_output_with; SynthesizeFrom -> icc_profile_for_primaries const-fn
table (no CMS, no silent drop; sRGB -> None).
- helpers::set_exif_orientation closes the double-rotation hazard (pipeline-applied).
472 lib tests + 16 doctests pass, clippy + fmt clean. Design + rejected
alternatives recorded in docs/color-emit-model.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #17 (
feat/metadata-policy). The diff here is color-only — base it on #17, retarget tomainafter #17 merges.What
A minimal cross-codec color-signaling production policy in
zencodec::color:resolve_color_emit(&SourceColor, &EncodeCapabilities, ColorPolicy) -> ColorPlan— reconciles a source's color description against a target's capabilities and returnsColorPlan { cicp: Option<Cicp>, icc: IccDisposition }.ColorPolicy { Compatibility, Balanced (default), Compact, Verbatim, Custom(ColorFields) }— intent presets; the same meaning whether encoding from pixels or transcoding.EncodeCapabilities::cicp_is_format_authority(a conformant decoder honors CICP) vscicp_safe_sole_carrier(safe to ship CICP-only and drop the ICC — JXL today, per libjxl'swant_icc=false; false for AVIF/HEIC/PNG per 2026 ecosystem support).IccRetentiongainsDropIfCicpRepresentable/DropIfCicpSafeSoleCarrier.Behavior: under
Balanced, derive CICP from an ICC and drop the redundant profile only where CICP is the format's authority and safe as the sole carrier (→ JXL); else keep the ICC (AVIF/PNG keep both). Grayscale and CMYK suppress CICP entirely (an RGB CICP over gray/CMYK pixels would recolor them) and keep the ICC.Deliberately minimal surface
Only what current transcode (JPEG→JXL) needs. HDR/gain-map/range/rendering-intent dispositions and a warnings-channel
noteslist were trimmed — every type is#[non_exhaustive], so they re-land additively when a consumer needs them. No cargo feature: gating struct fields the crate constructs itself would forkresolve_color_emit's body; removal is cleaner pre-publish.Consumers (separate PRs)
Metadata::cicpdrives the codestream enum color; redundant ICC stripped; the decoder synthesizes an ICC back from the enum (so a profile is still present after decode). End-to-end Display-P3 round-trip test added.nclxfrommeta.cicp.jbrdpath — unaffected.Tests
zencodec lib 466 pass (8 new color), zenjxl 48 (incl. CICP round-trip), zencodecs
metadata_conformance15 (JXLcicppromotedGap → Ok).