summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/vo.rst21
-rw-r--r--video/out/filter_kernels.c5
-rw-r--r--video/out/filter_kernels.h2
-rw-r--r--video/out/gl_video.c10
-rw-r--r--video/out/gl_video.h1
5 files changed, 33 insertions, 6 deletions
diff --git a/DOCS/man/vo.rst b/DOCS/man/vo.rst
index 79694d748a..a928809d93 100644
--- a/DOCS/man/vo.rst
+++ b/DOCS/man/vo.rst
@@ -297,6 +297,9 @@ Available video output drivers are:
``lanczos3``
Lanczos with radius=3.
+ ``lanczos``
+ Generic Lanczos scaling filter. Set radius with ``lradius``.
+
``spline36``
This is the default when using ``opengl-hq``.
@@ -329,6 +332,16 @@ Available video output drivers are:
``lparam2=<value>``
See ``lparam1``.
+ ``lradius=<r>``
+ Set radius for filters listed below, must be a float number between 1.0
+ and 8.0. Defaults to be 2.0 if not specified.
+
+ ``sinc``, ``lanczos``, ``blackman``
+
+ Note that depending on filter implementation details and video scaling
+ ratio, the radius that actually being used might be different
+ (most likely being increased a bit).
+
``scaler-resizes-only``
Disable the scaler if the video image is not resized. In that case,
``bilinear`` is used instead whatever is set with ``lscale``. Bilinear
@@ -430,12 +443,10 @@ Available video output drivers are:
RGB. If chroma is not subsampled, this option is ignored, and the
luma scaler is used instead. Setting this option is often useless.
- ``cparam1=<value>``
- Set filter parameters for ``cscale`` . Same as ``lparam1`` for
- ``lscale``.
+ ``cparam1``, ``cparam2``, ``cradius``
+ Set filter parameters and radius for ``cscale``.
- ``cparam2=<value>``
- See ``cparam1``.
+ See ``lparam1``, ``lparam2`` and ``lradius``.
``fancy-downscaling``
When using convolution based filters, extend the filter size
diff --git a/video/out/filter_kernels.c b/video/out/filter_kernels.c
index c8efbe5731..66116ce18b 100644
--- a/video/out/filter_kernels.c
+++ b/video/out/filter_kernels.c
@@ -56,6 +56,8 @@ const struct filter_kernel *mp_find_filter_kernel(const char *name)
bool mp_init_filter(struct filter_kernel *filter, const int *sizes,
double inv_scale)
{
+ if (filter->radius < 0)
+ filter->radius = 2.0;
// only downscaling requires widening the filter
filter->inv_scale = inv_scale >= 1.0 ? inv_scale : 1.0;
double support = filter->radius * filter->inv_scale;
@@ -294,11 +296,14 @@ const struct filter_kernel mp_filter_kernels[] = {
{"sinc2", 2, sinc},
{"sinc3", 3, sinc},
{"sinc4", 4, sinc},
+ {"sinc", -1, sinc},
{"lanczos2", 2, lanczos},
{"lanczos3", 3, lanczos},
{"lanczos4", 4, lanczos},
+ {"lanczos", -1, lanczos},
{"blackman2", 2, blackman},
{"blackman3", 3, blackman},
{"blackman4", 4, blackman},
+ {"blackman", -1, blackman},
{0}
};
diff --git a/video/out/filter_kernels.h b/video/out/filter_kernels.h
index 46a392c40a..f9a413b9f7 100644
--- a/video/out/filter_kernels.h
+++ b/video/out/filter_kernels.h
@@ -23,7 +23,7 @@
struct filter_kernel {
const char *name;
- double radius;
+ double radius; // A negative value will use user specified radius instead.
double (*weight)(struct filter_kernel *kernel, double x);
// The filter params can be changed at runtime. Only used by some filters.
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index 3478c8afcc..359013a6e6 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -289,6 +289,7 @@ static const struct gl_video_opts gl_video_opts_def = {
.scale_sep = 1,
.scalers = { "bilinear", "bilinear" },
.scaler_params = {{NAN, NAN}, {NAN, NAN}},
+ .scaler_radius = {NAN, NAN},
.alpha_mode = 2,
};
@@ -300,6 +301,7 @@ const struct gl_video_opts gl_video_opts_hq_def = {
.scale_sep = 1,
.scalers = { "spline36", "bilinear" },
.scaler_params = {{NAN, NAN}, {NAN, NAN}},
+ .scaler_radius = {NAN, NAN},
.alpha_mode = 2,
};
@@ -326,6 +328,8 @@ const struct m_sub_options gl_video_conf = {
OPT_FLOAT("lparam2", scaler_params[0][1], 0),
OPT_FLOAT("cparam1", scaler_params[1][0], 0),
OPT_FLOAT("cparam2", scaler_params[1][1], 0),
+ OPT_FLOATRANGE("lradius", scaler_radius[0], 0, 1.0, 8.0),
+ OPT_FLOATRANGE("cradius", scaler_radius[1], 0, 1.0, 8.0),
OPT_FLAG("scaler-resizes-only", scaler_resizes_only, 0),
OPT_FLAG("fancy-downscaling", fancy_downscaling, 0),
OPT_FLAG("indirect", indirect, 0),
@@ -1117,6 +1121,12 @@ static void init_scaler(struct gl_video *p, struct scaler *scaler)
scaler->kernel->params[n] = p->opts.scaler_params[scaler->index][n];
}
+ if (scaler->kernel->radius < 0) {
+ float radius = p->opts.scaler_radius[scaler->index];
+ if (!isnan(radius))
+ scaler->kernel->radius = radius;
+ }
+
update_scale_factor(p, scaler->kernel);
int size = scaler->kernel->size;
diff --git a/video/out/gl_video.h b/video/out/gl_video.h
index c5f2e558c7..8ea5d3420f 100644
--- a/video/out/gl_video.h
+++ b/video/out/gl_video.h
@@ -30,6 +30,7 @@ struct lut3d {
struct gl_video_opts {
char *scalers[2];
float scaler_params[2][2];
+ float scaler_radius[2];
int indirect;
float gamma;
int srgb;