diff options
-rw-r--r-- | video/out/gpu/video.c | 4 | ||||
-rw-r--r-- | video/out/gpu/video_shaders.c | 8 |
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) |