Skip to main content

signed_weight

Function signed_weight 

Source
pub fn signed_weight(
    metadata: &GainMapMetadata,
    display_headroom_stops: f32,
) -> Option<f32>
Expand description

Compute the ISO 21496-1 signed application weight for display_headroom_stops using exact i128 rational cross-products (never divides by zero or yields NaN on close valid rationals):

  • Returns None if display_headroom_stops is non-finite or H_base == H_alt.
  • Returns 0.0 at or beyond the base endpoint (amount == 0.0), signaling exact base-rendition identity bypass.
  • Returns sign(H_alt - H_base) * clamp((H - H_base) / (H_alt - H_base), 0, 1) (+amount for Forward SDR→HDR, -amount for Reverse HDR→SDR).