Skip to main content

Cicp

Struct Cicp 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§color_primaries: u8

Color primaries (ColourPrimaries). Common values: 1 = BT.709/sRGB, 9 = BT.2020, 12 = Display P3.

§transfer_characteristics: u8

Transfer characteristics (TransferCharacteristics). Common values: 1 = BT.709, 13 = sRGB, 16 = PQ (HDR), 18 = HLG (HDR).

§matrix_coefficients: u8

Matrix coefficients (MatrixCoefficients). Common values: 0 = Identity/RGB, 1 = BT.709, 6 = BT.601, 9 = BT.2020.

§full_range: bool

Whether 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

Source

pub const SRGB: Cicp

sRGB color space: BT.709 primaries, sRGB transfer, Identity (RGB) matrix, full range.

Source

pub const BT2100_PQ: Cicp

BT.2100 PQ (HDR10): BT.2020 primaries, PQ transfer, BT.2020 matrix, full range.

Source

pub const BT2100_HLG: Cicp

BT.2100 HLG (HDR): BT.2020 primaries, HLG transfer, BT.2020 matrix, full range.

Source

pub const DISPLAY_P3: Cicp

Display P3 with sRGB transfer: P3 primaries, sRGB transfer, Identity matrix, full range.

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn color_primaries_name(code: u8) -> &'static str

Human-readable name for the color primaries code (ITU-T H.273 Table 2).

Source

pub fn transfer_characteristics_name(code: u8) -> &'static str

Human-readable name for the transfer characteristics code (ITU-T H.273 Table 3).

Source

pub fn matrix_coefficients_name(code: u8) -> &'static str

Human-readable name for the matrix coefficients code (ITU-T H.273 Table 4).

Trait Implementations§

Source§

impl Clone for Cicp

Source§

fn clone(&self) -> Cicp

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Cicp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Cicp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Hash for Cicp

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Cicp

Source§

fn eq(&self, other: &Cicp) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Cicp

Source§

impl Eq for Cicp

Source§

impl StructuralPartialEq for Cicp

Auto Trait Implementations§

§

impl Freeze for Cicp

§

impl RefUnwindSafe for Cicp

§

impl Send for Cicp

§

impl Sync for Cicp

§

impl Unpin for Cicp

§

impl UnsafeUnpin for Cicp

§

impl UnwindSafe for Cicp

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.