+2015-11-06 Carl Hetherington <cth@carlh.net>
+
+ * Make single-frame image sources adjust their notional
+ frame rate to that of the DCP (#714).
+
2015-11-05 Carl Hetherington <cth@carlh.net>
* Correct time display when previewing multi-reel DCP content.
}
if (content->still ()) {
- _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 ();
}
optional<double>
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();
}
{
list<int> 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<FrameRateCandidate> candidates;
/* Start with the ones without skip / repeat so they will get matched in preference to skipped/repeated ones */
float this_error = 0;
BOOST_FOREACH (shared_ptr<Content> j, _content) {
shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (j);
- if (!vc) {
+ if (!vc || !vc->has_own_video_frame_rate()) {
continue;
}
VideoContent::VideoContent (shared_ptr<const Film> 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)
VideoContent::VideoContent (shared_ptr<const Film> 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)
VideoContent::VideoContent (shared_ptr<const Film> 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)
{
_video_size.width = node->number_child<int> ("VideoWidth");
_video_size.height = node->number_child<int> ("VideoHeight");
- _video_frame_rate = node->number_child<double> ("VideoFrameRate");
+ _video_frame_rate = node->optional_number_child<double> ("VideoFrameRate");
_video_length = node->number_child<Frame> ("VideoLength");
_video_frame_type = static_cast<VideoFrameType> (node->number_child<int> ("VideoFrameType"));
_sample_aspect_ratio = node->optional_number_child<double> ("SampleAspectRatio");
node->add_child("VideoLength")->add_child_text (raw_convert<string> (_video_length));
node->add_child("VideoWidth")->add_child_text (raw_convert<string> (_video_size.width));
node->add_child("VideoHeight")->add_child_text (raw_convert<string> (_video_size.height));
- node->add_child("VideoFrameRate")->add_child_text (raw_convert<string> (_video_frame_rate));
+ if (_video_frame_rate) {
+ node->add_child("VideoFrameRate")->add_child_text (raw_convert<string> (_video_frame_rate.get()));
+ }
node->add_child("VideoFrameType")->add_child_text (raw_convert<string> (static_cast<int> (_video_frame_type)));
if (_sample_aspect_ratio) {
node->add_child("SampleAspectRatio")->add_child_text (raw_convert<string> (_sample_aspect_ratio.get ()));
{
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;
t.push_back (position().round_up (film->video_frame_rate()));
return t;
}
+
+double
+VideoContent::video_frame_rate () const
+{
+ boost::shared_ptr<const Film> film = _film.lock ();
+ DCPOMATIC_ASSERT (film);
+
+ boost::mutex::scoped_lock lm (_mutex);
+ return _video_frame_rate.get_value_or (film->video_frame_rate ());
+}
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;
}
void add_properties (std::list<std::pair<std::string, std::string> > &) 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<double> _video_frame_rate;
boost::optional<ColourConversion> _colour_conversion;
private:
/* XXX: check for lots of files here and do something */
for (list<boost::filesystem::path>::const_iterator i = paths.begin(); i != paths.end(); ++i) {
- shared_ptr<Content> c = content_factory (_film, *i);
- shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (c);
- if (ic) {
- ic->set_video_frame_rate (24);
- }
- _film->examine_and_add_content (c);
+ _film->examine_and_add_content (content_factory (_film, *i));
}
}
}
- if (check_vc.size() == 1 || count_sc == 1) {
+ bool const single_frame_image_content = vc && dynamic_pointer_cast<const ImageContent> (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<string> (vc->video_frame_rate (), 5));
} else if (sc) {