X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdcpomatic_time.cc;h=28f76607499134933815f888815265fdbceae9c4;hb=f74d619bf98c6069ecc012c1c34fb543592d6bff;hp=ae4dea44f5c0752f6b387365713f772336e8d867;hpb=74fe68e5895654e27a7cf8097917c1e95fa89519;p=dcpomatic.git diff --git a/src/lib/dcpomatic_time.cc b/src/lib/dcpomatic_time.cc index ae4dea44f..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) { @@ -55,3 +94,9 @@ ContentTimePeriod::overlaps (ContentTimePeriod const & other) const { return (from < other.to && to > other.from); } + +bool +ContentTimePeriod::contains (ContentTime const & other) const +{ + return (from <= other && other < to); +}