From patchwork Wed Jul 13 09:17:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 36769 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:6da0:b0:8b:e47:9dbf with SMTP id wl32csp225804pzb; Wed, 13 Jul 2022 02:18:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vwQ8L/XYafHiso8NmL+jWGYMEi512I+OG6zv0+uZ6tWy5UxkvhD0PMnZrMriIHHIipNwr8 X-Received: by 2002:a05:6402:d0a:b0:437:f9a1:8493 with SMTP id eb10-20020a0564020d0a00b00437f9a18493mr3513992edb.226.1657703884136; Wed, 13 Jul 2022 02:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657703884; cv=none; d=google.com; s=arc-20160816; b=V5qkmOZaaoAS9Mmq87PijpAVhdSDnQHOJALdi2gcj2MBtU5eWf+SQissHvnNrjVSiu WBkbJ3IFHUEop9wIlyxXgZ2pP7cSVS7yOnpJjQbdbvLsmlAw7H2d05tikoA3qB52K/dZ z4yV3la9rs/qBSH/VaNnpYzFODBysg8bVqeYqC499IH4tPEN/FqMtncDFJreEWIi8KXr 6aJAnc2dtwO6GVfsrb8QSikvNyznmTrp8jR6cq1zkOc58VImkhoFzm1P/gXmYCwtbT8B OHskkh+/TfdGRMD90f2IhBaGpucHBviRu4fj6WknC8ORwIJoDhQm0tLjqF/Vz5pCafJM YXeQ== 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:delivered-to; bh=8C8oOn6kEsKyxbFMwRN7dKsYWgq8E6kEuw9cky+2ebk=; b=HeZnO7URX3jERimpCANCQ8hpTVNAe/LEbu6x0pHuQepZEgyxEAE0S0E+RkwbF/mADB eTB/OaLCpTdj6dyFS4Q8+6tQiNSjZEPiBGsomP7TArNW5p21yulhcyOh87s0yblotYHs FjZIZpIcwiNh9z98Hi4QapDgDXIRcoGbvn/vcs1LwHJFZe1+c9QixUETOD0HKmr3AJX2 bygvxKbhnmVm3tCRyK4v2hX8179MD1ir6tTPjKpmca4IZRbmR83rFyTV/bB+E6ctDxwi tU3VrzplmwvzGvzDjbn22MP65WdN7fR8lP8bazLS46mmUiDxu6DSAZH+JK46Y/zJhYmO ooBg== ARC-Authentication-Results: i=1; mx.google.com; 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 g9-20020a056402090900b0043aa1eea0e3si19964773edz.330.2022.07.13.02.18.03; Wed, 13 Jul 2022 02:18:04 -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; 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 5948968B8EB; Wed, 13 Jul 2022 12:17:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DEEFF68B87F for ; Wed, 13 Jul 2022 12:17:31 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 3ACAB24017C for ; Wed, 13 Jul 2022 11:17:31 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id PCHNEDzM5vgt for ; Wed, 13 Jul 2022 11:17:28 +0200 (CEST) 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 mail0.khirnov.net (Postfix) with ESMTPS id 45C8D2400F5 for ; Wed, 13 Jul 2022 11:17:28 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id D06253A0311; Wed, 13 Jul 2022 11:17:27 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 13 Jul 2022 11:17:19 +0200 Message-Id: <20220713091725.16638-3-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220713091725.16638-1-anton@khirnov.net> References: <20220713091725.16638-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/9] lavfi: use AVFrame.duration instead of AVFrame.pkt_duration 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: GkiZ89buU8c3 --- doc/filters.texi | 2 +- libavfilter/buffersrc.c | 7 +++++++ libavfilter/f_loop.c | 14 ++++++++++++++ libavfilter/vf_deshake_opencl.c | 7 +++++++ libavfilter/vf_drawtext.c | 16 ++++++++++++++++ 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index 40f21fb34c..0e7beac63d 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -11842,7 +11842,7 @@ The current packet's position in the input file or stream (in bytes, from the start of the input). A value of -1 indicates this info is not available. -@item pkt_duration +@item duration The current packet's duration, in seconds. @item pkt_size diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index a3190468bb..ae8bba19b0 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -243,6 +243,13 @@ FF_ENABLE_DEPRECATION_WARNINGS } } +#if FF_API_PKT_DURATION +FF_DISABLE_DEPRECATION_WARNINGS + if (copy->pkt_duration && copy->pkt_duration != copy->duration) + copy->duration = copy->pkt_duration; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + ret = ff_filter_frame(ctx->outputs[0], copy); if (ret < 0) return ret; diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c index 672aa4c8f7..d217efe2fd 100644 --- a/libavfilter/f_loop.c +++ b/libavfilter/f_loop.c @@ -331,9 +331,16 @@ static int push_frame(AVFilterContext *ctx) if (!out) return AVERROR(ENOMEM); out->pts += s->duration - s->start_pts; +#if FF_API_PKT_DURATION +FF_DISABLE_DEPRECATION_WARNINGS if (out->pkt_duration) duration = out->pkt_duration; else +FF_ENABLE_DEPRECATION_WARNINGS +#endif + if (out->duration) + duration = out->duration; + else duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base); pts = out->pts + duration; ret = ff_filter_frame(outlink, out); @@ -368,9 +375,16 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) return AVERROR(ENOMEM); } s->nb_frames++; +#if FF_API_PKT_DURATION +FF_DISABLE_DEPRECATION_WARNINGS if (frame->pkt_duration) duration = frame->pkt_duration; else +FF_ENABLE_DEPRECATION_WARNINGS +#endif + if (frame->duration) + duration = frame->duration; + else duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base); s->duration = frame->pts + duration; ret = ff_filter_frame(outlink, frame); diff --git a/libavfilter/vf_deshake_opencl.c b/libavfilter/vf_deshake_opencl.c index c2b5bef897..d488da7fa0 100644 --- a/libavfilter/vf_deshake_opencl.c +++ b/libavfilter/vf_deshake_opencl.c @@ -1413,8 +1413,15 @@ static int filter_frame(AVFilterLink *link, AVFrame *input_frame) &debug_matches, 1); } +#if FF_API_PKT_DURATION +FF_DISABLE_DEPRECATION_WARNINGS if (input_frame->pkt_duration) { duration = input_frame->pkt_duration; + } else +FF_ENABLE_DEPRECATION_WARNINGS +#endif + if (input_frame->duration) { + duration = input_frame->duration; } else { duration = av_rescale_q(1, av_inv_q(outlink->frame_rate), outlink->time_base); } diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index feb6898848..50012bb258 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -91,8 +91,11 @@ static const char *const var_names[] = { "y", "pict_type", "pkt_pos", +#if FF_API_PKT_DURATION "pkt_duration", +#endif "pkt_size", + "duration", NULL }; @@ -131,8 +134,11 @@ enum var_name { VAR_Y, VAR_PICT_TYPE, VAR_PKT_POS, +#if FF_API_PKT_DURATION VAR_PKT_DURATION, +#endif VAR_PKT_SIZE, + VAR_DURATION, VAR_VARS_NB }; @@ -1649,8 +1655,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) s->var_values[VAR_PICT_TYPE] = frame->pict_type; s->var_values[VAR_PKT_POS] = frame->pkt_pos; +#if FF_API_PKT_DURATION +FF_DISABLE_DEPRECATION_WARNINGS s->var_values[VAR_PKT_DURATION] = frame->pkt_duration * av_q2d(inlink->time_base); + + if (frame->pkt_duration) + s->var_values[VAR_DURATION] = frame->pkt_duration * av_q2d(inlink->time_base); + else +FF_ENABLE_DEPRECATION_WARNINGS +#endif + s->var_values[VAR_DURATION] = frame->duration * av_q2d(inlink->time_base); s->var_values[VAR_PKT_SIZE] = frame->pkt_size; + s->metadata = frame->metadata; for (int i = 0; i < loop; i++) {