aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-04-05 12:10:21 +0200
committerAnton Khirnov <anton@khirnov.net>2024-04-09 10:34:18 +0200
commit3d01996b242ee588bcb27d61d6351439b8849260 (patch)
tree412e971c420ea7c05575f1ce733e7d64885b9a54
parent243a51490a85923c29ea9c276786e7b7d29cff0d (diff)
downloadffmpeg-3d01996b242ee588bcb27d61d6351439b8849260.tar.gz
fftools/ffmpeg_filter: change processing order in fg_finalise_bindings()
First bind all inputs in all filtergraphs, only then check that all outputs are bound. Needed by the following commit.
-rw-r--r--fftools/ffmpeg.h2
-rw-r--r--fftools/ffmpeg_filter.c33
-rw-r--r--fftools/ffmpeg_opt.c10
3 files changed, 31 insertions, 14 deletions
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 882d241bdb..885a7c0c10 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -724,7 +724,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
char *graph_desc,
Scheduler *sch, unsigned sch_idx_enc,
const OutputFilterOptions *opts);
-int fg_finalise_bindings(FilterGraph *fg);
+int fg_finalise_bindings(void);
/**
* Get our axiliary frame data attached to the frame, allocating it
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 388c8919fd..1e14962f41 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1272,7 +1272,7 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
return 0;
}
-int fg_finalise_bindings(FilterGraph *fg)
+static int bind_inputs(FilterGraph *fg)
{
// bind filtergraph inputs to input streams
for (int i = 0; i < fg->nb_inputs; i++) {
@@ -1287,14 +1287,33 @@ int fg_finalise_bindings(FilterGraph *fg)
return ret;
}
- for (int i = 0; i < fg->nb_outputs; i++) {
- OutputFilter *output = fg->outputs[i];
- if (!output->bound) {
- av_log(filtergraphs[i], AV_LOG_FATAL,
- "Filter %s has an unconnected output\n", output->name);
- return AVERROR(EINVAL);
+ return 0;
+}
+
+int fg_finalise_bindings(void)
+{
+ int ret;
+
+ for (int i = 0; i < nb_filtergraphs; i++) {
+ ret = bind_inputs(filtergraphs[i]);
+ if (ret < 0)
+ return ret;
+ }
+
+ // check that all outputs were bound
+ for (int i = 0; i < nb_filtergraphs; i++) {
+ FilterGraph *fg = filtergraphs[i];
+
+ for (int j = 0; j < fg->nb_outputs; j++) {
+ OutputFilter *output = fg->outputs[j];
+ if (!output->bound) {
+ av_log(filtergraphs[j], AV_LOG_FATAL,
+ "Filter %s has an unconnected output\n", output->name);
+ return AVERROR(EINVAL);
+ }
}
}
+
return 0;
}
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index f764da1ed4..6526e8e3e8 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1264,12 +1264,10 @@ int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
}
// bind unbound filtegraph inputs/outputs and check consistency
- for (int i = 0; i < nb_filtergraphs; i++) {
- ret = fg_finalise_bindings(filtergraphs[i]);
- if (ret < 0) {
- errmsg = "binding filtergraph inputs/outputs";
- goto fail;
- }
+ ret = fg_finalise_bindings();
+ if (ret < 0) {
+ errmsg = "binding filtergraph inputs/outputs";
+ goto fail;
}
correct_input_start_times();