Add Content::full_length_content and make full_length_dcp use it.
authorCarl Hetherington <cth@carlh.net>
Thu, 6 May 2021 09:26:47 +0000 (11:26 +0200)
committerCarl Hetherington <cth@carlh.net>
Fri, 7 May 2021 07:29:58 +0000 (09:29 +0200)
16 files changed:
src/lib/atmos_mxf_content.cc
src/lib/atmos_mxf_content.h
src/lib/content.cc
src/lib/content.h
src/lib/dcp_content.cc
src/lib/dcp_content.h
src/lib/dcp_subtitle_content.cc
src/lib/dcp_subtitle_content.h
src/lib/ffmpeg_content.cc
src/lib/ffmpeg_content.h
src/lib/image_content.cc
src/lib/image_content.h
src/lib/string_text_file_content.cc
src/lib/string_text_file_content.h
src/lib/video_mxf_content.cc
src/lib/video_mxf_content.h

index 5c153309f0fde53052fa2e16b84537b3c13dbc67..ebbfdb09bb27294688296476f99e272487534c87 100644 (file)
@@ -106,11 +106,10 @@ AtmosMXFContent::as_xml (xmlpp::Node* node, bool with_paths) const
 }
 
 
-DCPTime
-AtmosMXFContent::full_length_dcp (shared_ptr<const Film> film) const
+ContentTime
+AtmosMXFContent::full_length_content () const
 {
-       FrameRateChange const frc (film, shared_from_this());
-       return DCPTime::from_frames (llrint(atmos->length() * frc.factor()), film->video_frame_rate());
+       return ContentTime::from_frames (atmos->length(), atmos->edit_rate().as_float());
 }
 
 
index 912c818f6935b42a0969ef74ee319fdad782b867..fccc1e51a7ca87ed10757e343acc7789d8f147a2 100644 (file)
@@ -40,7 +40,7 @@ public:
        void examine (std::shared_ptr<const Film> film, std::shared_ptr<Job> job) override;
        std::string summary () const override;
        void as_xml (xmlpp::Node* node, bool with_path) const override;
-       dcpomatic::DCPTime full_length_dcp (std::shared_ptr<const Film> film) const override;
+       dcpomatic::ContentTime full_length_content () const override;
        dcpomatic::DCPTime approximate_length () const override;
 
        static bool valid_mxf (boost::filesystem::path path);
index 2dbb218a6a1550d0c9d7adf198ebd1502033a215..bcd4cabccd0e06005e9d4868c172dc89936bb140 100644 (file)
@@ -541,3 +541,11 @@ Content::add_path (boost::filesystem::path p)
        auto last_write = boost::filesystem::last_write_time(p, ec);
        _last_write_times.push_back (ec ? 0 : last_write);
 }
+
+
+DCPTime
+Content::full_length_dcp (shared_ptr<const Film> film) const
+{
+       return DCPTime (full_length_content(), FrameRateChange(film, shared_from_this()));
+}
+
index 89ea28ab389a65431c5368761fd022b8371ecab1..4255a0cb453c92e25cf96d7106018b540b5b1e93 100644 (file)
@@ -97,7 +97,8 @@ public:
        virtual std::string technical_summary () const;
 
        virtual void as_xml (xmlpp::Node *, bool with_paths) const;
