vf: minor simplification

Remove the extra vf_chain.output field - there's absolutely no need for
it, because there is always a last filter which will buffer the output.

For some reason, vf_chain.last was never set, which we now need to fix
too.
This commit is contained in:
wm4 2014-11-12 18:51:05 +01:00
parent b244d5d817
commit 509997ec12
2 changed files with 9 additions and 16 deletions

View File

@ -444,7 +444,7 @@ int vf_filter_frame(struct vf_chain *c, struct mp_image *img)
// returns: -1: error, 0: no output, 1: output available // returns: -1: error, 0: no output, 1: output available
int vf_output_frame(struct vf_chain *c, bool eof) int vf_output_frame(struct vf_chain *c, bool eof)
{ {
if (c->output) if (c->last->num_out_queued)
return 1; return 1;
if (c->initialized < 1) if (c->initialized < 1)
return -1; return -1;
@ -463,12 +463,9 @@ int vf_output_frame(struct vf_chain *c, bool eof)
} }
if (!last) if (!last)
return 0; return 0;
struct mp_image *img = vf_dequeue_output_frame(last); if (!last->next)
if (!last->next) { return 1;
c->output = img; int r = vf_do_filter(last->next, vf_dequeue_output_frame(last));
return !!c->output;
}
int r = vf_do_filter(last->next, img);
if (r < 0) if (r < 0)
return r; return r;
} }
@ -476,11 +473,9 @@ int vf_output_frame(struct vf_chain *c, bool eof)
struct mp_image *vf_read_output_frame(struct vf_chain *c) struct mp_image *vf_read_output_frame(struct vf_chain *c)
{ {
if (!c->output) if (!c->last->num_out_queued)
vf_output_frame(c, false); vf_output_frame(c, false);
struct mp_image *res = c->output; return vf_dequeue_output_frame(c->last);
c->output = NULL;
return res;
} }
static void vf_forget_frames(struct vf_instance *vf) static void vf_forget_frames(struct vf_instance *vf)
@ -494,7 +489,6 @@ static void vf_chain_forget_frames(struct vf_chain *c)
{ {
for (struct vf_instance *cur = c->first; cur; cur = cur->next) for (struct vf_instance *cur = c->first; cur; cur = cur->next)
vf_forget_frames(cur); vf_forget_frames(cur);
mp_image_unrefp(&c->output);
} }
void vf_seek_reset(struct vf_chain *c) void vf_seek_reset(struct vf_chain *c)
@ -705,12 +699,13 @@ struct vf_chain *vf_new(struct mpv_global *global)
.query_format = input_query_format, .query_format = input_query_format,
}; };
static const struct vf_info out = { .name = "out" }; static const struct vf_info out = { .name = "out" };
c->first->next = talloc(c, struct vf_instance); c->last = talloc(c, struct vf_instance);
*c->first->next = (struct vf_instance) { *c->last = (struct vf_instance) {
.info = &out, .info = &out,
.query_format = output_query_format, .query_format = output_query_format,
.priv = (void *)c, .priv = (void *)c,
}; };
c->first->next = c->last;
return c; return c;
} }

View File

@ -121,8 +121,6 @@ struct vf_chain {
struct MPOpts *opts; struct MPOpts *opts;
struct mpv_global *global; struct mpv_global *global;
struct mp_hwdec_info *hwdec; struct mp_hwdec_info *hwdec;
struct mp_image *output;
}; };
typedef struct vf_seteq { typedef struct vf_seteq {