Skip to content

Instantly share code, notes, and snippets.

@fritsch
Created February 8, 2015 20:24
Show Gist options
  • Save fritsch/c8ef64db99d0df857f4e to your computer and use it in GitHub Desktop.
Save fritsch/c8ef64db99d0df857f4e to your computer and use it in GitHub Desktop.
DVDClock Calculate in float
From 79fb33920de49b34a00000ce7f62546ea32a91b0 Mon Sep 17 00:00:00 2001
From: fritsch <fritsch@xbmc.org>
Date: Sun, 8 Feb 2015 21:23:30 +0100
Subject: [PATCH] DVDClock: Calculate in floats
---
xbmc/cores/dvdplayer/DVDClock.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/xbmc/cores/dvdplayer/DVDClock.cpp b/xbmc/cores/dvdplayer/DVDClock.cpp
index 0a253e4..dd97994 100644
--- a/xbmc/cores/dvdplayer/DVDClock.cpp
+++ b/xbmc/cores/dvdplayer/DVDClock.cpp
@@ -218,14 +218,19 @@ int CDVDClock::UpdateFramerate(double fps, double* interval /*= NULL*/)
CSingleLock lock(m_speedsection);
- double weight = rate / (double)MathUtils::round_int(fps);
+ double weight = rate / fps;
//set the speed of the videoreferenceclock based on fps, refreshrate and maximum speed adjust set by user
if (m_maxspeedadjust > 0.05)
{
if (weight / MathUtils::round_int(weight) < 1.0 + m_maxspeedadjust / 100.0
&& weight / MathUtils::round_int(weight) > 1.0 - m_maxspeedadjust / 100.0)
+ {
+ // in this case we are just there and refreshrate / fps is good enough 1.0
+ // so that we are more in sync to the refreshrate as the fps gets accurate
+ // e.g. 23.98 fps on a 23.976 display
weight = MathUtils::round_int(weight);
+ }
}
double speed = rate / (fps * weight);
lock.Leave();
--
2.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment