Add a Type to Time.
authorCarl Hetherington <cth@carlh.net>
Tue, 1 Jul 2014 13:13:10 +0000 (14:13 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 1 Jul 2014 13:13:10 +0000 (14:13 +0100)
src/lib/dcpomatic_time.h
src/lib/ffmpeg_examiner.cc
src/lib/player.cc
src/lib/sndfile_content.cc
src/lib/subrip_content.cc
src/lib/video_content.cc

index 4afc9ab40623e09a226965ce8cdfb7e7a77d7784..7f5379595ac211c9da77982f86a6b92f980bad64 100644 (file)
@@ -39,13 +39,15 @@ public:
                : _t (0)
        {}
 
-       explicit Time (int64_t t)
+       typedef int64_t Type;
+
+       explicit Time (Type t)
                : _t (t)
        {}
 
        virtual ~Time () {}
 
-       int64_t get () const {
+       Type get () const {
                return _t;
        }
 
@@ -97,7 +99,7 @@ public:
 protected:
        friend class dcptime_round_up_test;
        
-       int64_t _t;
+       Type _t;
        static const int HZ = 96000;
 };
 
@@ -107,8 +109,8 @@ class ContentTime : public Time
 {
 public:
        ContentTime () : Time () {}
-       explicit ContentTime (int64_t t) : Time (t) {}
-       ContentTime (int64_t n, int64_t d) : Time (n * HZ / d) {}
+       explicit ContentTime (Type t) : Time (t) {}
+       ContentTime (Type n, Type d) : Time (n * HZ / d) {}
        ContentTime (DCPTime d, FrameRateChange f);
 
        bool operator< (ContentTime const & o) const {
@@ -162,8 +164,8 @@ public:
         *  @param r Sampling rate.
         */
        ContentTime round_up (float r) {
-               int64_t const n = rint (HZ / r);
-               int64_t const a = _t + n - 1;
+               Type const n = rint (HZ / r);
+               Type const a = _t + n - 1;
                return ContentTime (a - (a % n));
        }
 
@@ -207,7 +209,7 @@ class DCPTime : public Time
 {
 public:
        DCPTime () : Time () {}
-       explicit DCPTime (int64_t t) : Time (t) {}
+       explicit DCPTime (Type t) : Time (t) {}
        DCPTime (ContentTime t, FrameRateChange c) : Time (rint (t.get() / c.speed_up)) {}
 
        bool operator< (DCPTime const & o) const {
@@ -261,8 +263,8 @@ public:
         *  @param r Sampling rate.
         */
        DCPTime round_up (float r) {
-               int64_t const n = rint (HZ / r);
-               int64_t const a = _t + n - 1;
+               Type const n = rint (HZ / r);
+               Type const a = _t + n - 1;
                return DCPTime (a - (a % n));
        }
 
index 949062f5bd5c3a9e5b1eace869ffc4474007560f..62b909b1d65f3708293ca8dcbe91fe4a371d4608 100644 (file)
@@ -177,7 +177,7 @@ ContentTime
 FFmpegExaminer::video_length () const
 {
        ContentTime const length = ContentTime::from_seconds (double (_format_context->duration - _format_context->start_time) / AV_TIME_BASE);
-       return ContentTime (max (int64_t (1), length.get ()));
+       return ContentTime (max (ContentTime::Type (1), length.get ()));
 }
 
 string
index bb1a4cdeb582298d8d22bd9cc1fcda08e4bf241c..380133b61da5a970eb09dd2da62ef83fd6ecd21d 100644 (file)
@@ -501,7 +501,7 @@ Player::dcp_to_content_video (shared_ptr<const Piece> piece, DCPTime t) const
 {
        /* s is the offset of t from the start position of this content */
        DCPTime s = t - piece->content->position ();
-       s = DCPTime (max (int64_t (0), s.get ()));
+       s = DCPTime (max (DCPTime::Type (0), s.get ()));
        s = DCPTime (min (piece->content->length_after_trim().get(), s.get()));
 
        /* Convert this to the content frame */
@@ -513,7 +513,7 @@ Player::dcp_to_content_audio (shared_ptr<const Piece> piece, DCPTime t) const
 {
        /* s is the offset of t from the start position of this content */
        DCPTime s = t - piece->content->position ();
-       s = DCPTime (max (int64_t (0), s.get ()));
+       s = DCPTime (max (DCPTime::Type (0), s.get ()));
        s = DCPTime (min (piece->content->length_after_trim().get(), s.get()));
 
        /* Convert this to the content frame */
@@ -525,7 +525,7 @@ Player::dcp_to_content_subtitle (shared_ptr<const Piece> piece, DCPTime t) const
 {
        /* s is the offset of t from the start position of this content */
        DCPTime s = t - piece->content->position ();
-       s = DCPTime (max (int64_t (0), s.get ()));
+       s = DCPTime (max (DCPTime::Type (0), s.get ()));
        s = DCPTime (min (piece->content->length_after_trim().get(), s.get()));
 
        return ContentTime (s + piece->content->trim_start(), piece->frc);
index 37f2055359aa8a9d39dcced316a5476cd57bcec8..aab69f3063c5cf9c229dd7e97f79f6f0e0a5fd53 100644 (file)
@@ -50,7 +50,7 @@ SndfileContent::SndfileContent (shared_ptr<const Film> f, cxml::ConstNodePtr nod
        , _audio_mapping (node->node_child ("AudioMapping"), version)
 {
        _audio_channels = node->number_child<int> ("AudioChannels");
-       _audio_length = ContentTime (node->number_child<int64_t> ("AudioLength"));
+       _audio_length = ContentTime (node->number_child<ContentTime::Type> ("AudioLength"));
        _audio_frame_rate = node->number_child<int> ("AudioFrameRate");
 }
 
index 892578adecc11595bf8059ee2530f87bf88dca14..455bd1e8fb32286c5ceecc00be0714d088e755d7 100644 (file)
@@ -42,7 +42,7 @@ SubRipContent::SubRipContent (shared_ptr<const Film> film, boost::filesystem::pa
 SubRipContent::SubRipContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version)
        : Content (film, node)
        , SubtitleContent (film, node, version)
-       , _length (node->number_child<int64_t> ("Length"))
+       , _length (node->number_child<DCPTime::Type> ("Length"))
 {
 
 }
index f52a75e706c5105067117c66cf6921556afe5a55..97e7915df33dd81ad8ea71460fc993204fe394ac 100644 (file)
@@ -96,7 +96,7 @@ VideoContent::VideoContent (shared_ptr<const Film> f, cxml::ConstNodePtr node, i
                /* DCP-o-matic 1.0 branch */
                _video_length = ContentTime::from_frames (node->number_child<int64_t> ("VideoLength"), _video_frame_rate);
        } else {
-               _video_length = ContentTime (node->number_child<int64_t> ("VideoLength"));
+               _video_length = ContentTime (node->number_child<ContentTime::Type> ("VideoLength"));
        }
        
        _video_frame_type = static_cast<VideoFrameType> (node->number_child<int> ("VideoFrameType"));