#[non_exhaustive]pub struct Cicp {
pub color_primaries: u8,
pub transfer_characteristics: u8,
pub matrix_coefficients: u8,
pub full_range: bool,
}Expand description
CICP color description (ITU-T H.273).
Coding-Independent Code Points describe the color space of an image without requiring an ICC profile. Used by AVIF, HEIF, JPEG XL, and video codecs (H.264, H.265, AV1).
Common combinations:
- sRGB:
(1, 13, 6, true)— BT.709 primaries, sRGB transfer, BT.601 matrix - Display P3:
(12, 13, 6, true)— P3 primaries, sRGB transfer - BT.2100 PQ (HDR):
(9, 16, 9, true)— BT.2020 primaries, PQ transfer - BT.2100 HLG (HDR):
(9, 18, 9, true)— BT.2020 primaries, HLG transfer
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.color_primaries: u8Color primaries (ColourPrimaries). Common values: 1 = BT.709/sRGB, 9 = BT.2020, 12 = Display P3.
transfer_characteristics: u8Transfer characteristics (TransferCharacteristics). Common values: 1 = BT.709, 13 = sRGB, 16 = PQ (HDR), 18 = HLG (HDR).
matrix_coefficients: u8Matrix coefficients (MatrixCoefficients). Common values: 0 = Identity/RGB, 1 = BT.709, 6 = BT.601, 9 = BT.2020.
full_range: boolWhether pixel values use the full range (0-255 for 8-bit) or video/limited range (16-235 for 8-bit luma).
Implementations§
Source§impl Cicp
impl Cicp
Sourcepub const SRGB: Cicp
pub const SRGB: Cicp
sRGB color space: BT.709 primaries, sRGB transfer, Identity (RGB) matrix, full range.
Sourcepub const BT2100_PQ: Cicp
pub const BT2100_PQ: Cicp
BT.2100 PQ (HDR10): BT.2020 primaries, PQ transfer, BT.2020 matrix, full range.
Sourcepub const BT2100_HLG: Cicp
pub const BT2100_HLG: Cicp
BT.2100 HLG (HDR): BT.2020 primaries, HLG transfer, BT.2020 matrix, full range.
Sourcepub const DISPLAY_P3: Cicp
pub const DISPLAY_P3: Cicp
Display P3 with sRGB transfer: P3 primaries, sRGB transfer, Identity matrix, full range.
Sourcepub const fn new(
color_primaries: u8,
transfer_characteristics: u8,
matrix_coefficients: u8,
full_range: bool,
) -> Cicp
pub const fn new( color_primaries: u8, transfer_characteristics: u8, matrix_coefficients: u8, full_range: bool, ) -> Cicp
Create a CICP color description from raw code points.
Sourcepub fn color_primaries_enum(&self) -> ColorPrimaries
pub fn color_primaries_enum(&self) -> ColorPrimaries
Map the CICP color_primaries code to a ColorPrimaries enum.
Returns Unknown for unrecognized codes.
This is a convenience wrapper around ColorPrimaries::from_cicp.
Sourcepub fn transfer_function_enum(&self) -> TransferFunction
pub fn transfer_function_enum(&self) -> TransferFunction
Map the CICP transfer_characteristics code to a TransferFunction enum.
Returns Unknown for unrecognized codes.
This is a convenience wrapper around TransferFunction::from_cicp.
Sourcepub fn from_descriptor(desc: &PixelDescriptor) -> Option<Cicp>
pub fn from_descriptor(desc: &PixelDescriptor) -> Option<Cicp>
Create a CICP from a PixelDescriptor.
Returns None if the descriptor’s transfer function or color primaries
cannot be mapped to CICP code points (e.g., Unknown variants).
Sourcepub fn to_descriptor(&self, format: PixelFormat) -> PixelDescriptor
pub fn to_descriptor(&self, format: PixelFormat) -> PixelDescriptor
Convert to a PixelDescriptor with the given
PixelFormat.
Maps the CICP code points to the corresponding enum variants.
Unmapped codes become Unknown.
Sourcepub fn color_primaries_name(code: u8) -> &'static str
pub fn color_primaries_name(code: u8) -> &'static str
Human-readable name for the color primaries code (ITU-T H.273 Table 2).
Sourcepub fn transfer_characteristics_name(code: u8) -> &'static str
pub fn transfer_characteristics_name(code: u8) -> &'static str
Human-readable name for the transfer characteristics code (ITU-T H.273 Table 3).
Sourcepub fn matrix_coefficients_name(code: u8) -> &'static str
pub fn matrix_coefficients_name(code: u8) -> &'static str
Human-readable name for the matrix coefficients code (ITU-T H.273 Table 4).