Fixes for writing 3D CPLs.
authorCarl Hetherington <cth@carlh.net>
Tue, 23 Jul 2013 10:56:28 +0000 (11:56 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 23 Jul 2013 10:56:28 +0000 (11:56 +0100)
src/picture_asset.cc
src/picture_asset.h
src/picture_asset_writer.cc

index cba5ecefee663bdcbcbd4096abb15fa6fdcce225..c1805e6f3bf124e706faaa672506e2cedab6850f 100644 (file)
@@ -68,11 +68,29 @@ PictureAsset::PictureAsset (string directory, string mxf_name)
 }
 
 string
-PictureAsset::cpl_node_name () const
+MonoPictureAsset::cpl_node_name () const
 {
        return "MainPicture";
 }
 
+int
+MonoPictureAsset::edit_rate_factor () const
+{
+       return 1;
+}
+
+string
+StereoPictureAsset::cpl_node_name () const
+{
+       return "MainStereoscopicPicture";
+}
+
+int
+StereoPictureAsset::edit_rate_factor () const
+{
+       return 2;
+}
+
 void
 PictureAsset::write_to_cpl (xmlpp::Node* node) const
 {
@@ -86,7 +104,7 @@ PictureAsset::write_to_cpl (xmlpp::Node* node) const
 
        assert (i != c.end ());
 
-       (*i)->add_child ("FrameRate")->add_child_text (lexical_cast<string> (_edit_rate) + " 1");
+       (*i)->add_child ("FrameRate")->add_child_text (lexical_cast<string> (_edit_rate * edit_rate_factor ()) + " 1");
        (*i)->add_child ("ScreenAspectRatio")->add_child_text (lexical_cast<string> (_size.width) + " " + lexical_cast<string> (_size.height));
 }
 
index 2031a9ed5bd052b72074e07a6bc52be3e5eb7226..58d9c748a58f63a4bb2dce02195594a481283e8c 100644 (file)
@@ -81,12 +81,10 @@ protected:
 
 private:
        std::string key_type () const;
-       std::string cpl_node_name () const;
+       std::string cpl_node_name () const = 0;
+       virtual int edit_rate_factor () const = 0;
 };
 
-class MonoPictureAsset;
-
-
 /** A 2D (monoscopic) picture asset */
 class MonoPictureAsset : public PictureAsset
 {
@@ -164,6 +162,8 @@ public:
 private:
        std::string path_from_list (int f, std::vector<std::string> const & files) const;
        void construct (boost::function<std::string (int)>, MXFMetadata const &);
+       std::string cpl_node_name () const;
+       int edit_rate_factor () const;
 };
 
 /** A 3D (stereoscopic) picture asset */       
@@ -187,6 +187,10 @@ public:
 
        boost::shared_ptr<const StereoPictureFrame> get_frame (int n) const;
        bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
+
+private:
+       std::string cpl_node_name () const;
+       int edit_rate_factor () const;
 };
        
 
index 18e509d69a27d71b073d1c8d53af0f253ca0c40d..32e13a176312eb9196153a8a8d52d6aa74398594 100644 (file)
@@ -183,7 +183,6 @@ StereoPictureAssetWriter::write (uint8_t* data, int size, Eye eye)
                boost::throw_exception (MXFFileError ("error in writing video MXF", _asset->path().string()));
        }
 
-       ++_frames_written;
        return FrameInfo (before_offset, _state->mxf_writer.Tell() - before_offset, hash);
 }
 
@@ -237,6 +236,6 @@ StereoPictureAssetWriter::finalize ()
        }
 
        _finalized = true;
-       _asset->set_intrinsic_duration (_frames_written);
-       _asset->set_duration (_frames_written);
+       _asset->set_intrinsic_duration (_frames_written / 2);
+       _asset->set_duration (_frames_written / 2);
 }