From: Anton Khirnov <anton@khirnov.net> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 1/3] fftools/ffmpeg_sched: add filter API to signal EOF on input Date: Wed, 24 Jan 2024 11:46:20 +0100 Message-ID: <20240124104622.24343-1-anton@khirnov.net> (raw) --- fftools/ffmpeg_sched.c | 27 +++++++++++++++++++++++++-- fftools/ffmpeg_sched.h | 7 +++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c index 4fc5a33941..c6ed2e21ff 100644 --- a/fftools/ffmpeg_sched.c +++ b/fftools/ffmpeg_sched.c @@ -226,6 +226,7 @@ typedef struct SchFilterIn { SchedulerNode src; SchedulerNode src_sched; int send_finished; + int receive_finished; } SchFilterIn; typedef struct SchFilterOut { @@ -237,7 +238,8 @@ typedef struct SchFilterGraph { SchFilterIn *inputs; unsigned nb_inputs; - atomic_uint nb_inputs_finished; + atomic_uint nb_inputs_finished_send; + unsigned nb_inputs_finished_receive; SchFilterOut *outputs; unsigned nb_outputs; @@ -1959,7 +1961,7 @@ static int send_to_filter(Scheduler *sch, SchFilterGraph *fg, tq_send_finish(fg->queue, in_idx); // close the control stream when all actual inputs are done - if (atomic_fetch_add(&fg->nb_inputs_finished, 1) == fg->nb_inputs - 1) + if (atomic_fetch_add(&fg->nb_inputs_finished_send, 1) == fg->nb_inputs - 1) tq_send_finish(fg->queue, fg->nb_inputs); } return 0; @@ -2143,6 +2145,27 @@ int sch_filter_receive(Scheduler *sch, unsigned fg_idx, } } +void sch_filter_receive_finish(Scheduler *sch, unsigned fg_idx, unsigned in_idx) +{ + SchFilterGraph *fg; + SchFilterIn *fi; + + av_assert0(fg_idx < sch->nb_filters); + fg = &sch->filters[fg_idx]; + + av_assert0(in_idx < fg->nb_inputs); + fi = &fg->inputs[in_idx]; + + if (!fi->receive_finished) { + fi->receive_finished = 1; + tq_receive_finish(fg->queue, in_idx); + + // close the control stream when all actual inputs are done + if (++fg->nb_inputs_finished_receive == fg->nb_inputs) + tq_receive_finish(fg->queue, fg->nb_inputs); + } +} + int sch_filter_send(Scheduler *sch, unsigned fg_idx, unsigned out_idx, AVFrame *frame) { SchFilterGraph *fg; diff --git a/fftools/ffmpeg_sched.h b/fftools/ffmpeg_sched.h index b167d8d158..811146f6ed 100644 --- a/fftools/ffmpeg_sched.h +++ b/fftools/ffmpeg_sched.h @@ -388,6 +388,13 @@ int sch_dec_send(Scheduler *sch, unsigned dec_idx, struct AVFrame *frame); */ int sch_filter_receive(Scheduler *sch, unsigned fg_idx, unsigned *in_idx, struct AVFrame *frame); +/** + * Called by filter tasks to signal that a filter input will no longer accept input. + * + * @param fg_idx Filtergraph index previously returned from sch_add_filtergraph(). + * @param in_idx Index of the input to finish. + */ +void sch_filter_receive_finish(Scheduler *sch, unsigned fg_idx, unsigned in_idx); /** * Called by filtergraph tasks to send a filtered frame or EOF to consumers. -- 2.42.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2024-01-24 10:46 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-24 10:46 Anton Khirnov [this message] 2024-01-24 10:46 ` [FFmpeg-devel] [PATCH 2/3] fftools/ffmpeg_filter: do not end filtering when a graph input EOFs Anton Khirnov 2024-01-24 10:46 ` [FFmpeg-devel] [PATCH 3/3] tests/fate/ffmpeg: add a test for the issue fixed in previous commit Anton Khirnov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240124104622.24343-1-anton@khirnov.net \ --to=anton@khirnov.net \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git