[FFmpeg-devel] [PATCH 1/4] lavfi: add flush callback.

Nicolas George nicolas.george at normalesup.org
Fri Jun 29 14:41:06 CEST 2012


For sinks, the pull-based flushing can not work,
because sinks have no unified request_frame.

Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 libavfilter/avfilter.c |    9 ++++++---
 libavfilter/avfilter.h |    7 +++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 0474192..019807e 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -320,13 +320,16 @@ void ff_tlog_link(void *ctx, AVFilterLink *link, int end)
 
 int ff_request_frame(AVFilterLink *link)
 {
+    int ret = -1;
     FF_TPRINTF_START(NULL, request_frame); ff_tlog_link(NULL, link, 1);
 
     if (link->srcpad->request_frame)
-        return link->srcpad->request_frame(link);
+        ret = link->srcpad->request_frame(link);
     else if (link->src->inputs[0])
-        return ff_request_frame(link->src->inputs[0]);
-    else return -1;
+        ret = ff_request_frame(link->src->inputs[0]);
+    if (ret == AVERROR_EOF && link->dstpad->flush)
+        ret = link->dstpad->flush(link);
+    return ret;
 }
 
 int ff_poll_frame(AVFilterLink *link)
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index b679635..f35d282 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -352,6 +352,13 @@ struct AVFilterPad {
      * input pads only.
      */
     int needs_fifo;
+
+    /**
+     * Flush callback. A call to this happens when request_frame() on the
+     * link returns AVERROR_EOF. The return value of the callback replaces
+     * the return value of request_frame().
+     */
+    int (*flush)(AVFilterLink *link);
 };
 #endif
 
-- 
1.7.10



More information about the ffmpeg-devel mailing list