From: Carl Hetherington Date: Fri, 6 Nov 2015 01:10:27 +0000 (+0000) Subject: Allow single-frame image contents to adjust their video frame rates to that of the... X-Git-Tag: v2.5.1~22 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=9af90d8c2c88b86a2d6b7b9c4e7096e0ba4a4cf0 Allow single-frame image contents to adjust their video frame rates to that of the DCP (fixes #714). --- diff --git a/ChangeLog b/ChangeLog index 889de809f..406fc7371 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-11-06 Carl Hetherington + + * Make single-frame image sources adjust their notional + frame rate to that of the DCP (#714). + 2015-11-05 Carl Hetherington * Correct time display when previewing multi-reel DCP content. diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc index 7a93b5cd1..376491738 100644 --- a/src/lib/image_examiner.cc +++ b/src/lib/image_examiner.cc @@ -69,7 +69,7 @@ ImageExaminer::ImageExaminer (shared_ptr film, shared_ptrstill ()) { - _video_length = Config::instance()->default_still_length() * video_frame_rate().get_value_or (24); + _video_length = Config::instance()->default_still_length() * video_frame_rate().get_value_or (film->video_frame_rate ()); } else { _video_length = _image_content->number_of_paths (); } @@ -84,7 +84,7 @@ ImageExaminer::video_size () const optional ImageExaminer::video_frame_rate () const { - if (_image_content->video_frame_rate() != 0) { + if (_image_content->has_own_video_frame_rate()) { /* The content already knows what frame rate it should be */ return _image_content->video_frame_rate(); } diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index c9de9b88f..c5cd4b02d 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -212,7 +212,7 @@ Playlist::best_dcp_frame_rate () const { list const allowed_dcp_frame_rates = Config::instance()->allowed_dcp_frame_rates (); - /* Work out what rates we could manage, including those achieved by using skip / repeat. */ + /* Work out what rates we could manage, including those achieved by using skip / repeat */ list candidates; /* Start with the ones without skip / repeat so they will get matched in preference to skipped/repeated ones */ @@ -235,7 +235,7 @@ Playlist::best_dcp_frame_rate () const float this_error = 0; BOOST_FOREACH (shared_ptr j, _content) { shared_ptr vc = dynamic_pointer_cast (j); - if (!vc) { + if (!vc || !vc->has_own_video_frame_rate()) { continue; } diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 1e8b9034a..f11b40bb4 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -67,7 +67,6 @@ using boost::dynamic_pointer_cast; VideoContent::VideoContent (shared_ptr film) : Content (film) , _video_length (0) - , _video_frame_rate (0) , _video_frame_type (VIDEO_FRAME_TYPE_2D) , _scale (VideoContentScale (Ratio::from_id ("178"))) , _fade_in (0) @@ -79,7 +78,6 @@ VideoContent::VideoContent (shared_ptr film) VideoContent::VideoContent (shared_ptr film, DCPTime s, Frame len) : Content (film, s) , _video_length (len) - , _video_frame_rate (0) , _video_frame_type (VIDEO_FRAME_TYPE_2D) , _scale (VideoContentScale (Ratio::from_id ("178"))) , _fade_in (0) @@ -91,7 +89,6 @@ VideoContent::VideoContent (shared_ptr film, DCPTime s, Frame len) VideoContent::VideoContent (shared_ptr film, boost::filesystem::path p) : Content (film, p) , _video_length (0) - , _video_frame_rate (0) , _video_frame_type (VIDEO_FRAME_TYPE_2D) , _scale (VideoContentScale (Ratio::from_id ("178"))) , _fade_in (0) @@ -105,7 +102,7 @@ VideoContent::VideoContent (shared_ptr film, cxml::ConstNodePtr node { _video_size.width = node->number_child ("VideoWidth"); _video_size.height = node->number_child ("VideoHeight"); - _video_frame_rate = node->number_child ("VideoFrameRate"); + _video_frame_rate = node->optional_number_child ("VideoFrameRate"); _video_length = node->number_child ("VideoLength"); _video_frame_type = static_cast (node->number_child ("VideoFrameType")); _sample_aspect_ratio = node->optional_number_child ("SampleAspectRatio"); @@ -193,7 +190,9 @@ VideoContent::as_xml (xmlpp::Node* node) const node->add_child("VideoLength")->add_child_text (raw_convert (_video_length)); node->add_child("VideoWidth")->add_child_text (raw_convert (_video_size.width)); node->add_child("VideoHeight")->add_child_text (raw_convert (_video_size.height)); - node->add_child("VideoFrameRate")->add_child_text (raw_convert (_video_frame_rate)); + if (_video_frame_rate) { + node->add_child("VideoFrameRate")->add_child_text (raw_convert (_video_frame_rate.get())); + } node->add_child("VideoFrameType")->add_child_text (raw_convert (static_cast (_video_frame_type))); if (_sample_aspect_ratio) { node->add_child("SampleAspectRatio")->add_child_text (raw_convert (_sample_aspect_ratio.get ())); @@ -227,8 +226,7 @@ VideoContent::take_from_video_examiner (shared_ptr d) { boost::mutex::scoped_lock lm (_mutex); _video_size = vs; - /* Default video frame rate to 24fps if the examiner doesn't know */ - _video_frame_rate = vfr.get_value_or (24); + _video_frame_rate = vfr; _video_length = vl; _sample_aspect_ratio = ar; @@ -590,3 +588,13 @@ VideoContent::reel_split_points () const t.push_back (position().round_up (film->video_frame_rate())); return t; } + +double +VideoContent::video_frame_rate () const +{ + boost::shared_ptr film = _film.lock (); + DCPOMATIC_ASSERT (film); + + boost::mutex::scoped_lock lm (_mutex); + return _video_frame_rate.get_value_or (film->video_frame_rate ()); +} diff --git a/src/lib/video_content.h b/src/lib/video_content.h index c0a609a6a..aa541fc32 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -79,7 +79,12 @@ public: return _video_size; } - double video_frame_rate () const { + double video_frame_rate () const; + + /** @return true if this content has a specific video frame rate, false + * if it should use the DCP's rate. + */ + bool has_own_video_frame_rate () const { boost::mutex::scoped_lock lm (_mutex); return _video_frame_rate; } @@ -172,7 +177,8 @@ protected: void add_properties (std::list > &) const; Frame _video_length; - double _video_frame_rate; + /** Video frame rate, or not set if this content should use the DCP's frame rate */ + boost::optional _video_frame_rate; boost::optional _colour_conversion; private: diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 8ca0d5b29..a84698032 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -526,11 +526,6 @@ ContentPanel::add_files (list paths) /* XXX: check for lots of files here and do something */ for (list::const_iterator i = paths.begin(); i != paths.end(); ++i) { - shared_ptr c = content_factory (_film, *i); - shared_ptr ic = dynamic_pointer_cast (c); - if (ic) { - ic->set_video_frame_rate (24); - } - _film->examine_and_add_content (c); + _film->examine_and_add_content (content_factory (_film, *i)); } } diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index e416a671c..f05268f92 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -267,7 +267,9 @@ TimingPanel::film_content_changed (int property) } - if (check_vc.size() == 1 || count_sc == 1) { + bool const single_frame_image_content = vc && dynamic_pointer_cast (vc) && vc->number_of_paths() == 1; + + if ((check_vc.size() == 1 || count_sc == 1) && !single_frame_image_content) { if (vc) { checked_set (_video_frame_rate, raw_convert (vc->video_frame_rate (), 5)); } else if (sc) {