-       virtual dcpomatic::DCPTime full_length_dcp (std::shared_ptr<const Film>) const = 0;
+       virtual dcpomatic::DCPTime full_length_dcp (std::shared_ptr<const Film>) const;
+       virtual dcpomatic::ContentTime full_length_content () const = 0;
        virtual dcpomatic::DCPTime approximate_length () const = 0;
        virtual std::string identifier () const;
        /** @return points at which to split this content when
index 3c9e1fddd0b76639a65f0f354f5dfec435e24013..2b67860b10a3c43c8e698f7476b348adece2d263 100644 (file)
@@ -409,16 +409,19 @@ DCPContent::as_xml (xmlpp::Node* node, bool with_paths) const
        }
 }
 
-DCPTime
-DCPContent::full_length_dcp (shared_ptr<const Film> film) const
+
+ContentTime
+DCPContent::full_length_content () const
 {
        if (!video) {
                return {};
        }
-       FrameRateChange const frc (film, shared_from_this());
-       return DCPTime::from_frames (llrint(video->length() * frc.factor()), film->video_frame_rate());
+       auto vfr = video_frame_rate();
+        DCPOMATIC_ASSERT (vfr);
+        return ContentTime::from_frames (video->length(), *vfr);
 }
 
+
 DCPTime
 DCPContent::approximate_length () const
 {
index 29d5b24981a0e5d067a5044106c67dc412e2e6b7..1fa9122ef4dd9b1df6e6aca92040d2ef3823f478 100644 (file)
@@ -61,7 +61,7 @@ public:
                return std::dynamic_pointer_cast<const DCPContent> (Content::shared_from_this ());
        }
 
-       dcpomatic::DCPTime full_length_dcp (std::shared_ptr<const Film> film) const override;
+       dcpomatic::ContentTime full_length_content () const override;
        dcpomatic::DCPTime approximate_length () const override;
 
        void examine (std::shared_ptr<const Film> film, std::shared_ptr<Job>) override;
index d42076e5a82b2b87faa51a713cb20ac1a5bdb477..0ac659c06ff66b2e9d95f3638e38e6522ff721f3 100644 (file)
@@ -78,12 +78,6 @@ DCPSubtitleContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
        }
 }
 
-DCPTime
-DCPSubtitleContent::full_length_dcp (shared_ptr<const Film> film) const
-{
-       FrameRateChange const frc (film, shared_from_this());
-       return DCPTime (_length, frc);
-}
 
 DCPTime
 DCPSubtitleContent::approximate_length () const
index f734d04ba8db53f530ff382d6c6e28c65c31b42b..2858728ac576c27dd41b263975023f834a7ed504 100644 (file)
@@ -31,7 +31,9 @@ public:
        std::string summary () const override;
        std::string technical_summary () const override;
        void as_xml (xmlpp::Node *, bool with_paths) const override;
-       dcpomatic::DCPTime full_length_dcp (std::shared_ptr<const Film> film) const override;
+       dcpomatic::ContentTime full_length_content () const override {
+               return _length;
+       }
        dcpomatic::DCPTime approximate_length () const override;
 
 private:
index 5cbc210ad8af8872de4381f8a8977bff43635011..65826506eec2222cabc81121177c4b48400ccca7 100644 (file)
@@ -43,6 +43,7 @@ extern "C" {
 }
 #include <libxml++/libxml++.h>
 #include <iostream>
+#include <numeric>
 
 #include "i18n.h"
 
@@ -410,20 +411,18 @@ operator!= (FFmpegStream const & a, FFmpegStream const & b)
 }
 
 
-DCPTime
-FFmpegContent::full_length_dcp (shared_ptr<const Film> film) const
+ContentTime
+FFmpegContent::full_length_content () const
 {
-       FrameRateChange const frc (film, shared_from_this());
        if (video) {
-               return DCPTime::from_frames (llrint (video->length_after_3d_combine() * frc.factor()), film->video_frame_rate());
+               return ContentTime::from_frames(video->length_after_3d_combine(), video_frame_rate().get());
        }
 
        if (audio) {
-               DCPTime longest;
-               for (auto i: audio->streams()) {
-                       longest = max (longest, DCPTime::from_frames(llrint(i->length() / frc.speed_up), i->frame_rate()));
-               }
-               return longest;
+               auto streams = audio->streams();
+               return std::accumulate (streams.begin(), streams.end(), ContentTime(), [](ContentTime const& a, shared_ptr<AudioStream> const& b) {
+                       return std::max(a, ContentTime::from_frames(b->length(), b->frame_rate()));
+               });
        }
 
        /* XXX: subtitle content? */
index a92e613f0a86ca1d9538611872a0bccedec7c029..93a67f826a4efd6ec77e80bf19093bede3c2074e 100644 (file)
@@ -64,7 +64,7 @@ public:
        std::string summary () const override;
        std::string technical_summary () const override;
        void as_xml (xmlpp::Node *, bool with_paths) const override;
-       dcpomatic::DCPTime full_length_dcp (std::shared_ptr<const Film> film) const override;
+       dcpomatic::ContentTime full_length_content () const override;
        dcpomatic::DCPTime approximate_length () const override;
 
        std::string identifier () const override;
