Skip to main content

Bt2446A

Struct Bt2446A 

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

BT.2446 Method A tonemapper with explicit baked HDR/SDR peak luminances.

Construct with with_peaks, then apply directly via map_rgb_bt2020_peak_normalized or map_strip_bt2020_peak_normalized, or pass into ConvertPolicy::with_tone_mapper. For pipeline-managed peak resolution (measuring or reading declared metadata at ToneMapper::prepare time), use Bt2446APipelineManaged (or Bt2446A::pipeline_managed).

Input is linear-light BT.2020 RGB normalized so 1.0 = hdr_peak_nits. Output is linear-light BT.2020 RGB normalized so 1.0 = sdr_peak_nits — the BT.2446-1 §4 pipeline natively emits gamma-encoded R'_TMO G'_TMO B'_TMO (BT.1886 1/2.4); we apply the BT.1886 EOTF (^2.4) at the output to deliver a linear-light contract (matching libplacebo’s own bt2446a which ends with bt1886_eotf).

§When to pick this

The most rigorously validated HDR → SDR curve published — the only one with a peer-reviewed psychophysical study showing imperceptible degradation after a full HDR → SDR → HDR round-trip on graded content. Pick when broadcast-grade fidelity matters.

Reference: ITU-R BT.2446-1 (03/2021) §4 + Annex 1 (12 participants, 115 images, Sony BVM-X300, 2AFC, p ≈ 0.17 indistinguishability).

§Examples

use zenpixels_convert::{Nits, tonemap::Bt2446A};

let curve = Bt2446A::with_peaks(
    Nits::new_positive_or_panic(1000.0),
    Nits::new_positive_or_panic(100.0),
);
let sdr = curve.map_rgb_bt2020_peak_normalized([0.6, 0.4, 0.2]);
assert!(sdr.iter().all(|&c| (0.0..=1.0).contains(&c)));

Implementations§

Source§

impl Bt2446A

Source

pub fn with_peaks(hdr_peak: Nits, sdr_peak: Nits) -> Self

Create a new BT.2446 Method A tonemapper with explicit typed peak luminances baked in.

  • hdr_peak: peak luminance of HDR content (e.g. Nits::new_positive_or_panic(1000.0)).
  • sdr_peak: peak luminance of SDR target (e.g. Nits::new_positive_or_panic(100.0)).

Use this when the source peak is already known at construction time. For pipeline-orchestrated peak resolution via PeakSource (Measured, Declared, or Fixed) at prepare() time, use pipeline_managed / Bt2446APipelineManaged instead.

Source

pub const fn pipeline_managed() -> Bt2446APipelineManaged

Construct a pipeline-managed BT.2446-A descriptor (Bt2446APipelineManaged) whose peaks are supplied by the pipeline at ToneMapper::prepare time.

Use this when you don’t know the source peak nits at the builder-construction site and want ImagePlan to resolve peaks via PeakSource or measure_content_light_level.

Source

pub const fn source_peak(&self) -> Nits

Baked HDR source peak luminance in cd/m².

Source

pub const fn target_peak(&self) -> Nits

Baked SDR target peak luminance in cd/m².

Source

pub fn map_rgb_bt2020_peak_normalized(&self, rgb: [f32; 3]) -> [f32; 3]

Map a single HDR pixel (linear-light BT.2020 RGB normalized so 1.0 = source_peak()) to an SDR pixel (linear-light BT.2020 RGB normalized so 1.0 = target_peak()).

Input must be finite; NaN/negative channels are not scrubbed here (see Self::map_strip_bt2020_peak_normalized).

Implemented as a 1-element strip through Self::map_strip_bt2020_peak_normalized. A single pixel runs the same lanes as a row, padded.

Source

pub fn map_strip_bt2020_peak_normalized(&self, strip: &mut [[f32; 3]])

Apply the curve to a strip of linear-light BT.2020 RGB pixels (normalized so 1.0 = source_peak() on input and 1.0 = target_peak() on output) in place, dispatching to the widest available SIMD tier.

§Input contract

Expects finite linear-light BT.2020 RGB. Non-finite input is not scrubbed, and NaN/inf can reach the output. The conversion pipeline scrubs non-finite values before calling this; direct callers own that themselves.

Trait Implementations§

Source§

impl Clone for Bt2446A

Source§

fn clone(&self) -> Bt2446A

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 Bt2446A

Source§

impl Debug for Bt2446A

Source§

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

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

impl ToneMapper for Bt2446A

Source§

fn requirements(&self) -> Requirements

What pipeline-gathered context does this mapper need before it can produce a PreparedMapper? Read more
Source§

fn prepare( &self, _ctx: &ToneMapContext, pulse: Option<&dyn Pulse>, ) -> Result<PreparedMapper, At<ConvertError>>

Build a per-image strip executor from the gathered context. Read more
Source§

fn name(&self) -> &'static str

Short kebab-case identifier for diagnostics, trace logs, and estimate / oracle cache keys. Read more
Source§

fn working_primaries_for(&self, _target: Primaries) -> Primaries

The working color primaries this mapper expects on its input strip, given a target primaries hint. Read more
Source§

fn baked_peaks(&self) -> Option<(f32, f32)>

Pre-baked (source_peak_nits, target_peak_nits) when this mapper ignores pipeline-supplied peaks (e.g., Bt2446A::with_peaks(Nits::new_positive_or_panic(4000.0), Nits::new_positive_or_panic(100.0))). 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.