diff mbox series

[FFmpeg-devel,17/21] fftools/ffmpeg: stop using InputStream.pts for generating video timestamps

Message ID 20230427142601.2613-17-anton@khirnov.net
State Accepted
Commit ef69f6a9d24e5508294f4009b1011289c683284e
Headers show
Series [FFmpeg-devel,01/21] fftools/ffmpeg: deprecate -adrift_threshold | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 fail Make fate failed

Commit Message

Anton Khirnov April 27, 2023, 2:25 p.m. UTC
This was added in 380db569287ba99d903b7629f209b9adc7fd2723 as a
temporary crutch that is not needed anymore. The only case where this
code can be triggered is the very first frame, for which InputStream.pts
is always equal to 0.
---
 fftools/ffmpeg.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d074d3e03b..a69aceec9f 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1114,12 +1114,9 @@  static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_
         best_effort_timestamp = ist->cfr_next_pts++;
 
     // no timestamp available - extrapolate from previous frame duration
-    if (best_effort_timestamp == AV_NOPTS_VALUE &&
-        ist->last_frame_pts != AV_NOPTS_VALUE)
-        best_effort_timestamp = ist->last_frame_pts + ist->last_frame_duration_est;
-
     if (best_effort_timestamp == AV_NOPTS_VALUE)
-        best_effort_timestamp = av_rescale_q(ist->pts, AV_TIME_BASE_Q, ist->st->time_base);
+        best_effort_timestamp = ist->last_frame_pts == AV_NOPTS_VALUE ? 0 :
+                                ist->last_frame_pts + ist->last_frame_duration_est;
 
     if(best_effort_timestamp != AV_NOPTS_VALUE) {
         int64_t ts = av_rescale_q(decoded_frame->pts = best_effort_timestamp, ist->st->time_base, AV_TIME_BASE_Q);