From patchwork Thu Oct 3 19:31:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 52014 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:938f:0:b0:48e:c0f8:d0de with SMTP id z15csp105vqg; Thu, 3 Oct 2024 13:09:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX4msHW0KMOTXFm7HHcvo9FSx6ZQHH6A6At9xNwi1FWpY+eT10TsjncziKTjQMpcvp/2N8WEJNizLWGCNy6uAW2@gmail.com X-Google-Smtp-Source: AGHT+IEPDxWTgKrRqasATtgzi8zMSEiwJRQObxsG5EdoCFU4gvCM00W1XSjLqSVend8rPTTAoqs0 X-Received: by 2002:a17:907:d599:b0:a8d:5472:b56c with SMTP id a640c23a62f3a-a991bd0ca74mr46997866b.22.1727986149158; Thu, 03 Oct 2024 13:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727986149; cv=none; d=google.com; s=arc-20240605; b=MBFxihO3d9lw7V2NDd375uRlcDChsW7jBI5PBtKQC5/uWgaphOvI56hF8+BjmEpXJ3 1ToqqIPrtBp+hNQxR793XEESi6ztZZ/ZPjXMGtnSHuWnpZ0DgFzXjOLrwh1aE9SISrfh dsipogJHbkL9bFtd3FRFWTf2qqOzPPXZODALG1aNsgPIA9x6PKz4PEhD4LGZCXukPDKv I6l6fKmhCSadtILJLEjukD4Unq9qI0wnc0VGn1ZhRPQ+BjzawYkLWcvLbmKfWbeEiDgD GA3EMs7/PnsrICcA92hrNI7Z8NT8PiN6evRQSPcry1TCmjH8n1TfS4cc2AP93l52t4C1 ivbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:message-id:date:to:from :dkim-signature:delivered-to; bh=+uTr6eJ0Q6f1yy9gIwh/w9D0aTFOSBy5iadfIW+djbU=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=AT8aqMflWBkCXQzExF3zRqGQP2ZwQV/KghW/S3S0uvkjlaTh359RbQatTa4iWs+p+u hLdMUJVeE5VkZsYYkiI4XB/63H/DoDNF/EB+KAZGFH6lDZ9p+W2PhVf2h+6FZQ8pFwLU FavodMXgk9ViCyIsxBnaz94sAseZMLx4K0/xEkcu00T9ywNHT0ofRDlasdwK39sAGu5e 6sl87bzDbcHyiGcSg+ylzxERSK6us5/44dc3BMfuCkVzP1BMrF1F9AzLcCmxz4cYXCDo /eu9sKNbX5srdAH+hlSHuNz3zt0jmOqYb4g86YgwBhj1ypYRZbJ3lyfFPCOtnkWZT7k1 tT/Q==; 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=DGKYkpIP; 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 a640c23a62f3a-a9910dce9a0si121154866b.97.2024.10.03.13.09.01; Thu, 03 Oct 2024 13:09:09 -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=DGKYkpIP; 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 F33B268DAD5; Thu, 3 Oct 2024 22:32:33 +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 6796568DA73 for ; Thu, 3 Oct 2024 22:32:24 +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=DGKYkpIP; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 0F21C4E14 for ; Thu, 3 Oct 2024 21:32:24 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id LhlV5_zf3BD7 for ; Thu, 3 Oct 2024 21:32:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1727983942; bh=UKxU+k7SZQAKwRA7pUA+/WAv73fCuwWU8fvYRGQyDZE=; h=From:To:Subject:Date:From; b=DGKYkpIP0HiwgU0vbit/Tvik2JXCj/j71h7QCnPLhqOz7y8g+pEDC1VFSPnwaSWr+ Jp68bwjIBYrwocSlwcSNEZufnk3hqNNUmtR/7otxt1CPDJNFMSOG9SCz2GPNYCawI6 aw6qrci0LimjsJbkBPD+oO2cUrxEOrnENLRbNVLFuwSHFS13lMWdk2W1RTtTHOpgBd I+SsYPKRJfz26m5kyJulSjP0OjTKCqC3FtKQ1sFAtzi9zgcvxQo16Iqy2azvq5Hjl6 F5bSVtJGqeh2pJc/bWzw995T8J6DFjhEHPtMkRlOYla8CzkYmIjtGQOi8uebi8eEgo fItAthXw3GCdg== 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 0F3124E13 for ; Thu, 3 Oct 2024 21:32:22 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 9E3463A02F7 for ; Thu, 03 Oct 2024 21:32:15 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Oct 2024 21:31:21 +0200 Message-ID: <20241003193127.15818-1-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/7] lavfi/avfilter: move AVFilterContext.ready to FFFilterContext 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: d4ZpoIfVol2e This field is private to the generic filtering code. --- libavfilter/avfilter.c | 9 ++++++--- libavfilter/avfilter.h | 7 ++++--- libavfilter/avfilter_internal.h | 7 +++++++ libavfilter/avfiltergraph.c | 18 +++++++++++------- libavfilter/version_major.h | 1 + 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index dc06ebab4d..1a0e94b21d 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -237,7 +237,8 @@ static void update_link_current_pts(FilterLinkInternal *li, int64_t pts) void ff_filter_set_ready(AVFilterContext *filter, unsigned priority) { - filter->ready = FFMAX(filter->ready, priority); + FFFilterContext *ctxi = fffilterctx(filter); + ctxi->ready = FFMAX(ctxi->ready, priority); } /** @@ -473,6 +474,7 @@ void ff_tlog_link(void *ctx, AVFilterLink *link, int end) int ff_request_frame(AVFilterLink *link) { FilterLinkInternal * const li = ff_link_internal(link); + FFFilterContext * const ctxi_dst = fffilterctx(link->dst); FF_TPRINTF_START(NULL, request_frame); ff_tlog_link(NULL, link, 1); @@ -482,7 +484,7 @@ int ff_request_frame(AVFilterLink *link) if (li->status_in) { if (ff_framequeue_queued_frames(&li->fifo)) { av_assert1(!li->frame_wanted_out); - av_assert1(link->dst->ready >= 300); + av_assert1(ctxi_dst->ready >= 300); return 0; } else { /* Acknowledge status change. Filters using ff_request_frame() will @@ -1384,12 +1386,13 @@ static int ff_filter_activate_default(AVFilterContext *filter) int ff_filter_activate(AVFilterContext *filter) { + FFFilterContext *ctxi = fffilterctx(filter); int ret; /* Generic timeline support is not yet implemented but should be easy */ av_assert1(!(filter->filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC && filter->filter->activate)); - filter->ready = 0; + ctxi->ready = 0; ret = filter->filter->activate ? filter->filter->activate(filter) : ff_filter_activate_default(filter); if (ret == FFERROR_NOT_READY) diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index f2c4a64004..1748dd3023 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -518,12 +518,13 @@ struct AVFilterContext { */ AVBufferRef *hw_device_ctx; +#if FF_API_CONTEXT_PUBLIC /** - * Ready status of the filter. - * A non-0 value means that the filter needs activating; - * a higher value suggests a more urgent activation. + * @deprecated this field should never have been accessed by callers */ + attribute_deprecated unsigned ready; +#endif /** * Sets the number of extra hardware frames which the filter will diff --git a/libavfilter/avfilter_internal.h b/libavfilter/avfilter_internal.h index 9ba890a70c..7041d787b0 100644 --- a/libavfilter/avfilter_internal.h +++ b/libavfilter/avfilter_internal.h @@ -102,6 +102,13 @@ typedef struct FFFilterContext { // AV_CLASS_STATE_FLAG_* unsigned state_flags; + + /** + * Ready status of the filter. + * A non-0 value means that the filter needs activating; + * a higher value suggests a more urgent activation. + */ + unsigned ready; } FFFilterContext; static inline FFFilterContext *fffilterctx(AVFilterContext *ctx) diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 38077ff701..7bc7700743 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -1470,15 +1470,19 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph) int ff_filter_graph_run_once(AVFilterGraph *graph) { - AVFilterContext *filter; + FFFilterContext *ctxi; unsigned i; av_assert0(graph->nb_filters); - filter = graph->filters[0]; - for (i = 1; i < graph->nb_filters; i++) - if (graph->filters[i]->ready > filter->ready) - filter = graph->filters[i]; - if (!filter->ready) + ctxi = fffilterctx(graph->filters[0]); + for (i = 1; i < graph->nb_filters; i++) { + FFFilterContext *ctxi_other = fffilterctx(graph->filters[i]); + + if (ctxi_other->ready > ctxi->ready) + ctxi = ctxi_other; + } + + if (!ctxi->ready) return AVERROR(EAGAIN); - return ff_filter_activate(filter); + return ff_filter_activate(&ctxi->p); } diff --git a/libavfilter/version_major.h b/libavfilter/version_major.h index b2c761370f..41374fbbe5 100644 --- a/libavfilter/version_major.h +++ b/libavfilter/version_major.h @@ -37,5 +37,6 @@ #define FF_API_LINK_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 11) #define FF_API_BUFFERSINK_OPTS (LIBAVFILTER_VERSION_MAJOR < 11) +#define FF_API_CONTEXT_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 11) #endif /* AVFILTER_VERSION_MAJOR_H */