summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2019-01-09 17:14:19 +0100
committerJan Ekström <jeebjp@gmail.com>2019-02-18 01:54:06 +0200
commit8b563a034604ff5ab2ad92d12c63e806f45d1bb6 (patch)
treef76d54bf75583cb17e81a104c94b43407c1738c7
parent3f1bc25d4de6150b0acff7e92d3e3084a7d989f0 (diff)
downloadmpv-8b563a034604ff5ab2ad92d12c63e806f45d1bb6.tar.bz2
mpv-8b563a034604ff5ab2ad92d12c63e806f45d1bb6.tar.xz
vo_gpu: fix initial seeding of the peak detect ssbo
This solves some edge cases when using files with very weird metadata (e.g. MaxCLL 10k and so forth). Instead of just blindly seeding it with the tagged metadata, forcibly set the initial state from the detected values.
-rw-r--r--video/out/gpu/video.c4
-rw-r--r--video/out/gpu/video_shaders.c8
2 files changed, 7 insertions, 5 deletions
diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c
index 24e6990139..593f5fb9c1 100644
--- a/video/out/gpu/video.c
+++ b/video/out/gpu/video.c
@@ -2499,9 +2499,7 @@ static void pass_colormanage(struct gl_video *p, struct mp_colorspace src, bool
int32_t frame_sum;
uint32_t frame_max;
uint32_t counter;
- } peak_ssbo = {
- .average = { 0.25, src.sig_peak },
- };
+ } peak_ssbo = {0};
struct ra_buf_params params = {
.type = RA_BUF_TYPE_SHADER_STORAGE,
diff --git a/video/out/gpu/video_shaders.c b/video/out/gpu/video_shaders.c
index 5fea739385..b34aa90bfa 100644
--- a/video/out/gpu/video_shaders.c
+++ b/video/out/gpu/video_shaders.c
@@ -571,8 +571,10 @@ static void hdr_update_peak(struct gl_shader_cache *sc,
const struct gl_tone_map_opts *opts)
{
// Update the sig_peak/sig_avg from the old SSBO state
- GLSL(sig_avg = max(1e-3, average.x);)
- GLSL(sig_peak = max(1.00, average.y);)
+ GLSL(if (average.y > 0.0) {)
+ GLSL( sig_avg = max(1e-3, average.x);)
+ GLSL( sig_peak = max(1.00, average.y);)
+ GLSL(})
// Chosen to avoid overflowing on an 8K buffer
const float log_min = 1e-3, log_scale = 400.0, sig_scale = 10000.0;
@@ -605,6 +607,8 @@ static void hdr_update_peak(struct gl_shader_cache *sc,
GLSL( vec2 cur = vec2(float(frame_sum) / float(num_wg), frame_max);)
GLSLF(" cur *= vec2(1.0/%f, 1.0/%f);\n", log_scale, sig_scale);
GLSL( cur.x = exp(cur.x);)
+ GLSL( if (average.y == 0.0))
+ GLSL( average = cur;)
// Use an IIR low-pass filter to smooth out the detected values, with a
// configurable decay rate based on the desired time constant (tau)