summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/interface-changes.rst1
-rw-r--r--DOCS/man/options.rst7
-rw-r--r--video/out/gpu/video.c1
-rw-r--r--video/out/gpu/video.h1
-rw-r--r--video/out/vo_gpu_next.c60
5 files changed, 69 insertions, 1 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 4a21d3ba5c..7bbbfd5a0c 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -49,6 +49,7 @@ Interface changes
- deprecate `--gamma-factor`
- deprecate `--gamma-auto`
- remove `--vulkan-disable-events`
+ - add `--glsl-shader-opts`
--- mpv 0.34.0 ---
- deprecate selecting by card number with `--drm-connector`, add
`--drm-device` which can be used instead
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 278a5e4d87..9b7908eaec 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -5857,6 +5857,13 @@ them.
``--glsl-shader=<file>``
CLI/config file only alias for ``--glsl-shaders-append``.
+``--glsl-shader-opts=param1=value1,param2=value2,...``
+ Specifies the options to use for tunable shader parameters. You can target
+ specific named shaders by prefixing the shader name with a ``/``, e.g.
+ ``shader/param=value``. Without a prefix, parameters affect all shaders.
+ The shader name is the base part of the shader filename, without the
+ extension. (``--vo=gpu-next`` only)
+
``--deband``
Enable the debanding algorithm. This greatly reduces the amount of visible
banding, blocking and other quantization artifacts, at the expense of
diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c
index 65a696cc38..abe5e9333c 100644
--- a/video/out/gpu/video.c
+++ b/video/out/gpu/video.c
@@ -455,6 +455,7 @@ const struct m_sub_options gl_video_conf = {
{"video", BLEND_SUBS_VIDEO})},
{"glsl-shaders", OPT_PATHLIST(user_shaders), .flags = M_OPT_FILE},
{"glsl-shader", OPT_CLI_ALIAS("glsl-shaders-append")},
+ {"glsl-shader-opts", OPT_KEYVALUELIST(user_shader_opts)},
{"deband", OPT_FLAG(deband)},
{"deband", OPT_SUBSTRUCT(deband_opts, deband_conf)},
{"sharpen", OPT_FLOAT(unsharp)},
diff --git a/video/out/gpu/video.h b/video/out/gpu/video.h
index 7637710fa7..30abd972f9 100644
--- a/video/out/gpu/video.h
+++ b/video/out/gpu/video.h
@@ -162,6 +162,7 @@ struct gl_video_opts {
float interpolation_threshold;
int blend_subs;
char **user_shaders;
+ char **user_shader_opts;
int deband;
struct deband_opts *deband_opts;
float unsharp;
diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c
index bbce4f2065..0536abcea1 100644
--- a/video/out/vo_gpu_next.c
+++ b/video/out/vo_gpu_next.c
@@ -1682,6 +1682,62 @@ static void update_lut(struct priv *p, struct user_lut *lut)
talloc_free(lutdata.start);
}
+static void update_hook_opts(struct priv *p, char **opts, const char *shaderpath,
+ const struct pl_hook *hook)
+{
+ if (!opts)
+ return;
+
+#if PL_API_VER >= 233
+ const char *basename = mp_basename(shaderpath);
+ struct bstr shadername;
+ if (!mp_splitext(basename, &shadername))
+ shadername = bstr0(basename);
+
+ for (int n = 0; opts[n * 2]; n++) {
+ struct bstr k = bstr0(opts[n * 2 + 0]);
+ struct bstr v = bstr0(opts[n * 2 + 1]);
+ int pos;
+ if ((pos = bstrchr(k, '/')) >= 0) {
+ if (!bstr_equals(bstr_splice(k, 0, pos), shadername))
+ continue;
+ k = bstr_cut(k, pos + 1);
+ }
+
+ for (int i = 0; i < hook->num_parameters; i++) {
+ const struct pl_hook_par *hp = &hook->parameters[i];
+ if (!bstr_equals0(k, hp->name) != 0)
+ continue;
+
+ m_option_t opt = {
+ .name = hp->name,
+ };
+
+ switch (hp->type) {
+ case PL_VAR_FLOAT:
+ opt.type = &m_option_type_float;
+ opt.min = hp->minimum.f;
+ opt.max = hp->maximum.f;
+ break;
+ case PL_VAR_SINT:
+ opt.type = &m_option_type_int;
+ opt.min = hp->minimum.i;
+ opt.max = hp->maximum.i;
+ break;
+ case PL_VAR_UINT:
+ opt.type = &m_option_type_int;
+ opt.min = MPMIN(hp->minimum.u, INT_MAX);
+ opt.max = MPMIN(hp->maximum.u, INT_MAX);
+ break;
+ }
+
+ opt.type->parse(p->log, &opt, k, v, hp->data);
+ break;
+ }
+ }
+#endif
+}
+
static void update_render_options(struct vo *vo)
{
struct priv *p = vo->priv;
@@ -1808,8 +1864,10 @@ static void update_render_options(struct vo *vo)
const struct pl_hook *hook;
for (int i = 0; opts->user_shaders && opts->user_shaders[i]; i++) {
- if ((hook = load_hook(p, opts->user_shaders[i])))
+ if ((hook = load_hook(p, opts->user_shaders[i]))) {
MP_TARRAY_APPEND(p, p->hooks, p->params.num_hooks, hook);
+ update_hook_opts(p, opts->user_shader_opts, opts->user_shaders[i], hook);
+ }
}
p->params.hooks = p->hooks;