Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 3/9] lavfi: use AVFrame.duration instead of AVFrame.pkt_duration
Date: Wed, 13 Jul 2022 11:17:19 +0200
Message-ID: <20220713091725.16638-3-anton@khirnov.net> (raw)
In-Reply-To: <20220713091725.16638-1-anton@khirnov.net>

---
 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++) {
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2022-07-13  9:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13  9:17 [FFmpeg-devel] [PATCH 1/9] lavu/frame: add a duration field to AVFrame Anton Khirnov
2022-07-13  9:17 ` [FFmpeg-devel] [PATCH 2/9] lavc: use AVFrame.duration instead of AVFrame.pkt_duration Anton Khirnov
2022-07-13  9:17 ` Anton Khirnov [this message]
2022-07-13 15:02   ` [FFmpeg-devel] [PATCH 3/9] lavfi: " Nicolas George
2022-07-14  8:46     ` Anton Khirnov
2022-07-13  9:17 ` [FFmpeg-devel] [PATCH 4/9] lavf: " Anton Khirnov
2022-07-13  9:17 ` [FFmpeg-devel] [PATCH 5/9] lavd: " Anton Khirnov
2022-07-13  9:17 ` [FFmpeg-devel] [PATCH 6/9] ffprobe: " Anton Khirnov
2022-07-13 12:39   ` James Almer
2022-07-14  9:34     ` Anton Khirnov
2022-07-14 11:50       ` James Almer
2022-07-18  7:34         ` [FFmpeg-devel] [PATCH] " Anton Khirnov
2022-07-18  8:23           ` Nicolas George
2022-07-18  8:44             ` Anton Khirnov
2022-07-18 11:49           ` James Almer
2022-07-18 11:54             ` Anton Khirnov
2022-07-13  9:17 ` [FFmpeg-devel] [PATCH 7/9] ffmpeg: " Anton Khirnov
2022-07-13  9:17 ` [FFmpeg-devel] [PATCH 8/9] tests/api: " Anton Khirnov
2022-07-13  9:17 ` [FFmpeg-devel] [PATCH 9/9] lavfi/vf_showinfo: print frame durations Anton Khirnov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220713091725.16638-3-anton@khirnov.net \
    --to=anton@khirnov.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git