[mythtv] vsync and frame timing adjustments

Bruce Markey bjm at lvcm.com
Thu Aug 26 16:36:48 EDT 2004


Doug, try this. It includes a counter adjustment but should
be more stable for synchronous refresh and much less intrusive
for asynchronous monitors.

This shrinks the DMZ, uses a significantly smaller counter
adjust and removes the CalcDelay so that it uses the delay
value from when it fell through.

For synchronous monitors (TV), -500 is more than enough to
discover that it has stepped over the line. The adjustment
is still large to get it safely out of the way. The counter-
adjustment is on 50 (max 1500usec per second). This is more
than enough to overcome normal drift and will gently slew to
stay below roughly -4000 and it won't make a drastic move on
'late' frames.

For asynchronous monitors, the delay values do follow a pattern
of sorts but are different from one frame to the next and could
fall anywhere in the range. 0 thru -500 will be hit about 1
out of 66 frames and shift by about 1/17th of a frame. If the
counter-adjust was 2000 on 3/4 of the frames, it would cause
a drift of more than 1fps. However, an adjustment of 50 is
only 1/667 of a frame. These two just about cancel each other
and make the total drift insignificant.

No idea yet why the position of the trigger in between
refreshes would make a difference but this seems to keep it
in a safe spot.

--  bjm
-------------- next part --------------
Index: libs/libmythtv/vsync.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/vsync.cpp,v
retrieving revision 1.3
diff -u -r1.3 vsync.cpp
--- libs/libmythtv/vsync.cpp	23 Aug 2004 01:44:30 -0000	1.3
+++ libs/libmythtv/vsync.cpp	26 Aug 2004 19:52:23 -0000
@@ -165,7 +165,6 @@
 
 void VideoSync::KeepPhase()
 {
-    m_delay = CalcDelay();
     // Keep our nexttrigger from drifting too close to the exact retrace.
     // If delay is near 0, some frames will be delay < 0 and others delay > 0.
     // This will cause continous rapid fire stuttering. Nexttrigger only
@@ -173,8 +172,12 @@
     // falls in the DMZ. Otherwise, nexttrigger should be left alone.
     // This method is only useful for those sync methods where WaitForFrame
     // targets hardware retrace rather than targeting nexttrigger.
-    if (m_delay > -1000)
+
+    cerr << m_delay << endl;
+    if (m_delay > -500)
         OffsetTimeval(m_nexttrigger, -2000);
+    else if (m_delay < -(m_refresh_interval/4))
+        OffsetTimeval(m_nexttrigger, 50);
 }
 
 #define DRM_VBLANK_RELATIVE 0x1;


More information about the mythtv-dev mailing list