From patchwork Sun Aug 11 14:42:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 50983 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:1ff2:b0:489:2eb3:e4c4 with SMTP id ks18csp895296vqb; Sun, 11 Aug 2024 07:51:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVcam3KBkRD+UXGTPlBEtdwGytZMCKisaWphWbAZoGZc0FoDhF4X90aSGVkjgI32EHzpTobJXUdO/tJU7brFHnoNA1ElsO8sC+GWQ== X-Google-Smtp-Source: AGHT+IFwtwIub90tPDVh7Cz9PWuLe6Wi8Blu857UbcjAcsoTUcIyYhyDfxkUniUrtKTLqtPhrtu8 X-Received: by 2002:a05:6512:39d0:b0:530:b871:eba9 with SMTP id 2adb3069b0e04-530ee975b4cmr6424729e87.1.1723387871093; Sun, 11 Aug 2024 07:51:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723387871; cv=none; d=google.com; s=arc-20160816; b=DApems+IqYE2ZrdwI+tRWMwiQylThtQij/7Oz4p/QqOiU+od6oiArjYY1nh0pLDux8 LJQejjXnEg5vOTdQnZhX/RbT9OD07jslnT8rWJuNx1jD91m/ks5sKXCbduYU0dyioXRk dcstwz/7xh3tNmUVKOeLcGS+KX+CWuHBBWKspF+2TmfVDy3EoOhpaPICLveXI4nDk9vJ ReIqGVimu4VD11FOkK2OAizb1DlkslKf21KsU+K06mx7sYDTTgqjvYVDB2LqYnDyzky7 Kc9eQ/0Rw8+y9X8v8XEgaTcFFUYUGU53q5L7Cs4kiMQc5L0OULc55PbTWiUOJ3ZaofFG f3nQ== 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=oJx6cL7WJTKk3bzytiaKS7hesQHOKt7fqP0YjlaRXIw=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Jq8Uiv4mIFqwqrsA+maeJpSOKEZ0PFRLhe18u94Rxlq6rRTz9fx8UpPDisYt8qd23u VVPz0RWlL8S4cj1d8JJv/9+V0lioWgWddaBB3EVlipL4Zy96C7qVCczGBt8WGSKJk1QM 0cpKjTt5qJHnkb+qMzmPnV9wacnNTZv6lyBwQHpmUQetpvQKBWcFLqR5q4RMAUevhaTO 53agOpyVJe41LV8FfNlJc3zIPmq5FqehNYf8ZC0S5yWTXLp3cK3B/RuBJdaoGGvgF1fB M40v+YnzERwB00Bs1lbe+2JC3XJxL4GtbsOYbvtj/FbULH1A+THoRU3ifBC6+KbE5mai O5Pg==; 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="OoKa/olY"; 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-a80bb34225dsi194418566b.788.2024.08.11.07.51.10; Sun, 11 Aug 2024 07:51:11 -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="OoKa/olY"; 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 31A4A68D9D9; Sun, 11 Aug 2024 17:42:28 +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 B594F68D981 for ; Sun, 11 Aug 2024 17:42:19 +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=OoKa/olY; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 1E76F4DF6 for ; Sun, 11 Aug 2024 16:42:19 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id lN4HeV150wDl for ; Sun, 11 Aug 2024 16:42:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1723387338; bh=OvQxdizOAc7McZuwJDGpw6Vtvr9CWMsAp6/aYNKA8Yw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OoKa/olYJe/C9ATYdm3aK/gSOjvWh/RzJ62LyctAbKkOIAkBqiglyoSxu07CNPnzW zf9qM6BYsRwQlNxRJEHYY/duEaXrBIBqflfRE/Rr3kD3S7e5OQjeIyIqNQwURM/sCh VcwtwpgEv/idTXiKz9knuVTQOIlDa8JAwqePG5D1nIvP2wL9EO4IXxbG/dBK7TmJuI K/ym+Eo8FgjCyp1SfYJVdscMgue0FovzFSfkudBc78vDEKbmv7pmkZThX8vepHSX4u Ls2Bfwmkr021g/OtZaDUWhKD+oSRk4dol3I5k2woiJzHX6lVnxGtURV2/e2IX+u7HQ 2YPSdNDloJoDA== 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 0D7714DDE 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 E78023A05A2 for ; Sun, 11 Aug 2024 16:42:17 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 11 Aug 2024 16:42:03 +0200 Message-ID: <20240811144211.5712-2-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 02/10] lavfi: add a new struct for private link properties 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: 6mGvqjjf/RIS Specifically those that should be visible to filters, but hidden from API callers. Such properties are currently located at the end of the public AVFilterLink struct, demarcated by a comment marking them as private. However it is generally better to hide them explicitly, using the same pattern already employed in avformat or avcodec. The new struct is currently trivial, but will become more useful in following commits. --- libavfilter/avfilter.c | 10 +++++----- libavfilter/avfilter_internal.h | 3 ++- libavfilter/avfiltergraph.c | 10 +++++----- libavfilter/filters.h | 10 ++++++++++ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index c4bd134fb2..80c9cf7b51 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -176,7 +176,7 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, li = av_mallocz(sizeof(*li)); if (!li) return AVERROR(ENOMEM); - link = &li->l; + link = &li->l.pub; src->outputs[srcpad] = dst->inputs[dstpad] = link; @@ -222,7 +222,7 @@ int avfilter_config_links(AVFilterContext *filter) static void update_link_current_pts(FilterLinkInternal *li, int64_t pts) { - AVFilterLink *const link = &li->l; + AVFilterLink *const link = &li->l.pub; if (pts == AV_NOPTS_VALUE) return; @@ -1077,7 +1077,7 @@ static int samples_ready(FilterLinkInternal *link, unsigned min) static int take_samples(FilterLinkInternal *li, unsigned min, unsigned max, AVFrame **rframe) { - AVFilterLink *link = &li->l; + AVFilterLink *link = &li->l.pub; AVFrame *frame0, *frame, *buf; unsigned nb_samples, nb_frames, i, p; int ret; @@ -1169,7 +1169,7 @@ static int ff_filter_frame_to_filter(AVFilterLink *link) static int forward_status_change(AVFilterContext *filter, FilterLinkInternal *li_in) { - AVFilterLink *in = &li_in->l; + AVFilterLink *in = &li_in->l.pub; unsigned out = 0, progress = 0; int ret; @@ -1431,7 +1431,7 @@ int ff_inlink_check_available_samples(AVFilterLink *link, unsigned min) static void consume_update(FilterLinkInternal *li, const AVFrame *frame) { - AVFilterLink *const link = &li->l; + AVFilterLink *const link = &li->l.pub; update_link_current_pts(li, frame->pts); ff_inlink_process_commands(link, frame); if (link == link->dst->inputs[0]) diff --git a/libavfilter/avfilter_internal.h b/libavfilter/avfilter_internal.h index 2c31c3e7de..7084411d68 100644 --- a/libavfilter/avfilter_internal.h +++ b/libavfilter/avfilter_internal.h @@ -28,10 +28,11 @@ #include #include "avfilter.h" +#include "filters.h" #include "framequeue.h" typedef struct FilterLinkInternal { - AVFilterLink l; + FilterLink l; struct FFFramePool *frame_pool; diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 2791ffa64a..47655703cd 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -1326,7 +1326,7 @@ static void heap_bubble_up(FFFilterGraph *graph, while (index) { int parent = (index - 1) >> 1; - if (links[parent]->l.current_pts_us >= li->l.current_pts_us) + if (links[parent]->l.pub.current_pts_us >= li->l.pub.current_pts_us) break; links[index] = links[parent]; links[index]->age_index = index; @@ -1348,9 +1348,9 @@ static void heap_bubble_down(FFFilterGraph *graph, if (child >= graph->sink_links_count) break; if (child + 1 < graph->sink_links_count && - links[child + 1]->l.current_pts_us < links[child]->l.current_pts_us) + links[child + 1]->l.pub.current_pts_us < links[child]->l.pub.current_pts_us) child++; - if (li->l.current_pts_us < links[child]->l.current_pts_us) + if (li->l.pub.current_pts_us < links[child]->l.pub.current_pts_us) break; links[index] = links[child]; links[index]->age_index = index; @@ -1372,13 +1372,13 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph) { FFFilterGraph *graphi = fffiltergraph(graph); FilterLinkInternal *oldesti = graphi->sink_links[0]; - AVFilterLink *oldest = &oldesti->l; + AVFilterLink *oldest = &oldesti->l.pub; int64_t frame_count; int r; while (graphi->sink_links_count) { oldesti = graphi->sink_links[0]; - oldest = &oldesti->l; + oldest = &oldesti->l.pub; if (oldest->dst->filter->activate) { r = av_buffersink_get_frame_flags(oldest->dst, NULL, AV_BUFFERSINK_FLAG_PEEK); diff --git a/libavfilter/filters.h b/libavfilter/filters.h index 86bc49d459..2c856fead7 100644 --- a/libavfilter/filters.h +++ b/libavfilter/filters.h @@ -33,6 +33,16 @@ */ #define FFERROR_NOT_READY FFERRTAG('N','R','D','Y') +/** + * Link properties exposed to filter code, but not external callers. + * + * Cf. AVFilterLink for public properties, FilterLinkInternal for + * properties private to the generic layer. + */ +typedef struct FilterLink { + AVFilterLink pub; +} FilterLink; + /** * Mark a filter ready and schedule it for activation. *