diff mbox

[FFmpeg-devel,16/17] lavfi: do not call ff_filter_frame() with activate.

Message ID 20161224174149.8995-17-george@nsup.org
State Accepted
Commit 32c59a115d3cc757676b5384a5ea44b5a7a7b872
Headers show

Commit Message

Nicolas George Dec. 24, 2016, 5:41 p.m. UTC
avfilter_graph_request_oldest() does work that should be done by
either the filter or the application.

The principle of this function, calling ff_request_frame() from
outside the filter was always shaky. This version is less elegant
since it requires making special cases for each filter, but it
is more robust since it no longer calls ff_request_frame()
directly without notifying the filter.

Eventually, avfilter_graph_request_oldest() will be deprecated
for a function to just run the graph.

Signed-off-by: Nicolas George <george@nsup.org>
---
 libavfilter/avfiltergraph.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox

Patch

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index cb5d618ab1..07586e71be 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -36,6 +36,7 @@ 
 #include "framequeue.h"
 
 #include "avfilter.h"
+#include "buffersink.h"
 #include "formats.h"
 #include "internal.h"
 #include "thread.h"
@@ -1389,6 +1390,11 @@  int avfilter_graph_request_oldest(AVFilterGraph *graph)
 
     while (graph->sink_links_count) {
         oldest = graph->sink_links[0];
+        if (oldest->dst->filter->activate) {
+            /* For now, buffersink is the only filter implementing activate. */
+            return av_buffersink_get_frame_flags(oldest->dst, NULL,
+                                                 AV_BUFFERSINK_FLAG_PEEK);
+        }
         r = ff_request_frame(oldest);
         if (r != AVERROR_EOF)
             break;
@@ -1403,6 +1409,7 @@  int avfilter_graph_request_oldest(AVFilterGraph *graph)
     }
     if (!graph->sink_links_count)
         return AVERROR_EOF;
+    av_assert1(!oldest->dst->filter->activate);
     av_assert1(oldest->age_index >= 0);
     frame_count = oldest->frame_count_out;
     while (frame_count == oldest->frame_count_out) {