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 2/9] lavc: use AVFrame.duration instead of AVFrame.pkt_duration
Date: Wed, 13 Jul 2022 11:17:18 +0200
Message-ID: <20220713091725.16638-2-anton@khirnov.net> (raw)
In-Reply-To: <20220713091725.16638-1-anton@khirnov.net>

---
 libavcodec/crystalhd.c |  2 +-
 libavcodec/cuviddec.c  |  2 +-
 libavcodec/decode.c    | 14 ++++++++++----
 libavcodec/encode.c    | 11 ++++++++++-
 libavcodec/gifdec.c    |  2 +-
 libavcodec/libdav1d.c  |  2 +-
 libavcodec/mfenc.c     |  2 +-
 libavcodec/rawdec.c    |  2 +-
 8 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c
index cf74f22e7d..211a485918 100644
--- a/libavcodec/crystalhd.c
+++ b/libavcodec/crystalhd.c
@@ -546,7 +546,7 @@ static inline CopyRet copy_frame(AVCodecContext *avctx,
     frame->pts = pkt_pts;
 
     frame->pkt_pos = -1;
-    frame->pkt_duration = 0;
+    frame->duration = 0;
     frame->pkt_size = -1;
 
     if (!priv->need_second_field) {
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index b544b3361d..d1b5dbc6f5 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -624,7 +624,7 @@ static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame)
          * So set pkt_pts and clear all the other pkt_ fields.
          */
         frame->pkt_pos = -1;
-        frame->pkt_duration = 0;
+        frame->duration = 0;
         frame->pkt_size = -1;
 
         frame->interlaced_frame = !parsed_frame.is_deinterlacing && !parsed_frame.dispinfo.progressive_frame;
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 1893caa6a6..14ce4c2e2f 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -394,8 +394,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
                         frame->pts += diff_ts;
                     if(frame->pkt_dts!=AV_NOPTS_VALUE)
                         frame->pkt_dts += diff_ts;
-                    if (frame->pkt_duration >= diff_ts)
-                        frame->pkt_duration -= diff_ts;
+                    if (frame->duration >= diff_ts)
+                        frame->duration -= diff_ts;
                 } else {
                     av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for skipped samples.\n");
                 }
@@ -417,7 +417,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
                     int64_t diff_ts = av_rescale_q(frame->nb_samples - discard_padding,
                                                    (AVRational){1, avctx->sample_rate},
                                                    avctx->pkt_timebase);
-                    frame->pkt_duration = diff_ts;
+                    frame->duration = diff_ts;
                 } else {
                     av_log(avctx, AV_LOG_WARNING, "Could not update timestamps for discarded samples.\n");
                 }
@@ -549,6 +549,12 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
                                                          frame->pts,
                                                          frame->pkt_dts);
 
+#if FF_API_PKT_DURATION
+FF_DISABLE_DEPRECATION_WARNINGS
+        frame->pkt_duration = frame->duration;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
         /* the only case where decode data is not set should be decoders
          * that do not call ff_get_buffer() */
         av_assert0((frame->private_ref && frame->private_ref->size == sizeof(FrameDecodeData)) ||
@@ -1267,7 +1273,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
     if (!(ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) {
         frame->pts = pkt->pts;
         frame->pkt_pos      = pkt->pos;
-        frame->pkt_duration = pkt->duration;
+        frame->duration     = pkt->duration;
         frame->pkt_size     = pkt->size;
 
         for (int i = 0; i < FF_ARRAY_ELEMS(sd); i++) {
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 1f39ab1a2f..310fe20777 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -339,7 +339,7 @@ static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src)
                     return ret;
 
                 avctx->internal->last_audio_frame = 1;
-                return 0;
+                goto finish;
             } else if (src->nb_samples > avctx->frame_size) {
                 av_log(avctx, AV_LOG_ERROR, "nb_samples (%d) != frame_size (%d)\n", src->nb_samples, avctx->frame_size);
                 return AVERROR(EINVAL);
@@ -351,6 +351,15 @@ static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src)
     if (ret < 0)
         return ret;
 
+finish:
+
+#if FF_API_PKT_DURATION
+FF_DISABLE_DEPRECATION_WARNINGS
+    if (dst->pkt_duration && dst->pkt_duration != dst->duration)
+        dst->duration = dst->pkt_duration;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
     return 0;
 }
 
diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
index 3936de1cd2..fbb1ef6ad5 100644
--- a/libavcodec/gifdec.c
+++ b/libavcodec/gifdec.c
@@ -475,7 +475,7 @@ static int gif_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
 
     s->frame->pts     = avpkt->pts;
     s->frame->pkt_dts = avpkt->dts;
-    s->frame->pkt_duration = avpkt->duration;
+    s->frame->duration = avpkt->duration;
 
     if (avpkt->size >= 6) {
         s->keyframe = memcmp(avpkt->data, gif87a_sig, 6) == 0 ||
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index 0a46cf2264..126bc3ae06 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -415,7 +415,7 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
     frame->pkt_dts = p->m.timestamp;
     frame->pkt_pos = p->m.offset;
     frame->pkt_size = p->m.size;
-    frame->pkt_duration = p->m.duration;
+    frame->duration = p->m.duration;
     frame->key_frame = p->frame_hdr->frame_type == DAV1D_FRAME_TYPE_KEY;
 
     switch (p->frame_hdr->frame_type) {
diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index bbe78605a9..4646302430 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -344,7 +344,7 @@ static IMFSample *mf_v_avframe_to_sample(AVCodecContext *avctx, const AVFrame *f
         return NULL;
     }
 
-    IMFSample_SetSampleDuration(sample, mf_to_mf_time(avctx, frame->pkt_duration));
+    IMFSample_SetSampleDuration(sample, mf_to_mf_time(avctx, frame->duration));
 
     return sample;
 }
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index c10b20d4f9..bf9a2b1f56 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -234,7 +234,7 @@ static int raw_decode(AVCodecContext *avctx, AVFrame *frame,
         return res;
 
     frame->pkt_pos      = avctx->internal->last_pkt_props->pos;
-    frame->pkt_duration = avctx->internal->last_pkt_props->duration;
+    frame->duration     = avctx->internal->last_pkt_props->duration;
 
     if (context->tff >= 0) {
         frame->interlaced_frame = 1;
-- 
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".

  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 ` Anton Khirnov [this message]
2022-07-13  9:17 ` [FFmpeg-devel] [PATCH 3/9] lavfi: use AVFrame.duration instead of AVFrame.pkt_duration Anton Khirnov
2022-07-13 15:02   ` 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-2-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