vo_gpu: allow --hdr-peak-decay-rate=0.0

This completely disables all smoothing. Despite what the manual claims,
a decay rate of 1.0 does *not*.

It's worth pointing out that this depends on the following commit to
work properly in --vo=gpu-next, but I don't think working around such a
minor detail is worth the trouble, considering people building nightly
mpv are probably also building nightly libplacebo it should just work
(tm).

See-Also: 1c464baaf4
See-Also: 83af2d4ebd
This commit is contained in:
Niklas Haas 2023-08-18 14:16:29 +02:00 committed by Niklas Haas
parent 0b4a36476d
commit 36972aec53
3 changed files with 9 additions and 6 deletions

View File

@ -6707,12 +6707,12 @@ them.
range of scenes with very bright isolated highlights. Values other than 100
come with a small performance penalty. (Only for ``--vo=gpu-next``)
``--hdr-peak-decay-rate=<1.0..1000.0>``
``--hdr-peak-decay-rate=<0.0..1000.0>``
The decay rate used for the HDR peak detection algorithm (default: 100.0).
This is only relevant when ``--hdr-compute-peak`` is enabled. Higher values
make the peak decay more slowly, leading to more stable values at the cost
of more "eye adaptation"-like effects (although this is mitigated somewhat
by ``--hdr-scene-threshold``). A value of 1.0 (the lowest possible) disables
by ``--hdr-scene-threshold``). A value of 0.0 (the lowest possible) disables
all averaging, meaning each frame's value is used directly as measured,
but doing this is not recommended for "noisy" sources since it may lead
to excessive flicker. (In signal theory terms, this controls the time

View File

@ -419,7 +419,7 @@ const struct m_sub_options gl_video_conf = {
{"hdr-peak-percentile", OPT_FLOAT(tone_map.peak_percentile),
M_RANGE(0.0, 100.0)},
{"hdr-peak-decay-rate", OPT_FLOAT(tone_map.decay_rate),
M_RANGE(1.0, 1000.0)},
M_RANGE(0.0, 1000.0)},
{"hdr-scene-threshold-low", OPT_FLOAT(tone_map.scene_threshold_low),
M_RANGE(0, 20.0)},
{"hdr-scene-threshold-high", OPT_FLOAT(tone_map.scene_threshold_high),

View File

@ -644,9 +644,12 @@ static void hdr_update_peak(struct gl_shader_cache *sc,
// Use an IIR low-pass filter to smooth out the detected values, with a
// configurable decay rate based on the desired time constant (tau)
float a = 1.0 - cos(1.0 / opts->decay_rate);
float decay = sqrt(a*a + 2*a) - a;
GLSLF(" average += %f * (cur - average);\n", decay);
if (opts->decay_rate) {
float decay = 1.0f - expf(-1.0f / opts->decay_rate);
GLSLF(" average += %f * (cur - average);\n", decay);
} else {
GLSLF(" average = cur;\n");
}
// Scene change hysteresis
float log_db = 10.0 / log(10.0);