Hi,

patch attached.
From f4d05fabeffd30ba83b85ca844f6d583f3794bd9 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <one...@gmail.com>
Date: Wed, 17 Feb 2016 12:42:37 +0100
Subject: [PATCH] avfilter: make possible to receive eof when shortest sink
 ends

Signed-off-by: Paul B Mahol <one...@gmail.com>
---
 libavfilter/avfilter.h      |  6 ++++++
 libavfilter/avfiltergraph.c | 10 ++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 04bf585..a53cab0 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -826,6 +826,7 @@ typedef struct AVFilterGraph {
     int sink_links_count;
 
     unsigned disable_auto_convert;
+    int shortest;
 } AVFilterGraph;
 
 /**
@@ -895,6 +896,11 @@ int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *fil
                                  AVFilterGraph *graph_ctx);
 
 /**
+ * Let filter graph ends with shortest filter chain.
+ */
+void avfilter_graph_set_shortest(AVFilterGraph *graph);
+
+/**
  * Enable or disable automatic format conversion inside the graph.
  *
  * Note that format conversion can still happen inside explicitly inserted
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 9f50b41..d430820 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -169,6 +169,11 @@ void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags)
     graph->disable_auto_convert = flags;
 }
 
+void avfilter_graph_set_shortest(AVFilterGraph *graph)
+{
+    graph->shortest = 1;
+}
+
 AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph,
                                              const AVFilter *filter,
                                              const char *name)
@@ -1368,13 +1373,14 @@ void ff_avfilter_graph_update_heap(AVFilterGraph *graph, AVFilterLink *link)
 int avfilter_graph_request_oldest(AVFilterGraph *graph)
 {
     AVFilterLink *oldest = graph->sink_links[0];
-    int r;
+    int r, first_eof = 0;
 
     while (graph->sink_links_count) {
         oldest = graph->sink_links[0];
         r = ff_request_frame(oldest);
         if (r != AVERROR_EOF)
             break;
+        first_eof = 1;
         av_log(oldest->dst, AV_LOG_DEBUG, "EOF on sink link %s:%s.\n",
                oldest->dst ? oldest->dst->name : "unknown",
                oldest->dstpad ? oldest->dstpad->name : "unknown");
@@ -1384,7 +1390,7 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph)
                              oldest->age_index);
         oldest->age_index = -1;
     }
-    if (!graph->sink_links_count)
+    if (!graph->sink_links_count || (graph->shortest && first_eof))
         return AVERROR_EOF;
     av_assert1(oldest->age_index >= 0);
     while (oldest->frame_wanted_out) {
-- 
1.9.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to