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 13/13] fftools/ffmpeg: stop using deprecated ticks_per_frame
Date: Sun,  7 May 2023 15:32:55 +0200
Message-ID: <20230507133255.20881-13-anton@khirnov.net> (raw)
In-Reply-To: <20230507133255.20881-1-anton@khirnov.net>

---
 fftools/ffmpeg.c       | 13 +++++++------
 fftools/ffmpeg.h       |  1 +
 fftools/ffmpeg_demux.c |  2 ++
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 4e45ab74b9..a731b4bd7d 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1516,12 +1516,13 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
             } else if (pkt->duration) {
                 ist->next_dts += av_rescale_q(pkt->duration, pkt->time_base, AV_TIME_BASE_Q);
             } else if(ist->dec_ctx->framerate.num != 0) {
-                int ticks = ist->last_pkt_repeat_pict >= 0 ?
-                            ist->last_pkt_repeat_pict + 1  :
-                            ist->dec_ctx->ticks_per_frame;
-                ist->next_dts += ((int64_t)AV_TIME_BASE *
-                                  ist->dec_ctx->framerate.den * ticks) /
-                                  ist->dec_ctx->framerate.num / ist->dec_ctx->ticks_per_frame;
+                int fields = (ist->codec_desc &&
+                              (ist->codec_desc->props & AV_CODEC_PROP_FIELDS)) ?
+                             ist->last_pkt_repeat_pict + 1 : 2;
+                AVRational field_rate = av_mul_q(ist->dec_ctx->framerate,
+                                                 (AVRational){ 2, 1 });
+
+                ist->next_dts += av_rescale_q(fields, av_inv_q(field_rate), AV_TIME_BASE_Q);
             }
             break;
         }
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index b6389d7f99..0cceffbe9b 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -354,6 +354,7 @@ typedef struct InputStream {
     AVCodecParameters *par;
     AVCodecContext *dec_ctx;
     const AVCodec *dec;
+    const AVCodecDescriptor *codec_desc;
     AVFrame *decoded_frame;
     AVPacket *pkt;
 
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 26426c7ac1..6f26e4226d 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -941,6 +941,8 @@ static void add_input_streams(const OptionsContext *o, Demuxer *d)
             av_log(ist, AV_LOG_ERROR, "Error initializing the decoder context.\n");
             exit_program(1);
         }
+
+        ist->codec_desc = avcodec_descriptor_get(ist->par->codec_id);
     }
 }
 
-- 
2.39.2

_______________________________________________
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:[~2023-05-07 13:34 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-07 13:32 [FFmpeg-devel] [PATCH 01/13] lavu/frame: extend AVFrame.repeat_pict documentation Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 02/13] fftools/ffmpeg: fix computing video frame duration from repeat_pict Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 03/13] lavc/codec_desc: add a property for codecs that support field coding Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 04/13] lavf: use AV_CODEC_PROP_FIELDS where appropriate Anton Khirnov
2023-05-08 14:12   ` Michael Niedermayer
2023-05-09  8:37     ` [FFmpeg-devel] [PATCH v2 " Anton Khirnov
2023-05-08 14:15   ` [FFmpeg-devel] [PATCH " Michael Niedermayer
2023-05-09  8:44     ` Anton Khirnov
2023-05-15 18:59       ` Michael Niedermayer
2023-05-15 20:44         ` Anton Khirnov
2023-05-16 17:41           ` Michael Niedermayer
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 05/13] lavc/av1*: fix exporting framerate Anton Khirnov
2023-05-10 11:52   ` James Almer
2023-05-14 19:39     ` [FFmpeg-devel] [PATCH] " Anton Khirnov
2023-05-14 19:50       ` James Almer
2023-05-15  8:22         ` Anton Khirnov
2023-05-15 11:41           ` James Almer
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 06/13] lavc/libdav1d: " Anton Khirnov
2023-05-15  8:22   ` [FFmpeg-devel] [PATCH] " Anton Khirnov
2023-05-15 11:47     ` James Almer
2023-05-15 12:22       ` Anton Khirnov
2023-05-15 12:41         ` James Almer
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 07/13] lavc/ratecontrol: use AVCodecContext.framerate when available Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 08/13] lavc/msmpeg4enc: " Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 09/13] libaomenc: " Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 10/13] lavc/libkvazaar, libopenh264enc: drop redundant checks Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 11/13] lavc/libvpxenc: send frame durations to the encoder Anton Khirnov
2023-05-09  1:18   ` James Zern
2023-05-09  9:09     ` [FFmpeg-devel] [PATCH v2 " Anton Khirnov
2023-05-09 18:17       ` James Zern
2023-05-10  6:34         ` Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 12/13] lavc: deprecate AVCodecContext.ticks_per_frame Anton Khirnov
2023-05-07 13:32 ` Anton Khirnov [this message]
2023-05-07 16:59 ` [FFmpeg-devel] [PATCH 01/13] lavu/frame: extend AVFrame.repeat_pict documentation Kieran Kunhya
2023-05-07 18:01   ` 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=20230507133255.20881-13-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