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 647CE460C5 for ; Fri, 5 May 2023 09:08:48 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BE81F68C163; Fri, 5 May 2023 12:07:45 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 986D068C12A for ; Fri, 5 May 2023 12:07:36 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 599152405B5 for ; Fri, 5 May 2023 11:07:33 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Bu1dUxUN8Rhc for ; Fri, 5 May 2023 11:07:32 +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 194C92405EC for ; Fri, 5 May 2023 11:07:30 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 0BB8F3A11B4 for ; Fri, 5 May 2023 11:07:30 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 May 2023 11:07:21 +0200 Message-Id: <20230505090723.24872-9-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 09/11] fftools/ffmpeg: move unconfigured graph handling to ffmpeg_filter 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: 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".