Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 01/11] fftools/ffmpeg: merge choose_output() and got_eagain()
@ 2023-05-05  9:07 Anton Khirnov
  2023-05-05  9:07 ` [FFmpeg-devel] [PATCH 02/11] fftools/ffmpeg: eliminate need_output() Anton Khirnov
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Anton Khirnov @ 2023-05-05  9:07 UTC (permalink / raw)
  To: ffmpeg-devel

These two functions are a part of a single logical action - determining
which, if any, output stream needs to be processed next. Keeping them
separate is a historical artifact that obscures what is actually being
done.
---
 fftools/ffmpeg.c | 41 +++++++++++++++++++----------------------
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 27bfc28798..8c1c5b7fec 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1683,9 +1683,11 @@ static int need_output(void)
 /**
  * Select the output stream to process.
  *
- * @return  selected output stream, or NULL if none available
+ * @retval 0 an output stream was selected
+ * @retval AVERROR(EAGAIN) need to wait until more input is available
+ * @retval AVERROR_EOF no more streams need output
  */
-static OutputStream *choose_output(void)
+static int choose_output(OutputStream **post)
 {
     int64_t opts_min = INT64_MAX;
     OutputStream *ost_min = NULL;
@@ -1704,15 +1706,19 @@ static OutputStream *choose_output(void)
                     ost->initialized, ost->inputs_done, ost->finished);
         }
 
-        if (!ost->initialized && !ost->inputs_done && !ost->finished)
-            return ost->unavailable ? NULL : ost;
-
+        if (!ost->initialized && !ost->inputs_done && !ost->finished) {
+            ost_min = ost;
+            break;
+        }
         if (!ost->finished && opts < opts_min) {
             opts_min = opts;
-            ost_min  = ost->unavailable ? NULL : ost;
+            ost_min  = ost;
         }
     }
-    return ost_min;
+    if (!ost_min)
+        return AVERROR_EOF;
+    *post = ost_min;
+    return ost_min->unavailable ? AVERROR(EAGAIN) : 0;
 }
 
 static void set_tty_echo(int on)
@@ -1800,14 +1806,6 @@ static int check_keyboard_interaction(int64_t cur_time)
     return 0;
 }
 
-static int got_eagain(void)
-{
-    for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost))
-        if (ost->unavailable)
-            return 1;
-    return 0;
-}
-
 static void reset_eagain(void)
 {
     int i;
@@ -2052,13 +2050,12 @@ static int transcode_step(void)
     InputStream  *ist = NULL;
     int ret;
 
-    ost = choose_output();
-    if (!ost) {
-        if (got_eagain()) {
-            reset_eagain();
-            av_usleep(10000);
-            return 0;
-        }
+    ret = choose_output(&ost);
+    if (ret == AVERROR(EAGAIN)) {
+        reset_eagain();
+        av_usleep(10000);
+        return 0;
+    } else if (ret < 0) {
         av_log(NULL, AV_LOG_VERBOSE, "No more inputs to read from, finishing.\n");
         return AVERROR_EOF;
     }
-- 
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".

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-05-05  9:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [FFmpeg-devel] [PATCH 09/11] fftools/ffmpeg: move unconfigured graph handling to ffmpeg_filter Anton Khirnov
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

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