Add custom reels option to Film.
authorCarl Hetherington <cth@carlh.net>
Tue, 19 Dec 2023 11:45:38 +0000 (12:45 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 12 Mar 2024 22:41:00 +0000 (23:41 +0100)
src/lib/film.cc
src/lib/film.h
src/lib/film_property.h
src/lib/types.h

index d94ef0af31061c82e2e8f009deda3df1663e6b60..835f3efdf5653058ae3366c31506a2a16f643ffd 100644 (file)
@@ -413,6 +413,9 @@ Film::metadata (bool with_content_paths) const
        }
        root->add_child("ReelType")->add_child_text (raw_convert<string> (static_cast<int> (_reel_type)));
        root->add_child("ReelLength")->add_child_text (raw_convert<string> (_reel_length));
+       for (auto boundary: _custom_reel_boundaries) {
+               root->add_child("CustomReelBoundary")->add_child_text(raw_convert<string>(boundary.get()));
+       }
        root->add_child("ReencodeJ2K")->add_child_text (_reencode_j2k ? "1" : "0");
        root->add_child("UserExplicitVideoFrameRate")->add_child_text(_user_explicit_video_frame_rate ? "1" : "0");
        for (auto const& marker: _markers) {
@@ -600,6 +603,9 @@ Film::read_metadata (optional<boost::filesystem::path> path)
 
        _reel_type = static_cast<ReelType> (f.optional_number_child<int>("ReelType").get_value_or (static_cast<int>(ReelType::SINGLE)));
        _reel_length = f.optional_number_child<int64_t>("ReelLength").get_value_or (2000000000);
+       for (auto boundary: f.node_children("CustomReelBoundary")) {
+               _custom_reel_boundaries.push_back(DCPTime(raw_convert<int64_t>(boundary->content())));
+       }
        _reencode_j2k = f.optional_bool_child("ReencodeJ2K").get_value_or(false);
        _user_explicit_video_frame_rate = f.optional_bool_child("UserExplicitVideoFrameRate").get_value_or(false);
 
@@ -1233,6 +1239,16 @@ Film::set_reel_length (int64_t r)
        _reel_length = r;
 }
 
+
+void
+Film::set_custom_reel_boundaries(vector<DCPTime> boundaries)
+{
+       FilmChangeSignaller ch(this, FilmProperty::CUSTOM_REEL_BOUNDARIES);
+       std::sort(boundaries.begin(), boundaries.end());
+       _custom_reel_boundaries = std::move(boundaries);
+}
+
+
 void
 Film::set_reencode_j2k (bool r)
 {
@@ -1865,6 +1881,18 @@ Film::reels () const
                }
                break;
        }
+       case ReelType::CUSTOM:
+       {
+               DCPTimePeriod current;
+               for (auto boundary: _custom_reel_boundaries) {
+                       current.to = boundary;
+                       periods.push_back(current);
+                       current.from = boundary;
+               }
+               current.to = len;
+               periods.push_back(current);
+               break;
+       }
        }
 
        return periods;
index a5cefa4d42db8437d9b3f4930bca2ddaf8445b07..0a0c5a4e1dcadd716af7197d3335eeb185ca0821 100644 (file)
@@ -291,6 +291,10 @@ public:
                return _reel_length;
        }
 
+       std::vector<dcpomatic::DCPTime> custom_reel_boundaries() const {
+               return _custom_reel_boundaries;
+       }
+
        std::string context_id () const {
                return _context_id;
        }
@@ -408,6 +412,7 @@ public:
        void set_audio_processor (AudioProcessor const * processor);
        void set_reel_type (ReelType);
        void set_reel_length (int64_t);
+       void set_custom_reel_boundaries(std::vector<dcpomatic::DCPTime> boundaries);
        void set_reencode_j2k (bool);
        void set_marker (dcp::Marker type, dcpomatic::DCPTime time);
        void unset_marker (dcp::Marker type);
@@ -527,8 +532,10 @@ private:
        bool _limit_to_smpte_bv20;
        AudioProcessor const * _audio_processor;
        ReelType _reel_type;
-       /** Desired reel length in bytes, if _reel_type == REELTYPE_BY_LENGTH */
+       /** Desired reel length in bytes, if _reel_type == BY_LENGTH */
        int64_t _reel_length;
+       /** Reel boundaries (excluding those at the start and end, sorted in ascending order) if _reel_type == CUSTOM */
+       std::vector<dcpomatic::DCPTime> _custom_reel_boundaries;
        bool _reencode_j2k;
        /** true if the user has ever explicitly set the video frame rate of this film */
        bool _user_explicit_video_frame_rate;
index c232979657620e09a51a366415afb207d0b9d2e3..0841caa5ca19ea56ab1b3778e36c6cd18b687db3 100644 (file)
@@ -51,6 +51,7 @@ enum class FilmProperty {
        AUDIO_PROCESSOR,
        REEL_TYPE,
        REEL_LENGTH,
+       CUSTOM_REEL_BOUNDARIES,
        REENCODE_J2K,
        MARKERS,
        RATINGS,
index 36059401ec8eb96d73a6921d4715443ab028d9fc..c9c87bae5200b48bdf9bfdaf48d99216400bc110 100644 (file)
@@ -107,7 +107,8 @@ enum class ReelType
 {
        SINGLE,
        BY_VIDEO_CONTENT,
-       BY_LENGTH
+       BY_LENGTH,
+       CUSTOM
 };