summaryrefslogtreecommitdiffstats
path: root/video/out/gpu/video_shaders.c
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2019-01-04 16:46:38 +0100
committerJan Ekström <jeebjp@gmail.com>2019-02-18 01:54:06 +0200
commit3f1bc25d4de6150b0acff7e92d3e3084a7d989f0 (patch)
tree71d9e56cebef3fa8553795847a3c47bba54be1bb /video/out/gpu/video_shaders.c
parentb4b719e33748970a9bf98a82a017d8f149ecb557 (diff)
downloadmpv-3f1bc25d4de6150b0acff7e92d3e3084a7d989f0.tar.bz2
mpv-3f1bc25d4de6150b0acff7e92d3e3084a7d989f0.tar.xz
vo_gpu: use dB units for scene change detection
Rather than the linear cd/m^2 units, these (relative) logarithmic units lend themselves much better to actually detecting scene changes, especially since the scene averaging was changed to also work logarithmically.
Diffstat (limited to 'video/out/gpu/video_shaders.c')
-rw-r--r--video/out/gpu/video_shaders.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/video/out/gpu/video_shaders.c b/video/out/gpu/video_shaders.c
index 07ac0b940f..5fea739385 100644
--- a/video/out/gpu/video_shaders.c
+++ b/video/out/gpu/video_shaders.c
@@ -613,9 +613,10 @@ static void hdr_update_peak(struct gl_shader_cache *sc,
GLSLF(" average += %f * (cur - average);\n", decay);
// Scene change hysteresis
- GLSLF(" float weight = smoothstep(%f, %f, abs(cur.x - average.x));\n",
- (float) opts->scene_threshold_low / MP_REF_WHITE,
- (float) opts->scene_threshold_high / MP_REF_WHITE);
+ float log_db = 10.0 / log(10.0);
+ GLSLF(" float weight = smoothstep(%f, %f, abs(log(cur.x / average.x)));\n",
+ opts->scene_threshold_low / log_db,
+ opts->scene_threshold_high / log_db);
GLSL( average = mix(average, cur, weight);)
// Reset SSBO state for the next frame