X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdcpomatic_time.cc;h=4541ced7dc504db73621e9db29e23bbe4b2750d5;hb=661de111c0dbc968ecb004eca5b26f8400b136f1;hp=98888646d0a841e26bcb077a426be8ac66e1e8e4;hpb=a4c19a34244aeaf183c25878933b570fc5c0ee34;p=dcpomatic.git diff --git a/src/lib/dcpomatic_time.cc b/src/lib/dcpomatic_time.cc index 98888646d..4541ced7d 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 (rint (d.get() * f.speed_up)) { } -DCPTime min (DCPTime a, DCPTime b) +template <> +Time::Time (ContentTime d, FrameRateChange f) + : _t (rint (d.get() / f.speed_up)) +{ + +} + +DCPTime +min (DCPTime a, DCPTime b) { if (a < b) { return a; @@ -49,3 +58,15 @@ operator<< (ostream& s, DCPTime t) s << "[DCP " << t.get() << " " << t.seconds() << "s]"; return s; } + +bool +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); +}