[FFmpeg-devel] [PATCH 4/8] avfiltergraph: add avfilter_graph_request_oldest().
Nicolas George
nicolas.george at normalesup.org
Fri Apr 20 12:31:43 CEST 2012
Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
libavfilter/avfiltergraph.c | 19 +++++++++++++++++++
libavfilter/avfiltergraph.h | 10 ++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
This is used to trigger movement inside the graph.
If the graph is connected, a request on any link will cause frames to
circulate more or less everywhere, and thus, the actual choice of which link
to request on is not important.
If the graph is not connected, we could request a frame on any component, it
would not have any advert effect on the filtering process. Then we have to
take a guess at what the user wants to do with the frames when they come
out. A common case is to mux them together, and therefore require, more or
less, the frames to be ordered by timestamp. Thus, requesting on the oldest
link is a good guess.
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index b5a8171..cf9c4a0 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -471,3 +471,22 @@ int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const
return 0;
}
+
+int avfilter_graph_request_oldest(AVFilterGraph *graph)
+{
+ while (graph->oldest_sink_link) {
+ AVFilterLink *oldest = graph->oldest_sink_link;
+ int r = avfilter_request_frame(oldest);
+ if (r != AVERROR_EOF)
+ return r;
+ /* EOF: remove the link from the list */
+ if (oldest->next_by_age[1])
+ oldest->next_by_age[1]->next_by_age[0] = oldest->next_by_age[0];
+ if (oldest->next_by_age[0])
+ oldest->next_by_age[0]->next_by_age[1] = oldest->next_by_age[1];
+ else
+ graph->oldest_sink_link = oldest->next_by_age[1];
+ oldest->next_by_age[0] = oldest->next_by_age[1] = NULL;
+ }
+ return AVERROR_EOF;
+}
diff --git a/libavfilter/avfiltergraph.h b/libavfilter/avfiltergraph.h
index ef82da9..fb3d299 100644
--- a/libavfilter/avfiltergraph.h
+++ b/libavfilter/avfiltergraph.h
@@ -230,4 +230,14 @@ int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const
*/
char *avfilter_graph_dump(AVFilterGraph *graph, const char *options);
+/**
+ * Request a frame on the oldest sink link.
+ *
+ * If the request returns AVERROR_EOF, try the next.
+ *
+ * @return the return value of avfilter_request_frame,
+ * or AVERROR_EOF of all links returned AVERROR_EOF.
+ */
+int avfilter_graph_request_oldest(AVFilterGraph *graph);
+
#endif /* AVFILTER_AVFILTERGRAPH_H */
--
1.7.2.5
More information about the ffmpeg-devel
mailing list