From d43fd5b3321cc1ece25835e2b44936880ee05328 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Tue, 9 Sep 2025 13:10:53 +0200 Subject: [PATCH] fftools/ffmpeg_sched: close stream when sch_filter_send receives EOF THis is currently done by sch_demux_send() (via demux_stream_send_to_dst()), sch_enc_send() (via enc_send_to_dst()), and sch_dec_send() (via dec_send_to_dst()), but not by sch_filter_send(). Implement the same queue-closing logic for them. The main benefit here is that this will allow them to mark downstream inputs as send-done (in addition to received-done), which is useful for a following commit. --- fftools/ffmpeg_sched.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c index 589f5360f2..dbe337ca16 100644 --- a/fftools/ffmpeg_sched.c +++ b/fftools/ffmpeg_sched.c @@ -2492,6 +2492,7 @@ int sch_filter_send(Scheduler *sch, unsigned fg_idx, unsigned out_idx, AVFrame * { SchFilterGraph *fg; SchedulerNode dst; + int ret; av_assert0(fg_idx < sch->nb_filters); fg = &sch->filters[fg_idx]; @@ -2499,9 +2500,16 @@ int sch_filter_send(Scheduler *sch, unsigned fg_idx, unsigned out_idx, AVFrame * av_assert0(out_idx < fg->nb_outputs); dst = fg->outputs[out_idx].dst; - return (dst.type == SCH_NODE_TYPE_ENC) ? - send_to_enc (sch, &sch->enc[dst.idx], frame) : - send_to_filter(sch, &sch->filters[dst.idx], dst.idx_stream, frame); + if (dst.type == SCH_NODE_TYPE_ENC) { + ret = send_to_enc(sch, &sch->enc[dst.idx], frame); + if (ret == AVERROR_EOF) + send_to_enc(sch, &sch->enc[dst.idx], NULL); + } else { + ret = send_to_filter(sch, &sch->filters[dst.idx], dst.idx_stream, frame); + if (ret == AVERROR_EOF) + send_to_filter(sch, &sch->filters[dst.idx], dst.idx_stream, NULL); + } + return ret; } static int filter_done(Scheduler *sch, unsigned fg_idx)