diff options
author | Nicolas George <george@nsup.org> | 2017-08-31 17:05:04 +0200 |
---|---|---|
committer | Nicolas George <george@nsup.org> | 2017-09-12 11:03:50 +0200 |
commit | 76613618d978f9dbee0f391a85a732f77fac75cd (patch) | |
tree | d4f59210504aee87dd2d1dd30c7f96d0cacbe21f /libavfilter/filters.h | |
parent | e952d4b7ace607132130599905c75f25aaea9e56 (diff) | |
download | ffmpeg-76613618d978f9dbee0f391a85a732f77fac75cd.tar.gz |
lavfi: add helper functions and macros for activate.
Diffstat (limited to 'libavfilter/filters.h')
-rw-r--r-- | libavfilter/filters.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/libavfilter/filters.h b/libavfilter/filters.h index 1cbc18158f..4e2652ebe5 100644 --- a/libavfilter/filters.h +++ b/libavfilter/filters.h @@ -141,6 +141,12 @@ int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts void ff_inlink_request_frame(AVFilterLink *link); /** + * Set the status on an input link. + * Also discard all frames in the link's FIFO. + */ +void ff_inlink_set_status(AVFilterLink *link, int status); + +/** * Test if a frame is wanted on an output link. */ static inline int ff_outlink_frame_wanted(AVFilterLink *link) @@ -149,6 +155,11 @@ static inline int ff_outlink_frame_wanted(AVFilterLink *link) } /** + * Get the status on an output link. + */ +int ff_outlink_get_status(AVFilterLink *link); + +/** * Set the status field of a link from the source filter. * The pts should reflect the timestamp of the status change, * in link time base and relative to the frames timeline. @@ -160,4 +171,71 @@ static inline void ff_outlink_set_status(AVFilterLink *link, int status, int64_t ff_avfilter_link_set_in_status(link, status, pts); } +/** + * Forward the status on an output link to an input link. + * If the status is set, it will discard all queued frames and this macro + * will return immediately. + */ +#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink) do { \ + int ret = ff_outlink_get_status(outlink); \ + if (ret) { \ + ff_inlink_set_status(inlink, ret); \ + return 0; \ + } \ +} while (0) + +/** + * Forward the status on an output link to all input links. + * If the status is set, it will discard all queued frames and this macro + * will return immediately. + */ +#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter) do { \ + int ret = ff_outlink_get_status(outlink); \ + if (ret) { \ + unsigned i; \ + for (i = 0; i < filter->nb_inputs; i++) \ + ff_inlink_set_status(filter->inputs[i], ret); \ + return 0; \ + } \ +} while (0) + +/** + * Acknowledge the status on an input link and forward it to an output link. + * If the status is set, this macro will return immediately. + */ +#define FF_FILTER_FORWARD_STATUS(inlink, outlink) do { \ + int status; \ + int64_t pts; \ + if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { \ + ff_outlink_set_status(outlink, status, pts); \ + return 0; \ + } \ +} while (0) + +/** + * Acknowledge the status on an input link and forward it to an output link. + * If the status is set, this macro will return immediately. + */ +#define FF_FILTER_FORWARD_STATUS_ALL(inlink, filter) do { \ + int status; \ + int64_t pts; \ + if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { \ + unsigned i; \ + for (i = 0; i < filter->nb_outputs; i++) \ + ff_outlink_set_status(filter->outputs[i], status, pts); \ + return 0; \ + } \ +} while (0) + +/** + * Forward the frame_wanted_out flag from an output link to an input link. + * If the flag is set, this macro will return immediately. + */ +#define FF_FILTER_FORWARD_WANTED(outlink, inlink) do { \ + if (ff_outlink_frame_wanted(outlink)) { \ + ff_inlink_request_frame(inlink); \ + return 0; \ + } \ +} while (0) + #endif /* AVFILTER_FILTERS_H */ |