index 23493057658f20e476b8a7e6b0b89399fda9681c..36059011d77f8068ccbeb653ba41a7f391c334a9 100644 (file)
@@ -132,13 +132,22 @@ ImageContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
        set_default_colour_conversion ();
 }
 
+
 DCPTime
 ImageContent::full_length_dcp (shared_ptr<const Film> film) const
 {
-       FrameRateChange const frc (film, shared_from_this());
-       return DCPTime::from_frames (llrint(video->length_after_3d_combine() * frc.factor()), film->video_frame_rate());
+        FrameRateChange const frc (film, shared_from_this());
+        return DCPTime::from_frames (llrint(video->length_after_3d_combine() * frc.factor()), film->video_frame_rate());
+}
+
+
+ContentTime
+ImageContent::full_length_content () const
+{
+       return ContentTime::from_frames (video->length_after_3d_combine(), video_frame_rate().get_value_or(24));
 }
 
+
 DCPTime
 ImageContent::approximate_length () const
 {
index f496e253129e08e0485b877511e6804d61daa98e..a5d4a529ac327284a9953a5a2928006f1c318161 100644 (file)
@@ -42,6 +42,7 @@ public:
        std::string technical_summary () const override;
        void as_xml (xmlpp::Node *, bool with_paths) const override;
        dcpomatic::DCPTime full_length_dcp (std::shared_ptr<const Film> film) const override;
+       dcpomatic::ContentTime full_length_content () const override;
        dcpomatic::DCPTime approximate_length () const override;
 
        std::string identifier () const override;
index 8796b5ee9c6805a1ab4f1615b87e0858f9e9d6e3..5a2b3d87e52038ad5c231216db37765374b774cc 100644 (file)
@@ -101,14 +101,6 @@ StringTextFileContent::as_xml (xmlpp::Node* node, bool with_paths) const
 }
 
 
-DCPTime
-StringTextFileContent::full_length_dcp (shared_ptr<const Film> film) const
-{
-       FrameRateChange const frc (film, shared_from_this());
-       return DCPTime (_length, frc);
-}
-
-
 DCPTime
 StringTextFileContent::approximate_length () const
 {
index d3c0368b9360b7252e7b188510772d35fdcb8a70..ea8ac57870015da0776f888019eadd35dbaacbf8 100644 (file)
@@ -46,7 +46,9 @@ public:
        std::string summary () const override;
        std::string technical_summary () const override;
        void as_xml (xmlpp::Node *, bool with_paths) const override;
-       dcpomatic::DCPTime full_length_dcp (std::shared_ptr<const Film> film) const override;
+       dcpomatic::ContentTime full_length_content () const override {
+               return _length;
+       }
        dcpomatic::DCPTime approximate_length () const override;
        std::string identifier () const override;
 
index 1be9787fba6a46cda662122641b6b202527f7342..1aa7282ffb4045e8d5588a23a4f8130c1e96c9b8 100644 (file)
@@ -129,11 +129,12 @@ VideoMXFContent::as_xml (xmlpp::Node* node, bool with_paths) const
 }
 
 
-DCPTime
-VideoMXFContent::full_length_dcp (shared_ptr<const Film> film) const
+ContentTime
+VideoMXFContent::full_length_content () const
 {
-       FrameRateChange const frc (film, shared_from_this());
-       return DCPTime::from_frames (llrint(video->length_after_3d_combine() * frc.factor()), film->video_frame_rate());
+       auto vfr = video_frame_rate();
+       DCPOMATIC_ASSERT (vfr);
+       return ContentTime::from_frames (video->length_after_3d_combine(), *vfr);
 }
 
 
index 14d31f91543a3b77dde15044a46476f9c367b149..a0c986d13b8ff2310dd30d258799bae69d5d1ce5 100644 (file)
@@ -41,7 +41,7 @@ public:
        std::string technical_summary () const override;
        std::string identifier () const override;
        void as_xml (xmlpp::Node* node, bool with_paths) const override;
-       dcpomatic::DCPTime full_length_dcp (std::shared_ptr<const Film> film) const override;
+       dcpomatic::ContentTime full_length_content () const override;
        dcpomatic::DCPTime approximate_length () const override;
        void add_properties (std::shared_ptr<const Film> film, std::list<UserProperty>& p) const override;