73 _secs = s + (frames / fr);
80 if (newFramerate <= 0)
92 _secs = s + (frames / fr);
100 assert(newFramerate != 0);
192 ts.
_secs += ms / 1000;
203 throw Exception(
"Cannot add two timestamps of different frame rates");
251 delta -= ((long)ts.
_numFrames * p + q/2) / (long)q;
T gcd(T a, T b)
Euclid's algorithm to compute the greatest common divisor.
int64 frameDiff(const Timestamp &ts) const
Computes the number of frames between this timestamp and ts.
A simple rational class that holds fractions.
uint64 framerate() const
Return the framerate used by this timestamp.
uint64 _framerate
The internal framerate, i.e.
bool operator==(const Timestamp &ts) const
Check whether to timestamps describe the exact same moment in time.
int64 msecsDiff(const Timestamp &ts) const
Computes the number off milliseconds between this timestamp and ts.
bool operator!=(const Timestamp &ts) const
int64 _secs
The seconds part of this timestamp.
bool operator>=(const Timestamp &ts) const
bool operator<=(const Timestamp &ts) const
Timestamp operator-() const
Basic exceptions to throw.
Timestamp(uint64 msecs=0, uint64 framerate=1)
Set up a timestamp with a given time and framerate.
Timestamp addMsecs(int64 msecs) const
Returns a new timestamp, which corresponds to the time encoded by this timestamp with the given numbe...
Timestamp operator+(const Timestamp &ts) const
Compute the sum of two timestamps.
uint64 _framerateFactor
Factor by which the original framerate specified by the client code was multipled to obtain the inter...
int64 cmp(const Timestamp &ts) const
Compare this timestamp to another one and return a value similar to strcmp.
void normalize()
Normalize this timestamp by making _numFrames non-negative and reducing it modulo _framerate...
int getDenominator() const
bool operator>(const Timestamp &ts) const
bool operator<(const Timestamp &ts) const
Timestamps allow specifying points in time and measuring time intervals with a sub-millisecond granul...
int64 msecs() const
Return the time in milliseconds described by this timestamp, rounded down.
Rational number implementation.
int64 _numFrames
The number of frames which together with _secs encodes the timestamp.
Timestamp addFrames(int64 frames) const
Returns a new timestamp, which corresponds to the time encoded by this timestamp with the given numbe...
Rational getInverse() const
Timestamp convertToFramerate(uint64 newFramerate) const
Return a timestamp which represents as closely as possible the point in time describes by this timest...
void addIntern(const Timestamp &ts)
Add another timestamp to this one and normalize the result.