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 1B8A74FA35 for ; Tue, 24 Jun 2025 19:23:35 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id B679768D232; Tue, 24 Jun 2025 22:23:31 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 7AE6B68CF6C for ; Tue, 24 Jun 2025 22:23:25 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 7E85AE9EF1; Tue, 24 Jun 2025 21:20:36 +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 1xvFv1nWKIKe; Tue, 24 Jun 2025 21:20:34 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 949C7E9E73; Tue, 24 Jun 2025 21:20:34 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 24 Jun 2025 21:22:59 +0200 Message-ID: <20250624192318.7430-1-cus@passwd.hu> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/12] avfilter: factorize requesting an input frame from multi output filters 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: Signed-off-by: Marton Balint --- doc/filter_design.txt | 1 + libavfilter/af_acrossover.c | 10 +--------- libavfilter/af_channelsplit.c | 10 +--------- libavfilter/filters.h | 15 +++++++++++++++ libavfilter/split.c | 10 +--------- libavfilter/vf_extractplanes.c | 10 +--------- 6 files changed, 20 insertions(+), 36 deletions(-) diff --git a/doc/filter_design.txt b/doc/filter_design.txt index 885b19b6f6..b6bfca12f5 100644 --- a/doc/filter_design.txt +++ b/doc/filter_design.txt @@ -214,6 +214,7 @@ Frame scheduling FF_FILTER_FORWARD_STATUS(inlink, outlink); FF_FILTER_FORWARD_STATUS_ALL(inlink, filter); FF_FILTER_FORWARD_WANTED(outlink, inlink); + FF_FILTER_FORWARD_WANTED_ANY(filter, inlink); filter_frame ------------ diff --git a/libavfilter/af_acrossover.c b/libavfilter/af_acrossover.c index 2c9a1e00bc..e24bf9eb73 100644 --- a/libavfilter/af_acrossover.c +++ b/libavfilter/af_acrossover.c @@ -588,15 +588,7 @@ static int activate(AVFilterContext *ctx) return 0; } - for (int i = 0; i < ctx->nb_outputs; i++) { - if (ff_outlink_get_status(ctx->outputs[i])) - continue; - - if (ff_outlink_frame_wanted(ctx->outputs[i])) { - ff_inlink_request_frame(inlink); - return 0; - } - } + FF_FILTER_FORWARD_WANTED_ANY(ctx, inlink); return FFERROR_NOT_READY; } diff --git a/libavfilter/af_channelsplit.c b/libavfilter/af_channelsplit.c index 0156c0c28c..638e81593c 100644 --- a/libavfilter/af_channelsplit.c +++ b/libavfilter/af_channelsplit.c @@ -228,15 +228,7 @@ static int activate(AVFilterContext *ctx) return 0; } - for (int i = 0; i < ctx->nb_outputs; i++) { - if (ff_outlink_get_status(ctx->outputs[i])) - continue; - - if (ff_outlink_frame_wanted(ctx->outputs[i])) { - ff_inlink_request_frame(inlink); - return 0; - } - } + FF_FILTER_FORWARD_WANTED_ANY(ctx, inlink); return FFERROR_NOT_READY; } diff --git a/libavfilter/filters.h b/libavfilter/filters.h index 654aed5c9e..66dc611a98 100644 --- a/libavfilter/filters.h +++ b/libavfilter/filters.h @@ -696,6 +696,21 @@ static inline void ff_outlink_set_status(AVFilterLink *link, int status, int64_t } \ } while (0) +/** + * Forward the frame_wanted_out flag from any of the output links to an input link. + * If the flag is set on any of the outputs, this macro will return immediately. + */ +#define FF_FILTER_FORWARD_WANTED_ANY(filter, inlink) do { \ + for (int i = 0; i < filter->nb_outputs; i++) { \ + if (ff_outlink_get_status(filter->outputs[i])) \ + continue; \ + if (ff_outlink_frame_wanted(filter->outputs[i])) { \ + ff_inlink_request_frame(inlink); \ + return 0; \ + } \ + } \ +} while (0) + /** * Check for flow control between input and output. * This is necessary for filters that may produce several output frames for diff --git a/libavfilter/split.c b/libavfilter/split.c index 0557f54cce..d0bd0c3b2a 100644 --- a/libavfilter/split.c +++ b/libavfilter/split.c @@ -110,15 +110,7 @@ static int activate(AVFilterContext *ctx) return 0; } - for (int i = 0; i < ctx->nb_outputs; i++) { - if (ff_outlink_get_status(ctx->outputs[i])) - continue; - - if (ff_outlink_frame_wanted(ctx->outputs[i])) { - ff_inlink_request_frame(inlink); - return 0; - } - } + FF_FILTER_FORWARD_WANTED_ANY(ctx, inlink); return FFERROR_NOT_READY; } diff --git a/libavfilter/vf_extractplanes.c b/libavfilter/vf_extractplanes.c index 337ad12ac7..99e37ba04a 100644 --- a/libavfilter/vf_extractplanes.c +++ b/libavfilter/vf_extractplanes.c @@ -367,15 +367,7 @@ static int activate(AVFilterContext *ctx) return 0; } - for (int i = 0; i < ctx->nb_outputs; i++) { - if (ff_outlink_get_status(ctx->outputs[i])) - continue; - - if (ff_outlink_frame_wanted(ctx->outputs[i])) { - ff_inlink_request_frame(inlink); - return 0; - } - } + FF_FILTER_FORWARD_WANTED_ANY(ctx, inlink); return FFERROR_NOT_READY; } -- 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".