diff options
author | phintuka <phintuka> | 2007-01-01 08:09:11 +0000 |
---|---|---|
committer | phintuka <phintuka> | 2007-01-01 08:09:11 +0000 |
commit | 075c4189a0864aabd19881e526713651f023facc (patch) | |
tree | d09c1692b964a85d0fb5154be25f368a2d8eafb2 | |
parent | f9f85fb1d6a8d173a260ce04df74af8e89476922 (diff) | |
download | xineliboutput-075c4189a0864aabd19881e526713651f023facc.tar.gz xineliboutput-075c4189a0864aabd19881e526713651f023facc.tar.bz2 |
Fix synchronizing clock to video (B/P frames are sent out-of-order, so PTS timestamps are not monotonic)
-rw-r--r-- | tools/udp_pes_scheduler.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/tools/udp_pes_scheduler.c b/tools/udp_pes_scheduler.c index 7237492a..3fd19f0c 100644 --- a/tools/udp_pes_scheduler.c +++ b/tools/udp_pes_scheduler.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: udp_pes_scheduler.c,v 1.19 2007-01-01 07:50:50 phintuka Exp $ + * $Id: udp_pes_scheduler.c,v 1.20 2007-01-01 08:09:11 phintuka Exp $ * */ @@ -532,22 +532,28 @@ int cUdpScheduler::calc_elapsed_vtime(int64_t pts, bool Audio) { int64_t diff = 0; - if(!Audio /*Video*/) { - /* #warning TODO: should be possible to use video pts too (if ac3 or muted ...) */ + if(!Audio) { diff = pts - current_video_vtime; - if(diff < 0) diff = -diff; - if(diff > JUMP_LIMIT_TIME) { // 1 s (must be > GOP) + if(diff > JUMP_LIMIT_TIME || (-diff) > JUMP_LIMIT_TIME) { // 1 s (must be > GOP) // RESET #ifdef LOG_SCR LOGDBG("cUdpScheduler RESET (Video jump %lld->%lld)", - current_audio_vtime, pts); + current_video_vtime, pts); data_sent = frames_sent = 0; #endif - //diff = 0; current_video_vtime = pts; + + // Use video pts for sync only in audioless trickspeeds + // (audio has smaller, constant and increasing intervals) + if(m_TrickSpeed) + MasterClock.Set(current_video_vtime + INITIAL_BURST_TIME); + return -1; } - current_video_vtime = pts; + if(diff < 0) /* ignore small negative differences (B/P frames are sent out-of-order) */ + diff = 0; + else + current_video_vtime = pts; } else if(Audio) { diff = pts - current_audio_vtime; @@ -559,7 +565,6 @@ int cUdpScheduler::calc_elapsed_vtime(int64_t pts, bool Audio) current_audio_vtime, pts); data_sent = frames_sent = 0; #endif - //diff = 0; current_audio_vtime = pts; // Use audio pts for sync (audio has constant and increasing intervals) @@ -579,7 +584,7 @@ int cUdpScheduler::calc_elapsed_vtime(int64_t pts, bool Audio) data_sent = frames_sent = 0; } #endif - + return (int) diff; } |