aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_filter.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-02-21 15:28:01 +0100
committerAnton Khirnov <anton@khirnov.net>2024-03-13 08:01:15 +0100
commit7b51523f12dca2339683a4ec244b3bfd6029196e (patch)
tree047d6000ee804f6b3c59225f7c8f9c11c71fb606 /fftools/ffmpeg_filter.c
parentc4de5778bceab3c15f1239f1f16816749a7fd3b6 (diff)
downloadffmpeg-7b51523f12dca2339683a4ec244b3bfd6029196e.tar.gz
fftools/ffmpeg_opt: merge init_complex_filters() and check_filter_outputs()
The first of these binds inputs of complex filtergraphs to demuxer streams (with a misleading comment claiming it *creates* complex filtergraphs). The second ensures that all filtergraph outputs are connected to an encoder. Merge them into a single function, which simplifies the ffmpeg_filter API, is shorter, and will also be useful in following commits. Also, rename misleadingly-named init_input_filter() to fg_complex_bind_input().
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r--fftools/ffmpeg_filter.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 28d287a627..44e84c2043 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1096,7 +1096,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
return 0;
}
-static int init_input_filter(FilterGraph *fg, InputFilter *ifilter)
+static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
{
FilterGraphPriv *fgp = fgp_from_fg(fg);
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
@@ -1162,14 +1162,29 @@ static int init_input_filter(FilterGraph *fg, InputFilter *ifilter)
return 0;
}
-int init_complex_filtergraph(FilterGraph *fg)
+int fg_finalise_bindings(FilterGraph *fg)
{
// bind filtergraph inputs to input streams
for (int i = 0; i < fg->nb_inputs; i++) {
- int ret = init_input_filter(fg, fg->inputs[i]);
+ InputFilterPriv *ifp = ifp_from_ifilter(fg->inputs[i]);
+ int ret;
+
+ if (ifp->bound)
+ continue;
+
+ ret = fg_complex_bind_input(fg, &ifp->ifilter);
if (ret < 0)
return ret;
}
+
+ for (int i = 0; i < fg->nb_outputs; i++) {
+ OutputFilter *output = fg->outputs[i];
+ if (!output->ost) {
+ av_log(filtergraphs[i], AV_LOG_FATAL,
+ "Filter %s has an unconnected output\n", output->name);
+ return AVERROR(EINVAL);
+ }
+ }
return 0;
}
@@ -1436,23 +1451,6 @@ static int configure_output_filter(FilterGraph *fg, AVFilterGraph *graph,
}
}
-int check_filter_outputs(void)
-{
- for (int i = 0; i < nb_filtergraphs; i++) {
- int n;
- for (n = 0; n < filtergraphs[i]->nb_outputs; n++) {
- OutputFilter *output = filtergraphs[i]->outputs[n];
- if (!output->ost) {
- av_log(filtergraphs[i], AV_LOG_FATAL,
- "Filter %s has an unconnected output\n", output->name);
- return AVERROR(EINVAL);
- }
- }
- }
-
- return 0;
-}
-
static void sub2video_prepare(InputFilterPriv *ifp)
{
ifp->sub2video.last_pts = INT64_MIN;