Merge master.
[dcpomatic.git] / src / lib / subrip.cc
index 380a2ce2cb7e7757c2e1fc7472f571d72aa0a693..9d207d528d0f04f7060ebc18c5e8d2fbe4228a16 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include <boost/algorithm/string.hpp>
+#include <boost/lexical_cast.hpp>
 #include "subrip.h"
 #include "subrip_content.h"
 #include "subrip_subtitle.h"
@@ -126,18 +127,18 @@ SubRip::SubRip (shared_ptr<const SubRipContent> content)
 ContentTime
 SubRip::convert_time (string t)
 {
-       ContentTime r = 0;
+       ContentTime r;
 
        vector<string> a;
        boost::algorithm::split (a, t, boost::is_any_of (":"));
        assert (a.size() == 3);
-       r += lexical_cast<int> (a[0]) * 60 * 60 * TIME_HZ;
-       r += lexical_cast<int> (a[1]) * 60 * TIME_HZ;
+       r += ContentTime::from_seconds (lexical_cast<int> (a[0]) * 60 * 60);
+       r += ContentTime::from_seconds (lexical_cast<int> (a[1]) * 60);
 
        vector<string> b;
        boost::algorithm::split (b, a[2], boost::is_any_of (","));
-       r += lexical_cast<int> (b[0]) * TIME_HZ;
-       r += lexical_cast<int> (b[1]) * TIME_HZ / 1000;
+       r += ContentTime::from_seconds (lexical_cast<int> (b[0]));
+       r += ContentTime::from_seconds (lexical_cast<double> (b[1]) / 1000);
 
        return r;
 }
@@ -229,7 +230,7 @@ ContentTime
 SubRip::length () const
 {
        if (_subtitles.empty ()) {
-               return 0;
+               return ContentTime ();
        }
 
        return _subtitles.back().to;