Rework on the ffmpeg video decoder (Bg were videos flickering? Can't reproduce)

This commit is contained in:
Flamefire committed 2013-10-21 15:31:20 +02:00
1 parent 5a5d94d18b
commit c4d0bcd723
1 file changed
+9 -18
+9 -18
View File
@@ -23,7 +23,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
private float _FrameDuration; // frame time in s
private float _LastDecodedTime; // time of last decoded frame
private float _LastShownTime; // current video position
private float _LastShownTime; // time if the last shown frame in s
private float _Time;
private float _Gap;
@@ -106,12 +106,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
public bool GetFrame(ref CTexture frame, float time, out float videoTime)
{
if (_Paused)
{
videoTime = 0;
return false;
}
if (Loop)
{
lock (_MutexSyncSignals)
@@ -120,17 +114,17 @@ namespace Vocaluxe.Lib.Video.Acinerella
_LoopTimer.Restart();
}
}
else if (Math.Abs(_SetTime - time) > float.Epsilon)
else if (Math.Abs(_SetTime - time) >= 1f / 1000f) //Check 1 ms difference
{
lock (_MutexSyncSignals)
{
_SetTime = time;
}
}
else
else if (Math.Abs(_LastShownTime - time) < 1f / 1000 && frame != null) //Check 1 ms difference
{
videoTime = 0;
return false; //Check if this false is right. But should as we don't give a frame here
videoTime = _LastShownTime;
return true;
}
_UploadNewFrame(ref frame);
videoTime = _LastShownTime;
@@ -168,11 +162,6 @@ namespace Vocaluxe.Lib.Video.Acinerella
}
_LastDecodedTime = _SkipTime;
lock (_MutexSyncSignals)
{
_LastShownTime = _LastDecodedTime;
}
lock (_MutexFramebuffer)
{
_Framebuffer.Clear();
@@ -408,13 +397,15 @@ namespace Vocaluxe.Lib.Video.Acinerella
float now = _SetTime + _Gap;
float maxEnd = now - _FrameDuration * 2; //Get only frames younger than 2
CFrame frame;
bool paused = _Paused;
while ((frame = _Framebuffer.Get()) != null)
{
float frameEnd = frame.Time + _FrameDuration;
//Don't show frames that are shown during or after now
if (frameEnd >= now)
break; //All following frames are after that one
if (paused) // Don't modify anything
break;
_Framebuffer.SetRead();
//Get the last(newest) possible frame and skip the rest to force in-order showing
if (frameEnd <= maxEnd)
@@ -438,4 +429,4 @@ namespace Vocaluxe.Lib.Video.Acinerella
}
#endregion Threading
}
}
}