X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdcpomatic_time.cc;h=1d965993598c20d6b573ca653d92692b374ff472;hb=3d2fdefdb1bcf0a2baf2285246ed413654bf1f9d;hp=812c756ec27891224495b1a57b3e374ee793321d;hpb=8d58a7c5f4320ad5c111e336c45e44d6b51ab509;p=dcpomatic.git diff --git a/src/lib/dcpomatic_time.cc b/src/lib/dcpomatic_time.cc index 812c756ec..1d9659935 100644 --- a/src/lib/dcpomatic_time.cc +++ b/src/lib/dcpomatic_time.cc @@ -21,13 +21,22 @@ using std::ostream; -ContentTime::ContentTime (DCPTime d, FrameRateChange f) - : Time (rint (d.get() * f.speed_up)) +template <> +Time::Time (DCPTime d, FrameRateChange f) + : _t (llrint (d.get() * f.speed_up)) { } -DCPTime min (DCPTime a, DCPTime b) +template <> +Time::Time (ContentTime d, FrameRateChange f) + : _t (llrint (d.get() / f.speed_up)) +{ + +} + +DCPTime +min (DCPTime a, DCPTime b) { if (a < b) { return a; @@ -36,6 +45,36 @@ DCPTime min (DCPTime a, DCPTime b) return b; } +DCPTime +max (DCPTime a, DCPTime b) +{ + if (a > b) { + return a; + } + + return b; +} + +ContentTime +min (ContentTime a, ContentTime b) +{ + if (a < b) { + return a; + } + + return b; +} + +ContentTime +max (ContentTime a, ContentTime b) +{ + if (a > b) { + return a; + } + + return b; +} + ostream & operator<< (ostream& s, ContentTime t) { @@ -50,14 +89,9 @@ operator<< (ostream& s, DCPTime t) return s; } -bool -ContentTimePeriod::overlaps (ContentTimePeriod const & other) const -{ - return (from < other.to && to >= other.from); -} - -bool -ContentTimePeriod::contains (ContentTime const & other) const +ostream & +operator<< (ostream& s, DCPTimePeriod p) { - return (from <= other && other < to); + s << "[DCP " << p.from.get() << " " << p.from.seconds() << "s -> " << p.to.get() << " " << p.to.seconds() << "s]"; + return s; }