Skip to content

present: Use 100 nits for the BT.2446 SDR constants - #1244

Merged
athei merged 1 commit into
mainfrom
fix/bt2446-p-sdr
Nov 18, 2026
Merged

athei merged 1 commit into
mainfrom
fix/bt2446-p-sdr

Conversation

@athei

@athei athei commented Nov 18, 2026

Copy link
Copy Markdown
Owner

The BT.2446 Method A inverse tone map uses SDR constants in present.msl that do not match the formula next to them. SDR white maps to 0.9995 of the peak instead of the peak, and midtones come out darker than the curve intends.

Cause

  • P_SDR = 5.4395284707 is 1 + 32 * (L / 10000)^(1/2.4) at about 87 nits, not at L_SDR = 100. At 100 nits the formula gives 5.6969577.
  • LOG_P_SDR = 1.6937747 is not the natural log of either value. ln(5.6969577) = 1.7399323.
  • hdr_uniforms computes the HDR side from the same formula at 100 nits, so the two sides disagree, also at peak 1.0.

Changes

  • P_SDR and LOG_P_SDR are set to the formula's values at 100 nits.
  • New test bt2446_sdr_constants_match_the_formula reads the literals from the MSL and checks them against the formula and against hdr_uniforms(1.0). It needs no Metal device.

Effect

Input Y Output change
1.0 (SDR white) exactly the peak, was 0.9995 × peak
0.5 about 1.5% brighter
0.18 about 3% brighter
0.01 about 5 to 6% brighter

Alternatives

  • Computing P_SDR in Rust and passing it in the uniform buffer: grows the 16-byte uniform for a value that never changes.

Verification

  • The new test fails on the old constants (P_SDR is 5.4395284707, the formula gives 5.696957656390622 at L_SDR = 100) and passes after.
  • cargo +nightly fmt --check: clean.
  • cargo +stable clippy --all-targets --config 'build.warnings="deny"', normal and PERF=1: clean.
  • cargo +stable nextest run: 850 passed, 2 skipped; 852 passed with PERF=1.
  • make audit: clean.
  • Not run locally: the windows-side Clippy legs, make doc and the e2e suite. No windows code changed.
  • No HDR picture was compared.

P_SDR and LOG_P_SDR were folded at about 87 nits, so the SDR side of
Method A disagreed with hdr_uniforms and SDR white mapped to 0.9995 of
the peak. Set both to the formula's values at L_SDR = 100 and add a test
that reads the literals from the MSL and checks them against the formula.
@athei
athei merged commit 14d3142 into main Nov 18, 2026
16 checks passed
@athei
athei deleted the fix/bt2446-p-sdr branch November 18, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant