From patchwork Sun Aug 11 14:42:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 50980 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:1ff2:b0:489:2eb3:e4c4 with SMTP id ks18csp892810vqb; Sun, 11 Aug 2024 07:43:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVkvoWWQ4CEpRjla6g4a4q7uW/ftIBlyPshfDKeHywY4+Qxujdf2OO0DUeVu4+qwcogj4Lp+VnfoEYPCzOwfNpi3k1HmuHw8+4K3w== X-Google-Smtp-Source: AGHT+IGC2rFMREshJ368EIAMYh57z89jg1GB6AR7PFxrwscRoi+PSjD7rGW6XkHkKDGt/MMiQxrd X-Received: by 2002:a05:651c:1549:b0:2ee:7c35:d892 with SMTP id 38308e7fff4ca-2f1a7aaebb9mr18497281fa.17.1723387382651; Sun, 11 Aug 2024 07:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723387382; cv=none; d=google.com; s=arc-20160816; b=VgguXwWM4+3tMxfC+OSzjllhj/wxSvkB5qzo0Uti+uzyPg2wePJIGMRjtVTPK5ySz0 LBHanDQ7LTd0Ok8FUCgAYrfGtL/lVX+SCQ9G+ZaQdEmRQRFog+i5G9cjNL5LW1Qf7ZYE f3LUCDJLW7Vemm8sub1EjrdjLRuMoTYSWo0Bso9Y1VSNIaPFW3AcDHxbEyWcublwIZQ6 1v8AO6Xk7aHg1sJWZOO5v3LBfqbW4KB8zTVzkblxfiOzYXreWfcjWL3M25wwoo9vTU8U 4l6rs1AsxwG41Gn4ZGmMb6Hmdpm1uyOoEFug1JM6GffpZg+CPVc9myMICt1kv4fDPTmm RURg== 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=HapyILGQJ8vPimDisOh72Nu+pAEJqd2MsVYVEOl808w=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=jJr3EzmcpPwN0Jby0xJ3340/6hMYSiPHaU2Z5TFwIACdJeeNlZmOwV4gXyNE8SZvza EZHmpfIYeQOeW8iODg+fmm7m8qcQjG44p27HhOfNdKcLcX/ILmB4xZ1cQQIXkdBuHi55 qul7djvyEeziybpjs/PUfV6cG+qfBvCSwnjxN4c2b/onSvwfwVG9Z7norIpynMavDXRg hPdov3c02Hab4hMq+rRsW6RMYbWALn6SFvV1Rzv2PclhzyNUPGIM4I3gbM7bUoknzuSs t1sOcyyei3ENBST+n9Aopd4Ed0qsrQY/ROvFc2fPDcn5+qvxvwvKYBErfUB81n7j7bds v5AA==; 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=fBoG0meH; 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-2f29207431bsi9647431fa.635.2024.08.11.07.43.02; Sun, 11 Aug 2024 07:43:02 -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=fBoG0meH; 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 B431268DA0D; Sun, 11 Aug 2024 17:42:30 +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 1CE7968D981 for ; Sun, 11 Aug 2024 17:42:20 +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=fBoG0meH; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id AA1504DDB 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 vkk_PqRLj69x for ; Sun, 11 Aug 2024 16:42:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1723387338; bh=u8i59/DoS4D790HF/73nMOWmApcpHEnUkhoLCUvbdDE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fBoG0meHnNb6eIYJ1jNuMZlBASidLGMWKhHmCPNW62XwmOa06jIhW3jDa9lg6ypVz Uix07Yj9Uuo5Iy6OiylDlPdo0X5NmdG2AuHDmD4Pb899jFM4o7brZ7zfVJAT77tqwu ROeyNnXeMPHSBay7aUQJWN4j9b5AWPwqi3lkA0Xw5KutXBV1F9fOWbEOtGK/wXK5Wq ewyh3mtjDGtUMZkOfx4x95P8EljgH1sxMC2bmhqq8qK3MoBP52pXctjOW0cej28t2c AlO9QGBgoqA1QvVKUJjw9fNwhTpssGJpRjHC6glsGMv8S/irQckAzp123LOUh8rTrM AZo9KOU25WyGg== 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 3A3C04DE6 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 25AC33A27B8 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:07 +0200 Message-ID: <20240811144211.5712-6-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 06/10] lavfi: move AVFilterLink.current_pts(_us) to FilterLink 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: e9BnsPjsJzWr --- libavfilter/avfilter.c | 14 +++++++------- libavfilter/avfilter.h | 12 ------------ libavfilter/avfiltergraph.c | 6 +++--- libavfilter/f_graphmonitor.c | 5 +++-- libavfilter/filters.h | 12 ++++++++++++ 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index de74fc2abf..9b72b6162f 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -228,8 +228,8 @@ static void update_link_current_pts(FilterLinkInternal *li, int64_t pts) if (pts == AV_NOPTS_VALUE) return; - link->current_pts = pts; - link->current_pts_us = av_rescale_q(pts, link->time_base, AV_TIME_BASE_Q); + li->l.current_pts = pts; + li->l.current_pts_us = av_rescale_q(pts, link->time_base, AV_TIME_BASE_Q); /* TODO use duration */ if (link->graph && li->age_index >= 0) ff_avfilter_graph_update_heap(link->graph, li); @@ -349,8 +349,8 @@ int ff_filter_config_links(AVFilterContext *filter) } inlink = link->src->nb_inputs ? link->src->inputs[0] : NULL; - link->current_pts = - link->current_pts_us = AV_NOPTS_VALUE; + li->l.current_pts = + li->l.current_pts_us = AV_NOPTS_VALUE; switch (li->init_state) { case AVLINK_INIT: @@ -503,7 +503,7 @@ static int64_t guess_status_pts(AVFilterContext *ctx, int status, AVRational lin for (i = 0; i < ctx->nb_inputs; i++) { FilterLinkInternal * const li = ff_link_internal(ctx->inputs[i]); if (li->status_out == status) - r = FFMIN(r, av_rescale_q(ctx->inputs[i]->current_pts, ctx->inputs[i]->time_base, link_time_base)); + r = FFMIN(r, av_rescale_q(li->l.current_pts, ctx->inputs[i]->time_base, link_time_base)); } if (r < INT64_MAX) return r; @@ -1396,7 +1396,7 @@ int ff_filter_activate(AVFilterContext *filter) int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts) { FilterLinkInternal * const li = ff_link_internal(link); - *rpts = link->current_pts; + *rpts = li->l.current_pts; if (ff_framequeue_queued_frames(&li->fifo)) return *rstatus = 0; if (li->status_out) @@ -1405,7 +1405,7 @@ int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts return *rstatus = 0; *rstatus = li->status_out = li->status_in; update_link_current_pts(li, li->status_in_pts); - *rpts = link->current_pts; + *rpts = li->l.current_pts; return 1; } diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index bf9a682bb7..0d1fdf980b 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -600,18 +600,6 @@ struct AVFilterLink { */ struct AVFilterGraph *graph; - /** - * Current timestamp of the link, as defined by the most recent - * frame(s), in link time_base units. - */ - int64_t current_pts; - - /** - * Current timestamp of the link, as defined by the most recent - * frame(s), in AV_TIME_BASE units. - */ - int64_t current_pts_us; - /** * Frame rate of the stream on the link, or 1/0 if unknown or variable; * if left to 0/0, will be automatically copied from the first input diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 47655703cd..e589ac2415 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.pub.current_pts_us >= li->l.pub.current_pts_us) + if (links[parent]->l.current_pts_us >= li->l.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.pub.current_pts_us < links[child]->l.pub.current_pts_us) + links[child + 1]->l.current_pts_us < links[child]->l.current_pts_us) child++; - if (li->l.pub.current_pts_us < links[child]->l.pub.current_pts_us) + if (li->l.current_pts_us < links[child]->l.current_pts_us) break; links[index] = links[child]; links[index]->age_index = index; diff --git a/libavfilter/f_graphmonitor.c b/libavfilter/f_graphmonitor.c index 3996261318..06573dbb96 100644 --- a/libavfilter/f_graphmonitor.c +++ b/libavfilter/f_graphmonitor.c @@ -258,8 +258,9 @@ static int draw_items(AVFilterContext *ctx, size_t frames) { GraphMonitorContext *s = ctx->priv; + FilterLink *fl = ff_filter_link(l); int64_t previous_pts_us = s->cache[s->cache_index].previous_pts_us; - int64_t current_pts_us = l->current_pts_us; + int64_t current_pts_us = fl->current_pts_us; const int flags = s->flags; const int mode = s->mode; char buffer[1024] = { 0 }; @@ -368,7 +369,7 @@ static int draw_items(AVFilterContext *ctx, xpos += len * 8; } - s->cache[s->cache_index].previous_pts_us = l->current_pts_us; + s->cache[s->cache_index].previous_pts_us = current_pts_us; if (s->cache_index + 1 >= s->cache_size / sizeof(*(s->cache))) { void *ptr = av_fast_realloc(s->cache, &s->cache_size, s->cache_size * 2); diff --git a/libavfilter/filters.h b/libavfilter/filters.h index 9e230dc987..98b2442389 100644 --- a/libavfilter/filters.h +++ b/libavfilter/filters.h @@ -42,6 +42,18 @@ typedef struct FilterLink { AVFilterLink pub; + /** + * Current timestamp of the link, as defined by the most recent + * frame(s), in link time_base units. + */ + int64_t current_pts; + + /** + * Current timestamp of the link, as defined by the most recent + * frame(s), in AV_TIME_BASE units. + */ + int64_t current_pts_us; + /** * Minimum number of samples to filter at once. *