From: Anton Khirnov <anton@khirnov.net> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 09/10] lavfi: move AVFilterLink.frame_wanted_out to FilterLinkInternal Date: Sun, 11 Aug 2024 16:42:10 +0200 Message-ID: <20240811144211.5712-9-anton@khirnov.net> (raw) In-Reply-To: <20240811144211.5712-1-anton@khirnov.net> --- libavfilter/avfilter.c | 22 ++++++++++++++-------- libavfilter/avfilter.h | 7 ------- libavfilter/avfilter_internal.h | 7 +++++++ libavfilter/avfiltergraph.c | 2 +- libavfilter/buffersink.c | 3 ++- libavfilter/filters.h | 5 +---- 6 files changed, 25 insertions(+), 21 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 9a01bc1c4e..055db01e02 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -264,7 +264,7 @@ void ff_avfilter_link_set_in_status(AVFilterLink *link, int status, int64_t pts) av_assert0(!li->status_in); li->status_in = status; li->status_in_pts = pts; - link->frame_wanted_out = 0; + li->frame_wanted_out = 0; li->frame_blocked_in = 0; filter_unblock(link->dst); ff_filter_set_ready(link->dst, 200); @@ -278,7 +278,7 @@ static void link_set_out_status(AVFilterLink *link, int status, int64_t pts) { FilterLinkInternal * const li = ff_link_internal(link); - av_assert0(!link->frame_wanted_out); + av_assert0(!li->frame_wanted_out); av_assert0(!li->status_out); li->status_out = status; if (pts != AV_NOPTS_VALUE) @@ -481,7 +481,7 @@ int ff_request_frame(AVFilterLink *link) return li->status_out; if (li->status_in) { if (ff_framequeue_queued_frames(&li->fifo)) { - av_assert1(!link->frame_wanted_out); + av_assert1(!li->frame_wanted_out); av_assert1(link->dst->ready >= 300); return 0; } else { @@ -492,7 +492,7 @@ int ff_request_frame(AVFilterLink *link) return li->status_out; } } - link->frame_wanted_out = 1; + li->frame_wanted_out = 1; ff_filter_set_ready(link->src, 100); return 0; } @@ -1058,7 +1058,7 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame) link->time_base); } - li->frame_blocked_in = link->frame_wanted_out = 0; + li->frame_blocked_in = li->frame_wanted_out = 0; li->l.frame_count_in++; li->l.sample_count_in += frame->nb_samples; filter_unblock(link->dst); @@ -1241,7 +1241,7 @@ static int ff_filter_activate_default(AVFilterContext *filter) } for (i = 0; i < filter->nb_outputs; i++) { FilterLinkInternal * const li = ff_link_internal(filter->outputs[i]); - if (filter->outputs[i]->frame_wanted_out && + if (li->frame_wanted_out && !li->frame_blocked_in) { return ff_request_frame_to_filter(filter->outputs[i]); } @@ -1581,7 +1581,7 @@ void ff_inlink_request_frame(AVFilterLink *link) av_unused FilterLinkInternal *li = ff_link_internal(link); av_assert1(!li->status_in); av_assert1(!li->status_out); - link->frame_wanted_out = 1; + li->frame_wanted_out = 1; ff_filter_set_ready(link->src, 100); } @@ -1590,7 +1590,7 @@ void ff_inlink_set_status(AVFilterLink *link, int status) FilterLinkInternal * const li = ff_link_internal(link); if (li->status_out) return; - link->frame_wanted_out = 0; + li->frame_wanted_out = 0; li->frame_blocked_in = 0; link_set_out_status(link, status, AV_NOPTS_VALUE); while (ff_framequeue_queued_frames(&li->fifo)) { @@ -1642,3 +1642,9 @@ int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link, return 0; } + +int ff_outlink_frame_wanted(AVFilterLink *link) +{ + FilterLinkInternal * const li = ff_link_internal(link); + return li->frame_wanted_out; +} diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 176498cdb4..a91b543f5e 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -599,13 +599,6 @@ struct AVFilterLink { * Graph the filter belongs to. */ struct AVFilterGraph *graph; - - /** - * True if a frame is currently wanted on the output of this filter. - * Set when ff_request_frame() is called by the output, - * cleared when a frame is filtered. - */ - int frame_wanted_out; }; /** diff --git a/libavfilter/avfilter_internal.h b/libavfilter/avfilter_internal.h index 7084411d68..974024254f 100644 --- a/libavfilter/avfilter_internal.h +++ b/libavfilter/avfilter_internal.h @@ -67,6 +67,13 @@ typedef struct FilterLinkInternal { */ int status_out; + /** + * True if a frame is currently wanted on the output of this filter. + * Set when ff_request_frame() is called by the output, + * cleared when a frame is filtered. + */ + int frame_wanted_out; + /** * Index in the age array. */ diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 18a3f54759..2d46dd7637 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -1406,7 +1406,7 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph) while (frame_count == oldesti->l.frame_count_out) { r = ff_filter_graph_run_once(graph); if (r == AVERROR(EAGAIN) && - !oldest->frame_wanted_out && !oldesti->frame_blocked_in && + !oldesti->frame_wanted_out && !oldesti->frame_blocked_in && !oldesti->status_in) (void)ff_request_frame(oldest); else if (r < 0) diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index f76d0af7ff..bc4c4ebd43 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -88,6 +88,7 @@ static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, i { BufferSinkContext *buf = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; + FilterLinkInternal *li = ff_link_internal(inlink); int status, ret; AVFrame *cur_frame; int64_t pts; @@ -107,7 +108,7 @@ static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, i return status; } else if ((flags & AV_BUFFERSINK_FLAG_NO_REQUEST)) { return AVERROR(EAGAIN); - } else if (inlink->frame_wanted_out) { + } else if (li->frame_wanted_out) { ret = ff_filter_graph_run_once(ctx->graph); if (ret < 0) return ret; diff --git a/libavfilter/filters.h b/libavfilter/filters.h index 3f591e6f9d..36164c171e 100644 --- a/libavfilter/filters.h +++ b/libavfilter/filters.h @@ -245,10 +245,7 @@ void ff_inlink_set_status(AVFilterLink *link, int status); /** * Test if a frame is wanted on an output link. */ -static inline int ff_outlink_frame_wanted(AVFilterLink *link) -{ - return link->frame_wanted_out; -} +int ff_outlink_frame_wanted(AVFilterLink *link); /** * Get the status on an output link. -- 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".
next prev parent reply other threads:[~2024-08-11 14:43 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-08-11 14:42 [FFmpeg-devel] [PATCH 01/10] lavfi: set AVFilterLink.graph on link creation Anton Khirnov 2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 02/10] lavfi: add a new struct for private link properties Anton Khirnov 2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 03/10] lavfi: move AVFilterLink.m{ax, in}_samples to FilterLink Anton Khirnov 2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 04/10] lavfi/vf_*_cuda: do not access hw contexts before checking they exist Anton Khirnov 2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 05/10] lavfi: move AVFilterLink.hw_frames_ctx to FilterLink Anton Khirnov 2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 06/10] lavfi: move AVFilterLink.current_pts(_us) " Anton Khirnov 2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 07/10] lavfi: move AVFilterLink.frame_rate " Anton Khirnov 2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 08/10] lavfi: move AVFilterLink.{frame, sample}_count_{in, out} " Anton Khirnov 2024-08-12 20:19 ` Michael Niedermayer 2024-08-13 8:28 ` Anton Khirnov 2024-08-11 14:42 ` Anton Khirnov [this message] 2024-08-11 14:42 ` [FFmpeg-devel] [PATCH 10/10] lavfi: move AVFilterLink.graph " Anton Khirnov
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=20240811144211.5712-9-anton@khirnov.net \ --to=anton@khirnov.net \ --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