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:
parent
0af9ede546
commit
37fbef2ccb
@ -143,10 +143,17 @@ const struct m_obj_list vf_obj_list = {
|
|||||||
.description = "video filters",
|
.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)
|
int vf_control_any(struct vf_chain *c, int cmd, void *arg)
|
||||||
{
|
{
|
||||||
if (c->first)
|
for (struct vf_instance *cur = c->first; cur; cur = cur->next) {
|
||||||
return c->first->control(c->first, cmd, arg);
|
if (cur->control) {
|
||||||
|
int r = cur->control(cur, cmd, arg);
|
||||||
|
if (r != CONTROL_UNKNOWN)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
return CONTROL_UNKNOWN;
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +252,6 @@ static struct vf_instance *vf_open(struct vf_chain *c, const char *name,
|
|||||||
.opts = c->opts,
|
.opts = c->opts,
|
||||||
.hwdec = c->hwdec,
|
.hwdec = c->hwdec,
|
||||||
.config = vf_next_config,
|
.config = vf_next_config,
|
||||||
.control = vf_next_control,
|
|
||||||
.query_format = vf_default_query_format,
|
.query_format = vf_default_query_format,
|
||||||
.filter = vf_default_filter,
|
.filter = vf_default_filter,
|
||||||
.out_pool = talloc_steal(vf, mp_image_pool_new(16)),
|
.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)
|
if (!c->first)
|
||||||
return;
|
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);
|
vf_forget_frames(cur);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vf_reconfig_wrapper(struct vf_instance *vf, const struct mp_image_params *p,
|
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;
|
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)
|
int vf_next_query_format(struct vf_instance *vf, unsigned int fmt)
|
||||||
{
|
{
|
||||||
return vf->next->query_format(vf->next, fmt);
|
return vf->next->query_format(vf->next, fmt);
|
||||||
|
@ -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 vf_next_config(struct vf_instance *vf,
|
||||||
int width, int height, int d_width, int d_height,
|
int width, int height, int d_width, int d_height,
|
||||||
unsigned int flags, unsigned int outfmt);
|
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_query_format(struct vf_instance *vf, unsigned int fmt);
|
||||||
|
|
||||||
int vf_next_reconfig(struct vf_instance *vf, struct mp_image_params *params,
|
int vf_next_reconfig(struct vf_instance *vf, struct mp_image_params *params,
|
||||||
|
@ -599,9 +599,9 @@ static int control(vf_instance_t *vf, int request, void *data)
|
|||||||
switch (request) {
|
switch (request) {
|
||||||
case VFCTRL_SEEK_RESET:
|
case VFCTRL_SEEK_RESET:
|
||||||
vf_detc_init_pts_buf(&vf->priv->ptsbuf);
|
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)
|
static int vf_open(vf_instance_t *vf)
|
||||||
|
@ -428,7 +428,7 @@ int control (vf_instance_t *vf, int request, void *data)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return vf_next_control (vf, request, data);
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -137,10 +137,6 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
|
|||||||
return dmpi;
|
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)
|
static int query_format(struct vf_instance *vf, unsigned int fmt)
|
||||||
{
|
{
|
||||||
if (!IMGFMT_IS_HWACCEL(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){
|
static int vf_open(vf_instance_t *vf){
|
||||||
vf->config=config;
|
vf->config=config;
|
||||||
vf->control=control;
|
|
||||||
vf->query_format=query_format;
|
vf->query_format=query_format;
|
||||||
vf->filter=filter;
|
vf->filter=filter;
|
||||||
mp_msg(MSGT_VFILTER, MSGL_INFO, "Expand: %d x %d, %d ; %d, aspect: %f, round: %d\n",
|
mp_msg(MSGT_VFILTER, MSGL_INFO, "Expand: %d x %d, %d ; %d, aspect: %f, round: %d\n",
|
||||||
|
@ -316,9 +316,9 @@ static int control(vf_instance_t *vf, int request, void *data)
|
|||||||
switch (request) {
|
switch (request) {
|
||||||
case VFCTRL_SEEK_RESET:
|
case VFCTRL_SEEK_RESET:
|
||||||
reset(vf);
|
reset(vf);
|
||||||
break;
|
return CONTROL_OK;
|
||||||
}
|
}
|
||||||
return vf_next_control(vf, request, data);
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uninit(struct vf_instance *vf)
|
static void uninit(struct vf_instance *vf)
|
||||||
|
@ -269,9 +269,9 @@ static int control(vf_instance_t *vf, int request, void *data)
|
|||||||
switch (request) {
|
switch (request) {
|
||||||
case VFCTRL_SEEK_RESET:
|
case VFCTRL_SEEK_RESET:
|
||||||
reset(vf);
|
reset(vf);
|
||||||
break;
|
return CONTROL_OK;
|
||||||
}
|
}
|
||||||
return vf_next_control(vf, request, data);
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vf_open(vf_instance_t *vf)
|
static int vf_open(vf_instance_t *vf)
|
||||||
|
@ -364,11 +364,9 @@ static int control(struct vf_instance *vf, int request, void *data)
|
|||||||
if (mp_sws_set_vf_equalizer(sws, data) < 1)
|
if (mp_sws_set_vf_equalizer(sws, data) < 1)
|
||||||
break;
|
break;
|
||||||
return CONTROL_TRUE;
|
return CONTROL_TRUE;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return vf_next_control(vf, request, data);
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================//
|
//===========================================================================//
|
||||||
|
@ -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);
|
args->out_image = mp_image_new_ref(vf->priv->current);
|
||||||
return CONTROL_TRUE;
|
return CONTROL_TRUE;
|
||||||
}
|
}
|
||||||
return vf_next_control (vf, request, data);
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int query_format(struct vf_instance *vf, unsigned int fmt)
|
static int query_format(struct vf_instance *vf, unsigned int fmt)
|
||||||
|
@ -121,9 +121,9 @@ static int control(vf_instance_t *vf, int request, void *data)
|
|||||||
switch (request) {
|
switch (request) {
|
||||||
case VFCTRL_SEEK_RESET:
|
case VFCTRL_SEEK_RESET:
|
||||||
vf_detc_init_pts_buf(&vf->priv->ptsbuf);
|
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)
|
static void uninit(struct vf_instance *vf)
|
||||||
|
@ -120,11 +120,11 @@ static int control(vf_instance_t *vf, int request, void *data)
|
|||||||
switch (request) {
|
switch (request) {
|
||||||
case VFCTRL_SET_OSD_OBJ:
|
case VFCTRL_SET_OSD_OBJ:
|
||||||
vf->priv->osd = data;
|
vf->priv->osd = data;
|
||||||
break;
|
return CONTROL_TRUE;
|
||||||
case VFCTRL_INIT_OSD:
|
case VFCTRL_INIT_OSD:
|
||||||
return CONTROL_TRUE;
|
return CONTROL_TRUE;
|
||||||
}
|
}
|
||||||
return vf_next_control(vf, request, data);
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vf_open(vf_instance_t *vf)
|
static int vf_open(vf_instance_t *vf)
|
||||||
|
@ -284,7 +284,7 @@ static int control(struct vf_instance *vf, int request, void* data)
|
|||||||
p->do_deint = *(int*)data;
|
p->do_deint = *(int*)data;
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return vf_next_control (vf, request, data);
|
return CONTROL_UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user