diff options
author | Niklas Haas <git@haasn.dev> | 2021-10-25 18:19:19 +0200 |
---|---|---|
committer | Niklas Haas <github-daiK1o@haasn.dev> | 2021-11-03 14:09:27 +0100 |
commit | edb0caa4415b47bb1b60a66ad2f3d1bdb42cdb25 (patch) | |
tree | 97c8b30893534166fa4cc0aa808060d38894b206 | |
parent | 242cd76ee70d1e0b06aec6aeb0cce3108463c936 (diff) | |
download | mpv-edb0caa4415b47bb1b60a66ad2f3d1bdb42cdb25.tar.bz2 mpv-edb0caa4415b47bb1b60a66ad2f3d1bdb42cdb25.tar.xz |
vo_gpu: allow using bare windows as --(t)scale
A lot of people seem to do something like --tscale=box
--tscale-window=<function>. Just let them use --tscale=<function>
directly, by also accepting raw windows.
Kinda hacky but needed for feature parity with vo_gpu_next, which no
longer has `--tscale=box`. Note that because the option struct is still
shared, vo_gpu_next inherits the same option handling code, so we have
to export this feature for vo_gpu as well.
-rw-r--r-- | video/out/gpu/video.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index e4c4ee9290..5d6b766d36 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -1697,9 +1697,17 @@ static void reinit_scaler(struct gl_video *p, struct scaler *scaler, uninit_scaler(p, scaler); + struct filter_kernel bare_window; const struct filter_kernel *t_kernel = mp_find_filter_kernel(conf->kernel.name); const struct filter_window *t_window = mp_find_filter_window(conf->window.name); bool is_tscale = scaler->index == SCALER_TSCALE; + if (!t_kernel) { + const struct filter_window *window = mp_find_filter_window(conf->kernel.name); + if (window) { + bare_window = (struct filter_kernel) { .f = *window }; + t_kernel = &bare_window; + } + } scaler->conf = *conf; scaler->conf.kernel.name = (char *)handle_scaler_opt(conf->kernel.name, is_tscale); @@ -3992,6 +4000,10 @@ static const char *handle_scaler_opt(const char *name, bool tscale) if (kernel && (!tscale || !kernel->polar)) return kernel->f.name; + const struct filter_window *window = mp_find_filter_window(name); + if (window) + return window->name; + for (const char *const *filter = tscale ? fixed_tscale_filters : fixed_scale_filters; *filter; filter++) { @@ -4105,6 +4117,14 @@ static int validate_scaler_opt(struct mp_log *log, const m_option_t *opt, if (!tscale || !mp_filter_kernels[n].polar) mp_info(log, " %s\n", mp_filter_kernels[n].f.name); } + for (int n = 0; mp_filter_windows[n].name; n++) { + for (int m = 0; mp_filter_kernels[m].f.name; m++) { + if (!strcmp(mp_filter_windows[n].name, mp_filter_kernels[m].f.name)) + goto next_window; // don't log duplicates + } + mp_info(log, " %s\n", mp_filter_windows[n].name); +next_window: ; + } if (s[0]) mp_fatal(log, "No scaler named '%s' found!\n", s); } |