Expand description
Color primitives for the gamut codecs: pixel formats, bit depths, chroma subsampling, the CICP code points carried in nclx / AV1 sequence headers, and planar buffers.
The M0 AVIF encoder uses only a narrow slice — 8-bit RGB in, mapped to identity (mc = 0)
4:4:4 planes. The enums here intentionally model the wider spec surface (more formats, bit
depths, subsamplings, and CICP code points) so later milestones (M2 pixel formats, M4 HDR;
see gamut-avif/STATUS.md) extend without reshaping the types.
On top of that metadata layer, the transfer, oklab, matrix, gamut_map, and
profile modules add f64 colour science — encoder-exact EOTFs, OKLab transforms with
per-gamut matrices (derived from chromaticities via Bradford adaptation), gamut clamping, and
source-profile bundles over the CICP axes. This math is Tier-1 (correctness only): it uses
std f64, so it is not bit-reproducible across platforms — see references/color/README.md.
Re-exports§
pub use cicp::ColorRange;pub use cicp::ColourPrimaries;pub use cicp::MatrixCoefficients;pub use cicp::TransferCharacteristics;
Modules§
- cicp
- CICP (ITU-T H.273 / ISO/IEC 23091-2) code points shared by the AVIF
colr(nclx) box and the AV1 sequence headercolor_config(AV1 §5.5.2 / §6.4.2). - gamut_
map - sRGB gamut membership and a hue-preserving soft gamut clamp.
- matrix
- Derivation of RGB→XYZ and OKLab
M1matrices from CIE 1931 chromaticities, with Bradford chromatic adaptation. - oklab
- OKLab transforms and the per-gamut linear-RGB → LMS (
M1) matrices. - profile
- Source-profile bundle: ties a colour-science
Gamuttogether with its encoder-exact transfer (and tone map) and projects them back onto gamut’s independent CICP axes. - transfer
- Transfer functions (EOTF / inverse-EOTF) in
f64, covering the gamuts the gamut ecosystem encodes through.
Structs§
- Planar8
- Three full-resolution (4:4:4) 8-bit planes, each
width * heightsamples, row-major. - Yuv420
- A BT.601 YCbCr image in 4:2:0 layout: a
width × heightluma plane and twochroma_width × chroma_heightchroma planes, all row-major 8-bit, where the chroma dimensions areceil(width / 2)andceil(height / 2). The signal range is a property of the conversion (Bt601Range), not of the stored planes.
Enums§
- BitDepth
- Bits per sample of a coded plane.
- Bt601
Range - The signal range of a BT.601 YCbCr encoding. See the module docs for which to use.
- Chroma
Subsampling - Chroma subsampling of the coded planes (AV1
subsampling_x/subsampling_y, §5.5.2).
Functions§
- clip_
pixel - Saturates a computed integer sample to the unsigned
bit_depth-bit pixel range0..=(1 << bit_depth) - 1(AV1Clip1, §3) — the high-bit-depth companion toclip_pixel8. - clip_
pixel8 - Saturates a computed integer sample to the unsigned 8-bit pixel range
0..=255. - rgb_
to_ ycbcr - Converts one RGB triple to BT.601 YCbCr in the given
Bt601Range(each component0..=255). - ycbcr_
to_ rgb - Converts one BT.601 YCbCr triple in the given
Bt601Rangeback to RGB (each0..=255).