Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Marton Balint <cus@passwd.hu>
To: ffmpeg-devel@ffmpeg.org
Cc: Marton Balint <cus@passwd.hu>
Subject: [FFmpeg-devel] [PATCH 10/12] avfilter/f_select: port to activate
Date: Tue, 24 Jun 2025 21:23:08 +0200
Message-ID: <20250624192318.7430-10-cus@passwd.hu> (raw)
In-Reply-To: <20250624192318.7430-1-cus@passwd.hu>

Multi-input or multi-output filters should use activate now.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavfilter/f_select.c | 45 ++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 19 deletions(-)

diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index aa374c6ad0..a5609ec178 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,35 @@ 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 && !ff_outlink_get_status(ctx->outputs[select->select_out]))
+            return ff_filter_frame(ctx->outputs[select->select_out], in);
+        av_frame_free(&in);
+    };
+
+    FF_FILTER_FORWARD_STATUS_ALL(inlink, ctx);
+    FF_FILTER_FORWARD_WANTED_ANY(ctx, inlink);
+
+    return FFERROR_NOT_READY;
 }
 
 static av_cold void uninit(AVFilterContext *ctx)
@@ -486,7 +494,6 @@ static const AVFilterPad avfilter_af_aselect_inputs[] = {
         .name         = "default",
         .type         = AVMEDIA_TYPE_AUDIO,
         .config_props = config_input,
-        .filter_frame = filter_frame,
     },
 };
 
@@ -542,7 +549,6 @@ static const AVFilterPad avfilter_vf_select_inputs[] = {
         .name         = "default",
         .type         = AVMEDIA_TYPE_VIDEO,
         .config_props = config_input,
-        .filter_frame = filter_frame,
     },
 };
 
@@ -553,6 +559,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".

  parent reply	other threads:[~2025-06-24 19:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-24 19:22 [FFmpeg-devel] [PATCH 01/12] avfilter: factorize requesting an input frame from multi output filters Marton Balint
2025-06-24 19:23 ` [FFmpeg-devel] [PATCH 02/12] avfilter/filters: simplify FF_FILTER_FORWARD_WANTED_ANY Marton Balint
2025-06-24 19:23 ` [FFmpeg-devel] [PATCH 03/12] avfilter/avfilter: fix forwarding EOF for simple API filters in filter_activate_default Marton Balint
2025-06-24 19:23 ` [FFmpeg-devel] [PATCH 04/12] fate/filter-video: add ffprobe test for dual output select filter Marton Balint
2025-06-24 19:23 ` [FFmpeg-devel] [PATCH 05/12] avfilter/avfilter: always forward request frame in filter_activate_default Marton Balint
2025-06-24 19:23 ` [FFmpeg-devel] [PATCH 06/12] avfilter/avfilter: make filter_activate_default request frames on behalf of sinks Marton Balint
2025-06-24 19:23 ` [FFmpeg-devel] [PATCH 07/12] tests/fate/filter-audio: add anullsink test Marton Balint
2025-06-24 19:23 ` [FFmpeg-devel] [PATCH 08/12] avfilter: signal an empty buffersrc with an explicit activate error code Marton Balint
2025-06-24 19:23 ` [FFmpeg-devel] [PATCH 09/12] avfilter/buffersink: keep requesting frames if one activation of the graph does not provide one Marton Balint
2025-06-24 19:23 ` Marton Balint [this message]
2025-06-24 19:23 ` [FFmpeg-devel] [PATCH 11/12] fftools/ffmpeg_filter: always reap all available frames before requesting new ones Marton Balint
2025-06-24 19:23 ` [FFmpeg-devel] [PATCH 12/12] avfilter/ffmpeg_filter: rate control all filter graphs Marton Balint

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250624192318.7430-10-cus@passwd.hu \
    --to=cus@passwd.hu \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git