aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_filter.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-11-23 11:22:57 +0100
committerAnton Khirnov <anton@khirnov.net>2021-12-04 14:08:17 +0100
commitab3ef54c8c6a47576a07ecdaacbc0b0096374f4a (patch)
tree93ac5198dd958a20ed7c41e26a414b333e2a8422 /fftools/ffmpeg_filter.c
parent425889396137451ae30288c84122e28532b71596 (diff)
downloadffmpeg-ab3ef54c8c6a47576a07ecdaacbc0b0096374f4a.tar.gz
ffmpeg: only copy bits_per_sample from decoder when it remains valid
I.e. when the only filters that are applied do not modify the frame data.
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r--fftools/ffmpeg_filter.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index dab0f28819..22bfdc572d 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -960,6 +960,30 @@ static void cleanup_filtergraph(FilterGraph *fg)
avfilter_graph_free(&fg->graph);
}
+static int filter_is_buffersrc(const AVFilterContext *f)
+{
+ return f->nb_inputs == 0 &&
+ (!strcmp(f->filter->name, "buffersrc") ||
+ !strcmp(f->filter->name, "abuffersrc"));
+}
+
+static int graph_is_meta(AVFilterGraph *graph)
+{
+ for (unsigned i = 0; i < graph->nb_filters; i++) {
+ const AVFilterContext *f = graph->filters[i];
+
+ /* in addition to filters flagged as meta, also
+ * disregard sinks and buffersources (but not other sources,
+ * since they introduce data we are not aware of)
+ */
+ if (!((f->filter->flags & AVFILTER_FLAG_METADATA_ONLY) ||
+ f->nb_outputs == 0 ||
+ filter_is_buffersrc(f)))
+ return 0;
+ }
+ return 1;
+}
+
int configure_filtergraph(FilterGraph *fg)
{
AVFilterInOut *inputs, *outputs, *cur;
@@ -1060,6 +1084,8 @@ int configure_filtergraph(FilterGraph *fg)
if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
goto fail;
+ fg->is_meta = graph_is_meta(fg->graph);
+
/* limit the lists of allowed formats to the ones selected, to
* make sure they stay the same if the filtergraph is reconfigured later */
for (i = 0; i < fg->nb_outputs; i++) {