diff mbox series

[FFmpeg-devel,2/5] avformat/fifo: fix handling of stream-time non-NOPTS recovery

Message ID 20201207100845.17520-3-jeebjp@gmail.com
State New
Headers show
Series FIFO meta muxer related improvements
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Jan Ekström Dec. 7, 2020, 10:08 a.m. UTC
From: Jan Ekström <jan.ekstrom@24i.com>

Until now the proper diff between last_recovery_ts and packet's pts
was only done when last_recovery_ts was AV_NOPTS_VALUE. This is
kind of an oxymoron as the result of comparing that difference to
AV_NOPTS_VALUE most likely always be relatively large.

Thus, move the immediate recovery to when last_recovery_ts is
AV_NOPTS_VALUE, and do a proper difference between the values
otherwise.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
---
 libavformat/fifo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/fifo.c b/libavformat/fifo.c
index 55cbf14ae93..b940d0dafe1 100644
--- a/libavformat/fifo.c
+++ b/libavformat/fifo.c
@@ -339,12 +339,12 @@  static int fifo_thread_attempt_recovery(FifoThreadContext *ctx, FifoMessage *msg
 
     if (fifo->recovery_wait_streamtime) {
         if (ctx->last_recovery_ts == AV_NOPTS_VALUE) {
+            /* Enforce recovery immediately */
+            time_since_recovery = fifo->recovery_wait_time;
+        } else {
             AVRational tb = avf->streams[pkt->stream_index]->time_base;
             time_since_recovery = av_rescale_q(pkt->pts - ctx->last_recovery_ts,
                                                tb, AV_TIME_BASE_Q);
-        } else {
-            /* Enforce recovery immediately */
-            time_since_recovery = fifo->recovery_wait_time;
         }
     } else {
         time_since_recovery = av_gettime_relative() - ctx->last_recovery_ts;