Skip to main content

HdrConfig

Struct HdrConfig 

Source
#[non_exhaustive]
pub struct HdrConfig { pub source_peak_nits: f32, pub target_peak_nits: f32, pub gamut_knee: f32, }
Expand description

HDR→SDR tone-mapping configuration for ConvertPlan::new_with_hdr_config.

Bundles the source-peak luminance (mandatory — the curve is parameterized by it), target-peak luminance (typically 100 cd/m² for SDR), and the OKLch soft chroma-compression knee (production default 0.96).

Construct via for_source_peak and refine with the with_* builders — the struct is #[non_exhaustive] so future knobs can land additively without a breaking release. The existing fields stay pub for reading (and in-place mutation).

Both peak fields must be positive and finite; ConvertPlan::new_with_hdr_config rejects anything else (including the unset Default value) with ConvertError::HdrSourceRequiresPeak instead of silently tone-mapping through a degenerate curve.

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.
§source_peak_nits: f32

HDR source peak luminance in cd/m². The BT.2446-A curve treats 1.0 source-normalized as this peak. Typical values: 1000 (HDR10, Apple HDR), 4000 (HDR10+ reference), 10000 (PQ peak).

§target_peak_nits: f32

SDR target peak luminance in cd/m². Typical value: 100 (BT.709 / sRGB diffuse-white peak; BT.1886 reference).

§gamut_knee: f32

Fraction of max chroma where OKLch soft compression kicks in (0.01.0). 0.96 (the default) compresses only the outermost 4 % of the gamut; lower values bring the compression in earlier. Ignored when the target primaries are BT.2020 (wide-gamut output mode emits no SoftCompressOklch step).

The default was calibrated against the 76-sample imazen-26 gain-mapped corpus on 2026-06-23: 0.96 is the largest knee (least desaturation) where the corpus-p90 fraction of pre-clamp out-of-gamut pixels stays under 0.1 %. Findings: zentone/benchmarks/softcompress_knee_findings_2026-06-23.md.

Implementations§

Source§

impl HdrConfig

Source

pub fn for_source_peak(source_peak_nits: f32) -> Self

Config for an HDR source with the given peak luminance in cd/m², keeping the calibrated defaults for everything else (target_peak_nits = 100.0, gamut_knee = 0.96).

Typical source_peak_nits values: 1000 (HDR10, Apple HDR), 4000 (HDR10+ reference), 10000 (PQ peak) — or better, the measured MaxCLL of the actual content (CllMeasure::measure_max).

Source

pub fn with_target_peak_nits(self, nits: f32) -> Self

Set the SDR target peak luminance in cd/m² (default 100.0).

Source

pub fn with_gamut_knee(self, knee: f32) -> Self

Set the OKLch soft-compression knee (default 0.96; meaningful range 0.0..=1.0 — values outside it are not validated and produce under-/over-compression rather than an error).

Trait Implementations§

Source§

impl Clone for HdrConfig

Source§

fn clone(&self) -> HdrConfig

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 HdrConfig

Source§

impl Debug for HdrConfig

Source§

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

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

impl Default for HdrConfig

Available on crate feature hdr-experimental only.
Source§

fn default() -> Self

Pipeline defaults: target_peak_nits = 100.0 (SDR reference white) and gamut_knee = 0.96 (empirically calibrated against the imazen-26 gain-mapped HDR corpus, 2026-06-23). source_peak_nits has no default — it returns 0.0 (“unset”), which ConvertPlan::new_with_hdr_config rejects with ConvertError::HdrSourceRequiresPeak. Start from HdrConfig::for_source_peak instead.

Source§

impl PartialEq for HdrConfig

Source§

fn eq(&self, other: &HdrConfig) -> 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 HdrConfig

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.