diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-11-06 01:29:06 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-11-06 01:29:06 +0000 |
| commit | 188877db5362b9b630588b2dfee4002d71a29372 (patch) | |
| tree | 69e734955b92f9fb7b72b43209f3423b2966354e /src/lib | |
| parent | 9af90d8c2c88b86a2d6b7b9c4e7096e0ba4a4cf0 (diff) | |
Clean up a bit by using Content::film() more.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/audio_content.cc | 5 | ||||
| -rw-r--r-- | src/lib/content.cc | 12 | ||||
| -rw-r--r-- | src/lib/content.h | 4 | ||||
| -rw-r--r-- | src/lib/dcp_content.cc | 17 | ||||
| -rw-r--r-- | src/lib/dcp_subtitle_content.cc | 8 | ||||
| -rw-r--r-- | src/lib/ffmpeg_content.cc | 11 | ||||
| -rw-r--r-- | src/lib/single_stream_audio_content.cc | 5 | ||||
| -rw-r--r-- | src/lib/sndfile_content.cc | 4 | ||||
| -rw-r--r-- | src/lib/subrip_content.cc | 8 | ||||
| -rw-r--r-- | src/lib/video_content.cc | 36 |
10 files changed, 35 insertions, 75 deletions
diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index c67a66ed8..838fdcae2 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -191,13 +191,10 @@ AudioContent::audio_mapping () const int AudioContent::resampled_audio_frame_rate () const { - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - /* Resample to a DCI-approved sample rate */ double t = has_rate_above_48k() ? 96000 : 48000; - FrameRateChange frc = film->active_frame_rate_change (position ()); + FrameRateChange frc = film()->active_frame_rate_change (position ()); /* Compensate if the DCP is being run at a different frame rate to the source; that is, if the video is run such that it will diff --git a/src/lib/content.cc b/src/lib/content.cc index aa596f75a..af85e0ff0 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -223,9 +223,7 @@ Content::technical_summary () const DCPTime Content::length_after_trim () const { - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - return max (DCPTime (), full_length() - DCPTime (trim_start() + trim_end(), film->active_frame_rate_change (position ()))); + return max (DCPTime (), full_length() - DCPTime (trim_start() + trim_end(), film()->active_frame_rate_change (position ()))); } /** @return string which changes when something about this content changes which affects @@ -289,3 +287,11 @@ Content::properties () const add_properties (p); return p; } + +shared_ptr<const Film> +Content::film () const +{ + shared_ptr<const Film> film = _film.lock (); + DCPOMATIC_ASSERT (film); + return film; +} diff --git a/src/lib/content.h b/src/lib/content.h index 14fa3c36a..b91b5778c 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -156,9 +156,7 @@ public: _change_signals_frequent = f; } - boost::shared_ptr<const Film> film () const { - return _film.lock (); - } + boost::shared_ptr<const Film> film () const; boost::signals2::signal<void (boost::weak_ptr<Content>, int, bool)> Changed; diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 85fbee012..f65aaec7e 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -161,10 +161,8 @@ DCPContent::as_xml (xmlpp::Node* node) const DCPTime DCPContent::full_length () const { - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - FrameRateChange const frc (video_frame_rate (), film->video_frame_rate ()); - return DCPTime::from_frames (llrint (video_length () * frc.factor ()), film->video_frame_rate ()); + FrameRateChange const frc (video_frame_rate (), film()->video_frame_rate ()); + return DCPTime::from_frames (llrint (video_length () * frc.factor ()), film()->video_frame_rate ()); } string @@ -266,11 +264,9 @@ DCPContent::reels () const return p; } - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); DCPTime from = position (); BOOST_FOREACH (shared_ptr<dcp::Reel> i, decoder->reels()) { - DCPTime const to = from + DCPTime::from_frames (i->main_picture()->duration(), film->video_frame_rate()); + DCPTime const to = from + DCPTime::from_frames (i->main_picture()->duration(), film()->video_frame_rate()); p.push_back (DCPTimePeriod (from, to)); from = to; } @@ -292,10 +288,7 @@ template <class T> bool DCPContent::can_reference (string overlapping, list<string>& why_not) const { - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - - list<DCPTimePeriod> const fr = film->reels (); + list<DCPTimePeriod> const fr = film()->reels (); /* fr must contain reels(). It can also contain other reels, but it must at least contain reels(). */ @@ -306,7 +299,7 @@ DCPContent::can_reference (string overlapping, list<string>& why_not) const } } - list<shared_ptr<T> > a = overlaps<T> (film->content(), position(), end()); + list<shared_ptr<T> > a = overlaps<T> (film()->content(), position(), end()); if (a.size() != 1 || a.front().get() != this) { why_not.push_back (overlapping); return false; diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc index 19f38c5f6..39f24b215 100644 --- a/src/lib/dcp_subtitle_content.cc +++ b/src/lib/dcp_subtitle_content.cc @@ -82,9 +82,7 @@ DCPSubtitleContent::examine (shared_ptr<Job> job) DCPTime DCPSubtitleContent::full_length () const { - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - FrameRateChange const frc (subtitle_video_frame_rate(), film->video_frame_rate()); + FrameRateChange const frc (subtitle_video_frame_rate(), film()->video_frame_rate()); return DCPTime (_length, frc); } @@ -133,7 +131,5 @@ DCPSubtitleContent::subtitle_video_frame_rate () const /* No frame rate specified, so assume this content has been prepared for any concurrent video content. */ - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - return film->active_frame_rate_change(position()).source; + return film()->active_frame_rate_change(position()).source; } diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 6df97a485..a317ec35f 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -187,9 +187,6 @@ FFmpegContent::examine (shared_ptr<Job> job) shared_ptr<FFmpegExaminer> examiner (new FFmpegExaminer (shared_from_this (), job)); take_from_video_examiner (examiner); - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - { boost::mutex::scoped_lock lm (_mutex); @@ -202,7 +199,7 @@ FFmpegContent::examine (shared_ptr<Job> job) if (!_audio_streams.empty ()) { AudioMapping m = _audio_streams.front()->mapping (); - film->make_audio_mapping_default (m); + film()->make_audio_mapping_default (m); _audio_streams.front()->set_mapping (m); } @@ -280,10 +277,8 @@ operator!= (FFmpegStream const & a, FFmpegStream const & b) DCPTime FFmpegContent::full_length () const { - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - FrameRateChange const frc (video_frame_rate (), film->video_frame_rate ()); - return DCPTime::from_frames (llrint (video_length_after_3d_combine() * frc.factor()), film->video_frame_rate()); + FrameRateChange const frc (video_frame_rate (), film()->video_frame_rate ()); + return DCPTime::from_frames (llrint (video_length_after_3d_combine() * frc.factor()), film()->video_frame_rate()); } void diff --git a/src/lib/single_stream_audio_content.cc b/src/lib/single_stream_audio_content.cc index 05b055865..4c59420cb 100644 --- a/src/lib/single_stream_audio_content.cc +++ b/src/lib/single_stream_audio_content.cc @@ -66,14 +66,11 @@ SingleStreamAudioContent::as_xml (xmlpp::Node* node) const void SingleStreamAudioContent::take_from_audio_examiner (shared_ptr<AudioExaminer> examiner) { - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - { boost::mutex::scoped_lock lm (_mutex); _audio_stream.reset (new AudioStream (examiner->audio_frame_rate(), examiner->audio_channels ())); AudioMapping m = _audio_stream->mapping (); - film->make_audio_mapping_default (m); + film()->make_audio_mapping_default (m); _audio_stream->set_mapping (m); } diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc index dc26a1a7e..c4f418775 100644 --- a/src/lib/sndfile_content.cc +++ b/src/lib/sndfile_content.cc @@ -106,8 +106,6 @@ SndfileContent::take_from_audio_examiner (shared_ptr<AudioExaminer> examiner) DCPTime SndfileContent::full_length () const { - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - FrameRateChange const frc = film->active_frame_rate_change (position ()); + FrameRateChange const frc = film()->active_frame_rate_change (position ()); return DCPTime::from_frames (audio_length() / frc.speed_up, audio_stream()->frame_rate ()); } diff --git a/src/lib/subrip_content.cc b/src/lib/subrip_content.cc index ba081624a..1a7efc117 100644 --- a/src/lib/subrip_content.cc +++ b/src/lib/subrip_content.cc @@ -89,9 +89,7 @@ SubRipContent::as_xml (xmlpp::Node* node) const DCPTime SubRipContent::full_length () const { - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - FrameRateChange const frc (subtitle_video_frame_rate(), film->video_frame_rate ()); + FrameRateChange const frc (subtitle_video_frame_rate(), film()->video_frame_rate ()); return DCPTime (_length, frc); } @@ -119,7 +117,5 @@ SubRipContent::subtitle_video_frame_rate () const /* No frame rate specified, so assume this content has been prepared for any concurrent video content. */ - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - return film->active_frame_rate_change(position()).source; + return film()->active_frame_rate_change(position()).source; } diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index f11b40bb4..498d5b9db 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -38,7 +38,7 @@ #include "i18n.h" -#define LOG_GENERAL(...) film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); +#define LOG_GENERAL(...) film()->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); int const VideoContentProperty::VIDEO_SIZE = 0; int const VideoContentProperty::VIDEO_FRAME_RATE = 1; @@ -236,8 +236,6 @@ VideoContent::take_from_video_examiner (shared_ptr<VideoExaminer> d) ); } - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); LOG_GENERAL ("Video length obtained from header as %1 frames", _video_length); set_default_colour_conversion (); @@ -447,12 +445,9 @@ VideoContent::video_size_after_crop () const void VideoContent::scale_and_crop_to_fit_width () { - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); + set_scale (VideoContentScale (film()->container ())); - set_scale (VideoContentScale (film->container ())); - - int const crop = max (0, int (video_size().height - double (film->frame_size().height) * video_size().width / film->frame_size().width)); + int const crop = max (0, int (video_size().height - double (film()->frame_size().height) * video_size().width / film()->frame_size().width)); set_top_crop (crop / 2); set_bottom_crop (crop / 2); } @@ -460,12 +455,9 @@ VideoContent::scale_and_crop_to_fit_width () void VideoContent::scale_and_crop_to_fit_height () { - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - - set_scale (VideoContentScale (film->container ())); + set_scale (VideoContentScale (film()->container ())); - int const crop = max (0, int (video_size().width - double (film->frame_size().width) * video_size().height / film->frame_size().height)); + int const crop = max (0, int (video_size().width - double (film()->frame_size().width) * video_size().height / film()->frame_size().height)); set_left_crop (crop / 2); set_right_crop (crop / 2); } @@ -536,10 +528,7 @@ VideoContent::processing_description () const d << " (" << fixed << setprecision(2) << cropped.ratio () << ":1)\n"; } - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - - dcp::Size const container_size = film->frame_size (); + dcp::Size const container_size = film()->frame_size (); dcp::Size const scaled = scale().size (dynamic_pointer_cast<const VideoContent> (shared_from_this ()), container_size, container_size); if (scaled != video_size_after_crop ()) { @@ -554,7 +543,7 @@ VideoContent::processing_description () const if (scaled != container_size) { d << String::compose ( _("Padded with black to fit container %1 (%2x%3)"), - film->container()->nickname (), + film()->container()->nickname (), container_size.width, container_size.height ); @@ -564,7 +553,7 @@ VideoContent::processing_description () const d << _("Content frame rate"); d << " " << fixed << setprecision(4) << video_frame_rate() << "\n"; - FrameRateChange frc (video_frame_rate(), film->video_frame_rate ()); + FrameRateChange frc (video_frame_rate(), film()->video_frame_rate ()); d << frc.description () << "\n"; return d.str (); @@ -582,19 +571,14 @@ list<DCPTime> VideoContent::reel_split_points () const { list<DCPTime> t; - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); /* XXX: this is questionable; perhaps the position should be forced to be on a frame boundary */ - t.push_back (position().round_up (film->video_frame_rate())); + 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_frame_rate.get_value_or (film()->video_frame_rate ()); } |
