Skip to main content

GainMapMetadata

Struct GainMapMetadata 

Source
#[non_exhaustive]
pub struct GainMapMetadata { /* private fields */ }
Expand description

ISO 21496-1 / UltraHDR gain-map reconstruction parameters in exact rational form.

Preserves exact unreduced rational pairs for lossless metadata transcoding across JPEG APP2, AVIF tmap, and JXL jhgm while projecting cleanly to float for rendering.

Implementations§

Source§

impl GainMapMetadata

Source

pub const fn new( channels: GainMapChannels, base_hdr_headroom: UnsignedFraction, alternate_hdr_headroom: UnsignedFraction, application_space: GainMapColorSpace, ) -> Option<GainMapMetadata>

Construct and validate an exact ISO 21496-1 parameter set.

Rejects non-positive gamma, min > max, or equal base_hdr_headroom == alternate_hdr_headroom (ISO 21496-1 §5.2.7 requires unequal headrooms).

Source

pub const fn with_backward_direction( self, backward: bool, ) -> Option<GainMapMetadata>

Set the explicit ISO 21496-1 direction flag when it agrees with the headroom ordering.

true declares the reverse direction. false declares the forward direction.

Source

pub const fn with_headrooms( self, base: UnsignedFraction, alternate: UnsignedFraction, ) -> Option<GainMapMetadata>

Replace both exact headrooms. Rejects equal values or a conflict with the explicit direction.

Source

pub const fn channels(self) -> GainMapChannels

Shared or per-channel gain parameters.

Source

pub const fn base_hdr_headroom(self) -> UnsignedFraction

Exact base rendition headroom in log₂ stops.

Source

pub const fn alternate_hdr_headroom(self) -> UnsignedFraction

Exact alternate rendition headroom in log₂ stops.

Source

pub const fn application_space(self) -> GainMapColorSpace

RGB primaries in which gain is applied.

Source

pub const fn backward_direction(self) -> Option<bool>

Explicit ISO 21496-1 direction flag, if present.

Source

pub fn sdr_to_hdr_stops(max_boost_stops: f32) -> Option<GainMapMetadata>

Fallibly construct a forward SDR-base (0 stops) → HDR-alternate (+max_boost_stops) gain-map parameter set with [0, +max_boost_stops] gain range and standard 1/64 base/alternate offsets.

Returns None if max_boost_stops is non-finite, <= 0.0, or rounds to zero at 1/1_000_000 precision.

Source

pub const fn is_valid(self) -> bool

Validate all exact rational invariants (gamma > 0, min <= max, H_base != H_alt, and any explicit backward_direction flag agrees with the headroom ordering).

Source

pub const fn direction(self) -> Option<GainMapDirection>

Exact gain-map direction (Forward if H_alt > H_base, Reverse if H_base > H_alt), returning None if headrooms are equal or an explicit backward_direction flag contradicts the headroom ordering.

Source

pub const fn channel(self, c: usize) -> GainMapComponent

Access parameter record for channel c (0..3).

Trait Implementations§

Source§

impl Clone for GainMapMetadata

Source§

fn clone(&self) -> GainMapMetadata

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for GainMapMetadata

Source§

impl Debug for GainMapMetadata

Source§

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

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

impl Eq for GainMapMetadata

Source§

impl Hash for GainMapMetadata

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 GainMapMetadata

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for GainMapMetadata

Auto Trait Implementations§

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