X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fgentime.cpp;h=21eb7b70af76466539db9460a1688a296003f0e1;hb=ecda842bf2b632f75198d6cf0fac1fcb5ef862ad;hp=a962e20e3c15332569891fe118bd4d67c50ecbab;hpb=1ecbd5b62783247938e9873868e6ce625ef23b6c;p=kdenlive diff --git a/src/gentime.cpp b/src/gentime.cpp index a962e20e..21eb7b70 100644 --- a/src/gentime.cpp +++ b/src/gentime.cpp @@ -19,36 +19,38 @@ double GenTime::s_delta = 0.00001; -/** Creates a time object, with a time of 0 seconds. */ GenTime::GenTime() { m_time = 0.0; } -/** Creates a time object, with time given in seconds. */ GenTime::GenTime(double seconds) { m_time = seconds; } -/** Creates a time object, by passing number of frames and how many frames per second */ GenTime::GenTime(int frames, double framesPerSecond) { m_time = (double) frames / framesPerSecond; } -/** Returns the time, in milliseconds */ +double GenTime::seconds() const +{ + return m_time; +} + double GenTime::ms() const { return m_time * 1000; } -/** Returns the time in frames, after being given the number of frames per second */ double GenTime::frames(double framesPerSecond) const { - return (int) floor(m_time * framesPerSecond + 0.5); + return floor(m_time * framesPerSecond + 0.5); } -GenTime::~GenTime() +GenTime& GenTime::roundNearestFrame(double framesPerSecond) { + m_time = floor((m_time * framesPerSecond) + 0.5) / framesPerSecond; + return *this; }