X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdcpomatic_time.cc;h=1d965993598c20d6b573ca653d92692b374ff472;hb=bd81f33a39c6d20e78fce0d5be3b2d487b6df344;hp=5344915c0c71c31639629ad58995ff6a3a96c25d;hpb=79ce26d031d109177ba4b0f637fa2960345a37a3;p=dcpomatic.git diff --git a/src/lib/dcpomatic_time.cc b/src/lib/dcpomatic_time.cc index 5344915c0..1d9659935 100644 --- a/src/lib/dcpomatic_time.cc +++ b/src/lib/dcpomatic_time.cc @@ -19,13 +19,44 @@ #include "dcpomatic_time.h" -ContentTime::ContentTime (DCPTime d, FrameRateChange f) - : Time (rint (d.get() * f.speed_up)) +using std::ostream; + +template <> +Time::Time (DCPTime d, FrameRateChange f) + : _t (llrint (d.get() * f.speed_up)) +{ + +} + +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; } -DCPTime min (DCPTime a, DCPTime b) +ContentTime +min (ContentTime a, ContentTime b) { if (a < b) { return a; @@ -33,3 +64,34 @@ 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) +{ + s << "[CONT " << t.get() << " " << t.seconds() << "s]"; + return s; +} + +ostream & +operator<< (ostream& s, DCPTime t) +{ + s << "[DCP " << t.get() << " " << t.seconds() << "s]"; + return s; +} + +ostream & +operator<< (ostream& s, DCPTimePeriod p) +{ + s << "[DCP " << p.from.get() << " " << p.from.seconds() << "s -> " << p.to.get() << " " << p.to.seconds() << "s]"; + return s; +}