From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id B1A6B4FA35 for ; Tue, 24 Jun 2025 19:25:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 619D968D422; Tue, 24 Jun 2025 22:24:06 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 98FA268D2D2 for ; Tue, 24 Jun 2025 22:24:04 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 55A69E9F05; Tue, 24 Jun 2025 21:21:17 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZB0CcaBEpdcL; Tue, 24 Jun 2025 21:21:16 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D790DEA12E; Tue, 24 Jun 2025 21:21:15 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 24 Jun 2025 21:23:09 +0200 Message-ID: <20250624192318.7430-11-cus@passwd.hu> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250624192318.7430-1-cus@passwd.hu> References: <20250624192318.7430-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/12] fftools/ffmpeg_filter: always reap all available frames before requesting new ones 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 Cc: Marton Balint 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: alfilter_graph_request_oldest() might return EAGAIN and produce a frame on not the oldest sink. Fixes ticket #11597. Fixes excessive frame buffering in #10959. Fixes excessive frame buffering in #11366. Signed-off-by: Marton Balint --- fftools/ffmpeg_filter.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index a0dc4c745e..f6e496158c 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -2669,6 +2669,22 @@ static int read_frames(FilterGraph *fg, FilterGraphThread *fgt, while (fgp->nb_outputs_done < fg->nb_outputs) { int ret; + /* Reap all buffers present in the buffer sinks */ + for (int i = 0; i < fg->nb_outputs; i++) { + OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[i]); + + ret = 0; + while (!ret) { + ret = fg_output_step(ofp, fgt, frame); + if (ret < 0) + return ret; + } + } + + // return after one iteration, so that scheduler can rate-control us + if (did_step && fgp->have_sources) + return 0; + ret = avfilter_graph_request_oldest(fgt->graph); if (ret == AVERROR(EAGAIN)) { fgt->next_in = choose_input(fg, fgt); @@ -2684,21 +2700,6 @@ static int read_frames(FilterGraph *fg, FilterGraphThread *fgt, } fgt->next_in = fg->nb_inputs; - // return after one iteration, so that scheduler can rate-control us - if (did_step && fgp->have_sources) - return 0; - - /* Reap all buffers present in the buffer sinks */ - for (int i = 0; i < fg->nb_outputs; i++) { - OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[i]); - - ret = 0; - while (!ret) { - ret = fg_output_step(ofp, fgt, frame); - if (ret < 0) - return ret; - } - } did_step = 1; } -- 2.43.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".