From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 1847A44204 for ; Fri, 5 May 2023 09:08:03 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 701D768BF65; Fri, 5 May 2023 12:07:40 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C3C0468AB4A for ; Fri, 5 May 2023 12:07:31 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 8A6A92404EE for ; Fri, 5 May 2023 11:07:31 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ZsgvxcOMqUj6 for ; Fri, 5 May 2023 11:07:29 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id E52FF240177 for ; Fri, 5 May 2023 11:07:29 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id B17A03A048F for ; Fri, 5 May 2023 11:07:29 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 May 2023 11:07:14 +0200 Message-Id: <20230505090723.24872-2-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230505090723.24872-1-anton@khirnov.net> References: <20230505090723.24872-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/11] fftools/ffmpeg: eliminate need_output() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Replace it by simply calling choose_output() earlier. --- fftools/ffmpeg.c | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 8c1c5b7fec..983573b991 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1667,19 +1667,6 @@ static int transcode_init(void) return 0; } -/* Return 1 if there remain streams where more output is wanted, 0 otherwise. */ -static int need_output(void) -{ - for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) { - if (ost->finished) - continue; - - return 1; - } - - return 0; -} - /** * Select the output stream to process. * @@ -2044,22 +2031,11 @@ discard_packet: * * @return 0 for success, <0 for error */ -static int transcode_step(void) +static int transcode_step(OutputStream *ost) { - OutputStream *ost; InputStream *ist = NULL; int ret; - 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; - } - if (ost->filter && !ost->filter->graph->graph) { if (ifilter_has_all_input_formats(ost->filter->graph)) { ret = configure_filtergraph(ost->filter->graph); @@ -2126,6 +2102,7 @@ static int transcode(void) timer_start = av_gettime_relative(); while (!received_sigterm) { + OutputStream *ost; int64_t cur_time= av_gettime_relative(); /* if 'q' pressed, exits */ @@ -2133,13 +2110,18 @@ static int transcode(void) if (check_keyboard_interaction(cur_time) < 0) break; - /* check if there's any stream where output is still needed */ - if (!need_output()) { + ret = choose_output(&ost); + if (ret == AVERROR(EAGAIN)) { + reset_eagain(); + av_usleep(10000); + continue; + } else if (ret < 0) { av_log(NULL, AV_LOG_VERBOSE, "No more output streams to write to, finishing.\n"); + ret = 0; break; } - ret = transcode_step(); + ret = transcode_step(ost); if (ret < 0 && ret != AVERROR_EOF) { av_log(NULL, AV_LOG_ERROR, "Error while filtering: %s\n", av_err2str(ret)); break; -- 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".