Skip to content

tone_mapping: refactor st2094 knee point selection

Niklas Haas requested to merge st2094_v2 into master

Avoid hard-coding constant brightness altogether, and instead treat the knee point as a relative point in both the source and destination dynamic ranges, defaulting to the same fixed constant for both.

This change in logic avoids inconsistencies in how src_avg and dst_avg are calculated, and better preserves the subjective intent of bright and dark scenes. It also ensures a no-op knee point is selected whenever the source and destination ranges are identical.

In addition to refactoring the logic, this commit exposes the target adaptation strength as a tunable paramater, since this magic constant provides a very good entry-point for users to choose their own desired subjective adpatation strength. Basically, values close to 1.0 make the tone-mapping function behave more like a perceptually linear map, while values close to 0.0 make the tone-mapping function behave more like a clipping (1:1) map. In other words, higher values preserve source brightness, while lower values make better use of the target dynamic range.

The default of 0.7 was picked to (subjectively) approximate reference OOTFs in HDR10+ test clips I had lying around.

Lastly, fix the documentation, which was severely out-of-sync with the actual code.

Fixes: #254 (closed)

Merge request reports