summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
Diffstat (limited to 'video')
-rw-r--r--video/out/opengl/video.c3
-rw-r--r--video/out/opengl/video_shaders.c7
-rw-r--r--video/out/opengl/video_shaders.h2
3 files changed, 8 insertions, 4 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 48477fe18d..f0a8635c56 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -1792,7 +1792,8 @@ static void deband_hook(struct gl_video *p, struct img_tex tex,
struct gl_transform *trans, void *priv)
{
pass_describe(p, "debanding (%s)", plane_names[tex.type]);
- pass_sample_deband(p->sc, p->opts.deband_opts, &p->lfg);
+ pass_sample_deband(p->sc, p->opts.deband_opts, &p->lfg,
+ p->image_params.color.gamma);
}
static void unsharp_hook(struct gl_video *p, struct img_tex tex,
diff --git a/video/out/opengl/video_shaders.c b/video/out/opengl/video_shaders.c
index a7b253249a..40c5e98729 100644
--- a/video/out/opengl/video_shaders.c
+++ b/video/out/opengl/video_shaders.c
@@ -808,7 +808,7 @@ const struct m_sub_options deband_conf = {
// Stochastically sample a debanded result from a hooked texture.
void pass_sample_deband(struct gl_shader_cache *sc, struct deband_opts *opts,
- AVLFG *lfg)
+ AVLFG *lfg, enum mp_csp_trc trc)
{
// Initialize the PRNG
GLSLF("{\n");
@@ -850,7 +850,10 @@ void pass_sample_deband(struct gl_shader_cache *sc, struct deband_opts *opts,
GLSL(noise.x = rand(h); h = permute(h);)
GLSL(noise.y = rand(h); h = permute(h);)
GLSL(noise.z = rand(h); h = permute(h);)
- GLSLF("color.xyz += %f * (noise - vec3(0.5));\n", opts->grain/8192.0);
+
+ // Noise is scaled to the signal level to prevent extreme noise for HDR
+ float gain = opts->grain/8192.0 / mp_trc_nom_peak(trc);
+ GLSLF("color.xyz += %f * (noise - vec3(0.5));\n", gain);
GLSLF("}\n");
}
diff --git a/video/out/opengl/video_shaders.h b/video/out/opengl/video_shaders.h
index f6edff6d2b..1fae830720 100644
--- a/video/out/opengl/video_shaders.h
+++ b/video/out/opengl/video_shaders.h
@@ -49,7 +49,7 @@ void pass_color_map(struct gl_shader_cache *sc,
bool is_linear);
void pass_sample_deband(struct gl_shader_cache *sc, struct deband_opts *opts,
- AVLFG *lfg);
+ AVLFG *lfg, enum mp_csp_trc trc);
void pass_sample_unsharp(struct gl_shader_cache *sc, float param);