forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on mainFiltered to crates/engine/tests/tonemap_render.rsClear filter

2026-10-23

🚚 edith moves to git.tahinli.comAhmet Kaan Gümüş · b02f499
🚚 edith moves to git.tahinli.com

The working tree as of 2026-10-23, as one commit on top of the last one
here. It carries the work up to that date plus the test-slimming work:
integration tests merged into one binary per crate, nextest config,
doctest = false, debug line tables only, perf tests behind --ignored,
and faster generators, reverse, undo, subtitle-export, hevc, stabilise
and hear tests.

2026-08-11

✨ feat(tonemap): the reference rendition converts a film at the peak the film declaresAhmet Kaan Gümüş · 27097e2
✨ feat(tonemap): the reference rendition converts a film at the peak the film declares

`Demuxer::light().peak()` -- a stream's MaxCLL, or its mastering display's
maximum -- has been read at every open and dropped on the floor. It now reaches
`ToneMapper::new` as `declared_peak`, and `Preset::master_nits_for` is the whole
composition rule: `Reference` takes the film's number (1000 stays the fallback
for a file that declared nothing), `Standard` and `Vivid` keep their fixed 400
and 250, because a picked exposure that moved per file would not be a pick.

One HDR film declares 1759 cd/m^2, so its 1000-nit highlights
land at SDR 215 instead of clipping at white, and BT.2408 diffuse white at 145
instead of 166.

Both sites that build a table have the demuxer in hand already, so nothing is
promoted through `VideoMeta`: the decode funnel reads it before the worker takes
the demuxer, and `source_rate` returns it off the header parse export already
did -- which is what keeps preview and export on one number.

A declared peak is a stranger's number and is checked before it becomes a
divisor: outside 100..=10000, or a NaN, is treated as not declared.

test_hdr_bright.mkv joins the fixtures for it -- the older HDR metadata ones all
say 1000, which no picture can tell apart from the fallback.
✨ feat(tonemap): the HDR rendition is a row you pick, not a constant someone chose for youAhmet Kaan Gümüş · 09671f7
✨ feat(tonemap): the HDR rendition is a row you pick, not a constant someone chose for you

BT.2446 Method A's assumed mastering peak was a constant in the module: 400
cd/m^2, one exposure decided for everybody. It is a matter of taste, not of
correctness -- a reference rendition and a vivid one are both honest pictures of
the same film -- so it becomes a project setting with three renditions through
the very same curve, which is what keeps the hues right whichever is picked:

  Reference  1000 nits, chroma 1.0   the published conversion (diffuse white 166)
  Standard    400 nits, chroma 1.0   display-referred, as bright as a player
  Vivid       250 nits, chroma 1.10  brightest, and a tenth more colour

The chroma gain is a scale about 128 in the SDR codes, after the map and clamped
to the legal range: a grey stays exactly grey at any gain, and at 1.0 it is a
clamp the maths cannot reach, so the other two presets are byte for byte what
Method A produced. HLG's OOTF gain is guarded at black -- below a 1000 cd/m^2
peak the system gamma is under 1, and the 0 * inf that follows byte-cast to 0
and put a hole where black belongs.

The preset lives on the Project beside the limiter (a setting, not an undo step),
reaches the decode workers and the export through the same value, and is saved as
a `tonemap` line in edith 11 -- left out when it is the default, so a project
holding no HDR media is the bytes it was, and a v10 file loads as the reference
rendition, which is the only one it ever had. Picking one rebuilds the picture
under the playhead the way a resize does; an SDR project is unmoved.

The panel names it beside the resolution and the rate -- the third thing that is
the project's rather than the media's -- and a click opens the three renditions
with the one in force marked. No stroke: this is a list to look at.
✨ feat(color): an HDR film reaches the window tone-mapped, and an SDR one is untouchedAhmet Kaan Gümüş · f8dea1c
✨ feat(color): an HDR film reaches the window tone-mapped, and an SDR one is untouched

The tone map existed and nothing called it: a PQ or HLG stream was
converted with its own matrix and then shown as if its curve were SDR --
flat, grey-washed, half the brightness a player gives it. `Render` now
builds one `ToneMapper` per stream (the transfer is a property of the
file, and the LUT is float work over 9 537 nodes) and maps the source
planes into BT.709 SDR before anything else looks at them, in both
branches of the funnel: the fused passthrough conversion and the
graded-then-placed one.

The grade lands *after* the map, on the one scratch copy the placed path
already made -- a look means what it says in the SDR a viewer is shown,
not in the ten stops the file was in. An SDR stream takes neither the
copy nor the map and is byte for byte the picture it was, asserted
against hashes measured before this change (`tonemap_render`).

`MASTER_NITS` is 400, not the 1000 an HDR10 grade is mastered to. Told
1000, BT.2446 Method A puts 203-nit diffuse white on code 166, which
reads as broadcast-dark; told 400 it lands on 205, which is the
brightness mpv shows. The anchor tests carry the recomputed codes rather
than wider tolerances, and HLG's OOTF now follows the assumed peak
through BT.2100's own log term -- its relative diffuse white is 19% of
whatever peak the display has, so it comes out at 170 and no longer
agrees with PQ's absolute 203, which is the standard's behaviour and is
written down beside the assert.

Measured on the real 4K HDR10 film (`hw_decode`, existence-gated): frame
3000 saturation 34.8 -> 98.9, mean luma 107.6 -> 122.2, and 32.5
ms/frame for the map plus the conversion at 3840x1600, inside the 39 ms
budget. New fixture `test_pq.mp4`: four flat patches whose codes are
written into the planes by hand, so a test names the code it feeds and
the code it expects back.