From patchwork Sun Aug 11 14:42:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 50984 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:1ff2:b0:489:2eb3:e4c4 with SMTP id ks18csp895351vqb; Sun, 11 Aug 2024 07:51:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW8JznOgWYwMVS/zskd4hBil4ML6vYO7JoD6LGjOVHIEl8HtNujfMS2R2UBJOCwSykNRI3wwe8bBsDDoG8pbkUfjoDOZ4fIIj3CoQ== X-Google-Smtp-Source: AGHT+IH37oKrII1p5IEjx30kZNzdaa4jIgMFneLxOLfFXP4ooLBW9aIDDQCHax5KT71l3m0JpjWV X-Received: by 2002:a2e:4e1a:0:b0:2ef:2543:457c with SMTP id 38308e7fff4ca-2f1a6d0002bmr40909941fa.24.1723387878960; Sun, 11 Aug 2024 07:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723387878; cv=none; d=google.com; s=arc-20160816; b=jOMV+K9sv8rcAagsaMFLi/hICgxzI+1Z3DWQJlR5k3GQFcX5vdgTYJrHGyBbzZ42Ky WdQ8bwMam9OPnzfTf1WsAECWcAXbUNSuaA9iTA5m+37x/wTbS+FT3NqR34vYu4Dm7dtC 5kkAZ/pCgzxNA29uEh4Shitf5Dt9pVk79upCerii/76Lxzwf3x2XuL7j8dW4kwi5L+qK 6aqY+wXEEP6S73ocjaPjB7v+RCsMBjc2UwhM69c1DCwCgPqm8t1IEdQq5VMqCVtT3uDa 8EF6kBeTeJNpcsApp9NsjFOI2HYMbdcOQcCUtAFNeRFjxNPtympGbpqO21a9zHfpjgKx pZOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=SLJw32HavKTb8ayO7VlmtgwcrvK1bf9TLlFja2AUwqE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=cF0AHVBblw9SScS09HoEh2aYKmUeNc4GbMjHc8aTh00/fh/xE4daAmq9RdkoM3lgcv 5gnqzp9raGYJ2Vi36xgsdPfDyDUBLLIYzRM3lG5E3bXej6kH8PGZy2b59LZrOugBbJ4E c4qHD2LAfi8TpXTKObH5ZcxNUiEN6rKwdbXiXhGhbWIzh9Bud+9UKUOKm+m+Sq/WZaTE DeWOYpJ95VpmSKP08NIYIExQnGAJVfgVswl2Jb4QLR8/C6O2Ca+KRZMQOT+hqkebCvO9 Jtc3wk8NOe6sbBv5D8f2bzZZ89f5LNue06Dn25q4NEwSdmGeJ940iyCSaLJIFhbFSxDc kRZg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=KEgM7CC+; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2f29204e93esi9301761fa.353.2024.08.11.07.51.18; Sun, 11 Aug 2024 07:51:18 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=KEgM7CC+; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4D54868DB0E; Sun, 11 Aug 2024 17:42:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 44EDB68DA1A for ; Sun, 11 Aug 2024 17:42:25 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=KEgM7CC+; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id C462F4DE4 for ; Sun, 11 Aug 2024 16:42:21 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 2Hf8D7BAb35i for ; Sun, 11 Aug 2024 16:42:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1723387338; bh=pTsWgFOrn9+a+BCDLLoZTKOb6v+P+NlJ2fsq69nWeMo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=KEgM7CC+sAzUyWGxi/Kq1jGHrGbKMHugxvwzRJgSYDLGhIT61X5o3nqOaa6OcreYi 1x+XxDy8NfWQeSfyf0wtGHbfE5seGdZMSZIxtdq1Rv/pouOTI9Z3zAytUwI9rK+REP DKaSkjHay3S1ECKxv8PKkgrxuNNqEWHf8pQRsipx4lDskc0d9VF9LAyQs8MFnMfJEW ZNhDyvhEhu7yQZEbxgxko6ZddWdbAMV7kRLpHvs9FJPn9uyZ42eQDGFU238nSRxPEY WfltAlFkeByNWvX8fekzN+jGDKj9CclzAL8KxtUWs08CWFFtHtpVUrcma+ztKnz4Ne Ddf055eJYQwBQ== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 6D4C14DFE for ; Sun, 11 Aug 2024 16:42:18 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 564703A05A2 for ; Sun, 11 Aug 2024 16:42:18 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 11 Aug 2024 16:42:10 +0200 Message-ID: <20240811144211.5712-9-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240811144211.5712-1-anton@khirnov.net> References: <20240811144211.5712-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/10] lavfi: move AVFilterLink.frame_wanted_out to FilterLinkInternal 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: kZMph0iL3HNb --- 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.