From 37fbef2ccb3c828dd41f6e15ccf635e697e4011f Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 7 Dec 2013 19:33:38 +0100 Subject: video/filter: make vf->control non-recursive Reason: I never liked it being recursive. Generally, this seems to cause more problems than trouble, and is less flexible for access outside of the chain. --- video/filter/vf.c | 23 +++++++++++++---------- video/filter/vf.h | 1 - video/filter/vf_divtc.c | 4 ++-- video/filter/vf_eq.c | 2 +- video/filter/vf_expand.c | 5 ----- video/filter/vf_lavfi.c | 4 ++-- video/filter/vf_pullup.c | 4 ++-- video/filter/vf_scale.c | 4 +--- video/filter/vf_screenshot.c | 2 +- video/filter/vf_softpulldown.c | 4 ++-- video/filter/vf_sub.c | 4 ++-- video/filter/vf_vavpp.c | 2 +- 12 files changed, 27 insertions(+), 32 deletions(-) diff --git a/video/filter/vf.c b/video/filter/vf.c index 712bacbf6b..a548bafbbb 100644 --- a/video/filter/vf.c +++ b/video/filter/vf.c @@ -143,10 +143,17 @@ const struct m_obj_list vf_obj_list = { .description = "video filters", }; +// Try the cmd on each filter (starting with the first), and stop at the first +// filter which does not return CONTROL_UNKNOWN for it. int vf_control_any(struct vf_chain *c, int cmd, void *arg) { - if (c->first) - return c->first->control(c->first, cmd, arg); + for (struct vf_instance *cur = c->first; cur; cur = cur->next) { + if (cur->control) { + int r = cur->control(cur, cmd, arg); + if (r != CONTROL_UNKNOWN) + return r; + } + } return CONTROL_UNKNOWN; } @@ -245,7 +252,6 @@ static struct vf_instance *vf_open(struct vf_chain *c, const char *name, .opts = c->opts, .hwdec = c->hwdec, .config = vf_next_config, - .control = vf_next_control, .query_format = vf_default_query_format, .filter = vf_default_filter, .out_pool = talloc_steal(vf, mp_image_pool_new(16)), @@ -391,9 +397,11 @@ void vf_seek_reset(struct vf_chain *c) { if (!c->first) return; - c->first->control(c->first, VFCTRL_SEEK_RESET, NULL); - for (struct vf_instance *cur = c->first; cur; cur = cur->next) + for (struct vf_instance *cur = c->first; cur; cur = cur->next) { + if (cur->control) + cur->control(cur, VFCTRL_SEEK_RESET, NULL); vf_forget_frames(cur); + } } static int vf_reconfig_wrapper(struct vf_instance *vf, const struct mp_image_params *p, @@ -468,11 +476,6 @@ int vf_next_config(struct vf_instance *vf, return r < 0 ? 0 : 1; } -int vf_next_control(struct vf_instance *vf, int request, void *data) -{ - return vf->next->control(vf->next, request, data); -} - int vf_next_query_format(struct vf_instance *vf, unsigned int fmt) { return vf->next->query_format(vf->next, fmt); diff --git a/video/filter/vf.h b/video/filter/vf.h index c241f1c329..ebe7637c0e 100644 --- a/video/filter/vf.h +++ b/video/filter/vf.h @@ -136,7 +136,6 @@ void vf_add_output_frame(struct vf_instance *vf, struct mp_image *img); int vf_next_config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt); -int vf_next_control(struct vf_instance *vf, int request, void *data); int vf_next_query_format(struct vf_instance *vf, unsigned int fmt); int vf_next_reconfig(struct vf_instance *vf, struct mp_image_params *params, diff --git a/video/filter/vf_divtc.c b/video/filter/vf_divtc.c index 87fcd8d049..c471d4a774 100644 --- a/video/filter/vf_divtc.c +++ b/video/filter/vf_divtc.c @@ -599,9 +599,9 @@ static int control(vf_instance_t *vf, int request, void *data) switch (request) { case VFCTRL_SEEK_RESET: vf_detc_init_pts_buf(&vf->priv->ptsbuf); - break; + return CONTROL_OK; } - return vf_next_control(vf, request, data); + return CONTROL_UNKNOWN; } static int vf_open(vf_instance_t *vf) diff --git a/video/filter/vf_eq.c b/video/filter/vf_eq.c index a8341a64a0..e423b301ff 100644 --- a/video/filter/vf_eq.c +++ b/video/filter/vf_eq.c @@ -428,7 +428,7 @@ int control (vf_instance_t *vf, int request, void *data) break; } - return vf_next_control (vf, request, data); + return CONTROL_UNKNOWN; } static diff --git a/video/filter/vf_expand.c b/video/filter/vf_expand.c index d336cf3d91..2e72f6bff7 100644 --- a/video/filter/vf_expand.c +++ b/video/filter/vf_expand.c @@ -137,10 +137,6 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi) return dmpi; } -static int control(struct vf_instance *vf, int request, void* data){ - return vf_next_control(vf,request,data); -} - static int query_format(struct vf_instance *vf, unsigned int fmt) { if (!IMGFMT_IS_HWACCEL(fmt)) @@ -150,7 +146,6 @@ static int query_format(struct vf_instance *vf, unsigned int fmt) static int vf_open(vf_instance_t *vf){ vf->config=config; - vf->control=control; vf->query_format=query_format; vf->filter=filter; mp_msg(MSGT_VFILTER, MSGL_INFO, "Expand: %d x %d, %d ; %d, aspect: %f, round: %d\n", diff --git a/video/filter/vf_lavfi.c b/video/filter/vf_lavfi.c index 13f7aa3867..47701ed1f9 100644 --- a/video/filter/vf_lavfi.c +++ b/video/filter/vf_lavfi.c @@ -316,9 +316,9 @@ static int control(vf_instance_t *vf, int request, void *data) switch (request) { case VFCTRL_SEEK_RESET: reset(vf); - break; + return CONTROL_OK; } - return vf_next_control(vf, request, data); + return CONTROL_UNKNOWN; } static void uninit(struct vf_instance *vf) diff --git a/video/filter/vf_pullup.c b/video/filter/vf_pullup.c index 8745e61519..36fac55cc5 100644 --- a/video/filter/vf_pullup.c +++ b/video/filter/vf_pullup.c @@ -269,9 +269,9 @@ static int control(vf_instance_t *vf, int request, void *data) switch (request) { case VFCTRL_SEEK_RESET: reset(vf); - break; + return CONTROL_OK; } - return vf_next_control(vf, request, data); + return CONTROL_UNKNOWN; } static int vf_open(vf_instance_t *vf) diff --git a/video/filter/vf_scale.c b/video/filter/vf_scale.c index d57ea07df7..c466c5d39a 100644 --- a/video/filter/vf_scale.c +++ b/video/filter/vf_scale.c @@ -364,11 +364,9 @@ static int control(struct vf_instance *vf, int request, void *data) if (mp_sws_set_vf_equalizer(sws, data) < 1) break; return CONTROL_TRUE; - default: - break; } - return vf_next_control(vf, request, data); + return CONTROL_UNKNOWN; } //===========================================================================// diff --git a/video/filter/vf_screenshot.c b/video/filter/vf_screenshot.c index d0e98f07b8..d60271acc4 100644 --- a/video/filter/vf_screenshot.c +++ b/video/filter/vf_screenshot.c @@ -50,7 +50,7 @@ static int control (vf_instance_t *vf, int request, void *data) args->out_image = mp_image_new_ref(vf->priv->current); return CONTROL_TRUE; } - return vf_next_control (vf, request, data); + return CONTROL_UNKNOWN; } static int query_format(struct vf_instance *vf, unsigned int fmt) diff --git a/video/filter/vf_softpulldown.c b/video/filter/vf_softpulldown.c index 4ad0e66552..4e713bd47f 100644 --- a/video/filter/vf_softpulldown.c +++ b/video/filter/vf_softpulldown.c @@ -121,9 +121,9 @@ static int control(vf_instance_t *vf, int request, void *data) switch (request) { case VFCTRL_SEEK_RESET: vf_detc_init_pts_buf(&vf->priv->ptsbuf); - break; + return CONTROL_OK; } - return vf_next_control(vf, request, data); + return CONTROL_UNKNOWN; } static void uninit(struct vf_instance *vf) diff --git a/video/filter/vf_sub.c b/video/filter/vf_sub.c index 34f22e02ce..bd2ab88fd0 100644 --- a/video/filter/vf_sub.c +++ b/video/filter/vf_sub.c @@ -120,11 +120,11 @@ static int control(vf_instance_t *vf, int request, void *data) switch (request) { case VFCTRL_SET_OSD_OBJ: vf->priv->osd = data; - break; + return CONTROL_TRUE; case VFCTRL_INIT_OSD: return CONTROL_TRUE; } - return vf_next_control(vf, request, data); + return CONTROL_UNKNOWN; } static int vf_open(vf_instance_t *vf) diff --git a/video/filter/vf_vavpp.c b/video/filter/vf_vavpp.c index 1a8a974e11..94666c13bd 100644 --- a/video/filter/vf_vavpp.c +++ b/video/filter/vf_vavpp.c @@ -284,7 +284,7 @@ static int control(struct vf_instance *vf, int request, void* data) p->do_deint = *(int*)data; return true; default: - return vf_next_control (vf, request, data); + return CONTROL_UNKNOWN; } } -- cgit v1.2.3