mirror of https://github.com/mpv-player/mpv
vo_opengl: simplify radius initialization
Somehow, the default radius for filters with variable radius was set in mp_init_filter(). gl_video.c used NAN as default value for the radius, which would make the filter use the default radius. Simplify this, and set the default radius directly in the gl_video options. It also makes the options easier to understand, because the default value listed in --vo=opengl:help actually shows the default value. Remove the function can_use_filter_kernel(), because it doesn't set a radius if none is set. The function is worthless anyway (something about making filter_kernels.c reusable to other VOs, and trying to deal with the possibility that it could provide filters not supported by vo_opengl.)
This commit is contained in:
parent
6945369e9c
commit
639e2bd12f
|
@ -56,8 +56,7 @@ const struct filter_kernel *mp_find_filter_kernel(const char *name)
|
||||||
bool mp_init_filter(struct filter_kernel *filter, const int *sizes,
|
bool mp_init_filter(struct filter_kernel *filter, const int *sizes,
|
||||||
double inv_scale)
|
double inv_scale)
|
||||||
{
|
{
|
||||||
if (filter->radius < 0)
|
assert(filter->radius > 0);
|
||||||
filter->radius = 3.0;
|
|
||||||
// polar filters are dependent only on the radius
|
// polar filters are dependent only on the radius
|
||||||
if (filter->polar) {
|
if (filter->polar) {
|
||||||
filter->size = 1;
|
filter->size = 1;
|
||||||
|
|
|
@ -335,7 +335,7 @@ const struct gl_video_opts gl_video_opts_def = {
|
||||||
.sigmoid_slope = 6.5,
|
.sigmoid_slope = 6.5,
|
||||||
.scalers = { "bilinear", "bilinear" },
|
.scalers = { "bilinear", "bilinear" },
|
||||||
.scaler_params = {{NAN, NAN}, {NAN, NAN}},
|
.scaler_params = {{NAN, NAN}, {NAN, NAN}},
|
||||||
.scaler_radius = {NAN, NAN},
|
.scaler_radius = {3, 3},
|
||||||
.alpha_mode = 2,
|
.alpha_mode = 2,
|
||||||
.background = {0, 0, 0, 255},
|
.background = {0, 0, 0, 255},
|
||||||
};
|
};
|
||||||
|
@ -351,7 +351,7 @@ const struct gl_video_opts gl_video_opts_hq_def = {
|
||||||
.sigmoid_upscaling = 1,
|
.sigmoid_upscaling = 1,
|
||||||
.scalers = { "spline36", "bilinear" },
|
.scalers = { "spline36", "bilinear" },
|
||||||
.scaler_params = {{NAN, NAN}, {NAN, NAN}},
|
.scaler_params = {{NAN, NAN}, {NAN, NAN}},
|
||||||
.scaler_radius = {NAN, NAN},
|
.scaler_radius = {3, 3},
|
||||||
.alpha_mode = 2,
|
.alpha_mode = 2,
|
||||||
.background = {0, 0, 0, 255},
|
.background = {0, 0, 0, 255},
|
||||||
};
|
};
|
||||||
|
@ -1390,11 +1390,8 @@ static void init_scaler(struct gl_video *p, struct scaler *scaler)
|
||||||
|
|
||||||
scaler->antiring = p->opts.scaler_antiring[scaler->index];
|
scaler->antiring = p->opts.scaler_antiring[scaler->index];
|
||||||
|
|
||||||
if (scaler->kernel->radius < 0) {
|
if (scaler->kernel->radius < 0)
|
||||||
float radius = p->opts.scaler_radius[scaler->index];
|
scaler->kernel->radius = p->opts.scaler_radius[scaler->index];
|
||||||
if (!isnan(radius))
|
|
||||||
scaler->kernel->radius = radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
update_scale_factor(p, scaler);
|
update_scale_factor(p, scaler);
|
||||||
|
|
||||||
|
@ -2720,20 +2717,12 @@ struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct osd_state *osd
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool can_use_filter_kernel(const struct filter_kernel *kernel)
|
|
||||||
{
|
|
||||||
if (!kernel)
|
|
||||||
return false;
|
|
||||||
struct filter_kernel k = *kernel;
|
|
||||||
return mp_init_filter(&k, filter_sizes, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get static string for scaler shader.
|
// Get static string for scaler shader.
|
||||||
static const char *handle_scaler_opt(const char *name)
|
static const char *handle_scaler_opt(const char *name)
|
||||||
{
|
{
|
||||||
if (name) {
|
if (name) {
|
||||||
const struct filter_kernel *kernel = mp_find_filter_kernel(name);
|
const struct filter_kernel *kernel = mp_find_filter_kernel(name);
|
||||||
if (can_use_filter_kernel(kernel))
|
if (kernel)
|
||||||
return kernel->name;
|
return kernel->name;
|
||||||
|
|
||||||
for (const char *const *filter = fixed_scale_filters; *filter; filter++) {
|
for (const char *const *filter = fixed_scale_filters; *filter; filter++) {
|
||||||
|
|
Loading…
Reference in New Issue