diff mbox series

[FFmpeg-devel,03/22] fftools/ffmpeg: stop using decoder properties in ist_dts_update()

Message ID 20230508091738.20813-3-anton@khirnov.net
State Accepted
Commit 989e87b03ce6a03b288f8049dbe11a4083929747
Headers show
Series [FFmpeg-devel,01/22] fftools/ffmpeg: consolidate InputStream.[next_]dts updates | expand

Checks

Context Check Description
andriy/configure_x86 warning Failed to apply patch

Commit Message

Anton Khirnov May 8, 2023, 9:17 a.m. UTC
This code runs post-demuxing and is not synchronized with the decoder
output (which may be delayed with respect to its input by arbitrary and
unknowable amounts), so accessing any decoder properties is incorrect.
---
 fftools/ffmpeg.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 817b643c48..ca6ff780c3 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1856,7 +1856,7 @@  static void ist_dts_update(InputStream *ist, AVPacket *pkt)
 
     if (!ist->saw_first_ts) {
         ist->first_dts =
-        ist->dts = ist->st->avg_frame_rate.num ? - ist->dec_ctx->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
+        ist->dts = ist->st->avg_frame_rate.num ? - ist->par->video_delay * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
         if (pkt->pts != AV_NOPTS_VALUE) {
             ist->first_dts =
             ist->dts += av_rescale_q(pkt->pts, pkt->time_base, AV_TIME_BASE_Q);
@@ -1889,11 +1889,11 @@  static void ist_dts_update(InputStream *ist, AVPacket *pkt)
             ist->next_dts = av_rescale_q(next_dts + 1, av_inv_q(ist->framerate), time_base_q);
         } 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) {
+        } else if (ist->par->framerate.num != 0) {
             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 field_rate = av_mul_q(ist->par->framerate,
                                              (AVRational){ 2, 1 });
 
             ist->next_dts += av_rescale_q(fields, av_inv_q(field_rate), AV_TIME_BASE_Q);