[vlc-commits] demux: asf: fix delay on seek

Francois Cartegnie git at videolan.org
Wed Nov 4 17:48:47 CET 2020


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Nov  4 15:54:12 2020 +0100| [5a688f368a031d147fbf61cd423d2dc112f8b4de] | committer: Francois Cartegnie

demux: asf: fix delay on seek

Increment base value was not set properly on seek,
causing to unroll by the amount of seek.

(cherry picked from commit 4d96a459cb7f8cb40820614fcf9b0e7c403cb70a)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=5a688f368a031d147fbf61cd423d2dc112f8b4de
---

 modules/demux/asf/asf.c | 38 +++++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c
index bc132fe0ad..edacca0c46 100644
--- a/modules/demux/asf/asf.c
+++ b/modules/demux/asf/asf.c
@@ -127,6 +127,7 @@ struct demux_sys_t
 
     bool                b_index;
     bool                b_canfastseek;
+    bool                b_pcr_sent;
     uint8_t             i_seek_track;
     uint8_t             i_access_selected_track[ES_CATEGORY_COUNT]; /* mms, depends on access algorithm */
     unsigned int        i_wait_keyframe;
@@ -238,7 +239,7 @@ static int Demux( demux_t *p_demux )
                 p_sys->b_eof = true;
         }
 
-        if ( p_sys->i_time == -1 )
+        if ( p_sys->i_time == VLC_TS_INVALID )
             p_sys->i_time = p_sys->i_sendtime;
     }
 
@@ -248,13 +249,21 @@ static int Demux( demux_t *p_demux )
     {
         bool b_data = Block_Dequeue( p_demux, p_sys->i_time + CHUNK );
 
-        p_sys->i_time += CHUNK;
-        es_out_SetPCR( p_demux->out, VLC_TS_0 + p_sys->i_time );
+        if( p_sys->i_time != VLC_TS_INVALID )
+        {
+            p_sys->i_time += CHUNK;
+            p_sys->b_pcr_sent = true;
+            es_out_SetPCR( p_demux->out, p_sys->i_time );
 #ifdef ASF_DEBUG
-        msg_Dbg( p_demux, "Demux Loop Setting PCR to %"PRId64, VLC_TS_0 + p_sys->i_time );
+            msg_Dbg( p_demux, "Demux Loop Setting PCR to %"PRId64, p_sys->i_time );
 #endif
+        }
+
         if ( !b_data && p_sys->b_eos )
         {
+            if( p_sys->i_time != VLC_TS_INVALID )
+                es_out_SetPCR( p_demux->out, p_sys->i_time );
+
             /* We end this stream */
             if( !p_sys->b_eof )
             {
@@ -393,8 +402,9 @@ static void SeekPrepare( demux_t *p_demux )
 
     p_sys->b_eof = false;
     p_sys->b_eos = false;
-    p_sys->i_time = -1;
-    p_sys->i_sendtime = -1;
+    p_sys->b_pcr_sent = false;
+    p_sys->i_time = VLC_TS_INVALID;
+    p_sys->i_sendtime = VLC_TS_INVALID;
     p_sys->i_preroll_start = ASFPACKET_PREROLL_FROM_CURRENT;
 
     for( int i = 0; i < MAX_ASF_TRACKS ; i++ )
@@ -583,7 +593,7 @@ static void Packet_SetAR( asf_packet_sys_t *p_packetsys, uint8_t i_stream_number
 
 static void Packet_SetSendTime( asf_packet_sys_t *p_packetsys, mtime_t i_time )
 {
-    p_packetsys->p_demux->p_sys->i_sendtime = i_time;
+    p_packetsys->p_demux->p_sys->i_sendtime = VLC_TS_0 + i_time;
 }
 
 static void Packet_UpdateTime( asf_packet_sys_t *p_packetsys, uint8_t i_stream_number,
@@ -591,7 +601,7 @@ static void Packet_UpdateTime( asf_packet_sys_t *p_packetsys, uint8_t i_stream_n
 {
     asf_track_t *tk = p_packetsys->p_demux->p_sys->track[i_stream_number];
     if ( tk )
-        tk->i_time = i_time;
+        tk->i_time = VLC_TS_0 + i_time;
 }
 
 static asf_track_info_t * Packet_GetTrackInfo( asf_packet_sys_t *p_packetsys,
@@ -677,11 +687,12 @@ static bool Block_Dequeue( demux_t *p_demux, mtime_t i_nexttime )
             else
                 p_block->p_next = NULL;
 
-            if( p_sys->i_time < VLC_TS_0 )
+            if( !p_sys->b_pcr_sent && p_sys->i_time != VLC_TS_INVALID )
             {
-                es_out_SetPCR( p_demux->out, VLC_TS_0 + p_sys->i_time );
+                p_sys->b_pcr_sent = true;
+                es_out_SetPCR( p_demux->out, p_sys->i_time );
 #ifdef ASF_DEBUG
-                msg_Dbg( p_demux, "    dequeue setting PCR to %"PRId64, VLC_TS_0 + p_sys->i_time );
+                msg_Dbg( p_demux, "    dequeue setting PCR to %"PRId64, p_sys->i_time );
 #endif
             }
 
@@ -775,8 +786,8 @@ static int DemuxInit( demux_t *p_demux )
     demux_sys_t *p_sys = p_demux->p_sys;
 
     /* init context */
-    p_sys->i_time   = -1;
-    p_sys->i_sendtime    = -1;
+    p_sys->i_time   = VLC_TS_INVALID;
+    p_sys->i_sendtime    = VLC_TS_INVALID;
     p_sys->i_length = 0;
     p_sys->b_eos = false;
     p_sys->b_eof = false;
@@ -786,6 +797,7 @@ static int DemuxInit( demux_t *p_demux )
     p_sys->b_index  = 0;
     p_sys->i_track  = 0;
     p_sys->i_seek_track = 0;
+    p_sys->b_pcr_sent = false;
     p_sys->i_wait_keyframe = 0;
     for( int i = 0; i < MAX_ASF_TRACKS; i++ )
     {



More information about the vlc-commits mailing list