Skip to main content

ToneMapper

Struct ToneMapper 

Source
pub struct ToneMapper { /* private fields */ }
Expand description

A configured tone-mapping transform.

Immutable: the tables are built once from the parameters, so changing a parameter means building another mapper.

Implementations§

Source§

impl ToneMapper

Source

pub fn bt709_to_bt2020_pq(sdr_white_nits: f32) -> Self

SDR into an HDR composition.

sdr_white_nits is where SDR’s 1.0 lands on the PQ curve. 100 is the conventional default and matches how most HDR displays render an SDR signal; 203 is the common “diffuse white” reference and makes the SDR part brighter within the composition.

Source

pub fn bt2020_pq_to_bt709(target_max_nits: f32, curve: ToneMapCurve) -> Self

HDR down to an SDR display.

target_max_nits is what SDR’s 1.0 means in absolute terms; anything above it goes through curve so highlights compress instead of clipping.

Source

pub fn hlg_to_bt709(target_max_nits: f32) -> Self

HLG down to an SDR display.

Always Reinhard, which only rolls off what lands above the target’s white. The curve is not selectable for HLG: its OOTF has already shaped the highlights.

Source

pub const fn direction(&self) -> Direction

The direction this mapper transforms.

Source

pub const fn curve(&self) -> ToneMapCurve

The curve it applies.

Source

pub const fn sdr_white_nits(&self) -> f32

Where SDR white lands, in nits.

Source

pub const fn target_max_nits(&self) -> f32

What SDR 1.0 represents, in nits.

Source

pub fn map(&self, pixel: u64) -> u64

Transform one pixel.

Source

pub fn apply(&self, src: &[u64], dst: &mut [u64])

Transform a run of pixels.

Equivalent to calling map on each pixel. Processes min(src.len(), dst.len()) pixels; any excess in either slice is left alone.

Trait Implementations§

Source§

impl Debug for ToneMapper

Source§

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

Formats the value using the given formatter. Read more

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.