mirror of
https://github.com/mpv-player/mpv
synced 2025-03-23 20:00:56 +00:00
vo_opengl: add radius options for filters
Add two new options, make it possible for user to set the radius for some of the filters with no fixed radius. Also add three new filters with the new radius parameter supported.
This commit is contained in:
parent
f14722a40f
commit
b3e788d3f4
@ -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
|
||||
|
@ -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}
|
||||
};
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user