summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2015-08-20 21:45:58 +0200
committerwm4 <wm4@nowhere>2015-08-20 21:55:19 +0200
commite1fd80097c6c224c9de06182d0a9aa0d21a57a67 (patch)
tree215e0f15984b045d5bc8df4149824b2a891bee30 /video
parent96648169e342b9843246075a36fae2ad0bd06f88 (diff)
downloadmpv-e1fd80097c6c224c9de06182d0a9aa0d21a57a67.tar.bz2
mpv-e1fd80097c6c224c9de06182d0a9aa0d21a57a67.tar.xz
vo_opengl: add tscale-clamp option
This significantly reduces the amount of noticeable flashing when using tscale kernels with negative lobes, by cutting them off completely. I'm not sure if this has any negative effects. It needs a bit of subjective testing over a period of time, so I just made it an option. Fixes #2155.
Diffstat (limited to 'video')
-rw-r--r--video/out/filter_kernels.c3
-rw-r--r--video/out/filter_kernels.h1
-rw-r--r--video/out/gl_video.c6
-rw-r--r--video/out/gl_video.h1
4 files changed, 9 insertions, 2 deletions
diff --git a/video/out/filter_kernels.c b/video/out/filter_kernels.c
index a748ac10ab..0f6d5a98bc 100644
--- a/video/out/filter_kernels.c
+++ b/video/out/filter_kernels.c
@@ -113,7 +113,8 @@ static double sample_filter(struct filter_kernel *filter,
double w = window->weight ? window->weight(window, x/bw * window->radius
/ filter->f.radius)
: 1.0;
- return c < filter->f.radius ? w * filter->f.weight(&filter->f, c) : 0.0;
+ double v = c < filter->f.radius ? w * filter->f.weight(&filter->f, c) : 0.0;
+ return filter->clamp ? fmax(0.0, fmin(1.0, v)) : v;
}
// Calculate the 1D filtering kernel for N sample points.
diff --git a/video/out/filter_kernels.h b/video/out/filter_kernels.h
index 9e6176293f..7b101cdd35 100644
--- a/video/out/filter_kernels.h
+++ b/video/out/filter_kernels.h
@@ -33,6 +33,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]
// Constant values
const char *window; // default window
bool polar; // whether or not the filter uses polar coordinates
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index a1d100f4dc..4eb4030244 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -415,6 +415,7 @@ const struct m_sub_options gl_video_conf = {
OPT_FLOATRANGE("dscale-antiring", scaler[1].antiring, 0, 0.0, 1.0),
OPT_FLOATRANGE("cscale-antiring", scaler[2].antiring, 0, 0.0, 1.0),
OPT_FLOATRANGE("tscale-antiring", scaler[3].antiring, 0, 0.0, 1.0),
+ OPT_FLAG("tscale-clamp", scaler[3].clamp, 0),
OPT_FLAG("scaler-resizes-only", scaler_resizes_only, 0),
OPT_FLAG("linear-scaling", linear_scaling, 0),
OPT_FLAG("fancy-downscaling", fancy_downscaling, 0),
@@ -950,7 +951,8 @@ static bool scaler_conf_eq(struct scaler_config a, struct scaler_config b)
// generation
return scaler_fun_eq(a.kernel, b.kernel) &&
scaler_fun_eq(a.window, b.window) &&
- a.radius == b.radius;
+ a.radius == b.radius &&
+ a.clamp == b.clamp;
}
static void reinit_scaler(struct gl_video *p, struct scaler *scaler,
@@ -1001,6 +1003,8 @@ static void reinit_scaler(struct gl_video *p, struct scaler *scaler,
if (scaler->kernel->f.resizable && conf->radius > 0.0)
scaler->kernel->f.radius = conf->radius;
+ scaler->kernel->clamp = conf->clamp;
+
scaler->insufficient = !mp_init_filter(scaler->kernel, sizes, scale_factor);
if (scaler->kernel->polar) {
diff --git a/video/out/gl_video.h b/video/out/gl_video.h
index 0881025a14..385477e051 100644
--- a/video/out/gl_video.h
+++ b/video/out/gl_video.h
@@ -39,6 +39,7 @@ struct scaler_config {
struct scaler_fun window;
float radius;
float antiring;
+ int clamp;
};
struct gl_video_opts {