diff mbox series

[FFmpeg-devel,1/2] lavfi: add ff_inoutlink_check_flow()

Message ID 20220219160137.2806285-1-george@nsup.org
State Accepted
Commit 531d09fb2d6bddb968dbef1fbb8b351aed85cbfa
Headers show
Series [FFmpeg-devel,1/2] lavfi: add ff_inoutlink_check_flow() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Nicolas George Feb. 19, 2022, 4:01 p.m. UTC
Signed-off-by: Nicolas George <george@nsup.org>
---
 libavfilter/avfilter.c | 8 ++++++++
 libavfilter/filters.h  | 8 ++++++++
 2 files changed, 16 insertions(+)

Comments

Paul B Mahol Feb. 19, 2022, 8:52 p.m. UTC | #1
OK for the set.
Nicolas George Feb. 20, 2022, 4:03 p.m. UTC | #2
Paul B Mahol (12022-02-19):
> OK for the set.

Thanks, pushed.

Regards,
diff mbox series

Patch

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 7362bcdab5..1f37a70179 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -1559,6 +1559,14 @@  int ff_outlink_get_status(AVFilterLink *link)
     return link->status_in;
 }
 
+int ff_inoutlink_check_flow(AVFilterLink *inlink, AVFilterLink *outlink)
+{
+    return ff_outlink_frame_wanted(outlink) ||
+           ff_inlink_check_available_frame(inlink) ||
+           inlink->status_out;
+}
+
+
 const AVClass *avfilter_get_class(void)
 {
     return &avfilter_class;
diff --git a/libavfilter/filters.h b/libavfilter/filters.h
index 1157755403..86bc49d459 100644
--- a/libavfilter/filters.h
+++ b/libavfilter/filters.h
@@ -258,4 +258,12 @@  static inline void ff_outlink_set_status(AVFilterLink *link, int status, int64_t
     } \
 } while (0)
 
+/**
+ * Check for flow control between input and output.
+ * This is necessary for filters that may produce several output frames for
+ * a single input event, otherwise they may produce them all at once,
+ * causing excessive memory consumption.
+ */
+int ff_inoutlink_check_flow(AVFilterLink *inlink, AVFilterLink *outlink);
+
 #endif /* AVFILTER_FILTERS_H */