summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-11-06 01:10:27 +0000
committerCarl Hetherington <cth@carlh.net>2015-11-06 01:10:27 +0000
commit9af90d8c2c88b86a2d6b7b9c4e7096e0ba4a4cf0 (patch)
tree08e66842b8158bec53b2e6fdd2afbfc2d5bbf737 /src/lib
parentaedaebb9a265128110085d3ca0ad5604409f0ddb (diff)
Allow single-frame image contents to adjust their video frame rates to that of the DCP (fixes #714).
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/image_examiner.cc4
-rw-r--r--src/lib/playlist.cc4
-rw-r--r--src/lib/video_content.cc22
-rw-r--r--src/lib/video_content.h10
4 files changed, 27 insertions, 13 deletions
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<const Film> film, shared_ptr<const Imag
}
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 ();
}
@@ -84,7 +84,7 @@ ImageExaminer::video_size () const
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();
}
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<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 */
@@ -235,7 +235,7 @@ Playlist::best_dcp_frame_rate () const
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;
}
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<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)
@@ -79,7 +78,6 @@ VideoContent::VideoContent (shared_ptr<const Film> film)
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)
@@ -91,7 +89,6 @@ VideoContent::VideoContent (shared_ptr<const Film> film, DCPTime s, Frame len)
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)
@@ -105,7 +102,7 @@ VideoContent::VideoContent (shared_ptr<const Film> film, cxml::ConstNodePtr node
{
_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");
@@ -193,7 +190,9 @@ VideoContent::as_xml (xmlpp::Node* node) const
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 ()));
@@ -227,8 +226,7 @@ VideoContent::take_from_video_examiner (shared_ptr<VideoExaminer> 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<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 ());
+}
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<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: