0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

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.
This commit is contained in:
wm4 2013-12-07 19:33:38 +01:00
parent 0af9ede546
commit 37fbef2ccb
12 changed files with 27 additions and 32 deletions

View File

@ -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);

View File

@ -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,

View File

@ -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)

View File

@ -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

View File

@ -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",

View File

@ -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)

View File

@ -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)

View File

@ -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;
}
//===========================================================================//

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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;
}
}