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 B0D884D0AF for ; Mon, 16 Jun 2025 22:44:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id DDF4368C846; Tue, 17 Jun 2025 01:44:17 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 6016168CC88 for ; Tue, 17 Jun 2025 01:44:14 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 9447CED977; Tue, 17 Jun 2025 00:41:20 +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 EnzkmXn1JFvQ; Tue, 17 Jun 2025 00:41:18 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 87AECED972; Tue, 17 Jun 2025 00:41:18 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 17 Jun 2025 00:43:53 +0200 Message-ID: <20250616224404.16142-3-cus@passwd.hu> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250616224404.16142-1-cus@passwd.hu> References: <20250616224404.16142-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/7] avfilter/f_select: port to activate 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: Multi-input or multi-output filters should always use activate now. Fixes ticket #10959. Signed-off-by: Marton Balint --- libavfilter/f_select.c | 54 +++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c index aa374c6ad0..38fe56623b 100644 --- a/libavfilter/f_select.c +++ b/libavfilter/f_select.c @@ -179,8 +179,6 @@ static const AVOption filt_name##_options[] = { \ { NULL } \ } -static int request_frame(AVFilterLink *outlink); - static av_cold int init(AVFilterContext *ctx) { SelectContext *select = ctx->priv; @@ -201,7 +199,6 @@ static av_cold int init(AVFilterContext *ctx) if (!pad.name) return AVERROR(ENOMEM); pad.type = ctx->filter->inputs[0].type; - pad.request_frame = request_frame; if ((ret = ff_append_outpad_free_name(ctx, &pad)) < 0) return ret; } @@ -349,7 +346,7 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame) if (isnan(select->var_values[VAR_START_T])) select->var_values[VAR_START_T] = TS2D(frame->pts) * av_q2d(inlink->time_base); - select->var_values[VAR_N ] = inl->frame_count_out; + select->var_values[VAR_N ] = inl->frame_count_out - 1; select->var_values[VAR_PTS] = TS2D(frame->pts); select->var_values[VAR_T ] = TS2D(frame->pts) * av_q2d(inlink->time_base); select->var_values[VAR_KEY] = !!(frame->flags & AV_FRAME_FLAG_KEY); @@ -428,24 +425,44 @@ static void select_frame(AVFilterContext *ctx, AVFrame *frame) select->var_values[VAR_PREV_T] = select->var_values[VAR_T]; } -static int filter_frame(AVFilterLink *inlink, AVFrame *frame) +static int activate(AVFilterContext *ctx) { - AVFilterContext *ctx = inlink->dst; SelectContext *select = ctx->priv; + AVFilterLink *inlink = ctx->inputs[0]; + AVFrame *in; + int nb_eofs = 0; + int ret; - select_frame(ctx, frame); - if (select->select) - return ff_filter_frame(ctx->outputs[select->select_out], frame); + for (int i = 0; i < ctx->nb_outputs; i++) + nb_eofs += ff_outlink_get_status(ctx->outputs[i]) == AVERROR_EOF; - av_frame_free(&frame); - return 0; -} + if (nb_eofs == ctx->nb_outputs) { + ff_inlink_set_status(inlink, AVERROR_EOF); + return 0; + } -static int request_frame(AVFilterLink *outlink) -{ - AVFilterLink *inlink = outlink->src->inputs[0]; - int ret = ff_request_frame(inlink); - return ret; + while ((ret = ff_inlink_consume_frame(inlink, &in))) { + if (ret < 0) + return ret; + select_frame(ctx, in); + if (select->select) + return ff_filter_frame(ctx->outputs[select->select_out], in); + av_frame_free(&in); + }; + + FF_FILTER_FORWARD_STATUS_ALL(inlink, ctx); + + 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; + } + } + + return FFERROR_NOT_READY; } static av_cold void uninit(AVFilterContext *ctx) @@ -486,7 +503,6 @@ static const AVFilterPad avfilter_af_aselect_inputs[] = { .name = "default", .type = AVMEDIA_TYPE_AUDIO, .config_props = config_input, - .filter_frame = filter_frame, }, }; @@ -542,7 +558,6 @@ static const AVFilterPad avfilter_vf_select_inputs[] = { .name = "default", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_input, - .filter_frame = filter_frame, }, }; @@ -553,6 +568,7 @@ const FFFilter ff_vf_select = { .p.flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS | AVFILTER_FLAG_METADATA_ONLY, .init = select_init, .uninit = uninit, + .activate = activate, .priv_size = sizeof(SelectContext), FILTER_INPUTS(avfilter_vf_select_inputs), FILTER_QUERY_FUNC2(query_formats), -- 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".