From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 09/11] fftools/ffmpeg: move unconfigured graph handling to ffmpeg_filter
Date: Fri, 5 May 2023 11:07:21 +0200
Message-ID: <20230505090723.24872-9-anton@khirnov.net> (raw)
In-Reply-To: <20230505090723.24872-1-anton@khirnov.net>
This code more properly belongs there.
---
fftools/ffmpeg.c | 25 +------------------------
fftools/ffmpeg_filter.c | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 38569c60a4..1ae9445b5d 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -2018,34 +2018,11 @@ static int transcode_step(OutputStream *ost)
InputStream *ist = NULL;
int ret;
- if (ost->filter && !ost->filter->graph->graph) {
- if (ifilter_has_all_input_formats(ost->filter->graph)) {
- ret = configure_filtergraph(ost->filter->graph);
- if (ret < 0) {
- av_log(NULL, AV_LOG_ERROR, "Error reinitializing filters!\n");
- return ret;
- }
- }
- }
-
- if (ost->filter && ost->filter->graph->graph) {
+ if (ost->filter) {
if ((ret = fg_transcode_step(ost->filter->graph, &ist)) < 0)
return ret;
if (!ist)
return 0;
- } else if (ost->filter) {
- int i;
- for (i = 0; i < ost->filter->graph->nb_inputs; i++) {
- InputFilter *ifilter = ost->filter->graph->inputs[i];
- if (!ifilter->ist->got_output && !input_files[ifilter->ist->file_index]->eof_reached) {
- ist = ifilter->ist;
- break;
- }
- }
- if (!ist) {
- ost->inputs_done = 1;
- return 0;
- }
} else {
ist = ost->ist;
av_assert0(ist);
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 0165be8f77..634315fa34 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1623,6 +1623,33 @@ int fg_transcode_step(FilterGraph *graph, InputStream **best_ist)
InputFilter *ifilter;
InputStream *ist;
+ if (!graph->graph && ifilter_has_all_input_formats(graph)) {
+ // graph has not been configured yet, but everything is ready;
+ // this can happen for graphs with no inputs, or when some input
+ // EOF'ed with zero frames and fallback parameters were used
+ ret = configure_filtergraph(graph);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_ERROR, "Error reinitializing filters!\n");
+ return ret;
+ }
+ }
+
+ if (!graph->graph) {
+ for (int i = 0; i < graph->nb_inputs; i++) {
+ InputFilter *ifilter = graph->inputs[i];
+ if (!ifilter->ist->got_output && !input_files[ifilter->ist->file_index]->eof_reached) {
+ *best_ist = ifilter->ist;
+ return 0;
+ }
+ }
+
+ // graph not configured, but all inputs are either initialized or EOF
+ for (int i = 0; i < graph->nb_outputs; i++)
+ graph->outputs[i]->ost->inputs_done = 1;
+
+ return 0;
+ }
+
*best_ist = NULL;
ret = avfilter_graph_request_oldest(graph->graph);
if (ret >= 0)
--
2.39.2
_______________________________________________
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 prev parent reply other threads:[~2023-05-05 9:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-05 9:07 [FFmpeg-devel] [PATCH 01/11] fftools/ffmpeg: merge choose_output() and got_eagain() Anton Khirnov
2023-05-05 9:07 ` [FFmpeg-devel] [PATCH 02/11] fftools/ffmpeg: eliminate need_output() Anton Khirnov
2023-05-05 9:07 ` [FFmpeg-devel] [PATCH 03/11] fftools/ffmpeg_enc: stop configuring filter inputs from encoder flush Anton Khirnov
2023-05-05 9:07 ` [FFmpeg-devel] [PATCH 04/11] fftools/ffmpeg_filter: take fallback parameters from decoder, not demuxer Anton Khirnov
2023-05-05 9:07 ` [FFmpeg-devel] [PATCH 05/11] fftools/ffmpeg_filter: move InputFilter.eof to private data Anton Khirnov
2023-05-05 9:07 ` [FFmpeg-devel] [PATCH 06/11] fftools/ffmpeg_filter: move InputFilter.displaymatrix " Anton Khirnov
2023-05-05 9:07 ` [FFmpeg-devel] [PATCH 07/11] fftools/ffmpeg_filter: move InputFilter.hw_frames_ctx " Anton Khirnov
2023-05-05 9:07 ` [FFmpeg-devel] [PATCH 08/11] fftools/ffmpeg_filter: use av_buffer_replace() to improve code Anton Khirnov
2023-05-05 9:07 ` Anton Khirnov [this message]
2023-05-05 9:07 ` [FFmpeg-devel] [PATCH 10/11] fftools/ffmpeg_filter: use InputFilterPriv.eof instead of InputFile.eof_reached Anton Khirnov
2023-05-05 9:07 ` [FFmpeg-devel] [PATCH 11/11] fftools/ffmpeg: discard packets for unused streams in demuxing thread 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=20230505090723.24872-9-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