mirror of https://github.com/mpv-player/mpv
vo_gpu_next: add dynamic hook parameters
Fixes: https://github.com/haasn/libplacebo/issues/230 Fixes: https://github.com/mpv-player/mpv/issues/8206
This commit is contained in:
parent
32bcaf865b
commit
89e608e169
|
@ -913,6 +913,9 @@ static void update_tm_viz(struct pl_color_map_params *params,
|
|||
params->visualize_hue = M_PI / 4.0;
|
||||
}
|
||||
|
||||
static void update_hook_opts_dynamic(struct priv *p, const struct pl_hook *hook,
|
||||
const struct mp_image *mpi);
|
||||
|
||||
static void draw_frame(struct vo *vo, struct vo_frame *frame)
|
||||
{
|
||||
struct priv *p = vo->priv;
|
||||
|
@ -1118,6 +1121,10 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame)
|
|||
// temporary memory that is only valid for this `pl_queue_update`.
|
||||
((uint64_t *) mix.signatures)[i] ^= fp->osd_sync << 48;
|
||||
}
|
||||
|
||||
// Update dynamic hook parameters
|
||||
for (int i = 0; i < pars->params.num_hooks; i++)
|
||||
update_hook_opts_dynamic(p, p->hooks[i], frame->current);
|
||||
}
|
||||
|
||||
// Render frame
|
||||
|
@ -2070,6 +2077,28 @@ static void update_lut(struct priv *p, struct user_lut *lut)
|
|||
talloc_free(lutdata.start);
|
||||
}
|
||||
|
||||
static void update_hook_opts_dynamic(struct priv *p, const struct pl_hook *hook,
|
||||
const struct mp_image *mpi)
|
||||
{
|
||||
const struct { const char *name; double value; } opts[] = {
|
||||
{ "PTS", mpi->pts },
|
||||
};
|
||||
|
||||
for (int i = 0; i < hook->num_parameters; i++) {
|
||||
const struct pl_hook_par *hp = &hook->parameters[i];
|
||||
for (int n = 0; n < MP_ARRAY_SIZE(opts); n++) {
|
||||
if (strcmp(hp->name, opts[n].name) != 0)
|
||||
continue;
|
||||
|
||||
switch (hp->type) {
|
||||
case PL_VAR_FLOAT: hp->data->f = opts[n].value; break;
|
||||
case PL_VAR_SINT: hp->data->i = round(opts[n].value); break;
|
||||
case PL_VAR_UINT: hp->data->u = round(opts[n].value); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void update_hook_opts(struct priv *p, char **opts, const char *shaderpath,
|
||||
const struct pl_hook *hook)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue