X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdcpomatic_time.cc;h=28f76607499134933815f888815265fdbceae9c4;hb=b299bc81a265d1934bab2c4bce2c8aa48452bbb0;hp=812c756ec27891224495b1a57b3e374ee793321d;hpb=d2137ac5db409e686b4d9b3fa567935a5e416d41;p=dcpomatic.git diff --git a/src/lib/dcpomatic_time.cc b/src/lib/dcpomatic_time.cc index 812c756ec..28f766074 100644 --- a/src/lib/dcpomatic_time.cc +++ b/src/lib/dcpomatic_time.cc @@ -21,13 +21,42 @@ 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; + } + + 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; @@ -36,6 +65,16 @@ DCPTime min (DCPTime a, DCPTime b) return b; } +ContentTime +max (ContentTime a, ContentTime b) +{ + if (a > b) { + return a; + } + + return b; +} + ostream & operator<< (ostream& s, ContentTime t) { @@ -53,7 +92,7 @@ operator<< (ostream& s, DCPTime t) bool ContentTimePeriod::overlaps (ContentTimePeriod const & other) const { - return (from < other.to && to >= other.from); + return (from < other.to && to > other.from); } bool