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.
This commit is contained in:
Anton Khirnov 2024-04-05 12:10:21 +02:00
parent 243a51490a
commit 3d01996b24
3 changed files with 31 additions and 14 deletions

View File

@ -724,7 +724,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
char *graph_desc, char *graph_desc,
Scheduler *sch, unsigned sch_idx_enc, Scheduler *sch, unsigned sch_idx_enc,
const OutputFilterOptions *opts); 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 * Get our axiliary frame data attached to the frame, allocating it

View File

@ -1272,7 +1272,7 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
return 0; return 0;
} }
int fg_finalise_bindings(FilterGraph *fg) static int bind_inputs(FilterGraph *fg)
{ {
// bind filtergraph inputs to input streams // bind filtergraph inputs to input streams
for (int i = 0; i < fg->nb_inputs; i++) { for (int i = 0; i < fg->nb_inputs; i++) {
@ -1287,14 +1287,33 @@ int fg_finalise_bindings(FilterGraph *fg)
return ret; return ret;
} }
for (int i = 0; i < fg->nb_outputs; i++) { return 0;
OutputFilter *output = fg->outputs[i]; }
if (!output->bound) {
av_log(filtergraphs[i], AV_LOG_FATAL, int fg_finalise_bindings(void)
"Filter %s has an unconnected output\n", output->name); {
return AVERROR(EINVAL); 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; return 0;
} }

View File

@ -1264,12 +1264,10 @@ int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
} }
// bind unbound filtegraph inputs/outputs and check consistency // bind unbound filtegraph inputs/outputs and check consistency
for (int i = 0; i < nb_filtergraphs; i++) { ret = fg_finalise_bindings();
ret = fg_finalise_bindings(filtergraphs[i]); if (ret < 0) {
if (ret < 0) { errmsg = "binding filtergraph inputs/outputs";
errmsg = "binding filtergraph inputs/outputs"; goto fail;
goto fail;
}
} }
correct_input_start_times(); correct_input_start_times();