All pastes #1687625 Raw Edit

Something

public text v1 · immutable
#1687625 ·published 2009-11-26 02:47 UTC
rendered paste body
Index: NuppelVideoPlayer.cpp
===================================================================
--- NuppelVideoPlayer.cpp	(revision 22909)
+++ NuppelVideoPlayer.cpp	(working copy)
@@ -248,6 +248,7 @@
       lastsync(false),              m_playing_slower(false),
       m_stored_audio_stretchfactor(1.0),
       audio_paused(false),
+      extra_delay(0),
       // Audio warping stuff
       usevideotimebase(false),
       warpfactor(1.0f),             warpfactor_avg(1.0f),
@@ -2361,6 +2362,8 @@
 
     avsync_adjustment = 0;
 
+    extra_delay = 0;
+
     if (usevideotimebase)
     {
         warpfactor_avg = gContext->GetNumSetting("WarpFactor", 0);
@@ -2478,11 +2481,19 @@
 
         VERBOSE(VB_PLAYBACK|VB_TIMESTAMP, QString("AVSync waitforframe %1 %2")
                 .arg(avsync_adjustment).arg(m_double_framerate));
-        videosync->WaitForFrame(avsync_adjustment);
+        videosync->WaitForFrame(avsync_adjustment + extra_delay);
         VERBOSE(VB_PLAYBACK|VB_TIMESTAMP, "AVSync show");
         if (!resetvideo)
             videoOutput->Show(ps);
 
+        if (buffer->repeat_pict) 
+        {
+            extra_delay = frame_interval * buffer->repeat_pict * 0.5;
+            VERBOSE(VB_PLAYBACK, QString("A/V repeat_pict detected (F1), adding %1 us extra delay").arg(extra_delay));
+        }
+        else
+            extra_delay = 0;
+
         if (videoOutput->IsErrored())
         {
             VERBOSE(VB_IMPORTANT, "NVP: Error condition detected "
@@ -2521,14 +2532,25 @@
             // Display the second field
             videosync->AdvanceTrigger();
 #ifdef NEW_AVSYNC
-            videosync->WaitForFrame(avsync_adjustment);
+            videosync->WaitForFrame(avsync_adjustment + extra_delay);
 #else
-            videosync->WaitForFrame(0);
+            videosync->WaitForFrame(extra_delay);
 #endif
             if (!resetvideo)
             {
                 videoOutput->Show(ps);
             }
+
+            if (buffer->repeat_pict) 
+            {
+                extra_delay = frame_interval * buffer->repeat_pict * 0.5;
+                VERBOSE(VB_PLAYBACK, QString("A/V repeat_pict detected (F2), adding %1 us extra delay").arg(extra_delay));
+            }
+            else
+            {
+                extra_delay = 0;
+            }
+
         }
     }
     else
Index: NuppelVideoPlayer.h
===================================================================
--- NuppelVideoPlayer.h	(revision 22909)
+++ NuppelVideoPlayer.h	(working copy)
@@ -803,6 +803,7 @@
     bool       decode_extra_audio;
     float      m_stored_audio_stretchfactor;
     bool       audio_paused;
+    int        extra_delay;
 
     // Audio warping stuff
     bool       usevideotimebase;