Skip to main content

LumaGainMapSplitter

Struct LumaGainMapSplitter 

Source
pub struct LumaGainMapSplitter<T>
where T: LumaToneMap,
{ /* private fields */ }
Expand description

Splits HDR rows into (SDR, log2-gain) pairs around a LumaToneMap.

Stateless after construction. Safe to share across threads (Sync) when the inner curve is Sync.

Implementations§

Source§

impl<T> LumaGainMapSplitter<T>
where T: LumaToneMap,

Source

pub fn new(curve: T, cfg: SplitConfig) -> LumaGainMapSplitter<T>

Construct from a curve and config.

Source

pub fn config(&self) -> &SplitConfig

Borrow the configuration (e.g. to feed into GainMapParams).

Source

pub fn curve(&self) -> &T

Borrow the curve.

Source

pub fn split_row( &self, hdr: &[f32], sdr_out: &mut [f32], gain_out: &mut [f32], channels: u8, stats: &mut SplitStats, )

Encode one row.

hdr: linear-light HDR (length = pixels · channels). sdr_out: receives linear SDR; must match hdr.len(). gain_out: receives one log2 gain per pixel; length = pixels. stats: accumulator; updated in place.

Panics if channels is not 3 or 4, or if lengths mismatch.

Source

pub fn apply_row( &self, sdr: &[f32], gain: &[f32], hdr_out: &mut [f32], channels: u8, )

Decode one row: SDR + log2 gain → HDR.

Inverse of Self::split_row (modulo SDR clipping recorded in SplitStats::clipped_sdr_pixels and any external u8 quantization of the gain map).

Source

pub fn split_pq_row( &self, pq: &[f32], sdr_linear: &mut [f32], gain: &mut [f32], channels: u8, content_peak_nits: f32, stats: &mut SplitStats, )

Encode one PQ-encoded HDR row (BT.2020 or BT.709 wire), normalizing internally so 1.0 = content_peak_nits before applying the curve.

PQ samples range [0, 1] mapping to [0, 10000 nits] (ST.2084). This method linearizes, rescales to 1.0 = content_peak_nits, runs Self::split_row, and emits linear-light SDR in [0, 1]. Caller may then sRGB-encode for storage. Allocates a transient linear buffer; for hot paths, call pq_to_normalized_linear_row

Source

pub fn split_hlg_row( &self, hlg: &[f32], sdr_linear: &mut [f32], gain: &mut [f32], channels: u8, display_peak_nits: f32, content_peak_nits: f32, stats: &mut SplitStats, )

Encode one HLG-encoded HDR row. Linearizes via the HLG inverse OETF + OOTF, rescales so 1.0 = content_peak_nits, then splits.

Allocates a transient linear buffer; for hot paths, call hlg_to_normalized_linear_row + Self::split_row with reused buffers.

Source

pub fn apply_hlg_row( &self, sdr_linear: &[f32], gain: &[f32], hlg_out: &mut [f32], channels: u8, display_peak_nits: f32, content_peak_nits: f32, )

Decode a linear-light SDR row + log2 gain row back to HLG-encoded HDR. Inverse of Self::split_hlg_row.

Source

pub fn apply_pq_row( &self, sdr_linear: &[f32], gain: &[f32], pq_out: &mut [f32], channels: u8, content_peak_nits: f32, )

Decode a linear-light SDR row + log2 gain row back to PQ-encoded HDR. Inverse of Self::split_pq_row.

Auto Trait Implementations§

§

impl<T> Freeze for LumaGainMapSplitter<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for LumaGainMapSplitter<T>
where T: RefUnwindSafe,

§

impl<T> Send for LumaGainMapSplitter<T>
where T: Send,

§

impl<T> Sync for LumaGainMapSplitter<T>
where T: Sync,

§

impl<T> Unpin for LumaGainMapSplitter<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for LumaGainMapSplitter<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for LumaGainMapSplitter<T>
where T: UnwindSafe,

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