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

Jan Ekström jeebjp at gmail.com
Mon Dec 7 12:08:42 EET 2020


From: Jan Ekström <jan.ekstrom at 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 at 24i.com>
---
 libavformat/fifo.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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;
-- 
2.29.2



More information about the ffmpeg-devel mailing list