]> git.sesse.net Git - vlc/commitdiff
* modules/stream_out/transcode.c: Fixed DTS madness after pausing when
authorChristophe Massiot <massiot@videolan.org>
Fri, 5 Aug 2005 14:46:20 +0000 (14:46 +0000)
committerChristophe Massiot <massiot@videolan.org>
Fri, 5 Aug 2005 14:46:20 +0000 (14:46 +0000)
   --sout-transcode-fps is in use.

modules/stream_out/transcode.c

index fc63decbe6e20a16ce36b988a8140221ec87c335..940ebf2cdaaec253150b833430e33a99e6ac5938 100644 (file)
@@ -37,6 +37,8 @@
 #include "vlc_filter.h"
 #include "osd.h"
 
+#define MASTER_SYNC_MAX_DRIFT 100000
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -1201,8 +1203,10 @@ static int transcode_audio_process( sout_stream_t *p_stream,
         if( p_sys->b_master_sync )
         {
             mtime_t i_dts = date_Get( &id->interpolated_pts ) + 1;
-            if ( i_dts == 1 )
+            if ( p_audio_buf->start_date - i_dts > MASTER_SYNC_MAX_DRIFT
+                  || p_audio_buf->start_date - i_dts < -MASTER_SYNC_MAX_DRIFT )
             {
+                msg_Dbg( p_stream, "drift is too high, resetting master sync" );
                 date_Set( &id->interpolated_pts, p_audio_buf->start_date );
                 i_dts = p_audio_buf->start_date + 1;
             }
@@ -1609,8 +1613,10 @@ static int transcode_video_process( sout_stream_t *p_stream,
             mtime_t i_pts;
 
             i_pts = date_Get( &id->interpolated_pts ) + 1;
-            if ( i_pts == 1 )
+            if ( p_pic->date - i_pts > MASTER_SYNC_MAX_DRIFT
+                  || p_pic->date - i_pts < -MASTER_SYNC_MAX_DRIFT )
             {
+                msg_Dbg( p_stream, "drift is too high, resetting master sync" );
                 date_Set( &id->interpolated_pts, p_pic->date );
                 i_pts = p_pic->date + 1;
             }
@@ -1849,8 +1855,10 @@ static int transcode_video_process( sout_stream_t *p_stream,
         if( p_sys->b_master_sync )
         {
             mtime_t i_pts = date_Get( &id->interpolated_pts ) + 1;
-            if ( i_pts == 1 )
+            if ( p_pic->date - i_pts > MASTER_SYNC_MAX_DRIFT
+                  || p_pic->date - i_pts < -MASTER_SYNC_MAX_DRIFT )
             {
+                msg_Dbg( p_stream, "drift is too high, resetting master sync" );
                 date_Set( &id->interpolated_pts, p_pic->date );
                 i_pts = p_pic->date + 1;
             }
@@ -1860,8 +1868,10 @@ static int transcode_video_process( sout_stream_t *p_stream,
         if( p_sys->b_master_sync && i_duplicate > 1 )
         {
             mtime_t i_pts = date_Get( &id->interpolated_pts ) + 1;
-            if ( i_pts == 1 )
+            if ( p_pic->date - i_pts > MASTER_SYNC_MAX_DRIFT
+                  || p_pic->date - i_pts < -MASTER_SYNC_MAX_DRIFT )
             {
+                msg_Dbg( p_stream, "drift is too high, resetting master sync" );
                 date_Set( &id->interpolated_pts, p_pic->date );
                 i_pts = p_pic->date + 1;
             }