pub struct Colorimetry {
pub space: Option<ColorSpace>,
pub transfer: Option<ColorTransfer>,
pub encoding: Option<ColorEncoding>,
pub range: Option<ColorRange>,
}Expand description
Full 4-axis colorimetry. Each axis is Option; None means “undefined”
and is never auto-filled — consumers (e.g. convert()) resolve missing
axes at use-time without mutating the value.
Fields§
§space: Option<ColorSpace>§transfer: Option<ColorTransfer>§encoding: Option<ColorEncoding>§range: Option<ColorRange>Implementations§
Source§impl Colorimetry
impl Colorimetry
Sourcepub fn jfif() -> Self
pub fn jfif() -> Self
JPEG/JFIF colorimetry: sRGB primaries, sRGB transfer, BT.601 encoding, full range.
Sourcepub fn from_v4l2(
colorspace: u32,
xfer: u32,
ycbcr_enc: u32,
quant: u32,
is_rgb_or_hsv: bool,
) -> Self
pub fn from_v4l2( colorspace: u32, xfer: u32, ycbcr_enc: u32, quant: u32, is_rgb_or_hsv: bool, ) -> Self
Build from the four raw V4L2 colorimetry integers of a negotiated
format whose pixel encoding is RGB or HSV when is_rgb_or_hsv is
true (see [PixelFormat::is_rgb_or_hsv]).
Explicit values map directly. For ycbcr_enc/quantization, the V4L2
DEFAULT (0) sentinel does NOT mean “unknown” — it means “derive”
(kernel V4L2_MAP_YCBCR_ENC_DEFAULT / V4L2_MAP_QUANTIZATION_DEFAULT),
and those axes are resolved here rather than left None for the
at-use height heuristic (which would wrongly pick BT.709/limited for an
HD JPEG frame):
quantization = DEFAULTis full range for an RGB/HSV format, whatever the colorspace, and forV4L2_COLORSPACE_JPEG; limited for a YUV format in any other recognised colorspace; and unset (None) for a YUV format in aDEFAULTor unrecognised colorspace, so the at-use height heuristic decides.ycbcr_enc = DEFAULTis the encoding the colorspace implies, and unset (None) for aDEFAULTor unrecognised colorspace.
Unrecognised non-default values also map to None.
Sourcepub fn with_space(self, s: ColorSpace) -> Self
pub fn with_space(self, s: ColorSpace) -> Self
Set color primaries (consuming builder).
Sourcepub fn with_transfer(self, t: ColorTransfer) -> Self
pub fn with_transfer(self, t: ColorTransfer) -> Self
Set transfer function (consuming builder).
Sourcepub fn with_encoding(self, e: ColorEncoding) -> Self
pub fn with_encoding(self, e: ColorEncoding) -> Self
Set YCbCr encoding matrix (consuming builder).
Sourcepub fn with_range(self, r: ColorRange) -> Self
pub fn with_range(self, r: ColorRange) -> Self
Set quantization range (consuming builder).
Sourcepub fn pack(&self) -> u32
pub fn pack(&self) -> u32
Pack all four axes into one u32 for
crate::protocol::TensorDesc::colorimetry.
One byte per axis, space in the low byte through range in the
high byte; 0 on an axis means “undefined”, so an all-None
Colorimetry packs to 0. Each byte is that axis’s code(), the
same word the C API’s ef_tensor_colorimetry returns. This crosses a
package boundary like TensorDesc itself: codes are appended, never
renumbered.
Sourcepub fn unpack(bits: u32) -> Self
pub fn unpack(bits: u32) -> Self
Inverse of Self::pack: rebuild a Colorimetry from a packed
u32, e.g. crate::protocol::TensorDesc::colorimetry on
import. 0 on an axis byte (undefined, including a build that
predates the axis) maps to None rather than erroring, the same
forward-compatibility rule crate::protocol::dtype_to_dtype
applies to another wire-coded axis – a code this build does not
recognise (e.g. one a newer producer added) also maps to None
instead of guessing.
Trait Implementations§
Source§impl Clone for Colorimetry
impl Clone for Colorimetry
impl Copy for Colorimetry
Source§impl Debug for Colorimetry
impl Debug for Colorimetry
Source§impl Default for Colorimetry
impl Default for Colorimetry
Source§impl<'de> Deserialize<'de> for Colorimetry
impl<'de> Deserialize<'de> for Colorimetry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Colorimetry
Source§impl Hash for Colorimetry
impl Hash for Colorimetry
Source§impl PartialEq for Colorimetry
impl PartialEq for Colorimetry
Source§impl Serialize for Colorimetry
impl Serialize for Colorimetry
impl StructuralPartialEq for Colorimetry
Auto Trait Implementations§
impl Freeze for Colorimetry
impl RefUnwindSafe for Colorimetry
impl Send for Colorimetry
impl Sync for Colorimetry
impl Unpin for Colorimetry
impl UnsafeUnpin for Colorimetry
impl UnwindSafe for Colorimetry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more