diff options
author | wm4 <wm4@nowhere> | 2013-05-22 23:19:57 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-05-23 01:02:24 +0200 |
commit | 3d87ca6b5ef1a25438cf05c685817a9b2d8de19e (patch) | |
tree | 95b72f87a72037ff75d452396db695b84efd48f0 /video | |
parent | b2c2fe7a3782c1c47ba3bee6481b0c2f8d41ef22 (diff) | |
download | mpv-3d87ca6b5ef1a25438cf05c685817a9b2d8de19e.tar.bz2 mpv-3d87ca6b5ef1a25438cf05c685817a9b2d8de19e.tar.xz |
m_option, vf: add label support
Can be used to refer to filters by name. Intended to be used when the
filter chain is changed at runtime.
A label can be assigned to a filter by prefixing it with '@name:', where
'name' is an user-chosen identifier. For example, a filter added with
'-vf-add @label1:gradfun=123' can be removed with '-vf-del @label1'.
If a filter with an already existing label is added, the existing filter
is replaced with the new filter (this happens for both -vf-add and
-vf-pre). If a filter is replaced, the new filter takes the position of
the old filter, instead of being appended/prepended to the filter chain
as usual. For -vf-toggle, labels are compared if at least one of the
filters has a label; otherwise they are compared by filter name and
arguments (like before). This means two filters are never considered
equal if one has a label and the other one does not.
Diffstat (limited to 'video')
-rw-r--r-- | video/filter/vf.c | 15 | ||||
-rw-r--r-- | video/filter/vf.h | 4 |
2 files changed, 18 insertions, 1 deletions
diff --git a/video/filter/vf.c b/video/filter/vf.c index 215bf0dc0e..94df76c0e1 100644 --- a/video/filter/vf.c +++ b/video/filter/vf.c @@ -487,13 +487,26 @@ vf_instance_t *append_filters(vf_instance_t *last, //printf("Open filter %s\n",vf_settings[i].name); vf = vf_open_filter(opts, last, vf_settings[i].name, vf_settings[i].attribs); - if (vf) + if (vf) { + if (vf_settings[i].label) + vf->label = talloc_strdup(vf, vf_settings[i].label); last = vf; + } } } return last; } +vf_instance_t *vf_find_by_label(vf_instance_t *chain, const char *label) +{ + while (chain) { + if (chain->label && label && strcmp(chain->label, label) == 0) + return chain; + chain = chain->next; + } + return NULL; +} + //============================================================================ void vf_uninit_filter(vf_instance_t *vf) diff --git a/video/filter/vf.h b/video/filter/vf.h index 3ff4b5ea87..fd0118e152 100644 --- a/video/filter/vf.h +++ b/video/filter/vf.h @@ -66,6 +66,8 @@ typedef struct vf_instance { void (*uninit)(struct vf_instance *vf); + char *label; + // data: struct vf_format fmt_in, fmt_out; struct vf_instance *next; @@ -133,6 +135,8 @@ struct m_obj_settings; vf_instance_t *append_filters(vf_instance_t *last, struct m_obj_settings *vf_settings); +vf_instance_t *vf_find_by_label(vf_instance_t *chain, const char *label); + void vf_uninit_filter(vf_instance_t *vf); void vf_uninit_filter_chain(vf_instance_t *vf); |