[FFmpeg-cvslog] lavf: fill in past dts based on reordered pts once the delay becomes known.

Michael Niedermayer git at videolan.org
Wed Sep 26 23:18:11 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Sep 26 22:54:57 2012 +0200| [2e4ec8947d954f1d00e724c520920499397b8ef7] | committer: Michael Niedermayer

lavf: fill in past dts based on reordered pts once the delay becomes known.

Previously we had ignored the past dts and just filled in from the
point where we have had sufficient information.

This should fix Ticket1734

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2e4ec8947d954f1d00e724c520920499397b8ef7
---

 libavformat/utils.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 83b2d26..05c4b7f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -940,15 +940,21 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
 {
     AVStream *st= s->streams[stream_index];
     AVPacketList *pktl= s->parse_queue ? s->parse_queue : s->packet_buffer;
+    int64_t pts_buffer[MAX_REORDER_DELAY];
     int64_t shift;
+    int i, delay;
 
     if(st->first_dts != AV_NOPTS_VALUE || dts == AV_NOPTS_VALUE || st->cur_dts == AV_NOPTS_VALUE || is_relative(dts))
         return;
 
+    delay = st->codec->has_b_frames;
     st->first_dts= dts - (st->cur_dts - RELATIVE_TS_BASE);
     st->cur_dts= dts;
     shift = st->first_dts - RELATIVE_TS_BASE;
 
+    for (i=0; i<MAX_REORDER_DELAY; i++)
+        pts_buffer[i] = AV_NOPTS_VALUE;
+
     if (is_relative(pts))
         pts += shift;
 
@@ -963,6 +969,14 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
 
         if(st->start_time == AV_NOPTS_VALUE && pktl->pkt.pts != AV_NOPTS_VALUE)
             st->start_time= pktl->pkt.pts;
+
+        if(pktl->pkt.pts != AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY && has_decode_delay_been_guessed(st)){
+            pts_buffer[0]= pktl->pkt.pts;
+            for(i=0; i<delay && pts_buffer[i] > pts_buffer[i+1]; i++)
+                FFSWAP(int64_t, pts_buffer[i], pts_buffer[i+1]);
+            if(pktl->pkt.dts == AV_NOPTS_VALUE)
+                pktl->pkt.dts= pts_buffer[0];
+        }
     }
     if (st->start_time == AV_NOPTS_VALUE)
         st->start_time = pts;



More information about the ffmpeg-cvslog mailing list