Bump current_state_version to 32 and read video lengths correctly from old files.
authorCarl Hetherington <cth@carlh.net>
Wed, 21 May 2014 15:41:56 +0000 (16:41 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 21 May 2014 15:41:56 +0000 (16:41 +0100)
src/lib/film.cc
src/lib/video_content.cc

index bdd650437568cd62ce2702ac931383384cc20666..50b1b4fad309e18c7bd848f829fce4e159b8fad6 100644 (file)
@@ -87,8 +87,11 @@ using dcp::raw_convert;
  * Subtitle offset changed to subtitle y offset, and subtitle x offset added.
  * 7 -> 8
  * Use <Scale> tag in <VideoContent> rather than <Ratio>.
+ *
+ * Bumped to 32 for 2.0 branch; some times are expressed in Times rather
+ * than frames now.
  */
-int const Film::current_state_version = 8;
+int const Film::current_state_version = 32;
 
 /** Construct a Film object in a given directory.
  *
index 9c8ecf0bb7d5c9b595077ced69a80d5aef8884b9..58053c822b9a61f5c08e643d50bd007f8ef94f45 100644 (file)
@@ -85,10 +85,17 @@ VideoContent::VideoContent (shared_ptr<const Film> f, boost::filesystem::path p)
 VideoContent::VideoContent (shared_ptr<const Film> f, cxml::ConstNodePtr node, int version)
        : Content (f, node)
 {
-       _video_length = ContentTime (node->number_child<int64_t> ("VideoLength"));
        _video_size.width = node->number_child<int> ("VideoWidth");
        _video_size.height = node->number_child<int> ("VideoHeight");
        _video_frame_rate = node->number_child<float> ("VideoFrameRate");
+
+       if (version < 32) {
+               /* 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_frame_type = static_cast<VideoFrameType> (node->number_child<int> ("VideoFrameType"));
        _crop.left = node->number_child<int> ("LeftCrop");
        _crop.right = node->number_child<int> ("RightCrop");