diff mbox series

[FFmpeg-devel,12/12] fftools/ffmpeg_sched: track dts+duration as last_dts

Message ID 20231213193007.17471-12-anton@khirnov.net
State Accepted
Commit 5c5140ded2c1bb74c79bed68f2c8d1b091d3e39b
Headers show
Series [FFmpeg-devel,01/12] fftools/ffmpeg_filter: move FilterGraph.graph to FilterGraphThread | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Dec. 13, 2023, 7:30 p.m. UTC
This should be slightly (probably negligibly) more accurate for
scheduling, but mainly it improves the final reported time.

Reported-by: Paul B Mahol
---
 fftools/ffmpeg_sched.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c
index b1c7db776e..263b0094ca 100644
--- a/fftools/ffmpeg_sched.c
+++ b/fftools/ffmpeg_sched.c
@@ -192,7 +192,7 @@  typedef struct SchMuxStream {
     ////////////////////////////////////////////////////////////
     // The following are protected by Scheduler.schedule_lock //
 
-    /* dts of the last packet sent to this stream
+    /* dts+duration of the last packet sent to this stream
        in AV_TIME_BASE_Q */
     int64_t             last_dts;
     // this stream no longer accepts input
@@ -1619,8 +1619,8 @@  static int send_to_mux(Scheduler *sch, SchMux *mux, unsigned stream_idx,
                        AVPacket *pkt)
 {
     SchMuxStream *ms = &mux->streams[stream_idx];
-    int64_t dts = (pkt && pkt->dts != AV_NOPTS_VALUE)                    ?
-                  av_rescale_q(pkt->dts, pkt->time_base, AV_TIME_BASE_Q) :
+    int64_t dts = (pkt && pkt->dts != AV_NOPTS_VALUE)                                    ?
+                  av_rescale_q(pkt->dts + pkt->duration, pkt->time_base, AV_TIME_BASE_Q) :
                   AV_NOPTS_VALUE;
 
     // queue the packet if the muxer cannot be started yet