Replace length with intrinsic_duration.
authorCarl Hetherington <cth@carlh.net>
Thu, 17 Jan 2013 20:23:43 +0000 (20:23 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 17 Jan 2013 20:23:43 +0000 (20:23 +0000)
src/cpl_file.h
src/mxf_asset.cc
src/mxf_asset.h
src/picture_asset.cc
src/picture_asset.h
src/sound_asset.cc
src/sound_asset.h

index 67b38a0d70f112c34ab346a1814dc3cec3adc5dd..44115401fa3169ada14329f92cf28c35892469db 100644 (file)
@@ -37,8 +37,11 @@ public:
        std::string id;
        std::string annotation_text;
        Fraction edit_rate;
+       /** Duration of the whole thing */
        int64_t intrinsic_duration;
+       /** Start point in frames */
        int64_t entry_point;
+       /** Duration that will actually play */
        int64_t duration;
        Fraction frame_rate;
        Fraction screen_aspect_ratio;
index 7e40f0e070090e68e855fa95167a4f6da879aaef..338d125f3726fcfdf7a227c1e0fbc6f0897b3875 100644 (file)
@@ -36,12 +36,12 @@ using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 using namespace libdcp;
 
-MXFAsset::MXFAsset (string directory, string file_name, boost::signals2::signal<void (float)>* progress, int fps, int length)
+MXFAsset::MXFAsset (string directory, string file_name, boost::signals2::signal<void (float)>* progress, int fps, int intrinsic_duration)
        : Asset (directory, file_name)
        , _progress (progress)
        , _fps (fps)
        , _entry_point (0)
-       , _length (length)
+       , _intrinsic_duration (intrinsic_duration)
 {
        
 }
@@ -84,8 +84,8 @@ MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions, list<string>&
                return false;
        }
        
-       if (_length != other_mxf->_length) {
-               notes.push_back ("MXF lengths differ");
+       if (_intrinsic_duration != other_mxf->_intrinsic_duration) {
+               notes.push_back ("MXF intrinsic durations differ");
                return false;
        }
 
@@ -93,7 +93,7 @@ MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions, list<string>&
 }
 
 int
-MXFAsset::length () const
+MXFAsset::intrinsic_duration () const
 {
-       return _length;
+       return _intrinsic_duration;
 }
index 798a7e50e19634b9f888495ba7f8339a5658bcca..10049232fae6409590ccf74c6b31cfdcfe6b2fb9 100644 (file)
@@ -35,15 +35,15 @@ public:
         *  @param file_name Name of MXF file.
         *  @param progress Signal to inform of progress.
         *  @param fps Frames per second.
-        *  @param length Length in frames.
+        *  @param intrinsic_duration Duration of the whole asset in frames.
         */
-       MXFAsset (std::string directory, std::string file_name, boost::signals2::signal<void (float)>* progress, int fps, int length);
+       MXFAsset (std::string directory, std::string file_name, boost::signals2::signal<void (float)>* progress, int fps, int intrinsic_duration);
 
        void set_entry_point (int e);
 
        virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, std::list<std::string>& notes) const;
        
-       int length () const;
+       int intrinsic_duration () const;
 
 protected:
        /** Fill in a ADSCP::WriteInfo struct.
@@ -56,8 +56,8 @@ protected:
        /** Frames per second */
        int _fps;
        int _entry_point;
-       /** Length in frames */
-       int _length;
+       /** Total length in frames */
+       int _intrinsic_duration;
 };
 
 }
index e5d88a6eed09e385b5d3ba068afb060f91a57c8d..905f75f56ef0f4af9f8e21b54805584b79a3b31d 100644 (file)
@@ -46,8 +46,8 @@ using boost::dynamic_pointer_cast;
 using boost::lexical_cast;
 using namespace libdcp;
 
-PictureAsset::PictureAsset (string directory, string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int length)
-       : MXFAsset (directory, mxf_name, progress, fps, length)
+PictureAsset::PictureAsset (string directory, string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int intrinsic_duration)
+       : MXFAsset (directory, mxf_name, progress, fps, intrinsic_duration)
 {
 
 }
