Jitter only of frame height has changed for three or more consecutive frames.

This commit is contained in:
Christian Speckner 2017-06-24 00:09:34 +02:00
parent 628133d2dd
commit 4515e79b4e
2 changed files with 29 additions and 3 deletions

View File

@ -38,7 +38,8 @@ enum Metrics: uInt32 {
framesForModeConfirmation = 5, framesForModeConfirmation = 5,
minStableFrames = 10, minStableFrames = 10,
maxStabilizationFrames = 20, maxStabilizationFrames = 20,
minDeltaForJitter = 3 minDeltaForJitter = 3,
framesForStableHeight = 2
}; };
static constexpr uInt32 static constexpr uInt32
@ -98,6 +99,9 @@ void FrameManager::reset()
myStabilizationFrames = 0; myStabilizationFrames = 0;
myStableFrames = 0; myStableFrames = 0;
myHasStabilized = false; myHasStabilized = false;
myStableFrameLines = -1;
myStableFrameHeightCountdown = 0;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -234,7 +238,20 @@ void FrameManager::setState(FrameManager::State state)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameManager::finalizeFrame() void FrameManager::finalizeFrame()
{ {
handleJitter(myCurrentFrameTotalLines - myCurrentFrameFinalLines); if (myCurrentFrameTotalLines != (uInt32)myStableFrameLines) {
if (myCurrentFrameTotalLines == myCurrentFrameFinalLines) {
if (++myStableFrameHeightCountdown >= Metrics::framesForStableHeight) {
if (myStableFrameLines >= 0) {
handleJitter(myCurrentFrameTotalLines - myStableFrameLines);
}
myStableFrameLines = myCurrentFrameTotalLines;
}
}
else myStableFrameHeightCountdown = 0;
}
myPreviousFrameFinalLines = myCurrentFrameFinalLines; myPreviousFrameFinalLines = myCurrentFrameFinalLines;
myCurrentFrameFinalLines = myCurrentFrameTotalLines; myCurrentFrameFinalLines = myCurrentFrameTotalLines;
@ -257,7 +274,7 @@ void FrameManager::finalizeFrame()
void FrameManager::handleJitter(Int32 scanlineDifference) void FrameManager::handleJitter(Int32 scanlineDifference)
{ {
if ( if (
abs(scanlineDifference) < minDeltaForJitter || (uInt32)abs(scanlineDifference) < Metrics::minDeltaForJitter ||
!myJitterEnabled || !myJitterEnabled ||
myTotalFrames < Metrics::initialGarbageFrames myTotalFrames < Metrics::initialGarbageFrames
) return; ) return;
@ -401,6 +418,9 @@ bool FrameManager::save(Serializer& out) const
out.putInt(myFixedHeight); out.putInt(myFixedHeight);
out.putBool(myJitterEnabled); out.putBool(myJitterEnabled);
out.putInt(myStableFrameLines);
out.putInt(myStableFrameHeightCountdown);
} }
catch(...) catch(...)
{ {
@ -451,6 +471,9 @@ bool FrameManager::load(Serializer& in)
myFixedHeight = in.getInt(); myFixedHeight = in.getInt();
myJitterEnabled = in.getBool(); myJitterEnabled = in.getBool();
myStableFrameLines = in.getInt();
myStableFrameHeightCountdown = in.getInt();
} }
catch(...) catch(...)
{ {

View File

@ -175,6 +175,9 @@ class FrameManager : public Serializable
bool myJitterEnabled; bool myJitterEnabled;
Int32 myStableFrameLines;
uInt8 myStableFrameHeightCountdown;
private: private:
FrameManager(const FrameManager&) = delete; FrameManager(const FrameManager&) = delete;
FrameManager(FrameManager&&) = delete; FrameManager(FrameManager&&) = delete;