summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2023-08-18 14:16:29 +0200
committerNiklas Haas <github-daiK1o@haasn.dev>2023-08-18 15:00:25 +0200
commit36972aec535354c70b68021935bb7d238442b1cd (patch)
tree1b1b619a97076bc314d5afd5839a56d341f8844f /video
parent0b4a36476d0efcb4715a56c6e6de241af9a4b9ec (diff)
downloadmpv-36972aec535354c70b68021935bb7d238442b1cd.tar.bz2
mpv-36972aec535354c70b68021935bb7d238442b1cd.tar.xz
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: https://github.com/haasn/libplacebo/commit/1c464baaf4c6228dcfac87f19db1dafc22e328c8 See-Also: https://github.com/haasn/libplacebo/commit/83af2d4ebd5086a56f7b1a2f86628ada3612ee7c
Diffstat (limited to 'video')
-rw-r--r--video/out/gpu/video.c2
-rw-r--r--video/out/gpu/video_shaders.c9
2 files changed, 7 insertions, 4 deletions
diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c
index db0d045852..a03e6e80c4 100644
--- a/video/out/gpu/video.c
+++ b/video/out/gpu/video.c
@@ -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),
diff --git a/video/out/gpu/video_shaders.c b/video/out/gpu/video_shaders.c
index 049151bd24..260d0afb3d 100644
--- a/video/out/gpu/video_shaders.c
+++ b/video/out/gpu/video_shaders.c
@@ -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);