Repository navigation
Description
Following #4353 (Bradford), the next duplicated normative constant on the colour-pipeline path is OKLab's pair of matrices. They exist in three places:
src/fl/gfx/oklab_q16.cpp.hpp— s16.16 integers, with the float values they were quantized from written in the comments beside them.ci/color_reference.py— float64, and what the golden corpus'smapped_xyztargets are computed with.tests/fl/gfx/oklab_q16.cpp— a float transcription, which is what "OKLab Q16 forward agrees with the float definition" scores the integers against.
OKLCh is A3's normative objective space — the gamut mapper's objective is stated in it — so a drift between the space the corpus's targets are computed in and the space the device solve runs in would leave both sides self-consistent and every comparison between them still agreeing with itself.
Why this one cannot be pinned the way Bradford was
#4353 pinned Bradford against ICC.1:2022 Annex E, the reasoning being that matching the copies to each other "would pass if someone 'corrected' both in the same wrong direction." That reasoning still holds, but the equivalent move here would be wrong.
The repo uses Ottosson's corrected high-precision M1 (+0.8190224432, +0.3619062563, -0.1288737826), not the table in his original published post (0.8189330101, …). Pinning to "the published values" would fail a correct implementation. The invariant that actually defines the space is the property, not the transcription: D65 goes to lightness 1 with no chroma, which is exactly the property the corrected coefficients exist to satisfy.
The C++ already pins that — "OKLab Q16 sends D65 white to lightness 1 with no chroma". The Python reference has no equivalent, and it is the copy the corpus is generated from.
What is actually duplicated
More than the three copies above suggest. Within ci/color_reference.py alone, M1 is hand-written three times:
_oklab_from_xyz— spelled out as inline arithmetic;- the
Matrix3literal that_xyz_from_oklabinverts; lms_boundin the zonotope chroma cap, re-copied with every sign forced positive.
and M2 twice (_oklab_from_xyz, and a_bound/b_bound in the same cap). The third copy cannot round-trip by construction, so no round-trip test reaches it — a cap built from drifted coefficients silently stops bounding what it claims to.
Proposed
A ci/tests/ test that:
- pins the defining property on the reference (D65 → (1, 0, 0)), and its round trip;
- checks
_oklab_from_xyzbehaviourally against a matrix built from the floats documented inoklab_q16.cpp.hpp, rather than scraping the reference's source text — that covers the inline copy, which is the one the corpus is generated from, and is robust to how it is spelled; - checks the sign-flipped bound copies as text, since they are not required to round-trip.
Verified by mutation before believing it, given the weak assertions caught in #4352 and #4354.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
test(ci): pin the colour reference's OKLab against the quantized matr…