diff options
author | wm4 <wm4@nowhere> | 2014-09-18 19:25:46 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-09-18 19:36:27 +0200 |
commit | 580cf433bd3713f1c00a612be2d57d5b959e8496 (patch) | |
tree | 327fedd77fc0c095009201f6a527b70cdf459e70 /video/filter/vf.c | |
parent | 5c8549ac68c1a8a4921e5f0ea842969aa8072a18 (diff) | |
download | mpv-580cf433bd3713f1c00a612be2d57d5b959e8496.tar.bz2 mpv-580cf433bd3713f1c00a612be2d57d5b959e8496.tar.xz |
video/filter: allow better dataflow
Consider a filter which turns 1 frame into 2 frames (such as an
deinterlacer). Until now, we forced filters to produce all output frames
at once. This was done for simplicity.
Change the filter API such that a filter can produce frames
incrementally.
Diffstat (limited to 'video/filter/vf.c')
-rw-r--r-- | video/filter/vf.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/video/filter/vf.c b/video/filter/vf.c index e76d30ea23..f00e9689c6 100644 --- a/video/filter/vf.c +++ b/video/filter/vf.c @@ -379,10 +379,19 @@ void vf_add_output_frame(struct vf_instance *vf, struct mp_image *img) } } +static bool vf_has_output_frame(struct vf_instance *vf) +{ + if (!vf->num_out_queued && vf->filter_out) { + if (vf->filter_out(vf) < 0) + MP_ERR(vf, "Error filtering frame.\n"); + } + return vf->num_out_queued > 0; +} + static struct mp_image *vf_dequeue_output_frame(struct vf_instance *vf) { struct mp_image *res = NULL; - if (vf->num_out_queued) { + if (vf_has_output_frame(vf)) { res = vf->out_queued[0]; MP_TARRAY_REMOVE_AT(vf->out_queued, vf->num_out_queued, 0); } @@ -445,7 +454,7 @@ int vf_output_frame(struct vf_chain *c, bool eof) if (r < 0) return r; } - if (cur->num_out_queued) + if (vf_has_output_frame(cur)) last = cur; } if (!last) |