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
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
add_properties (p);
return p;
}
+
+shared_ptr<const Film>
+Content::film () const
+{
+ shared_ptr<const Film> film = _film.lock ();
+ DCPOMATIC_ASSERT (film);
+ return film;
+}
_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;
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
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;
}
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().
*/
}
}
- 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;
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);
}
/* 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;
}
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);
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);
}
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
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);
}
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 ());
}
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);
}
/* 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;
}
#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;
);
}
- 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 ();
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);
}
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);
}
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 ()) {
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
);
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 ();
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 ());
}