vo_gpu_next: update for new pl_filter configuration API

Configuration of filter parameters was moved from pl_filter_function (of
which the user had to make a copy) to pl_filter_config, with the
pl_filter_function remaining immutable.

Implement this new logic in a way that can reasonably exist side-by-side
with the old configuration API. Once we drop support for PL_API_VER
below 303, we can drastically simplify this code.
This commit is contained in:
Niklas Haas 2023-08-06 18:09:04 +02:00 committed by Niklas Haas
parent 8417804224
commit f6de44dd6a
1 changed files with 33 additions and 9 deletions

View File

@ -69,8 +69,10 @@ struct osd_state {
struct scaler_params {
struct pl_filter_config config;
#if PL_API_VER < 303
struct pl_filter_function kernel;
struct pl_filter_function window;
#endif
};
struct user_hook {
@ -1556,13 +1558,16 @@ static const struct pl_filter_config *map_scaler(struct priv *p,
const struct pl_filter_function_preset *fpreset;
if ((preset = pl_find_filter_preset(cfg->kernel.name))) {
par->config = *preset->filter;
par->kernel = *par->config.kernel;
} else if ((fpreset = pl_find_filter_function_preset(cfg->kernel.name))) {
par->config = (struct pl_filter_config) {0};
par->kernel = *fpreset->function;
par->config = (struct pl_filter_config) {
.kernel = fpreset->function,
#if PL_API_VER >= 303
.params[0] = fpreset->function->params[0],
.params[1] = fpreset->function->params[1],
#endif
};
} else if (!strcmp(cfg->kernel.name, "ewa_lanczossharp")) {
par->config = pl_filter_ewa_lanczos;
par->kernel = *par->config.kernel;
par->config.blur = 0.9812505644269356;
MP_WARN(p, "'ewa_lanczossharp' is deprecated and will be removed from "
"vo=gpu-next in the future, use --scale=ewa_lanczos "
@ -1573,29 +1578,48 @@ static const struct pl_filter_config *map_scaler(struct priv *p,
return &pl_filter_bilinear;
}
const struct pl_filter_function_preset *wpreset;
if ((wpreset = pl_find_filter_function_preset(cfg->window.name))) {
par->config.window = wpreset->function;
#if PL_API_VER >= 303
par->config.wparams[0] = wpreset->function->params[0];
par->config.wparams[1] = wpreset->function->params[1];
#endif
}
#if PL_API_VER < 303
par->kernel = *par->config.kernel;
par->config.kernel = &par->kernel;
if (par->config.window) {
par->window = *par->config.window;
par->config.window = &par->window;
}
const struct pl_filter_function_preset *wpreset;
if ((wpreset = pl_find_filter_function_preset(cfg->window.name)))
par->window = *wpreset->function;
#endif
for (int i = 0; i < 2; i++) {
#if PL_API_VER >= 303
if (!isnan(cfg->kernel.params[i]))
par->config.params[i] = cfg->kernel.params[i];
if (!isnan(cfg->window.params[i]))
par->config.wparams[i] = cfg->window.params[i];
#else
if (!isnan(cfg->kernel.params[i]))
par->kernel.params[i] = cfg->kernel.params[i];
if (!isnan(cfg->window.params[i]))
par->window.params[i] = cfg->window.params[i];
#endif
}
par->config.clamp = cfg->clamp;
par->config.blur = cfg->kernel.blur;
par->config.taper = cfg->kernel.taper;
if (cfg->radius > 0.0) {
if (par->kernel.resizable) {
if (par->config.kernel->resizable) {
#if PL_API_VER >= 303
par->config.radius = cfg->radius;
#else
par->kernel.radius = cfg->radius;
#endif
} else {
MP_WARN(p, "Filter radius specified but filter '%s' is not "
"resizable, ignoring\n", cfg->kernel.name);