@@ -59,9 +59,9 @@ PictureAsset::write_to_cpl (ostream& s) const
          << "          <Id>urn:uuid:" << _uuid << "</Id>\n"
          << "          <AnnotationText>" << _file_name << "</AnnotationText>\n"
          << "          <EditRate>" << _fps << " 1</EditRate>\n"
-         << "          <IntrinsicDuration>" << _length << "</IntrinsicDuration>\n"
+         << "          <IntrinsicDuration>" << _intrinsic_duration << "</IntrinsicDuration>\n"
          << "          <EntryPoint>0</EntryPoint>\n"
-         << "          <Duration>" << _length << "</Duration>\n"
+         << "          <Duration>" << _intrinsic_duration << "</Duration>\n"
          << "          <FrameRate>" << _fps << " 1</FrameRate>\n"
          << "          <ScreenAspectRatio>" << _size.width << " " << _size.height << "</ScreenAspectRatio>\n"
          << "        </MainPicture>\n";
@@ -134,9 +134,9 @@ MonoPictureAsset::MonoPictureAsset (
        string mxf_name,
        boost::signals2::signal<void (float)>* progress,
        int fps,
-       int length,
+       int intrinsic_duration,
        Size size)
-       : PictureAsset (directory, mxf_name, progress, fps, length)
+       : PictureAsset (directory, mxf_name, progress, fps, intrinsic_duration)
 {
        _size = size;
        construct (get_path);
@@ -148,16 +148,16 @@ MonoPictureAsset::MonoPictureAsset (
        string mxf_name,
        boost::signals2::signal<void (float)>* progress,
        int fps,
-       int length,
+       int intrinsic_duration,
        Size size)
-       : PictureAsset (directory, mxf_name, progress, fps, length)
+       : PictureAsset (directory, mxf_name, progress, fps, intrinsic_duration)
 {
        _size = size;
        construct (boost::bind (&MonoPictureAsset::path_from_list, this, _1, files));
 }
 
-MonoPictureAsset::MonoPictureAsset (string directory, string mxf_name, int fps, int length)
-       : PictureAsset (directory, mxf_name, 0, fps, length)
+MonoPictureAsset::MonoPictureAsset (string directory, string mxf_name, int fps, int intrinsic_duration)
+       : PictureAsset (directory, mxf_name, 0, fps, intrinsic_duration)
 {
        ASDCP::JP2K::MXFReader reader;
        if (ASDCP_FAILURE (reader.OpenRead (path().string().c_str()))) {
@@ -194,7 +194,7 @@ MonoPictureAsset::construct (boost::function<string (int)> get_path)
                throw MXFFileError ("could not open MXF file for writing", path().string());
        }
 
-       for (int i = 0; i < _length; ++i) {
+       for (int i = 0; i < _intrinsic_duration; ++i) {
 
                string const path = get_path (i);
 
@@ -208,7 +208,7 @@ MonoPictureAsset::construct (boost::function<string (int)> get_path)
                }
 
                if (_progress) {
-                       (*_progress) (0.5 * float (i) / _length);
+                       (*_progress) (0.5 * float (i) / _intrinsic_duration);
                }
        }
        
@@ -240,7 +240,7 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, li
        shared_ptr<const MonoPictureAsset> other_picture = dynamic_pointer_cast<const MonoPictureAsset> (other);
        assert (other_picture);
 
-       for (int i = 0; i < _length; ++i) {
+       for (int i = 0; i < _intrinsic_duration; ++i) {
                shared_ptr<const MonoPictureFrame> frame_A = get_frame (i);
                shared_ptr<const MonoPictureFrame> frame_B = other_picture->get_frame (i);
                
@@ -266,7 +266,7 @@ StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt,
        shared_ptr<const StereoPictureAsset> other_picture = dynamic_pointer_cast<const StereoPictureAsset> (other);
        assert (other_picture);
 
-       for (int i = 0; i < _length; ++i) {
+       for (int i = 0; i < _intrinsic_duration; ++i) {
                shared_ptr<const StereoPictureFrame> frame_A = get_frame (i);
                shared_ptr<const StereoPictureFrame> frame_B = other_picture->get_frame (i);
                
@@ -356,8 +356,8 @@ PictureAsset::frame_buffer_equals (
 }
 
 
-StereoPictureAsset::StereoPictureAsset (string directory, string mxf_name, int fps, int length)
-       : PictureAsset (directory, mxf_name, 0, fps, length)
+StereoPictureAsset::StereoPictureAsset (string directory, string mxf_name, int fps, int intrinsic_duration)
+       : PictureAsset (directory, mxf_name, 0, fps, intrinsic_duration)
 {
        ASDCP::JP2K::MXFSReader reader;
        if (ASDCP_FAILURE (reader.OpenRead (path().string().c_str()))) {
index 4bd7e8e4abe20ca692c4250f720d48d5639031da..d2c6f656a546662a5c3b2bd26eea4ab8c492c46c 100644 (file)
@@ -35,7 +35,7 @@ class StereoPictureFrame;
 class PictureAsset : public MXFAsset
 {
 public:
-       PictureAsset (std::string directory, std::string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int length);
+       PictureAsset (std::string directory, std::string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int intrinsic_duration);
        
        /** Write details of this asset to a CPL stream.
         *  @param s Stream.
@@ -70,7 +70,7 @@ public:
         *  @param mxf_name Name of MXF file to create.
         *  @param progress Signal to inform of progress.
         *  @param fps Frames per second.
-        *  @param length Length in frames.
+        *  @param intrinsic_duration Length of the whole asset in frames.
         *  @param size Size of images in pixels.
         */
        MonoPictureAsset (
@@ -79,7 +79,7 @@ public:
                std::string mxf_name,
                boost::signals2::signal<void (float)>* progress,
                int fps,
-               int length,
+               int intrinsic_duration,
                Size size
                );
 
@@ -90,7 +90,7 @@ public:
         *  @param mxf_name Name of MXF file to create.
         *  @param progress Signal to inform of progress.
         *  @param fps Frames per second.
-        *  @param length Length in frames.
+        *  @param intrinsic_duration Length of the whole asset in frames.
         *  @param size Size of images in pixels.
         */
        MonoPictureAsset (
@@ -99,11 +99,11 @@ public:
                std::string mxf_name,
                boost::signals2::signal<void (float)>* progress,
                int fps,
-               int length,
+               int intrinsic_duration,
                Size size
                );
 
-       MonoPictureAsset (std::string directory, std::string mxf_name, int fps, int length);
+       MonoPictureAsset (std::string directory, std::string mxf_name, int fps, int intrinsic_duration);
        
        boost::shared_ptr<const MonoPictureFrame> get_frame (int n) const;
        bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, std::list<std::string>& notes) const;
@@ -117,7 +117,7 @@ private:
 class StereoPictureAsset : public PictureAsset
 {
 public:
-       StereoPictureAsset (std::string directory, std::string mxf_name, int fps, int length);
+       StereoPictureAsset (std::string directory, std::string mxf_name, int fps, int intrinsic_duration);
        
        boost::shared_ptr<const StereoPictureFrame> get_frame (int n) const;
        bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, std::list<std::string>& notes) const;
index 4f527409b7b8b54bfdc64204c1959180eb120ec0..071326657f364d2d8abb2f8049ef5fad73f36631 100644 (file)
@@ -42,9 +42,9 @@ using boost::lexical_cast;
 using namespace libdcp;
 
 SoundAsset::SoundAsset (
-       vector<string> const & files, string directory, string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int length, int start_frame
+       vector<string> const & files, string directory, string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int intrinsic_duration, int start_frame
        )
-       : MXFAsset (directory, mxf_name, progress, fps, length)
+       : MXFAsset (directory, mxf_name, progress, fps, intrinsic_duration)
        , _channels (files.size ())
        , _sampling_rate (0)
        , _start_frame (start_frame)
@@ -59,9 +59,9 @@ SoundAsset::SoundAsset (
        string directory,
        string mxf_name,
        boost::signals2::signal<void (float)>* progress,
-       int fps, int length, int start_frame, int channels
+       int fps, int intrinsic_duration, int start_frame, int channels
        )
-       : MXFAsset (directory, mxf_name, progress, fps, length)
+       : MXFAsset (directory, mxf_name, progress, fps, intrinsic_duration)
        , _channels (channels)
        , _sampling_rate (0)
        , _start_frame (start_frame)
@@ -71,8 +71,8 @@ SoundAsset::SoundAsset (
        construct (get_path);
 }
 
-SoundAsset::SoundAsset (string directory, string mxf_name, int fps, int length)
-       : MXFAsset (directory, mxf_name, 0, fps, length)
+SoundAsset::SoundAsset (string directory, string mxf_name, int fps, int intrinsic_duration)
+       : MXFAsset (directory, mxf_name, 0, fps, intrinsic_duration)
        , _channels (0)
        , _start_frame (0)
 {
@@ -169,7 +169,7 @@ SoundAsset::construct (boost::function<string (Channel)> get_path)
                }
        }
        
-       for (int i = 0; i < _length; ++i) {
+       for (int i = 0; i < _intrinsic_duration; ++i) {
 
                for (int j = 0; j < _channels; ++j) {
                        memset (frame_buffer_channel[j].Data(), 0, frame_buffer_channel[j].Capacity());
@@ -197,7 +197,7 @@ SoundAsset::construct (boost::function<string (Channel)> get_path)
                }
 
                if (_progress) {
-                       (*_progress) (0.5 * float (i) / _length);
+                       (*_progress) (0.5 * float (i) / _intrinsic_duration);
                }
        }
 
@@ -213,9 +213,9 @@ SoundAsset::write_to_cpl (ostream& s) const
          << "          <Id>urn:uuid:" << _uuid << "</Id>\n"
          << "          <AnnotationText>" << _file_name << "</AnnotationText>\n"
          << "          <EditRate>" << _fps << " 1</EditRate>\n"
-         << "          <IntrinsicDuration>" << _length << "</IntrinsicDuration>\n"
+         << "          <IntrinsicDuration>" << _intrinsic_duration << "</IntrinsicDuration>\n"
          << "          <EntryPoint>0</EntryPoint>\n"
-         << "          <Duration>" << _length << "</Duration>\n"
+         << "          <Duration>" << _intrinsic_duration << "</Duration>\n"
          << "        </MainSound>\n";
 }
 
@@ -265,7 +265,7 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, list<str
        ASDCP::PCM::FrameBuffer buffer_A (1 * Kumu::Megabyte);
        ASDCP::PCM::FrameBuffer buffer_B (1 * Kumu::Megabyte);
        
-       for (int i = 0; i < _length; ++i) {
+       for (int i = 0; i < _intrinsic_duration; ++i) {
                if (ASDCP_FAILURE (reader_A.ReadFrame (i, buffer_A))) {
                        throw DCPReadError ("could not read audio frame");
                }
index bd1811b1832a4ec58b5da83c411fc84ccfe61045..95efccd6378fe19338385d7b3d244a7cce4fb906 100644 (file)
@@ -43,7 +43,7 @@ public:
         *  @param mxf_name Name of MXF file to create.
         *  @param progress Signal to inform of progress.
         *  @param fps Frames per second.
-        *  @param length Length in frames.
+        *  @param intrinsic_duration Length of the whole asset in frames.
         *  @param start_frame Frame in the source to start writing from.
         */
        SoundAsset (
@@ -52,7 +52,7 @@ public:
                std::string mxf_name,
                boost::signals2::signal<void (float)>* progress,
                int fps,
-               int length,
+               int intrinsic_duration,
                int start_frame
                );
 
@@ -63,7 +63,7 @@ public:
         *  @param mxf_name Name of MXF file to create.
         *  @param progress Signal to inform of progress.
         *  @param fps Frames per second.
-        *  @param length Length in frames.
+        *  @param intrinsic_duration Length of the whole asset in frames.
         *  @param start_frame Frame in the source to start writing from.
         *  @param channels Number of audio channels.
         */
@@ -73,7 +73,7 @@ public:
                std::string mxf_name,
                boost::signals2::signal<void (float)>* progress,
                int fps,
-               int length,
+               int intrinsic_duration,
                int start_frame,
                int channels
                );
@@ -82,7 +82,7 @@ public:
                std::string directory,
                std::string mxf_name,
                int fps,
-               int length
+               int intrinsic_duration
                );
        
        /** Write details of this asset to a CPL stream.