diff options
author | Marton Balint <cus@passwd.hu> | 2025-06-22 12:07:26 +0200 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2025-07-03 21:41:53 +0200 |
commit | f3b7aa6c224dc6bbb96a57dceb39b8c4b77c1297 (patch) | |
tree | ec573ba104f5ce3e91ecfa06608534e6d31cfe2e | |
parent | 01ffe103e5024f859ffe586ea63a791c0bf55bfa (diff) | |
download | ffmpeg-f3b7aa6c224dc6bbb96a57dceb39b8c4b77c1297.tar.gz |
avfilter: factorize requesting an input frame from multi output filters
Signed-off-by: Marton Balint <cus@passwd.hu>
-rw-r--r-- | doc/filter_design.txt | 1 | ||||
-rw-r--r-- | libavfilter/af_acrossover.c | 10 | ||||
-rw-r--r-- | libavfilter/af_channelsplit.c | 10 | ||||
-rw-r--r-- | libavfilter/filters.h | 15 | ||||
-rw-r--r-- | libavfilter/split.c | 10 | ||||
-rw-r--r-- | 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 @@ -697,6 +697,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 * a single input event, otherwise they may produce them all at once, 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; } |