Skip to main content

LightLevelHistogram

Struct LightLevelHistogram 

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

1024-bin log2 histogram of per-pixel luminance in cd/m² over [0.005, 10_000] nits, tracking exact zero / non-positive counts separately from positive sub-bin samples.

Implementations§

Source§

impl LightLevelHistogram

Source

pub const BIN_MIN_NITS: f32 = 0.005

Lower bin edge (0.005 cd/m²).

Source

pub const BIN_MAX_NITS: f32 = 10_000.0

Upper bin edge (10_000.0 cd/m², ST 2084 PQ peak).

Source

pub const NUM_BINS: usize = 1024

Number of log2-spaced bins (1024, ~0.02 stops per bin).

Source

pub fn new(method: LightLevelMethod) -> Result<Self, At<ConvertError>>

Fallibly construct an empty histogram (returns Err(ConvertError::AllocationFailed) on OOM).

Source

pub fn record(&mut self, nits: f32)

Record a single pixel’s light level in cd/m².

Source

pub fn bins(&self) -> &[u64]

Read-only view of the 1024 log2-spaced luminance histogram bins.

Source

pub fn merge(&mut self, other: &Self) -> Result<(), At<ConvertError>>

Merge another LightLevelHistogram accumulated with the same LightLevelMethod into self (useful for parallel tile/strip reduction).

Returns ConvertError::UnsupportedRoute if self.method() != other.method().

Source

pub const fn method(&self) -> LightLevelMethod

Reduction method used to build this histogram.

Source

pub const fn total_pixels(&self) -> u64

Total pixels recorded.

Source

pub const fn zero_pixels(&self) -> u64

Number of recorded zero / non-positive / non-finite samples.

Source

pub const fn max_nits(&self) -> f32

Exact literal maximum luminance observed in cd/m².

Source

pub fn mean_nits(&self) -> f32

Arithmetic mean luminance (MaxFALL) in cd/m².

Source

pub fn quantile_nits(&self, quantile: f32) -> f32

Nearest-rank order-statistic quantile readout (quantile in 0.0..=1.0, e.g. 0.9999).

Uses rank k = ceil(quantile * total).max(1) over the sorted sample set (so quantile = 0.0 returns 0.0 when any black pixel was recorded, and quantile = 0.5 on [0, 1, 100] selects the 2nd sample ≈ 1.0).

Source

pub fn to_content_light_level(&self) -> ContentLightLevel

Convert literal max + mean into ITU-T H.274 / CTA-861.3 upper-bound ContentLightLevel.

Source

pub fn to_robust_content_light_level(&self, quantile: f32) -> ContentLightLevel

Convert quantile peak (quantile in 0.0..=1.0, e.g. 0.9999) + mean into ContentLightLevel.

Trait Implementations§

Source§

impl Clone for LightLevelHistogram

Source§

fn clone(&self) -> LightLevelHistogram

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 Debug for LightLevelHistogram

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