From 18c74f7dfe9cbefe9de818caa00c3f77ce600f71 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Wed, 12 Jul 2017 19:08:58 +0200 Subject: vo_opengl: generalize --scale-clamp etc. This can help fight ringing without completely killing it, thus providing a middle-ground between ringing and aliasing. --- video/out/filter_kernels.c | 4 ++-- video/out/filter_kernels.h | 2 +- video/out/opengl/video.c | 2 +- video/out/opengl/video.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'video') diff --git a/video/out/filter_kernels.c b/video/out/filter_kernels.c index 09f85af5f4..6c10eb30b5 100644 --- a/video/out/filter_kernels.c +++ b/video/out/filter_kernels.c @@ -117,8 +117,8 @@ static double sample_filter(struct filter_kernel *filter, double x) { // The window is always stretched to the entire kernel double w = sample_window(&filter->w, x / filter->f.radius * filter->w.radius); - double k = sample_window(&filter->f, x); - return filter->clamp ? fmax(0.0, fmin(1.0, w * k)) : w * k; + double k = w * sample_window(&filter->f, x); + return k < 0 ? (1 - filter->clamp) * k : k; } // Calculate the 1D filtering kernel for N sample points. diff --git a/video/out/filter_kernels.h b/video/out/filter_kernels.h index c9a89f6847..ac9b7fd39a 100644 --- a/video/out/filter_kernels.h +++ b/video/out/filter_kernels.h @@ -28,7 +28,7 @@ struct filter_window { struct filter_kernel { struct filter_window f; // the kernel itself struct filter_window w; // window storage - bool clamp; // clamp to the range [0-1] + double clamp; // clamping factor, affects negative weights double value_cutoff; // discard all contributions below this value (polar) // Constant values const char *window; // default window diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index 8f65b555c8..50e70ce08f 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -333,7 +333,7 @@ static int validate_window_opt(struct mp_log *log, const m_option_t *opt, OPT_FLOAT(n"-wparam", scaler[i].window.params[0], 0), \ OPT_FLOAT(n"-wblur", scaler[i].window.blur, 0), \ OPT_FLOATRANGE(n"-wtaper", scaler[i].window.taper, 0, 0.0, 1.0), \ - OPT_FLAG(n"-clamp", scaler[i].clamp, 0), \ + OPT_FLOATRANGE(n"-clamp", scaler[i].clamp, 0, 0.0, 1.0), \ OPT_FLOATRANGE(n"-radius", scaler[i].radius, 0, 0.5, 16.0), \ OPT_FLOATRANGE(n"-antiring", scaler[i].antiring, 0, 0.0, 1.0), \ OPT_STRING_VALIDATE(n"-window", scaler[i].window.name, 0, validate_window_opt) diff --git a/video/out/opengl/video.h b/video/out/opengl/video.h index b4f91b802f..09083da41b 100644 --- a/video/out/opengl/video.h +++ b/video/out/opengl/video.h @@ -44,7 +44,7 @@ struct scaler_config { float radius; float antiring; float cutoff; - int clamp; + float clamp; }; struct scaler { -- cgit v1.2.3