From 254b3044d72de6b033d7c584f5abd2b9aa70aad5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 21 Nov 2018 01:59:04 +0000 Subject: Take Film pointer out of Content. --- src/lib/analyse_audio_job.cc | 4 +- src/lib/atmos_mxf_content.cc | 18 ++++---- src/lib/atmos_mxf_content.h | 8 ++-- src/lib/audio_content.cc | 28 ++++++------ src/lib/audio_content.h | 8 ++-- src/lib/audio_decoder.cc | 24 +++++----- src/lib/audio_decoder.h | 9 ++-- src/lib/content.cc | 58 ++++++++---------------- src/lib/content.h | 30 ++++++------- src/lib/content_factory.cc | 42 +++++++++-------- src/lib/content_factory.h | 2 +- src/lib/dcp.cc | 2 +- src/lib/dcp_content.cc | 75 +++++++++++++++---------------- src/lib/dcp_content.h | 21 ++++----- src/lib/dcp_decoder.cc | 53 +++++++++++++--------- src/lib/dcp_decoder.h | 16 ++++--- src/lib/dcp_subtitle_content.cc | 16 +++---- src/lib/dcp_subtitle_content.h | 8 ++-- src/lib/dcp_subtitle_decoder.cc | 10 ++--- src/lib/dcp_subtitle_decoder.h | 6 +-- src/lib/decoder.cc | 16 +++---- src/lib/decoder.h | 7 +-- src/lib/decoder_factory.cc | 14 +++--- src/lib/decoder_factory.h | 2 +- src/lib/decoder_part.cc | 3 +- src/lib/decoder_part.h | 6 +-- src/lib/empty.cc | 6 +-- src/lib/empty.h | 2 +- src/lib/examine_content_job.cc | 2 +- src/lib/ffmpeg.cc | 6 +-- src/lib/ffmpeg_content.cc | 30 ++++++------- src/lib/ffmpeg_content.h | 12 ++--- src/lib/ffmpeg_decoder.cc | 58 ++++++++++++------------ src/lib/ffmpeg_decoder.h | 14 +++--- src/lib/film.cc | 24 +++++----- src/lib/image_content.cc | 22 ++++----- src/lib/image_content.h | 8 ++-- src/lib/image_decoder.cc | 14 +++--- src/lib/image_decoder.h | 6 +-- src/lib/log.cc | 2 + src/lib/log.h | 2 + src/lib/overlaps.cc | 4 +- src/lib/overlaps.h | 3 +- src/lib/player.cc | 54 +++++++++++----------- src/lib/player_video.cc | 4 +- src/lib/player_video.h | 3 +- src/lib/playlist.cc | 89 ++++++++++++++++++++----------------- src/lib/playlist.h | 25 ++++++----- src/lib/string_text_file_content.cc | 16 +++---- src/lib/string_text_file_content.h | 8 ++-- src/lib/string_text_file_decoder.cc | 10 ++--- src/lib/string_text_file_decoder.h | 7 ++- src/lib/text_decoder.cc | 3 +- src/lib/text_decoder.h | 3 +- src/lib/video_content.cc | 25 +++++------ src/lib/video_content.h | 10 ++--- src/lib/video_decoder.cc | 8 ++-- src/lib/video_decoder.h | 7 ++- src/lib/video_mxf_content.cc | 18 ++++---- src/lib/video_mxf_content.h | 8 ++-- src/lib/video_mxf_decoder.cc | 15 ++++--- src/lib/video_mxf_decoder.h | 6 +-- 62 files changed, 505 insertions(+), 515 deletions(-) (limited to 'src/lib') diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index 5994bc71a..8c9a90283 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -111,7 +111,7 @@ AnalyseAudioJob::run () player->set_play_referenced (); player->Audio.connect (bind (&AnalyseAudioJob::analyse, this, _1, _2)); - DCPTime const length = _playlist->length (); + DCPTime const length = _playlist->length (_film); Frame const len = DCPTime (length - _start).frames_round (_film->audio_frame_rate()); _samples_per_point = max (int64_t (1), len / _num_points); @@ -214,6 +214,6 @@ AnalyseAudioJob::analyse (shared_ptr b, DCPTime time) _done += frames; - DCPTime const length = _playlist->length (); + DCPTime const length = _playlist->length (_film); set_progress ((time.seconds() - _start.seconds()) / (length.seconds() - _start.seconds())); } diff --git a/src/lib/atmos_mxf_content.cc b/src/lib/atmos_mxf_content.cc index a42b10954..8300c2cd6 100644 --- a/src/lib/atmos_mxf_content.cc +++ b/src/lib/atmos_mxf_content.cc @@ -33,14 +33,14 @@ using std::list; using std::string; using boost::shared_ptr; -AtmosMXFContent::AtmosMXFContent (shared_ptr film, boost::filesystem::path path) - : Content (film, path) +AtmosMXFContent::AtmosMXFContent (boost::filesystem::path path) + : Content (path) { } -AtmosMXFContent::AtmosMXFContent (shared_ptr film, cxml::ConstNodePtr node, int) - : Content (film, node) +AtmosMXFContent::AtmosMXFContent (cxml::ConstNodePtr node, int) + : Content (node) { } @@ -65,10 +65,10 @@ AtmosMXFContent::valid_mxf (boost::filesystem::path path) } void -AtmosMXFContent::examine (shared_ptr job) +AtmosMXFContent::examine (shared_ptr film, shared_ptr job) { job->set_progress_unknown (); - Content::examine (job); + Content::examine (film, job); shared_ptr a (new dcp::AtmosAsset (path(0))); { @@ -91,8 +91,8 @@ AtmosMXFContent::as_xml (xmlpp::Node* node, bool with_paths) const } DCPTime -AtmosMXFContent::full_length () const +AtmosMXFContent::full_length (shared_ptr film) const { - FrameRateChange const frc (active_video_frame_rate(), film()->video_frame_rate()); - return DCPTime::from_frames (llrint (_length * frc.factor()), film()->video_frame_rate()); + FrameRateChange const frc (active_video_frame_rate(film), film->video_frame_rate()); + return DCPTime::from_frames (llrint (_length * frc.factor()), film->video_frame_rate()); } diff --git a/src/lib/atmos_mxf_content.h b/src/lib/atmos_mxf_content.h index 0f5225c2e..156ebc788 100644 --- a/src/lib/atmos_mxf_content.h +++ b/src/lib/atmos_mxf_content.h @@ -23,17 +23,17 @@ class AtmosMXFContent : public Content { public: - AtmosMXFContent (boost::shared_ptr film, boost::filesystem::path path); - AtmosMXFContent (boost::shared_ptr film, cxml::ConstNodePtr node, int version); + AtmosMXFContent (boost::filesystem::path path); + AtmosMXFContent (cxml::ConstNodePtr node, int version); boost::shared_ptr shared_from_this () { return boost::dynamic_pointer_cast (Content::shared_from_this ()); } - void examine (boost::shared_ptr job); + void examine (boost::shared_ptr film, boost::shared_ptr job); std::string summary () const; void as_xml (xmlpp::Node* node, bool with_path) const; - DCPTime full_length () const; + DCPTime full_length (boost::shared_ptr film) const; static bool valid_mxf (boost::filesystem::path path); diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index 59ba992ad..f33720119 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -194,12 +194,12 @@ AudioContent::mapping () const * that it is in sync with the active video content at its start time. */ int -AudioContent::resampled_frame_rate () const +AudioContent::resampled_frame_rate (shared_ptr film) const { /* Resample to a DCI-approved sample rate */ double t = has_rate_above_48k() ? 96000 : 48000; - FrameRateChange frc (_parent->active_video_frame_rate(), _parent->film()->video_frame_rate()); + FrameRateChange frc (_parent->active_video_frame_rate(film), film->video_frame_rate()); /* 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 @@ -214,7 +214,7 @@ AudioContent::resampled_frame_rate () const } string -AudioContent::processing_description () const +AudioContent::processing_description (shared_ptr film) const { if (streams().empty ()) { return ""; @@ -233,7 +233,7 @@ AudioContent::processing_description () const optional common_frame_rate; BOOST_FOREACH (AudioStreamPtr i, streams()) { - if (i->frame_rate() != resampled_frame_rate()) { + if (i->frame_rate() != resampled_frame_rate(film)) { resampled = true; } else { not_resampled = true; @@ -250,14 +250,14 @@ AudioContent::processing_description () const } if (not_resampled && resampled) { - return String::compose (_("Some audio will be resampled to %1Hz"), resampled_frame_rate ()); + return String::compose (_("Some audio will be resampled to %1Hz"), resampled_frame_rate(film)); } if (!not_resampled && resampled) { if (same) { - return String::compose (_("Audio will be resampled from %1Hz to %2Hz"), common_frame_rate.get(), resampled_frame_rate ()); + return String::compose (_("Audio will be resampled from %1Hz to %2Hz"), common_frame_rate.get(), resampled_frame_rate(film)); } else { - return String::compose (_("Audio will be resampled to %1Hz"), resampled_frame_rate ()); + return String::compose (_("Audio will be resampled to %1Hz"), resampled_frame_rate(film)); } } @@ -295,7 +295,7 @@ AudioContent::channel_names () const } void -AudioContent::add_properties (list& p) const +AudioContent::add_properties (shared_ptr film, list& p) const { shared_ptr stream; if (streams().size() == 1) { @@ -307,8 +307,8 @@ AudioContent::add_properties (list& p) const p.push_back (UserProperty (UserProperty::AUDIO, _("Content audio sample rate"), stream->frame_rate(), _("Hz"))); } - FrameRateChange const frc (_parent->active_video_frame_rate(), _parent->film()->video_frame_rate()); - ContentTime const c (_parent->full_length(), frc); + FrameRateChange const frc (_parent->active_video_frame_rate(film), film->video_frame_rate()); + ContentTime const c (_parent->full_length(film), frc); p.push_back ( UserProperty (UserProperty::LENGTH, _("Full length in video frames at content rate"), c.frames_round(frc.source)) @@ -324,7 +324,7 @@ AudioContent::add_properties (list& p) const ); } - p.push_back (UserProperty (UserProperty::AUDIO, _("DCP sample rate"), resampled_frame_rate (), _("Hz"))); + p.push_back (UserProperty (UserProperty::AUDIO, _("DCP sample rate"), resampled_frame_rate(film), _("Hz"))); p.push_back (UserProperty (UserProperty::LENGTH, _("Full length in video frames at DCP rate"), c.frames_round (frc.dcp))); if (stream) { @@ -332,7 +332,7 @@ AudioContent::add_properties (list& p) const UserProperty ( UserProperty::LENGTH, _("Full length in audio samples at DCP rate"), - c.frames_round (resampled_frame_rate ()) + c.frames_round(resampled_frame_rate(film)) ) ); } @@ -397,9 +397,9 @@ AudioContent::take_settings_from (shared_ptr c) } void -AudioContent::modify_position (DCPTime& pos) const +AudioContent::modify_position (shared_ptr film, DCPTime& pos) const { - pos = pos.round (_parent->film()->audio_frame_rate()); + pos = pos.round (film->audio_frame_rate()); } void diff --git a/src/lib/audio_content.h b/src/lib/audio_content.h index eec67b201..051fc8db8 100644 --- a/src/lib/audio_content.h +++ b/src/lib/audio_content.h @@ -52,7 +52,7 @@ public: AudioMapping mapping () const; void set_mapping (AudioMapping); - int resampled_frame_rate () const; + int resampled_frame_rate (boost::shared_ptr film) const; bool has_rate_above_48k () const; std::vector channel_names () const; @@ -69,7 +69,7 @@ public: return _delay; } - std::string processing_description () const; + std::string processing_description (boost::shared_ptr film) const; std::vector streams () const { boost::mutex::scoped_lock lm (_mutex); @@ -81,9 +81,9 @@ public: void set_streams (std::vector streams); AudioStreamPtr stream () const; - void add_properties (std::list &) const; + void add_properties (boost::shared_ptr film, std::list &) const; - void modify_position (DCPTime& pos) const; + void modify_position (boost::shared_ptr film, DCPTime& pos) const; void modify_trim_start (ContentTime& pos) const; static boost::shared_ptr from_xml (Content* parent, cxml::ConstNodePtr, int version); diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index b4aa2bacd..95b3a130d 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -29,7 +29,7 @@ #include "i18n.h" -#define LOG_GENERAL(...) _log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); +#define LOG_GENERAL(...) dcpomatic_log->log (String::compose(__VA_ARGS__), LogEntry::TYPE_GENERAL); using std::cout; using std::map; @@ -37,8 +37,8 @@ using std::pair; using boost::shared_ptr; using boost::optional; -AudioDecoder::AudioDecoder (Decoder* parent, shared_ptr content, shared_ptr log, bool fast) - : DecoderPart (parent, log) +AudioDecoder::AudioDecoder (Decoder* parent, shared_ptr content, bool fast) + : DecoderPart (parent) , _content (content) , _fast (fast) { @@ -49,7 +49,7 @@ AudioDecoder::AudioDecoder (Decoder* parent, shared_ptr cont } void -AudioDecoder::emit (AudioStreamPtr stream, shared_ptr data, ContentTime time) +AudioDecoder::emit (shared_ptr film, AudioStreamPtr stream, shared_ptr data, ContentTime time) { if (ignore ()) { return; @@ -66,7 +66,7 @@ AudioDecoder::emit (AudioStreamPtr stream, shared_ptr data, silence (_content->delay ()); } time += ContentTime::from_seconds (_content->delay() / 1000.0); - _positions[stream] = time.frames_round (_content->resampled_frame_rate ()); + _positions[stream] = time.frames_round (_content->resampled_frame_rate(film)); } shared_ptr resampler; @@ -74,15 +74,15 @@ AudioDecoder::emit (AudioStreamPtr stream, shared_ptr data, if (i != _resamplers.end ()) { resampler = i->second; } else { - if (stream->frame_rate() != _content->resampled_frame_rate()) { + if (stream->frame_rate() != _content->resampled_frame_rate(film)) { LOG_GENERAL ( "Creating new resampler from %1 to %2 with %3 channels", stream->frame_rate(), - _content->resampled_frame_rate(), + _content->resampled_frame_rate(film), stream->channels() ); - resampler.reset (new Resampler (stream->frame_rate(), _content->resampled_frame_rate(), stream->channels())); + resampler.reset (new Resampler (stream->frame_rate(), _content->resampled_frame_rate(film), stream->channels())); if (_fast) { resampler->set_fast (); } @@ -104,19 +104,19 @@ AudioDecoder::emit (AudioStreamPtr stream, shared_ptr data, /** @return Time just after the last thing that was emitted from a given stream */ ContentTime -AudioDecoder::stream_position (AudioStreamPtr stream) const +AudioDecoder::stream_position (shared_ptr film, AudioStreamPtr stream) const { PositionMap::const_iterator i = _positions.find (stream); DCPOMATIC_ASSERT (i != _positions.end ()); - return ContentTime::from_frames (i->second, _content->resampled_frame_rate()); + return ContentTime::from_frames (i->second, _content->resampled_frame_rate(film)); } ContentTime -AudioDecoder::position () const +AudioDecoder::position (shared_ptr film) const { optional p; for (PositionMap::const_iterator i = _positions.begin(); i != _positions.end(); ++i) { - ContentTime const ct = stream_position (i->first); + ContentTime const ct = stream_position (film, i->first); if (!p || ct < *p) { p = ct; } diff --git a/src/lib/audio_decoder.h b/src/lib/audio_decoder.h index 8765be426..50e361e8f 100644 --- a/src/lib/audio_decoder.h +++ b/src/lib/audio_decoder.h @@ -36,6 +36,7 @@ class AudioBuffers; class AudioContent; class AudioDecoderStream; class Log; +class Film; class Resampler; /** @class AudioDecoder. @@ -44,14 +45,14 @@ class Resampler; class AudioDecoder : public boost::enable_shared_from_this, public DecoderPart { public: - AudioDecoder (Decoder* parent, boost::shared_ptr content, boost::shared_ptr log, bool fast); + AudioDecoder (Decoder* parent, boost::shared_ptr content, bool fast); - ContentTime position () const; - void emit (AudioStreamPtr stream, boost::shared_ptr, ContentTime); + ContentTime position (boost::shared_ptr film) const; + void emit (boost::shared_ptr film, AudioStreamPtr stream, boost::shared_ptr, ContentTime); void seek (); void flush (); - ContentTime stream_position (AudioStreamPtr stream) const; + ContentTime stream_position (boost::shared_ptr film, AudioStreamPtr stream) const; /** @return Number of frames of data that were accepted */ boost::signals2::signal Data; diff --git a/src/lib/content.cc b/src/lib/content.cc index 6f5d23fd5..5139eb4cc 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -60,9 +60,8 @@ int const ContentProperty::TRIM_START = 403; int const ContentProperty::TRIM_END = 404; int const ContentProperty::VIDEO_FRAME_RATE = 405; -Content::Content (shared_ptr film) - : _film (film) - , _position (0) +Content::Content () + : _position (0) , _trim_start (0) , _trim_end (0) , _change_signals_frequent (false) @@ -70,9 +69,8 @@ Content::Content (shared_ptr film) } -Content::Content (shared_ptr film, DCPTime p) - : _film (film) - , _position (p) +Content::Content (DCPTime p) + : _position (p) , _trim_start (0) , _trim_end (0) , _change_signals_frequent (false) @@ -80,9 +78,8 @@ Content::Content (shared_ptr film, DCPTime p) } -Content::Content (shared_ptr film, boost::filesystem::path p) - : _film (film) - , _position (0) +Content::Content (boost::filesystem::path p) + : _position (0) , _trim_start (0) , _trim_end (0) , _change_signals_frequent (false) @@ -90,9 +87,8 @@ Content::Content (shared_ptr film, boost::filesystem::path p) add_path (p); } -Content::Content (shared_ptr film, cxml::ConstNodePtr node) - : _film (film) - , _change_signals_frequent (false) +Content::Content (cxml::ConstNodePtr node) + : _change_signals_frequent (false) { list path_children = node->node_children ("Path"); BOOST_FOREACH (cxml::NodePtr i, path_children) { @@ -113,9 +109,8 @@ Content::Content (shared_ptr film, cxml::ConstNodePtr node) _video_frame_rate = node->optional_number_child ("VideoFrameRate"); } -Content::Content (shared_ptr film, vector > c) - : _film (film) - , _position (c.front()->position ()) +Content::Content (vector > c) + : _position (c.front()->position ()) , _trim_start (c.front()->trim_start ()) , _trim_end (c.back()->trim_end ()) , _video_frame_rate (c.front()->video_frame_rate()) @@ -184,7 +179,7 @@ Content::calculate_digest () const } void -Content::examine (shared_ptr job) +Content::examine (shared_ptr, shared_ptr job) { if (job) { job->sub (_("Computing digest")); @@ -216,16 +211,16 @@ Content::signal_change (ChangeType c, int p) } void -Content::set_position (DCPTime p) +Content::set_position (shared_ptr film, DCPTime p) { /* video and audio content can modify its position */ if (video) { - video->modify_position (p); + video->modify_position (film, p); } if (audio) { - audio->modify_position (p); + audio->modify_position (film, p); } ChangeSignaller cc (this, ContentProperty::POSITION); @@ -275,13 +270,8 @@ Content::set_trim_end (ContentTime t) shared_ptr -Content::clone () const +Content::clone (shared_ptr film) const { - shared_ptr film = _film.lock (); - if (!film) { - return shared_ptr (); - } - /* This is a bit naughty, but I can't think of a compelling reason not to do it ... */ xmlpp::Document doc; xmlpp::Node* node = doc.create_root_node ("Content"); @@ -289,7 +279,7 @@ Content::clone () const /* notes is unused here (we assume) */ list notes; - return content_factory (film, cxml::NodePtr (new cxml::Node (node)), Film::current_state_version, notes); + return content_factory (film, cxml::NodePtr(new cxml::Node(node)), Film::current_state_version, notes); } string @@ -303,9 +293,9 @@ Content::technical_summary () const } DCPTime -Content::length_after_trim () const +Content::length_after_trim (shared_ptr film) const { - return max (DCPTime (), full_length() - DCPTime (trim_start() + trim_end(), film()->active_frame_rate_change (position ()))); + return max (DCPTime(), full_length(film) - DCPTime(trim_start() + trim_end(), film->active_frame_rate_change(position()))); } /** @return string which changes when something about this content changes which affects @@ -373,14 +363,6 @@ Content::user_properties () const return p; } -shared_ptr -Content::film () const -{ - shared_ptr film = _film.lock (); - DCPOMATIC_ASSERT (film); - return film; -} - /** @return DCP times of points within this content where a reel split could occur */ list Content::reel_split_points () const @@ -424,7 +406,7 @@ Content::unset_video_frame_rate () } double -Content::active_video_frame_rate () const +Content::active_video_frame_rate (shared_ptr film) const { { boost::mutex::scoped_lock lm (_mutex); @@ -437,8 +419,6 @@ Content::active_video_frame_rate () const prepared for any concurrent video content or perhaps just the DCP rate. */ - shared_ptr film = _film.lock (); - DCPOMATIC_ASSERT (film); return film->active_frame_rate_change(position()).source; } diff --git a/src/lib/content.h b/src/lib/content.h index 2eaa738d2..c6fa2c9f4 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -64,18 +64,18 @@ public: class Content : public boost::enable_shared_from_this, public Signaller, public boost::noncopyable { public: - explicit Content (boost::shared_ptr); - Content (boost::shared_ptr, DCPTime); - Content (boost::shared_ptr, boost::filesystem::path); - Content (boost::shared_ptr, cxml::ConstNodePtr); - Content (boost::shared_ptr, std::vector >); + explicit Content (); + Content (DCPTime); + Content (boost::filesystem::path); + Content (cxml::ConstNodePtr); + Content (std::vector >); virtual ~Content () {} /** Examine the content to establish digest, frame rates and any other * useful metadata. * @param job Job to use to report progress, or 0. */ - virtual void examine (boost::shared_ptr job); + virtual void examine (boost::shared_ptr film, boost::shared_ptr job); virtual void take_settings_from (boost::shared_ptr c); @@ -90,14 +90,14 @@ public: virtual std::string technical_summary () const; virtual void as_xml (xmlpp::Node *, bool with_paths) const; - virtual DCPTime full_length () const = 0; + virtual DCPTime full_length (boost::shared_ptr) const = 0; virtual std::string identifier () const; /** @return points at which to split this content when * REELTYPE_BY_VIDEO_CONTENT is in use. */ virtual std::list reel_split_points () const; - boost::shared_ptr clone () const; + boost::shared_ptr clone (boost::shared_ptr film) const; void set_paths (std::vector paths); @@ -134,7 +134,7 @@ public: return _digest; } - void set_position (DCPTime); + void set_position (boost::shared_ptr film, DCPTime); /** DCPTime that this content starts; i.e. the time that the first * bit of the content (trimmed or not) will happen. @@ -159,11 +159,11 @@ public: } /** @return Time immediately after the last thing in this content */ - DCPTime end () const { - return position() + length_after_trim(); + DCPTime end (boost::shared_ptr film) const { + return position() + length_after_trim(film); } - DCPTime length_after_trim () const; + DCPTime length_after_trim (boost::shared_ptr film) const; boost::optional video_frame_rate () const { boost::mutex::scoped_lock lm (_mutex); @@ -173,14 +173,12 @@ public: void set_video_frame_rate (double r); void unset_video_frame_rate (); - double active_video_frame_rate () const; + double active_video_frame_rate (boost::shared_ptr film) const; void set_change_signals_frequent (bool f) { _change_signals_frequent = f; } - boost::shared_ptr film () const; - std::list user_properties () const; std::string calculate_digest () const; @@ -199,8 +197,6 @@ protected: virtual void add_properties (std::list &) const; - boost::weak_ptr _film; - /** _mutex which should be used to protect accesses, as examine * jobs can update content state in threads other than the main one. */ diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc index 10486b0c3..934677c66 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -47,10 +47,9 @@ using std::list; using boost::shared_ptr; using boost::optional; -#define LOG_GENERAL(...) film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); +#define LOG_GENERAL(...) dcpomatic_log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); /** Create a Content object from an XML node. - * @param film Film that the content will be in. * @param node XML description. * @param version XML state version. * @param notes A list to which is added descriptions of any non-critial warnings / messages. @@ -67,14 +66,14 @@ content_factory (shared_ptr film, cxml::ConstNodePtr node, int versi /* SndfileContent is now handled by the FFmpeg code rather than by separate libsndfile-based code. */ - content.reset (new FFmpegContent (film, node, version, notes)); + content.reset (new FFmpegContent (node, version, notes)); } else if (type == "Image") { - content.reset (new ImageContent (film, node, version)); + content.reset (new ImageContent (node, version)); } else if (type == "Sndfile") { /* SndfileContent is now handled by the FFmpeg code rather than by separate libsndfile-based code. */ - content.reset (new FFmpegContent (film, node, version, notes)); + content.reset (new FFmpegContent (node, version, notes)); content->audio->set_stream ( AudioStreamPtr ( @@ -88,20 +87,20 @@ content_factory (shared_ptr film, cxml::ConstNodePtr node, int versi ); } else if (type == "SubRip" || type == "TextSubtitle") { - content.reset (new StringTextFileContent (film, node, version)); + content.reset (new StringTextFileContent (node, version)); } else if (type == "DCP") { - content.reset (new DCPContent (film, node, version)); + content.reset (new DCPContent (node, version)); } else if (type == "DCPSubtitle") { - content.reset (new DCPSubtitleContent (film, node, version)); + content.reset (new DCPSubtitleContent (node, version)); } else if (type == "VideoMXF") { - content.reset (new VideoMXFContent (film, node, version)); + content.reset (new VideoMXFContent (node, version)); } else if (type == "AtmosMXF") { - content.reset (new AtmosMXFContent (film, node, version)); + content.reset (new AtmosMXFContent (node, version)); } /* See if this content should be nudged to start on a video frame */ DCPTime const old_pos = content->position(); - content->set_position(old_pos); + content->set_position(film, old_pos); if (old_pos != content->position()) { string note = _("Your project contains video content that was not aligned to a frame boundary."); note += " "; @@ -143,12 +142,11 @@ content_factory (shared_ptr film, cxml::ConstNodePtr node, int versi } /** Create some Content objects from a file or directory. - * @param film Film that the content will be in. * @param path File or directory. * @return Content objects. */ list > -content_factory (shared_ptr film, boost::filesystem::path path) +content_factory (boost::filesystem::path path) { list > content; @@ -193,10 +191,10 @@ content_factory (shared_ptr film, boost::filesystem::path path) } if (image_files > 0 && sound_files == 0) { - content.push_back (shared_ptr (new ImageContent (film, path))); + content.push_back (shared_ptr (new ImageContent(path))); } else if (image_files == 0 && sound_files > 0) { for (boost::filesystem::directory_iterator i(path); i != boost::filesystem::directory_iterator(); ++i) { - content.push_back (shared_ptr (new FFmpegContent (film, i->path()))); + content.push_back (shared_ptr (new FFmpegContent(i->path()))); } } @@ -208,26 +206,26 @@ content_factory (shared_ptr film, boost::filesystem::path path) transform (ext.begin(), ext.end(), ext.begin(), ::tolower); if (valid_image_file (path)) { - single.reset (new ImageContent (film, path)); + single.reset (new ImageContent(path)); } else if (ext == ".srt" || ext == ".ssa" || ext == ".ass") { - single.reset (new StringTextFileContent (film, path)); + single.reset (new StringTextFileContent(path)); } else if (ext == ".xml") { cxml::Document doc; doc.read_file (path); if (doc.root_name() == "DCinemaSecurityMessage") { throw KDMAsContentError (); } - single.reset (new DCPSubtitleContent (film, path)); + single.reset (new DCPSubtitleContent(path)); } else if (ext == ".mxf" && dcp::SMPTESubtitleAsset::valid_mxf (path)) { - single.reset (new DCPSubtitleContent (film, path)); + single.reset (new DCPSubtitleContent(path)); } else if (ext == ".mxf" && VideoMXFContent::valid_mxf (path)) { - single.reset (new VideoMXFContent (film, path)); + single.reset (new VideoMXFContent(path)); } else if (ext == ".mxf" && AtmosMXFContent::valid_mxf (path)) { - single.reset (new AtmosMXFContent (film, path)); + single.reset (new AtmosMXFContent(path)); } if (!single) { - single.reset (new FFmpegContent (film, path)); + single.reset (new FFmpegContent(path)); } content.push_back (single); diff --git a/src/lib/content_factory.h b/src/lib/content_factory.h index f712d9364..af77d9358 100644 --- a/src/lib/content_factory.h +++ b/src/lib/content_factory.h @@ -29,4 +29,4 @@ class Film; class Content; extern boost::shared_ptr content_factory (boost::shared_ptr, cxml::ConstNodePtr, int, std::list &); -extern std::list > content_factory (boost::shared_ptr, boost::filesystem::path); +extern std::list > content_factory (boost::filesystem::path); diff --git a/src/lib/dcp.cc b/src/lib/dcp.cc index 9db478330..1bf15ca24 100644 --- a/src/lib/dcp.cc +++ b/src/lib/dcp.cc @@ -35,7 +35,7 @@ using std::list; using std::string; using boost::shared_ptr; -#define LOG_GENERAL(...) _dcp_content->film()->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); +#define LOG_GENERAL(...) dcpomatic_log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); /** Find all the CPLs in our directories, cross-add assets and return the CPLs */ list > diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index cc636b0bf..0bd28a9e3 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -64,11 +64,10 @@ int const DCPContentProperty::NAME = 605; int const DCPContentProperty::TEXTS = 606; int const DCPContentProperty::CPL = 607; -#define LOG_GENERAL(...) this->film()->log()->log(String::compose(__VA_ARGS__), LogEntry::TYPE_GENERAL); +#define LOG_GENERAL(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_GENERAL); -DCPContent::DCPContent (shared_ptr film, boost::filesystem::path p) - : Content (film) - , _encrypted (false) +DCPContent::DCPContent (boost::filesystem::path p) + : _encrypted (false) , _needs_assets (false) , _kdm_valid (false) , _reference_video (false) @@ -85,8 +84,8 @@ DCPContent::DCPContent (shared_ptr film, boost::filesystem::path p) } } -DCPContent::DCPContent (shared_ptr film, cxml::ConstNodePtr node, int version) - : Content (film, node) +DCPContent::DCPContent (cxml::ConstNodePtr node, int version) + : Content (node) { video = VideoContent::from_xml (this, node, version); audio = AudioContent::from_xml (this, node, version); @@ -176,7 +175,7 @@ DCPContent::read_directory (boost::filesystem::path p) } void -DCPContent::examine (shared_ptr job) +DCPContent::examine (shared_ptr film, shared_ptr job) { bool const needed_assets = needs_assets (); bool const needed_kdm = needs_kdm (); @@ -192,7 +191,7 @@ DCPContent::examine (shared_ptr job) if (job) { job->set_progress_unknown (); } - Content::examine (job); + Content::examine (film, job); shared_ptr examiner (new DCPExaminer (shared_from_this ())); @@ -214,7 +213,7 @@ DCPContent::examine (shared_ptr job) AudioStreamPtr as (new AudioStream (examiner->audio_frame_rate(), examiner->audio_length(), examiner->audio_channels())); audio->set_stream (as); AudioMapping m = as->mapping (); - film()->make_audio_mapping_default (m); + film->make_audio_mapping_default (m); as->set_mapping (m); } @@ -338,13 +337,13 @@ DCPContent::as_xml (xmlpp::Node* node, bool with_paths) const } DCPTime -DCPContent::full_length () const +DCPContent::full_length (shared_ptr film) const { if (!video) { return DCPTime(); } - FrameRateChange const frc (active_video_frame_rate (), film()->video_frame_rate ()); - return DCPTime::from_frames (llrint (video->length () * frc.factor ()), film()->video_frame_rate ()); + FrameRateChange const frc (active_video_frame_rate(film), film->video_frame_rate()); + return DCPTime::from_frames (llrint(video->length() * frc.factor()), film->video_frame_rate()); } string @@ -406,14 +405,14 @@ DCPContent::directories () const } void -DCPContent::add_properties (list& p) const +DCPContent::add_properties (shared_ptr film, list& p) const { Content::add_properties (p); if (video) { video->add_properties (p); } if (audio) { - audio->add_properties (p); + audio->add_properties (film, p); } } @@ -460,7 +459,7 @@ DCPContent::set_reference_text (TextType type, bool r) } list -DCPContent::reels () const +DCPContent::reels (shared_ptr film) const { list reel_lengths = _reel_lengths; if (reel_lengths.empty ()) { @@ -470,7 +469,7 @@ DCPContent::reels () const reel_lengths = examiner->reel_lengths (); } catch (...) { /* Could not examine the DCP; guess reels */ - reel_lengths.push_back (length_after_trim().frames_round (film()->video_frame_rate ())); + reel_lengths.push_back (length_after_trim(film).frames_round(film->video_frame_rate())); } } @@ -485,10 +484,10 @@ DCPContent::reels () const BOOST_FOREACH (int64_t i, reel_lengths) { /* This reel runs from `pos' to `to' */ - DCPTime const to = pos + DCPTime::from_frames (i, film()->video_frame_rate()); + DCPTime const to = pos + DCPTime::from_frames (i, film->video_frame_rate()); if (to > position()) { - p.push_back (DCPTimePeriod (max(position(), pos), min(end(), to))); - if (to > end()) { + p.push_back (DCPTimePeriod (max(position(), pos), min(end(film), to))); + if (to > end(film)) { break; } } @@ -499,25 +498,25 @@ DCPContent::reels () const } list -DCPContent::reel_split_points () const +DCPContent::reel_split_points (shared_ptr film) const { list s; - BOOST_FOREACH (DCPTimePeriod i, reels()) { + BOOST_FOREACH (DCPTimePeriod i, reels(film)) { s.push_back (i.from); } return s; } bool -DCPContent::can_reference (function)> part, string overlapping, string& why_not) const +DCPContent::can_reference (shared_ptr film, function)> part, string overlapping, string& why_not) const { /* We must be using the same standard as the film */ if (_standard) { - if (_standard.get() == dcp::INTEROP && !film()->interop()) { + if (_standard.get() == dcp::INTEROP && !film->interop()) { /// TRANSLATORS: this string will follow "Cannot reference this DCP: " why_not = _("it is Interop and the film is set to SMPTE."); return false; - } else if (_standard.get() == dcp::SMPTE && film()->interop()) { + } else if (_standard.get() == dcp::SMPTE && film->interop()) { /// TRANSLATORS: this string will follow "Cannot reference this DCP: " why_not = _("it is SMPTE and the film is set to Interop."); return false; @@ -525,17 +524,17 @@ DCPContent::can_reference (function)> part, stri } /* And the same frame rate */ - if (!video_frame_rate() || (lrint(video_frame_rate().get()) != film()->video_frame_rate())) { + if (!video_frame_rate() || (lrint(video_frame_rate().get()) != film->video_frame_rate())) { /// TRANSLATORS: this string will follow "Cannot reference this DCP: " why_not = _("it has a different frame rate to the film."); return false; } - list const fr = film()->reels (); + list const fr = film->reels (); list reel_list; try { - reel_list = reels (); + reel_list = reels (film); } catch (dcp::DCPReadError) { /* We couldn't read the DCP; it's probably missing */ return false; @@ -555,7 +554,7 @@ DCPContent::can_reference (function)> part, stri } } - ContentList a = overlaps (film()->content(), part, position(), end()); + ContentList a = overlaps (film, film->content(), part, position(), end(film)); if (a.size() != 1 || a.front().get() != this) { why_not = overlapping; return false; @@ -571,7 +570,7 @@ bool check_video (shared_ptr c) } bool -DCPContent::can_reference_video (string& why_not) const +DCPContent::can_reference_video (shared_ptr film, string& why_not) const { if (!video) { why_not = _("There is no video in this DCP"); @@ -583,7 +582,7 @@ DCPContent::can_reference_video (string& why_not) const video_res = RESOLUTION_4K; } - if (film()->resolution() != video_res) { + if (film->resolution() != video_res) { if (video_res == RESOLUTION_4K) { /// TRANSLATORS: this string will follow "Cannot reference this DCP: " why_not = _("it is 4K and the film is 2K."); @@ -592,14 +591,14 @@ DCPContent::can_reference_video (string& why_not) const why_not = _("it is 2K and the film is 4K."); } return false; - } else if (film()->frame_size() != video->size()) { + } else if (film->frame_size() != video->size()) { /// TRANSLATORS: this string will follow "Cannot reference this DCP: " why_not = _("its video frame size differs from the film's."); return false; } /// TRANSLATORS: this string will follow "Cannot reference this DCP: " - return can_reference (bind (&check_video, _1), _("it overlaps other video content; remove the other content."), why_not); + return can_reference (film, bind (&check_video, _1), _("it overlaps other video content; remove the other content."), why_not); } static @@ -609,11 +608,11 @@ bool check_audio (shared_ptr c) } bool -DCPContent::can_reference_audio (string& why_not) const +DCPContent::can_reference_audio (shared_ptr film, string& why_not) const { shared_ptr decoder; try { - decoder.reset (new DCPDecoder (shared_from_this(), film()->log(), false)); + decoder.reset (new DCPDecoder (shared_from_this(), false)); } catch (dcp::DCPReadError) { /* We couldn't read the DCP, so it's probably missing */ return false; @@ -634,7 +633,7 @@ DCPContent::can_reference_audio (string& why_not) const } /// TRANSLATORS: this string will follow "Cannot reference this DCP: " - return can_reference (bind (&check_audio, _1), _("it overlaps other audio content; remove the other content."), why_not); + return can_reference (film, bind (&check_audio, _1), _("it overlaps other audio content; remove the other content."), why_not); } static @@ -644,11 +643,11 @@ bool check_text (shared_ptr c) } bool -DCPContent::can_reference_text (TextType type, string& why_not) const +DCPContent::can_reference_text (shared_ptr film, TextType type, string& why_not) const { shared_ptr decoder; try { - decoder.reset (new DCPDecoder (shared_from_this(), film()->log(), false)); + decoder.reset (new DCPDecoder (shared_from_this(), false)); } catch (dcp::DCPReadError) { /* We couldn't read the DCP, so it's probably missing */ return false; @@ -671,7 +670,7 @@ DCPContent::can_reference_text (TextType type, string& why_not) const } /// TRANSLATORS: this string will follow "Cannot reference this DCP: " - return can_reference (bind (&check_text, _1), _("it overlaps other text content; remove the other content."), why_not); + return can_reference (film, bind (&check_text, _1), _("it overlaps other text content; remove the other content."), why_not); } void diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index 2a3ef46e8..874e1ee31 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -50,8 +50,8 @@ class ContentPart; class DCPContent : public Content { public: - DCPContent (boost::shared_ptr, boost::filesystem::path p); - DCPContent (boost::shared_ptr, cxml::ConstNodePtr, int version); + DCPContent (boost::filesystem::path p); + DCPContent (cxml::ConstNodePtr, int version); boost::shared_ptr shared_from_this () { return boost::dynamic_pointer_cast (Content::shared_from_this ()); @@ -61,9 +61,9 @@ public: return boost::dynamic_pointer_cast (Content::shared_from_this ()); } - DCPTime full_length () const; + DCPTime full_length (boost::shared_ptr film) const; - void examine (boost::shared_ptr); + void examine (boost::shared_ptr film, boost::shared_ptr); std::string summary () const; std::string technical_summary () const; void as_xml (xmlpp::Node *, bool with_paths) const; @@ -71,7 +71,7 @@ public: void take_settings_from (boost::shared_ptr c); void set_default_colour_conversion (); - std::list reel_split_points () const; + std::list reel_split_points (boost::shared_ptr film) const; std::vector directories () const; @@ -98,7 +98,7 @@ public: return _reference_video; } - bool can_reference_video (std::string &) const; + bool can_reference_video (boost::shared_ptr film, std::string &) const; void set_reference_audio (bool r); @@ -107,7 +107,7 @@ public: return _reference_audio; } - bool can_reference_audio (std::string &) const; + bool can_reference_audio (boost::shared_ptr film, std::string &) const; void set_reference_text (TextType type, bool r); @@ -119,7 +119,7 @@ public: return _reference_text[type]; } - bool can_reference_text (TextType type, std::string &) const; + bool can_reference_text (boost::shared_ptr film, TextType type, std::string &) const; void set_cpl (std::string id); @@ -148,11 +148,12 @@ public: private: friend class reels_test5; - void add_properties (std::list& p) const; + void add_properties (boost::shared_ptr film, std::list& p) const; void read_directory (boost::filesystem::path); - std::list reels () const; + std::list reels (boost::shared_ptr film) const; bool can_reference ( + boost::shared_ptr film, boost::function )>, std::string overlapping, std::string& why_not diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 71a7e42d0..a67b244f7 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -55,19 +55,19 @@ using boost::shared_ptr; using boost::dynamic_pointer_cast; using boost::optional; -DCPDecoder::DCPDecoder (shared_ptr c, shared_ptr log, bool fast) +DCPDecoder::DCPDecoder (shared_ptr c, bool fast) : DCP (c) , _decode_referenced (false) { if (c->video) { - video.reset (new VideoDecoder (this, c, log)); + video.reset (new VideoDecoder (this, c)); } if (c->audio) { - audio.reset (new AudioDecoder (this, c->audio, log, fast)); + audio.reset (new AudioDecoder (this, c->audio, fast)); } BOOST_FOREACH (shared_ptr i, c->text) { /* XXX: this time here should be the time of the first subtitle, not 0 */ - text.push_back (shared_ptr (new TextDecoder (this, i, log, ContentTime()))); + text.push_back (shared_ptr (new TextDecoder (this, i, ContentTime()))); } list > cpl_list = cpls (); @@ -101,13 +101,13 @@ DCPDecoder::DCPDecoder (shared_ptr c, shared_ptr log, boo bool -DCPDecoder::pass () +DCPDecoder::pass (shared_ptr film) { if (_reel == _reels.end () || !_dcp_content->can_be_played ()) { return true; } - double const vfr = _dcp_content->active_video_frame_rate (); + double const vfr = _dcp_content->active_video_frame_rate (film); /* Frame within the (played part of the) reel that is coming up next */ int64_t const frame = _next.frames_round (vfr); @@ -118,12 +118,13 @@ DCPDecoder::pass () /* We must emit texts first as when we emit the video for this frame it will expect already to have the texts. */ - pass_texts (_next, picture_asset->size()); + pass_texts (film, _next, picture_asset->size()); if ((_mono_reader || _stereo_reader) && (_decode_referenced || !_dcp_content->reference_video())) { int64_t const entry_point = (*_reel)->main_picture()->entry_point (); if (_mono_reader) { video->emit ( + film, shared_ptr ( new J2KImageProxy ( _mono_reader->get_frame (entry_point + frame), @@ -136,6 +137,7 @@ DCPDecoder::pass () ); } else { video->emit ( + film, shared_ptr ( new J2KImageProxy ( _stereo_reader->get_frame (entry_point + frame), @@ -149,6 +151,7 @@ DCPDecoder::pass () ); video->emit ( + film, shared_ptr ( new J2KImageProxy ( _stereo_reader->get_frame (entry_point + frame), @@ -179,7 +182,7 @@ DCPDecoder::pass () } } - audio->emit (_dcp_content->audio->stream(), data, ContentTime::from_frames (_offset, vfr) + _next); + audio->emit (film, _dcp_content->audio->stream(), data, ContentTime::from_frames (_offset, vfr) + _next); } _next += ContentTime::from_frames (1, vfr); @@ -195,29 +198,37 @@ DCPDecoder::pass () } void -DCPDecoder::pass_texts (ContentTime next, dcp::Size size) +DCPDecoder::pass_texts (shared_ptr film, ContentTime next, dcp::Size size) { list >::const_iterator decoder = text.begin (); if ((*_reel)->main_subtitle()) { DCPOMATIC_ASSERT (decoder != text.end ()); pass_texts ( - next, (*_reel)->main_subtitle()->asset(), _dcp_content->reference_text(TEXT_OPEN_SUBTITLE), (*_reel)->main_subtitle()->entry_point(), *decoder, size + film, + next, + (*_reel)->main_subtitle()->asset(), + _dcp_content->reference_text(TEXT_OPEN_SUBTITLE), + (*_reel)->main_subtitle()->entry_point(), + *decoder, + size ); ++decoder; } BOOST_FOREACH (shared_ptr i, (*_reel)->closed_captions()) { DCPOMATIC_ASSERT (decoder != text.end ()); pass_texts ( - next, i->asset(), _dcp_content->reference_text(TEXT_CLOSED_CAPTION), i->entry_point(), *decoder, size + film, next, i->asset(), _dcp_content->reference_text(TEXT_CLOSED_CAPTION), i->entry_point(), *decoder, size ); ++decoder; } } void -DCPDecoder::pass_texts (ContentTime next, shared_ptr asset, bool reference, int64_t entry_point, shared_ptr decoder, dcp::Size size) +DCPDecoder::pass_texts ( + shared_ptr film, ContentTime next, shared_ptr asset, bool reference, int64_t entry_point, shared_ptr decoder, dcp::Size size + ) { - double const vfr = _dcp_content->active_video_frame_rate (); + double const vfr = _dcp_content->active_video_frame_rate (film); /* Frame within the (played part of the) reel that is coming up next */ int64_t const frame = next.frames_round (vfr); @@ -348,13 +359,13 @@ DCPDecoder::get_readers () } void -DCPDecoder::seek (ContentTime t, bool accurate) +DCPDecoder::seek (shared_ptr film, ContentTime t, bool accurate) { if (!_dcp_content->can_be_played ()) { return; } - Decoder::seek (t, accurate); + Decoder::seek (film, t, accurate); _reel = _reels.begin (); _offset = 0; @@ -371,8 +382,8 @@ DCPDecoder::seek (ContentTime t, bool accurate) /* Seek to pre-roll position */ - while (_reel != _reels.end() && pre >= ContentTime::from_frames ((*_reel)->main_picture()->duration(), _dcp_content->active_video_frame_rate ())) { - ContentTime rd = ContentTime::from_frames ((*_reel)->main_picture()->duration(), _dcp_content->active_video_frame_rate ()); + while (_reel != _reels.end() && pre >= ContentTime::from_frames ((*_reel)->main_picture()->duration(), _dcp_content->active_video_frame_rate(film))) { + ContentTime rd = ContentTime::from_frames ((*_reel)->main_picture()->duration(), _dcp_content->active_video_frame_rate(film)); pre -= rd; t -= rd; next_reel (); @@ -380,16 +391,16 @@ DCPDecoder::seek (ContentTime t, bool accurate) /* Pass texts in the pre-roll */ - double const vfr = _dcp_content->active_video_frame_rate (); + double const vfr = _dcp_content->active_video_frame_rate (film); for (int i = 0; i < pre_roll_seconds * vfr; ++i) { - pass_texts (pre, (*_reel)->main_picture()->asset()->size()); + pass_texts (film, pre, (*_reel)->main_picture()->asset()->size()); pre += ContentTime::from_frames (1, vfr); } /* Seek to correct position */ - while (_reel != _reels.end() && t >= ContentTime::from_frames ((*_reel)->main_picture()->duration(), _dcp_content->active_video_frame_rate ())) { - t -= ContentTime::from_frames ((*_reel)->main_picture()->duration(), _dcp_content->active_video_frame_rate ()); + while (_reel != _reels.end() && t >= ContentTime::from_frames ((*_reel)->main_picture()->duration(), _dcp_content->active_video_frame_rate(film))) { + t -= ContentTime::from_frames ((*_reel)->main_picture()->duration(), _dcp_content->active_video_frame_rate(film)); next_reel (); } diff --git a/src/lib/dcp_decoder.h b/src/lib/dcp_decoder.h index 8281babc3..d3c5c57ed 100644 --- a/src/lib/dcp_decoder.h +++ b/src/lib/dcp_decoder.h @@ -40,7 +40,7 @@ struct dcp_subtitle_within_dcp_test; class DCPDecoder : public DCP, public Decoder { public: - DCPDecoder (boost::shared_ptr, boost::shared_ptr log, bool fast); + DCPDecoder (boost::shared_ptr, bool fast); std::list > reels () const { return _reels; @@ -49,17 +49,23 @@ public: void set_decode_referenced (bool r); void set_forced_reduction (boost::optional reduction); - bool pass (); - void seek (ContentTime t, bool accurate); + bool pass (boost::shared_ptr film); + void seek (boost::shared_ptr film, ContentTime t, bool accurate); private: friend struct dcp_subtitle_within_dcp_test; void next_reel (); void get_readers (); - void pass_texts (ContentTime next, dcp::Size size); + void pass_texts (boost::shared_ptr film, ContentTime next, dcp::Size size); void pass_texts ( - ContentTime next, boost::shared_ptr asset, bool reference, int64_t entry_point, boost::shared_ptr decoder, dcp::Size size + boost::shared_ptr film, + ContentTime next, + boost::shared_ptr asset, + bool reference, + int64_t entry_point, + boost::shared_ptr decoder, + dcp::Size size ); /** Time of next thing to return from pass relative to the start of _reel */ diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc index a8e98d426..21a50c199 100644 --- a/src/lib/dcp_subtitle_content.cc +++ b/src/lib/dcp_subtitle_content.cc @@ -37,23 +37,23 @@ using boost::shared_ptr; using boost::dynamic_pointer_cast; using dcp::raw_convert; -DCPSubtitleContent::DCPSubtitleContent (shared_ptr film, boost::filesystem::path path) - : Content (film, path) +DCPSubtitleContent::DCPSubtitleContent (boost::filesystem::path path) + : Content (path) { text.push_back (shared_ptr (new TextContent (this, TEXT_OPEN_SUBTITLE, TEXT_OPEN_SUBTITLE))); } -DCPSubtitleContent::DCPSubtitleContent (shared_ptr film, cxml::ConstNodePtr node, int version) - : Content (film, node) +DCPSubtitleContent::DCPSubtitleContent (cxml::ConstNodePtr node, int version) + : Content (node) , _length (node->number_child ("Length")) { text = TextContent::from_xml (this, node, version); } void -DCPSubtitleContent::examine (shared_ptr job) +DCPSubtitleContent::examine (shared_ptr film, shared_ptr job) { - Content::examine (job); + Content::examine (film, job); shared_ptr sc = load (path (0)); @@ -82,9 +82,9 @@ DCPSubtitleContent::examine (shared_ptr job) } DCPTime -DCPSubtitleContent::full_length () const +DCPSubtitleContent::full_length (shared_ptr film) const { - FrameRateChange const frc (active_video_frame_rate(), film()->video_frame_rate()); + FrameRateChange const frc (active_video_frame_rate(film), film->video_frame_rate()); return DCPTime (_length, frc); } diff --git a/src/lib/dcp_subtitle_content.h b/src/lib/dcp_subtitle_content.h index 36945adcd..5eaad0d2f 100644 --- a/src/lib/dcp_subtitle_content.h +++ b/src/lib/dcp_subtitle_content.h @@ -24,14 +24,14 @@ class DCPSubtitleContent : public DCPSubtitle, public Content { public: - DCPSubtitleContent (boost::shared_ptr, boost::filesystem::path); - DCPSubtitleContent (boost::shared_ptr, cxml::ConstNodePtr, int); + DCPSubtitleContent (boost::filesystem::path); + DCPSubtitleContent (cxml::ConstNodePtr, int); - void examine (boost::shared_ptr); + void examine (boost::shared_ptr film, boost::shared_ptr); std::string summary () const; std::string technical_summary () const; void as_xml (xmlpp::Node *, bool with_paths) const; - DCPTime full_length () const; + DCPTime full_length (boost::shared_ptr film) const; private: ContentTime _length; diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_subtitle_decoder.cc index 9c803a3b6..07e879ddf 100644 --- a/src/lib/dcp_subtitle_decoder.cc +++ b/src/lib/dcp_subtitle_decoder.cc @@ -29,7 +29,7 @@ using boost::shared_ptr; using boost::dynamic_pointer_cast; using boost::bind; -DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr content, shared_ptr log) +DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr content) { shared_ptr c (load (content->path (0))); _subtitles = c->subtitles (); @@ -39,13 +39,13 @@ DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr con if (_next != _subtitles.end()) { first = content_time_period(*_next).from; } - text.push_back (shared_ptr (new TextDecoder (this, content->only_text(), log, first))); + text.push_back (shared_ptr (new TextDecoder (this, content->only_text(), first))); } void -DCPSubtitleDecoder::seek (ContentTime time, bool accurate) +DCPSubtitleDecoder::seek (shared_ptr film, ContentTime time, bool accurate) { - Decoder::seek (time, accurate); + Decoder::seek (film, time, accurate); _next = _subtitles.begin (); list >::const_iterator i = _subtitles.begin (); @@ -55,7 +55,7 @@ DCPSubtitleDecoder::seek (ContentTime time, bool accurate) } bool -DCPSubtitleDecoder::pass () +DCPSubtitleDecoder::pass (shared_ptr) { if (_next == _subtitles.end ()) { return true; diff --git a/src/lib/dcp_subtitle_decoder.h b/src/lib/dcp_subtitle_decoder.h index 984d98826..7e832241e 100644 --- a/src/lib/dcp_subtitle_decoder.h +++ b/src/lib/dcp_subtitle_decoder.h @@ -26,10 +26,10 @@ class DCPSubtitleContent; class DCPSubtitleDecoder : public DCPSubtitle, public Decoder { public: - DCPSubtitleDecoder (boost::shared_ptr, boost::shared_ptr log); + DCPSubtitleDecoder (boost::shared_ptr); - bool pass (); - void seek (ContentTime time, bool accurate); + bool pass (boost::shared_ptr film); + void seek (boost::shared_ptr film, ContentTime time, bool accurate); private: ContentTimePeriod content_time_period (boost::shared_ptr s) const; diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 6078141dc..fb7663f5c 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -31,21 +31,21 @@ using boost::shared_ptr; /** @return Earliest time of content that the next pass() will emit */ ContentTime -Decoder::position () const +Decoder::position (shared_ptr film) const { optional pos; - if (video && !video->ignore() && (!pos || video->position() < *pos)) { - pos = video->position(); + if (video && !video->ignore() && (!pos || video->position(film) < *pos)) { + pos = video->position(film); } - if (audio && !audio->ignore() && (!pos || audio->position() < *pos)) { - pos = audio->position(); + if (audio && !audio->ignore() && (!pos || audio->position(film) < *pos)) { + pos = audio->position(film); } BOOST_FOREACH (shared_ptr i, text) { - if (!i->ignore() && (!pos || i->position() < *pos)) { - pos = i->position(); + if (!i->ignore() && (!pos || i->position(film) < *pos)) { + pos = i->position(film); } } @@ -53,7 +53,7 @@ Decoder::position () const } void -Decoder::seek (ContentTime, bool) +Decoder::seek (shared_ptr, ContentTime, bool) { if (video) { video->seek (); diff --git a/src/lib/decoder.h b/src/lib/decoder.h index 55d9cfc64..a8a67ee72 100644 --- a/src/lib/decoder.h +++ b/src/lib/decoder.h @@ -34,6 +34,7 @@ class VideoDecoder; class AudioDecoder; class TextDecoder; class DecoderPart; +class Film; /** @class Decoder. * @brief Parent class for decoders of content. @@ -52,10 +53,10 @@ public: /** Do some decoding and perhaps emit video, audio or subtitle data. * @return true if this decoder will emit no more data unless a seek() happens. */ - virtual bool pass () = 0; - virtual void seek (ContentTime time, bool accurate); + virtual bool pass (boost::shared_ptr film) = 0; + virtual void seek (boost::shared_ptr film, ContentTime time, bool accurate); - ContentTime position () const; + ContentTime position (boost::shared_ptr film) const; }; #endif diff --git a/src/lib/decoder_factory.cc b/src/lib/decoder_factory.cc index df23ef6f6..b3e16a3f0 100644 --- a/src/lib/decoder_factory.cc +++ b/src/lib/decoder_factory.cc @@ -37,17 +37,17 @@ using boost::shared_ptr; using boost::dynamic_pointer_cast; shared_ptr -decoder_factory (shared_ptr content, shared_ptr log, bool fast) +decoder_factory (shared_ptr film, shared_ptr content, bool fast) { shared_ptr fc = dynamic_pointer_cast (content); if (fc) { - return shared_ptr (new FFmpegDecoder (fc, log, fast)); + return shared_ptr (new FFmpegDecoder(film, fc, fast)); } shared_ptr dc = dynamic_pointer_cast (content); if (dc) { try { - return shared_ptr (new DCPDecoder (dc, log, fast)); + return shared_ptr (new DCPDecoder(dc, fast)); } catch (KDMError& e) { /* This will be found and reported to the user when the content is examined */ return shared_ptr(); @@ -56,22 +56,22 @@ decoder_factory (shared_ptr content, shared_ptr log, bool fa shared_ptr ic = dynamic_pointer_cast (content); if (ic) { - return shared_ptr (new ImageDecoder (ic, log)); + return shared_ptr (new ImageDecoder(ic)); } shared_ptr rc = dynamic_pointer_cast (content); if (rc) { - return shared_ptr (new StringTextFileDecoder (rc, log)); + return shared_ptr (new StringTextFileDecoder(rc)); } shared_ptr dsc = dynamic_pointer_cast (content); if (dsc) { - return shared_ptr (new DCPSubtitleDecoder (dsc, log)); + return shared_ptr (new DCPSubtitleDecoder(dsc)); } shared_ptr vmc = dynamic_pointer_cast (content); if (vmc) { - return shared_ptr (new VideoMXFDecoder (vmc, log)); + return shared_ptr (new VideoMXFDecoder(vmc)); } return shared_ptr (); diff --git a/src/lib/decoder_factory.h b/src/lib/decoder_factory.h index 52a53afd2..d4e39da17 100644 --- a/src/lib/decoder_factory.h +++ b/src/lib/decoder_factory.h @@ -21,7 +21,7 @@ class ImageDecoder; extern boost::shared_ptr decoder_factory ( + boost::shared_ptr film, boost::shared_ptr content, - boost::shared_ptr log, bool fast ); diff --git a/src/lib/decoder_part.cc b/src/lib/decoder_part.cc index d8f988388..3e06204de 100644 --- a/src/lib/decoder_part.cc +++ b/src/lib/decoder_part.cc @@ -23,9 +23,8 @@ using boost::shared_ptr; -DecoderPart::DecoderPart (Decoder* parent, shared_ptr log) +DecoderPart::DecoderPart (Decoder* parent) : _parent (parent) - , _log (log) , _ignore (false) { diff --git a/src/lib/decoder_part.h b/src/lib/decoder_part.h index 0b8b6a43b..7ba2cb2eb 100644 --- a/src/lib/decoder_part.h +++ b/src/lib/decoder_part.h @@ -26,14 +26,15 @@ class Decoder; class Log; +class Film; class DecoderPart { public: - DecoderPart (Decoder* parent, boost::shared_ptr log); + DecoderPart (Decoder* parent); virtual ~DecoderPart () {} - virtual ContentTime position () const = 0; + virtual ContentTime position (boost::shared_ptr film) const = 0; virtual void seek () = 0; void set_ignore (bool i) { @@ -46,7 +47,6 @@ public: protected: Decoder* _parent; - boost::shared_ptr _log; private: bool _ignore; diff --git a/src/lib/empty.cc b/src/lib/empty.cc index 1e6e1c3fb..1df318b25 100644 --- a/src/lib/empty.cc +++ b/src/lib/empty.cc @@ -35,16 +35,16 @@ using boost::shared_ptr; using boost::dynamic_pointer_cast; using boost::function; -Empty::Empty (list > pieces, DCPTime length, function)> part) +Empty::Empty (shared_ptr film, list > pieces, function)> part) { list full; BOOST_FOREACH (shared_ptr i, pieces) { if (part(i)) { - full.push_back (DCPTimePeriod (i->content->position(), i->content->end())); + full.push_back (DCPTimePeriod (i->content->position(), i->content->end(film))); } } - _periods = subtract (DCPTimePeriod(DCPTime(), length), coalesce(full)); + _periods = subtract (DCPTimePeriod(DCPTime(), film->length()), coalesce(full)); if (!_periods.empty ()) { _position = _periods.front().from; diff --git a/src/lib/empty.h b/src/lib/empty.h index 73548f729..50f21fc4d 100644 --- a/src/lib/empty.h +++ b/src/lib/empty.h @@ -35,7 +35,7 @@ class Empty { public: Empty () {} - Empty (std::list > pieces, DCPTime length, boost::function)> part); + Empty (boost::shared_ptr film, std::list > pieces, boost::function)> part); DCPTime position () const { return _position; diff --git a/src/lib/examine_content_job.cc b/src/lib/examine_content_job.cc index a9df63be7..81088a441 100644 --- a/src/lib/examine_content_job.cc +++ b/src/lib/examine_content_job.cc @@ -53,7 +53,7 @@ ExamineContentJob::json_name () const void ExamineContentJob::run () { - _content->examine (shared_from_this ()); + _content->examine (_film, shared_from_this()); set_progress (1); set_state (FINISHED_OK); } diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 1502b3de9..3bd08e84a 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -113,7 +113,6 @@ FFmpeg::setup_general () /* This might not work too well in some cases of multiple FFmpeg decoders, but it's probably good enough. */ - _ffmpeg_log = _ffmpeg_content->film()->log (); av_log_set_callback (FFmpeg::ffmpeg_log_callback); _file_group.set_paths (_ffmpeg_content->paths ()); @@ -219,10 +218,7 @@ FFmpeg::setup_decoders () throw DecodeError (N_("could not open decoder")); } } else { - shared_ptr log = _ffmpeg_log.lock (); - if (log) { - log->log (String::compose ("No codec found for stream %1", i), LogEntry::TYPE_WARNING); - } + dcpomatic_log->log (String::compose ("No codec found for stream %1", i), LogEntry::TYPE_WARNING); } } } diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index c7a15619d..2b494dc92 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -45,7 +45,7 @@ extern "C" { #include "i18n.h" -#define LOG_GENERAL(...) film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); +#define LOG_GENERAL(...) dcpomatic_log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); using std::string; using std::vector; @@ -63,8 +63,8 @@ int const FFmpegContentProperty::SUBTITLE_STREAMS = 100; int const FFmpegContentProperty::SUBTITLE_STREAM = 101; int const FFmpegContentProperty::FILTERS = 102; -FFmpegContent::FFmpegContent (shared_ptr film, boost::filesystem::path p) - : Content (film, p) +FFmpegContent::FFmpegContent (boost::filesystem::path p) + : Content (p) , _encrypted (false) { @@ -81,8 +81,8 @@ get_optional_enum (cxml::ConstNodePtr node, string name) return static_cast(*v); } -FFmpegContent::FFmpegContent (shared_ptr film, cxml::ConstNodePtr node, int version, list& notes) - : Content (film, node) +FFmpegContent::FFmpegContent (cxml::ConstNodePtr node, int version, list& notes) + : Content (node) { video = VideoContent::from_xml (this, node, version); audio = AudioContent::from_xml (this, node, version); @@ -130,8 +130,8 @@ FFmpegContent::FFmpegContent (shared_ptr film, cxml::ConstNodePtr no _encrypted = node->optional_bool_child("Encrypted").get_value_or(false); } -FFmpegContent::FFmpegContent (shared_ptr film, vector > c) - : Content (film, c) +FFmpegContent::FFmpegContent (vector > c) + : Content (c) { vector >::const_iterator i = c.begin (); @@ -258,14 +258,14 @@ FFmpegContent::as_xml (xmlpp::Node* node, bool with_paths) const } void -FFmpegContent::examine (shared_ptr job) +FFmpegContent::examine (shared_ptr film, shared_ptr job) { ChangeSignaller cc1 (this, FFmpegContentProperty::SUBTITLE_STREAMS); ChangeSignaller cc2 (this, FFmpegContentProperty::SUBTITLE_STREAM); job->set_progress_unknown (); - Content::examine (job); + Content::examine (film, job); shared_ptr examiner (new FFmpegExaminer (shared_from_this (), job)); @@ -309,7 +309,7 @@ FFmpegContent::examine (shared_ptr job) AudioStreamPtr as = audio->streams().front(); AudioMapping m = as->mapping (); - film()->make_audio_mapping_default (m, first_path); + film->make_audio_mapping_default (m, first_path); as->set_mapping (m); } @@ -400,11 +400,11 @@ operator!= (FFmpegStream const & a, FFmpegStream const & b) } DCPTime -FFmpegContent::full_length () const +FFmpegContent::full_length (shared_ptr film) const { - FrameRateChange const frc (active_video_frame_rate (), film()->video_frame_rate ()); + FrameRateChange const frc (active_video_frame_rate(film), film->video_frame_rate()); if (video) { - return DCPTime::from_frames (llrint (video->length_after_3d_combine() * frc.factor()), film()->video_frame_rate()); + return DCPTime::from_frames (llrint (video->length_after_3d_combine() * frc.factor()), film->video_frame_rate()); } DCPOMATIC_ASSERT (audio); @@ -490,7 +490,7 @@ FFmpegContent::set_default_colour_conversion () } void -FFmpegContent::add_properties (list& p) const +FFmpegContent::add_properties (shared_ptr film, list& p) const { Content::add_properties (p); @@ -627,7 +627,7 @@ FFmpegContent::add_properties (list& p) const } if (audio) { - audio->add_properties (p); + audio->add_properties (film, p); } } diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index d2e164f1d..8bd5ef4fa 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -46,20 +46,20 @@ public: class FFmpegContent : public Content { public: - FFmpegContent (boost::shared_ptr, boost::filesystem::path); - FFmpegContent (boost::shared_ptr, cxml::ConstNodePtr, int version, std::list &); - FFmpegContent (boost::shared_ptr, std::vector >); + FFmpegContent (boost::filesystem::path); + FFmpegContent (cxml::ConstNodePtr, int version, std::list &); + FFmpegContent (std::vector >); boost::shared_ptr shared_from_this () { return boost::dynamic_pointer_cast (Content::shared_from_this ()); } - void examine (boost::shared_ptr); + void examine (boost::shared_ptr film, boost::shared_ptr); void take_settings_from (boost::shared_ptr c); std::string summary () const; std::string technical_summary () const; void as_xml (xmlpp::Node *, bool with_paths) const; - DCPTime full_length () const; + DCPTime full_length (boost::shared_ptr film) const; std::string identifier () const; @@ -104,7 +104,7 @@ public: } private: - void add_properties (std::list &) const; + void add_properties (boost::shared_ptr film, std::list &) const; friend struct ffmpeg_pts_offset_test; friend struct audio_sampling_rate_test; diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 9076464ac..0e40f128b 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -58,10 +58,10 @@ extern "C" { #include "i18n.h" -#define LOG_GENERAL(...) _log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); -#define LOG_ERROR(...) _log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_ERROR); -#define LOG_WARNING_NC(...) _log->log (__VA_ARGS__, LogEntry::TYPE_WARNING); -#define LOG_WARNING(...) _log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_WARNING); +#define LOG_GENERAL(...) dcpomatic_log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); +#define LOG_ERROR(...) dcpomatic_log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_ERROR); +#define LOG_WARNING_NC(...) dcpomatic_log->log (__VA_ARGS__, LogEntry::TYPE_WARNING); +#define LOG_WARNING(...) dcpomatic_log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_WARNING); using std::cout; using std::string; @@ -78,14 +78,13 @@ using boost::optional; using boost::dynamic_pointer_cast; using dcp::Size; -FFmpegDecoder::FFmpegDecoder (shared_ptr c, shared_ptr log, bool fast) +FFmpegDecoder::FFmpegDecoder (shared_ptr film, shared_ptr c, bool fast) : FFmpeg (c) - , _log (log) , _have_current_subtitle (false) { if (c->video) { - video.reset (new VideoDecoder (this, c, log)); - _pts_offset = pts_offset (c->ffmpeg_audio_streams(), c->first_video(), c->active_video_frame_rate()); + video.reset (new VideoDecoder (this, c)); + _pts_offset = pts_offset (c->ffmpeg_audio_streams(), c->first_video(), c->active_video_frame_rate(film)); /* It doesn't matter what size or pixel format this is, it just needs to be black */ _black_image.reset (new Image (AV_PIX_FMT_RGB24, dcp::Size (128, 128), true)); _black_image->make_black (); @@ -94,19 +93,19 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr c, shared_ptr } if (c->audio) { - audio.reset (new AudioDecoder (this, c->audio, log, fast)); + audio.reset (new AudioDecoder (this, c->audio, fast)); } if (c->only_text()) { /* XXX: this time here should be the time of the first subtitle, not 0 */ - text.push_back (shared_ptr (new TextDecoder (this, c->only_text(), log, ContentTime()))); + text.push_back (shared_ptr (new TextDecoder (this, c->only_text(), ContentTime()))); } _next_time.resize (_format_context->nb_streams); } void -FFmpegDecoder::flush () +FFmpegDecoder::flush (shared_ptr film) { /* Get any remaining frames */ @@ -115,29 +114,29 @@ FFmpegDecoder::flush () /* XXX: should we reset _packet.data and size after each *_decode_* call? */ - while (video && decode_video_packet ()) {} + while (video && decode_video_packet(film)) {} if (audio) { - decode_audio_packet (); + decode_audio_packet (film); } /* Make sure all streams are the same length and round up to the next video frame */ - FrameRateChange const frc = _ffmpeg_content->film()->active_frame_rate_change(_ffmpeg_content->position()); - ContentTime full_length (_ffmpeg_content->full_length(), frc); + FrameRateChange const frc = film->active_frame_rate_change(_ffmpeg_content->position()); + ContentTime full_length (_ffmpeg_content->full_length(film), frc); full_length = full_length.ceil (frc.source); if (video) { double const vfr = _ffmpeg_content->video_frame_rate().get(); Frame const f = full_length.frames_round (vfr); - Frame v = video->position().frames_round (vfr) + 1; + Frame v = video->position(film).frames_round (vfr) + 1; while (v < f) { - video->emit (shared_ptr (new RawImageProxy (_black_image)), v); + video->emit (film, shared_ptr (new RawImageProxy (_black_image)), v); ++v; } } BOOST_FOREACH (shared_ptr i, _ffmpeg_content->ffmpeg_audio_streams ()) { - ContentTime a = audio->stream_position(i); + ContentTime a = audio->stream_position(film, i); /* Unfortunately if a is 0 that really means that we don't know the stream position since there has been no data on it since the last seek. In this case we'll just do nothing here. I'm not sure if that's the right idea. @@ -147,7 +146,7 @@ FFmpegDecoder::flush () ContentTime to_do = min (full_length - a, ContentTime::from_seconds (0.1)); shared_ptr silence (new AudioBuffers (i->channels(), to_do.frames_ceil (i->frame_rate()))); silence->make_silent (); - audio->emit (i, silence, a); + audio->emit (film, i, silence, a); a += to_do; } } @@ -159,7 +158,7 @@ FFmpegDecoder::flush () } bool -FFmpegDecoder::pass () +FFmpegDecoder::pass (shared_ptr film) { int r = av_read_frame (_format_context, &_packet); @@ -175,7 +174,7 @@ FFmpegDecoder::pass () LOG_ERROR (N_("error on av_read_frame (%1) (%2)"), &buf[0], r); } - flush (); + flush (film); return true; } @@ -183,11 +182,11 @@ FFmpegDecoder::pass () shared_ptr fc = _ffmpeg_content; if (_video_stream && si == _video_stream.get() && !video->ignore()) { - decode_video_packet (); + decode_video_packet (film); } else if (fc->subtitle_stream() && fc->subtitle_stream()->uses_index(_format_context, si) && !only_text()->ignore()) { decode_subtitle_packet (); } else { - decode_audio_packet (); + decode_audio_packet (film); } av_packet_unref (&_packet); @@ -341,9 +340,9 @@ FFmpegDecoder::bytes_per_audio_sample (shared_ptr stream) con } void -FFmpegDecoder::seek (ContentTime time, bool accurate) +FFmpegDecoder::seek (shared_ptr film, ContentTime time, bool accurate) { - Decoder::seek (time, accurate); + Decoder::seek (film, time, accurate); /* If we are doing an `accurate' seek, we need to use pre-roll, as we don't really know what the seek will give us. @@ -396,7 +395,7 @@ FFmpegDecoder::seek (ContentTime time, bool accurate) } void -FFmpegDecoder::decode_audio_packet () +FFmpegDecoder::decode_audio_packet (shared_ptr film) { /* Audio packets can contain multiple frames, so we may have to call avcodec_decode_audio4 several times. @@ -479,7 +478,7 @@ FFmpegDecoder::decode_audio_packet () /* Give this data provided there is some, and its time is sane */ if (ct >= ContentTime() && data->frames() > 0) { - audio->emit (*stream, data, ct); + audio->emit (film, *stream, data, ct); } } @@ -489,7 +488,7 @@ FFmpegDecoder::decode_audio_packet () } bool -FFmpegDecoder::decode_video_packet () +FFmpegDecoder::decode_video_packet (shared_ptr film) { DCPOMATIC_ASSERT (_video_stream); @@ -527,8 +526,9 @@ FFmpegDecoder::decode_video_packet () double const pts = i->second * av_q2d (_format_context->streams[_video_stream.get()]->time_base) + _pts_offset.seconds (); video->emit ( + film, shared_ptr (new RawImageProxy (image)), - llrint(pts * _ffmpeg_content->active_video_frame_rate()) + llrint(pts * _ffmpeg_content->active_video_frame_rate(film)) ); } else { LOG_WARNING_NC ("Dropping frame without PTS"); diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index 16a55d558..408ce30a7 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -45,21 +45,21 @@ struct ffmpeg_pts_offset_test; class FFmpegDecoder : public FFmpeg, public Decoder { public: - FFmpegDecoder (boost::shared_ptr, boost::shared_ptr log, bool fast); + FFmpegDecoder (boost::shared_ptr film, boost::shared_ptr, bool fast); - bool pass (); - void seek (ContentTime time, bool); + bool pass (boost::shared_ptr film); + void seek (boost::shared_ptr film, ContentTime time, bool); private: friend struct ::ffmpeg_pts_offset_test; - void flush (); + void flush (boost::shared_ptr film); AVSampleFormat audio_sample_format (boost::shared_ptr stream) const; int bytes_per_audio_sample (boost::shared_ptr stream) const; - bool decode_video_packet (); - void decode_audio_packet (); + bool decode_video_packet (boost::shared_ptr film); + void decode_audio_packet (boost::shared_ptr film); void decode_subtitle_packet (); void decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTime from); @@ -68,8 +68,6 @@ private: void maybe_add_subtitle (); boost::shared_ptr deinterleave_audio (boost::shared_ptr stream) const; - boost::shared_ptr _log; - std::list > _filter_graphs; boost::mutex _filter_graphs_mutex; diff --git a/src/lib/film.cc b/src/lib/film.cc index 426c7f81d..4d6b3d7e3 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -975,7 +975,7 @@ Film::signal_change (ChangeType type, Property p) /* We want to call Playlist::maybe_sequence but this must happen after the main signal emission (since the butler will see that emission and un-suspend itself). */ - emit (boost::bind(&Playlist::maybe_sequence, _playlist.get())); + emit (boost::bind(&Playlist::maybe_sequence, _playlist.get(), shared_from_this())); } } else { Change (type, p); @@ -1116,7 +1116,7 @@ Film::maybe_add_content (weak_ptr j, weak_ptr c, bool disable_audi if (Config::instance()->automatic_audio_analysis() && content->audio && !disable_audio_analysis) { shared_ptr playlist (new Playlist); - playlist->add (content); + playlist->add (shared_from_this(), content); boost::signals2::connection c; JobManager::instance()->analyse_audio ( shared_from_this(), playlist, false, c, bind (&Film::audio_analysis_finished, this) @@ -1130,9 +1130,9 @@ Film::add_content (shared_ptr c) { /* Add {video,subtitle} content after any existing {video,subtitle} content */ if (c->video) { - c->set_position (_playlist->video_end()); + c->set_position (shared_from_this(), _playlist->video_end(shared_from_this())); } else if (!c->text.empty()) { - c->set_position (_playlist->text_end()); + c->set_position (shared_from_this(), _playlist->text_end(shared_from_this())); } if (_template_film) { @@ -1142,7 +1142,7 @@ Film::add_content (shared_ptr c) } } - _playlist->add (c); + _playlist->add (shared_from_this(), c); } void @@ -1154,20 +1154,20 @@ Film::remove_content (shared_ptr c) void Film::move_content_earlier (shared_ptr c) { - _playlist->move_earlier (c); + _playlist->move_earlier (shared_from_this(), c); } void Film::move_content_later (shared_ptr c) { - _playlist->move_later (c); + _playlist->move_later (shared_from_this(), c); } /** @return length of the film from time 0 to the last thing on the playlist */ DCPTime Film::length () const { - return _playlist->length().ceil(video_frame_rate()); + return _playlist->length(shared_from_this()).ceil(video_frame_rate()); } int @@ -1379,7 +1379,7 @@ Film::make_kdms ( uint64_t Film::required_disk_space () const { - return _playlist->required_disk_space (j2k_bandwidth(), audio_channels(), audio_frame_rate()); + return _playlist->required_disk_space (shared_from_this(), j2k_bandwidth(), audio_channels(), audio_frame_rate()); } /** This method checks the disk that the Film is on and tries to decide whether or not @@ -1513,7 +1513,7 @@ Film::audio_output_names () const void Film::repeat_content (ContentList c, int n) { - _playlist->repeat (c, n); + _playlist->repeat (shared_from_this(), c, n); } void @@ -1554,7 +1554,7 @@ Film::reels () const } } - DCPTime video_end = last_video ? last_video->end() : DCPTime(0); + DCPTime video_end = last_video ? last_video->end(shared_from_this()) : DCPTime(0); if (last_split) { /* Definitely go from the last split to the end of the video content */ p.push_back (DCPTimePeriod (last_split.get(), video_end)); @@ -1589,7 +1589,7 @@ Film::reels () const string Film::content_summary (DCPTimePeriod period) const { - return _playlist->content_summary (period); + return _playlist->content_summary (shared_from_this(), period); } void diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index 9e0bb09b5..55ffac4f2 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -40,8 +40,7 @@ using std::list; using std::vector; using boost::shared_ptr; -ImageContent::ImageContent (shared_ptr film, boost::filesystem::path p) - : Content (film) +ImageContent::ImageContent (boost::filesystem::path p) { video.reset (new VideoContent (this)); @@ -55,8 +54,8 @@ ImageContent::ImageContent (shared_ptr film, boost::filesystem::path } -ImageContent::ImageContent (shared_ptr film, cxml::ConstNodePtr node, int version) - : Content (film, node) +ImageContent::ImageContent (cxml::ConstNodePtr node, int version) + : Content (node) { video = VideoContent::from_xml (this, node, version); } @@ -102,7 +101,7 @@ ImageContent::as_xml (xmlpp::Node* node, bool with_paths) const } void -ImageContent::examine (shared_ptr job) +ImageContent::examine (shared_ptr film, shared_ptr job) { if (_path_to_scan) { job->sub (_("Scanning image files")); @@ -126,10 +125,7 @@ ImageContent::examine (shared_ptr job) set_paths (paths); } - Content::examine (job); - - shared_ptr film = _film.lock (); - DCPOMATIC_ASSERT (film); + Content::examine (film, job); shared_ptr examiner (new ImageExaminer (film, shared_from_this(), job)); video->take_from_examiner (examiner); @@ -137,12 +133,10 @@ ImageContent::examine (shared_ptr job) } DCPTime -ImageContent::full_length () const +ImageContent::full_length (shared_ptr film) const { - shared_ptr film = _film.lock (); - DCPOMATIC_ASSERT (film); - FrameRateChange const frc (active_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 (active_video_frame_rate(film), film->video_frame_rate()); + return DCPTime::from_frames (llrint(video->length_after_3d_combine() * frc.factor()), film->video_frame_rate()); } string diff --git a/src/lib/image_content.h b/src/lib/image_content.h index eeaf1e2b0..bc0f33151 100644 --- a/src/lib/image_content.h +++ b/src/lib/image_content.h @@ -26,18 +26,18 @@ class ImageContent : public Content { public: - ImageContent (boost::shared_ptr, boost::filesystem::path); - ImageContent (boost::shared_ptr, cxml::ConstNodePtr, int); + ImageContent (boost::filesystem::path); + ImageContent (cxml::ConstNodePtr, int); boost::shared_ptr shared_from_this () { return boost::dynamic_pointer_cast (Content::shared_from_this ()); }; - void examine (boost::shared_ptr); + void examine (boost::shared_ptr film, boost::shared_ptr); std::string summary () const; std::string technical_summary () const; void as_xml (xmlpp::Node *, bool with_paths) const; - DCPTime full_length () const; + DCPTime full_length (boost::shared_ptr film) const; std::string identifier () const; diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index e06f6023d..ce8843b0d 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -36,15 +36,15 @@ using std::cout; using boost::shared_ptr; using dcp::Size; -ImageDecoder::ImageDecoder (shared_ptr c, shared_ptr log) +ImageDecoder::ImageDecoder (shared_ptr c) : _image_content (c) , _frame_video_position (0) { - video.reset (new VideoDecoder (this, c, log)); + video.reset (new VideoDecoder (this, c)); } bool -ImageDecoder::pass () +ImageDecoder::pass (boost::shared_ptr film) { if (_frame_video_position >= _image_content->video->length()) { return true; @@ -71,14 +71,14 @@ ImageDecoder::pass () } } - video->emit (_image, _frame_video_position); + video->emit (film, _image, _frame_video_position); ++_frame_video_position; return false; } void -ImageDecoder::seek (ContentTime time, bool accurate) +ImageDecoder::seek (shared_ptr film, ContentTime time, bool accurate) { - Decoder::seek (time, accurate); - _frame_video_position = time.frames_round (_image_content->active_video_frame_rate ()); + Decoder::seek (film, time, accurate); + _frame_video_position = time.frames_round (_image_content->active_video_frame_rate(film)); } diff --git a/src/lib/image_decoder.h b/src/lib/image_decoder.h index 140032317..25ad9f07f 100644 --- a/src/lib/image_decoder.h +++ b/src/lib/image_decoder.h @@ -27,14 +27,14 @@ class ImageProxy; class ImageDecoder : public Decoder { public: - ImageDecoder (boost::shared_ptr c, boost::shared_ptr log); + ImageDecoder (boost::shared_ptr c); boost::shared_ptr content () { return _image_content; } - bool pass (); - void seek (ContentTime, bool); + bool pass (boost::shared_ptr film); + void seek (boost::shared_ptr film, ContentTime, bool); private: diff --git a/src/lib/log.cc b/src/lib/log.cc index e3ffd1cad..8f7794aed 100644 --- a/src/lib/log.cc +++ b/src/lib/log.cc @@ -35,6 +35,8 @@ using std::string; using std::cout; using boost::shared_ptr; +boost::shared_ptr dcpomatic_log; + Log::Log () : _types (0) { diff --git a/src/lib/log.h b/src/lib/log.h index 65d0229e9..636de6a58 100644 --- a/src/lib/log.h +++ b/src/lib/log.h @@ -66,4 +66,6 @@ private: boost::signals2::scoped_connection _config_connection; }; +extern boost::shared_ptr dcpomatic_log; + #endif diff --git a/src/lib/overlaps.cc b/src/lib/overlaps.cc index 54077d96b..4c75ac0c3 100644 --- a/src/lib/overlaps.cc +++ b/src/lib/overlaps.cc @@ -26,12 +26,12 @@ using boost::shared_ptr; using boost::function; -ContentList overlaps (ContentList cl, function)> part, DCPTime from, DCPTime to) +ContentList overlaps (shared_ptr film, ContentList cl, function)> part, DCPTime from, DCPTime to) { ContentList overlaps; DCPTimePeriod period (from, to); BOOST_FOREACH (shared_ptr i, cl) { - if (part(i) && DCPTimePeriod(i->position(), i->end()).overlap(period)) { + if (part(i) && DCPTimePeriod(i->position(), i->end(film)).overlap(period)) { overlaps.push_back (i); } } diff --git a/src/lib/overlaps.h b/src/lib/overlaps.h index 7dd9802c3..be3edf9d4 100644 --- a/src/lib/overlaps.h +++ b/src/lib/overlaps.h @@ -22,11 +22,12 @@ #include "dcpomatic_time.h" class ContentPart; +class Film; /** @return Pieces of content with a given part (video, audio, * subtitle) that overlap a specified time range in the given * ContentList */ ContentList overlaps ( - ContentList cl, boost::function)> part, DCPTime from, DCPTime to + boost::shared_ptr film, ContentList cl, boost::function)> part, DCPTime from, DCPTime to ); diff --git a/src/lib/player.cc b/src/lib/player.cc index a7440cb4f..283a641d9 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -60,7 +60,7 @@ #include "i18n.h" -#define LOG_GENERAL(...) _film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); +#define LOG_GENERAL(...) dcpomatic_log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); using std::list; using std::cout; @@ -155,8 +155,8 @@ Player::setup_pieces_unlocked () continue; } - shared_ptr decoder = decoder_factory (i, _film->log(), _fast); - FrameRateChange frc (i->active_video_frame_rate(), _film->video_frame_rate()); + shared_ptr decoder = decoder_factory (_film, i, _fast); + FrameRateChange frc (i->active_video_frame_rate(_film), _film->video_frame_rate()); if (!decoder) { /* Not something that we can decode; e.g. Atmos content */ @@ -227,8 +227,8 @@ Player::setup_pieces_unlocked () } } - _black = Empty (_pieces, _film->length(), bind(&have_video, _1)); - _silent = Empty (_pieces, _film->length(), bind(&have_audio, _1)); + _black = Empty (_film, _pieces, bind(&have_video, _1)); + _silent = Empty (_film, _pieces, bind(&have_audio, _1)); _last_video_time = DCPTime (); _last_video_eyes = EYES_BOTH; @@ -343,7 +343,7 @@ Frame Player::dcp_to_content_video (shared_ptr piece, DCPTime t) const { DCPTime s = t - piece->content->position (); - s = min (piece->content->length_after_trim(), s); + s = min (piece->content->length_after_trim(_film), s); s = max (DCPTime(), s + DCPTime (piece->content->trim_start(), piece->frc)); /* It might seem more logical here to convert s to a ContentTime (using the FrameRateChange) @@ -368,7 +368,7 @@ Frame Player::dcp_to_resampled_audio (shared_ptr piece, DCPTime t) const { DCPTime s = t - piece->content->position (); - s = min (piece->content->length_after_trim(), s); + s = min (piece->content->length_after_trim(_film), s); /* See notes in dcp_to_content_video */ return max (DCPTime (), DCPTime (piece->content->trim_start (), piece->frc) + s).frames_floor (_film->audio_frame_rate ()); } @@ -386,7 +386,7 @@ ContentTime Player::dcp_to_content_time (shared_ptr piece, DCPTime t) const { DCPTime s = t - piece->content->position (); - s = min (piece->content->length_after_trim(), s); + s = min (piece->content->length_after_trim(_film), s); return max (ContentTime (), ContentTime (s, piece->frc) + piece->content->trim_start()); } @@ -480,7 +480,7 @@ Player::get_reel_assets () scoped_ptr decoder; try { - decoder.reset (new DCPDecoder (j, _film->log(), false)); + decoder.reset (new DCPDecoder (j, false)); } catch (...) { return a; } @@ -554,7 +554,7 @@ Player::pass () return false; } - if (_playlist->length() == DCPTime()) { + if (_playlist->length(_film) == DCPTime()) { /* Special case of an empty Film; just give one black frame */ emit_video (black_player_video_frame(EYES_BOTH), DCPTime()); return true; @@ -570,8 +570,8 @@ Player::pass () continue; } - DCPTime const t = content_time_to_dcp (i, max(i->decoder->position(), i->content->trim_start())); - if (t > i->content->end()) { + DCPTime const t = content_time_to_dcp (i, max(i->decoder->position(_film), i->content->trim_start())); + if (t > i->content->end(_film)) { i->done = true; } else { @@ -610,7 +610,7 @@ Player::pass () switch (which) { case CONTENT: - earliest_content->done = earliest_content->decoder->pass (); + earliest_content->done = earliest_content->decoder->pass (_film); break; case BLACK: emit_video (black_player_video_frame(EYES_BOTH), _black.position()); @@ -735,7 +735,7 @@ Player::video (weak_ptr wp, ContentVideo video) return; } - FrameRateChange frc(piece->content->active_video_frame_rate(), _film->video_frame_rate()); + FrameRateChange frc(piece->content->active_video_frame_rate(_film), _film->video_frame_rate()); if (frc.skip && (video.frame % 2) == 1) { return; } @@ -754,7 +754,7 @@ Player::video (weak_ptr wp, ContentVideo video) /* Fill gaps that we discover now that we have some video which needs to be emitted. This is where we need to fill to. */ - DCPTime fill_to = min (time, piece->content->end()); + DCPTime fill_to = min (time, piece->content->end(_film)); if (_last_video_time) { DCPTime fill_from = max (*_last_video_time, piece->content->position()); @@ -764,7 +764,7 @@ Player::video (weak_ptr wp, ContentVideo video) if (fill_to_eyes == EYES_BOTH) { fill_to_eyes = EYES_LEFT; } - if (fill_to == piece->content->end()) { + if (fill_to == piece->content->end(_film)) { /* Don't fill after the end of the content */ fill_to_eyes = EYES_LEFT; } @@ -801,7 +801,7 @@ Player::video (weak_ptr wp, ContentVideo video) new PlayerVideo ( video.image, piece->content->video->crop (), - piece->content->video->fade (video.frame), + piece->content->video->fade (_film, video.frame), piece->content->video->scale().size ( piece->content->video, _video_container_size, _film->frame_size () ), @@ -816,7 +816,7 @@ Player::video (weak_ptr wp, ContentVideo video) DCPTime t = time; for (int i = 0; i < frc.repeat; ++i) { - if (t < piece->content->end()) { + if (t < piece->content->end(_film)) { emit_video (_last_video[wp], t); } t += one_video_frame (); @@ -839,7 +839,7 @@ Player::audio (weak_ptr wp, AudioStreamPtr stream, ContentAudio content_a /* Compute time in the DCP */ DCPTime time = resampled_audio_to_dcp (piece, content_audio.frame); /* And the end of this block in the DCP */ - DCPTime end = time + DCPTime::from_frames(content_audio.audio->frames(), content->resampled_frame_rate()); + DCPTime end = time + DCPTime::from_frames(content_audio.audio->frames(), content->resampled_frame_rate(_film)); /* Remove anything that comes before the start or after the end of the content */ if (time < piece->content->position()) { @@ -850,11 +850,11 @@ Player::audio (weak_ptr wp, AudioStreamPtr stream, ContentAudio content_a } content_audio.audio = cut.first; time = cut.second; - } else if (time > piece->content->end()) { + } else if (time > piece->content->end(_film)) { /* Discard it all */ return; - } else if (end > piece->content->end()) { - Frame const remaining_frames = DCPTime(piece->content->end() - time).frames_round(_film->audio_frame_rate()); + } else if (end > piece->content->end(_film)) { + Frame const remaining_frames = DCPTime(piece->content->end(_film) - time).frames_round(_film->audio_frame_rate()); if (remaining_frames == 0) { return; } @@ -933,7 +933,7 @@ Player::plain_text_start (weak_ptr wp, weak_ptr wc, Co PlayerText ps; DCPTime const from (content_time_to_dcp (piece, subtitle.from())); - if (from > piece->content->end()) { + if (from > piece->content->end(_film)) { return; } @@ -984,7 +984,7 @@ Player::subtitle_stop (weak_ptr wp, weak_ptr wc, Conte DCPTime const dcp_to = content_time_to_dcp (piece, to); - if (dcp_to > piece->content->end()) { + if (dcp_to > piece->content->end(_film)) { return; } @@ -1024,11 +1024,11 @@ Player::seek (DCPTime time, bool accurate) BOOST_FOREACH (shared_ptr i, _pieces) { if (time < i->content->position()) { /* Before; seek to the start of the content */ - i->decoder->seek (dcp_to_content_time (i, i->content->position()), accurate); + i->decoder->seek (_film, dcp_to_content_time (i, i->content->position()), accurate); i->done = false; - } else if (i->content->position() <= time && time < i->content->end()) { + } else if (i->content->position() <= time && time < i->content->end(_film)) { /* During; seek to position */ - i->decoder->seek (dcp_to_content_time (i, time), accurate); + i->decoder->seek (_film, dcp_to_content_time (i, time), accurate); i->done = false; } else { /* After; this piece is done */ diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc index 94432d66e..6c0cf20c1 100644 --- a/src/lib/player_video.cc +++ b/src/lib/player_video.cc @@ -315,7 +315,7 @@ PlayerVideo::shallow_copy () const * @return true if this was possible, false if not. */ bool -PlayerVideo::reset_metadata (dcp::Size video_container_size, dcp::Size film_frame_size) +PlayerVideo::reset_metadata (shared_ptr film, dcp::Size video_container_size, dcp::Size film_frame_size) { shared_ptr content = _content.lock(); if (!content || !_video_frame) { @@ -323,7 +323,7 @@ PlayerVideo::reset_metadata (dcp::Size video_container_size, dcp::Size film_fram } _crop = content->video->crop(); - _fade = content->video->fade(_video_frame.get()); + _fade = content->video->fade(film, _video_frame.get()); _inter_size = content->video->scale().size(content->video, video_container_size, film_frame_size); _out_size = video_container_size; _colour_conversion = content->video->colour_conversion(); diff --git a/src/lib/player_video.h b/src/lib/player_video.h index 8ffe70afb..a874fd3b2 100644 --- a/src/lib/player_video.h +++ b/src/lib/player_video.h @@ -34,6 +34,7 @@ extern "C" { class Image; class ImageProxy; +class Film; class Socket; /** Everything needed to describe a video frame coming out of the player, but with the @@ -71,7 +72,7 @@ public: void add_metadata (xmlpp::Node* node) const; void send_binary (boost::shared_ptr socket) const; - bool reset_metadata (dcp::Size video_container_size, dcp::Size film_frame_size); + bool reset_metadata (boost::shared_ptr film, dcp::Size video_container_size, dcp::Size film_frame_size); bool has_j2k () const; dcp::Data j2k () const; diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index e4fc0f072..0e6497495 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -61,12 +61,15 @@ Playlist::Playlist () Playlist::~Playlist () { _content.clear (); - reconnect (); + disconnect (); } void -Playlist::content_change (ChangeType type, weak_ptr content, int property, bool frequent) +Playlist::content_change (weak_ptr weak_film, ChangeType type, weak_ptr content, int property, bool frequent) { + shared_ptr film = weak_film.lock (); + DCPOMATIC_ASSERT (film); + if (type == CHANGE_TYPE_DONE) { if ( property == ContentProperty::TRIM_START || @@ -79,7 +82,7 @@ Playlist::content_change (ChangeType type, weak_ptr content, int proper - any other position changes will be timeline drags which should not result in content being sequenced. */ - maybe_sequence (); + maybe_sequence (film); } if ( @@ -100,7 +103,7 @@ Playlist::content_change (ChangeType type, weak_ptr content, int proper } void -Playlist::maybe_sequence () +Playlist::maybe_sequence (shared_ptr film) { if (!_sequence || _sequencing) { return; @@ -123,11 +126,11 @@ Playlist::maybe_sequence () } if (i->video->frame_type() == VIDEO_FRAME_TYPE_3D_RIGHT) { - i->set_position (next_right); - next_right = i->end(); + i->set_position (film, next_right); + next_right = i->end(film); } else { - i->set_position (next_left); - next_left = i->end(); + i->set_position (film, next_left); + next_left = i->end(film); } placed.push_back (i); @@ -141,8 +144,8 @@ Playlist::maybe_sequence () continue; } - i->set_position (next); - next = i->end(); + i->set_position (film, next); + next = i->end(film); } @@ -188,7 +191,7 @@ Playlist::set_from_xml (shared_ptr film, cxml::ConstNodePtr node, in /* This shouldn't be necessary but better safe than sorry (there could be old files) */ sort (_content.begin(), _content.end(), ContentSorter ()); - reconnect (); + reconnect (film); } /** @param node <Playlist> node. @@ -203,12 +206,12 @@ Playlist::as_xml (xmlpp::Node* node, bool with_content_paths) } void -Playlist::add (shared_ptr c) +Playlist::add (shared_ptr film, shared_ptr c) { Change (CHANGE_TYPE_PENDING); _content.push_back (c); sort (_content.begin(), _content.end(), ContentSorter ()); - reconnect (); + reconnect (film); Change (CHANGE_TYPE_DONE); } @@ -323,11 +326,11 @@ Playlist::best_video_frame_rate () const /** @return length of the playlist from time 0 to the last thing on the playlist */ DCPTime -Playlist::length () const +Playlist::length (shared_ptr film) const { DCPTime len; BOOST_FOREACH (shared_ptr i, _content) { - len = max (len, i->end()); + len = max (len, i->end(film)); } return len; @@ -350,26 +353,32 @@ Playlist::start () const } void -Playlist::reconnect () +Playlist::disconnect () { for (list::iterator i = _content_connections.begin(); i != _content_connections.end(); ++i) { i->disconnect (); } _content_connections.clear (); +} + +void +Playlist::reconnect (shared_ptr film) +{ + disconnect (); BOOST_FOREACH (shared_ptr i, _content) { - _content_connections.push_back (i->Change.connect(boost::bind(&Playlist::content_change, this, _1, _2, _3, _4))); + _content_connections.push_back (i->Change.connect(boost::bind(&Playlist::content_change, this, film, _1, _2, _3, _4))); } } DCPTime -Playlist::video_end () const +Playlist::video_end (shared_ptr film) const { DCPTime end; BOOST_FOREACH (shared_ptr i, _content) { if (i->video) { - end = max (end, i->end ()); + end = max (end, i->end(film)); } } @@ -377,12 +386,12 @@ Playlist::video_end () const } DCPTime -Playlist::text_end () const +Playlist::text_end (shared_ptr film) const { DCPTime end; BOOST_FOREACH (shared_ptr i, _content) { if (!i->text.empty ()) { - end = max (end, i->end ()); + end = max (end, i->end(film)); } } @@ -446,14 +455,14 @@ Playlist::content () const } void -Playlist::repeat (ContentList c, int n) +Playlist::repeat (shared_ptr film, ContentList c, int n) { pair range (DCPTime::max (), DCPTime ()); BOOST_FOREACH (shared_ptr i, c) { range.first = min (range.first, i->position ()); range.second = max (range.second, i->position ()); - range.first = min (range.first, i->end ()); - range.second = max (range.second, i->end ()); + range.first = min (range.first, i->end(film)); + range.second = max (range.second, i->end(film)); } Change (CHANGE_TYPE_PENDING); @@ -461,8 +470,8 @@ Playlist::repeat (ContentList c, int n) DCPTime pos = range.second; for (int i = 0; i < n; ++i) { BOOST_FOREACH (shared_ptr j, c) { - shared_ptr copy = j->clone (); - copy->set_position (pos + copy->position() - range.first); + shared_ptr copy = j->clone (film); + copy->set_position (film, pos + copy->position() - range.first); _content.push_back (copy); } pos += range.second - range.first; @@ -470,12 +479,12 @@ Playlist::repeat (ContentList c, int n) sort (_content.begin(), _content.end(), ContentSorter ()); - reconnect (); + reconnect (film); Change (CHANGE_TYPE_DONE); } void -Playlist::move_earlier (shared_ptr c) +Playlist::move_earlier (shared_ptr film, shared_ptr c) { ContentList::iterator previous = _content.end (); ContentList::iterator i = _content.begin(); @@ -492,12 +501,12 @@ Playlist::move_earlier (shared_ptr c) shared_ptr previous_c = *previous; DCPTime const p = previous_c->position (); - previous_c->set_position (p + c->length_after_trim ()); - c->set_position (p); + previous_c->set_position (film, p + c->length_after_trim(film)); + c->set_position (film, p); } void -Playlist::move_later (shared_ptr c) +Playlist::move_later (shared_ptr film, shared_ptr c) { ContentList::iterator i = _content.begin(); while (i != _content.end() && *i != c) { @@ -515,24 +524,24 @@ Playlist::move_later (shared_ptr c) shared_ptr next_c = *next; - next_c->set_position (c->position ()); - c->set_position (c->position() + next_c->length_after_trim ()); + next_c->set_position (film, c->position()); + c->set_position (film, c->position() + next_c->length_after_trim(film)); } int64_t -Playlist::required_disk_space (int j2k_bandwidth, int audio_channels, int audio_frame_rate) const +Playlist::required_disk_space (shared_ptr film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const { - int64_t video = uint64_t (j2k_bandwidth / 8) * length().seconds (); - int64_t audio = uint64_t (audio_channels * audio_frame_rate * 3) * length().seconds (); + int64_t video = uint64_t (j2k_bandwidth / 8) * length(film).seconds(); + int64_t audio = uint64_t (audio_channels * audio_frame_rate * 3) * length(film).seconds(); BOOST_FOREACH (shared_ptr i, _content) { shared_ptr d = dynamic_pointer_cast (i); if (d) { if (d->reference_video()) { - video -= uint64_t (j2k_bandwidth / 8) * d->length_after_trim().seconds(); + video -= uint64_t (j2k_bandwidth / 8) * d->length_after_trim(film).seconds(); } if (d->reference_audio()) { - audio -= uint64_t (audio_channels * audio_frame_rate * 3) * d->length_after_trim().seconds(); + audio -= uint64_t (audio_channels * audio_frame_rate * 3) * d->length_after_trim(film).seconds(); } } } @@ -542,13 +551,13 @@ Playlist::required_disk_space (int j2k_bandwidth, int audio_channels, int audio_ } string -Playlist::content_summary (DCPTimePeriod period) const +Playlist::content_summary (shared_ptr film, DCPTimePeriod period) const { string best_summary; int best_score = -1; BOOST_FOREACH (shared_ptr i, _content) { int score = 0; - optional const o = DCPTimePeriod(i->position(), i->end()).overlap (period); + optional const o = DCPTimePeriod(i->position(), i->end(film)).overlap (period); if (o) { score += 100 * o.get().duration().get() / period.duration().get(); } diff --git a/src/lib/playlist.h b/src/lib/playlist.h index d55232dad..d9140bdfb 100644 --- a/src/lib/playlist.h +++ b/src/lib/playlist.h @@ -48,31 +48,31 @@ public: void as_xml (xmlpp::Node *, bool with_content_paths); void set_from_xml (boost::shared_ptr film, cxml::ConstNodePtr node, int version, std::list& notes); - void add (boost::shared_ptr); + void add (boost::shared_ptr film, boost::shared_ptr); void remove (boost::shared_ptr); void remove (ContentList); - void move_earlier (boost::shared_ptr); - void move_later (boost::shared_ptr); + void move_earlier (boost::shared_ptr film, boost::shared_ptr); + void move_later (boost::shared_ptr film, boost::shared_ptr); ContentList content () const; std::string video_identifier () const; - DCPTime length () const; + DCPTime length (boost::shared_ptr film) const; boost::optional start () const; - int64_t required_disk_space (int j2k_bandwidth, int audio_channels, int audio_frame_rate) const; + int64_t required_disk_space (boost::shared_ptr film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const; int best_video_frame_rate () const; - DCPTime video_end () const; - DCPTime text_end () const; + DCPTime video_end (boost::shared_ptr film) const; + DCPTime text_end (boost::shared_ptr film) const; FrameRateChange active_frame_rate_change (DCPTime, int dcp_frame_rate) const; - std::string content_summary (DCPTimePeriod period) const; + std::string content_summary (boost::shared_ptr film, DCPTimePeriod period) const; std::pair speed_up_range (int dcp_video_frame_rate) const; void set_sequence (bool); - void maybe_sequence (); + void maybe_sequence (boost::shared_ptr film); - void repeat (ContentList, int); + void repeat (boost::shared_ptr film, ContentList, int); /** Emitted when content has been added to or removed from the playlist; implies OrderChanged */ mutable boost::signals2::signal Change; @@ -81,8 +81,9 @@ public: mutable boost::signals2::signal, int, bool)> ContentChange; private: - void content_change (ChangeType, boost::weak_ptr, int, bool); - void reconnect (); + void content_change (boost::weak_ptr, ChangeType, boost::weak_ptr, int, bool); + void disconnect (); + void reconnect (boost::shared_ptr film); /** List of content. Kept sorted in position order. */ ContentList _content; diff --git a/src/lib/string_text_file_content.cc b/src/lib/string_text_file_content.cc index 9c941c2bb..35f76be7c 100644 --- a/src/lib/string_text_file_content.cc +++ b/src/lib/string_text_file_content.cc @@ -36,23 +36,23 @@ using boost::shared_ptr; using boost::optional; using dcp::raw_convert; -StringTextFileContent::StringTextFileContent (shared_ptr film, boost::filesystem::path path) - : Content (film, path) +StringTextFileContent::StringTextFileContent (boost::filesystem::path path) + : Content (path) { text.push_back (shared_ptr (new TextContent (this, TEXT_OPEN_SUBTITLE, TEXT_UNKNOWN))); } -StringTextFileContent::StringTextFileContent (shared_ptr film, cxml::ConstNodePtr node, int version) - : Content (film, node) +StringTextFileContent::StringTextFileContent (cxml::ConstNodePtr node, int version) + : Content (node) , _length (node->number_child ("Length")) { text = TextContent::from_xml (this, node, version); } void -StringTextFileContent::examine (boost::shared_ptr job) +StringTextFileContent::examine (shared_ptr film, shared_ptr job) { - Content::examine (job); + Content::examine (film, job); StringTextFile s (shared_from_this ()); /* Default to turning these subtitles on */ @@ -89,8 +89,8 @@ StringTextFileContent::as_xml (xmlpp::Node* node, bool with_paths) const } DCPTime -StringTextFileContent::full_length () const +StringTextFileContent::full_length (shared_ptr film) const { - FrameRateChange const frc (active_video_frame_rate(), film()->video_frame_rate ()); + FrameRateChange const frc (active_video_frame_rate(film), film->video_frame_rate()); return DCPTime (_length, frc); } diff --git a/src/lib/string_text_file_content.h b/src/lib/string_text_file_content.h index c2de86ce5..9a71d5828 100644 --- a/src/lib/string_text_file_content.h +++ b/src/lib/string_text_file_content.h @@ -28,18 +28,18 @@ class Job; class StringTextFileContent : public Content { public: - StringTextFileContent (boost::shared_ptr, boost::filesystem::path); - StringTextFileContent (boost::shared_ptr, cxml::ConstNodePtr, int); + StringTextFileContent (boost::filesystem::path); + StringTextFileContent (cxml::ConstNodePtr, int); boost::shared_ptr shared_from_this () { return boost::dynamic_pointer_cast (Content::shared_from_this ()); } - void examine (boost::shared_ptr); + void examine (boost::shared_ptr film, boost::shared_ptr); std::string summary () const; std::string technical_summary () const; void as_xml (xmlpp::Node *, bool with_paths) const; - DCPTime full_length () const; + DCPTime full_length (boost::shared_ptr film) const; private: ContentTime _length; diff --git a/src/lib/string_text_file_decoder.cc b/src/lib/string_text_file_decoder.cc index 8286c1e39..e67450b8b 100644 --- a/src/lib/string_text_file_decoder.cc +++ b/src/lib/string_text_file_decoder.cc @@ -35,7 +35,7 @@ using boost::shared_ptr; using boost::optional; using boost::dynamic_pointer_cast; -StringTextFileDecoder::StringTextFileDecoder (shared_ptr content, shared_ptr log) +StringTextFileDecoder::StringTextFileDecoder (shared_ptr content) : StringTextFile (content) , _next (0) { @@ -43,11 +43,11 @@ StringTextFileDecoder::StringTextFileDecoder (shared_ptr (new TextDecoder (this, content->only_text(), log, first))); + text.push_back (shared_ptr (new TextDecoder (this, content->only_text(), first))); } void -StringTextFileDecoder::seek (ContentTime time, bool accurate) +StringTextFileDecoder::seek (shared_ptr film, ContentTime time, bool accurate) { /* It's worth back-tracking a little here as decoding is cheap and it's nice if we don't miss too many subtitles when seeking. @@ -57,7 +57,7 @@ StringTextFileDecoder::seek (ContentTime time, bool accurate) time = ContentTime(); } - Decoder::seek (time, accurate); + Decoder::seek (film, time, accurate); _next = 0; while (_next < _subtitles.size() && ContentTime::from_seconds (_subtitles[_next].from.all_as_seconds ()) < time) { @@ -66,7 +66,7 @@ StringTextFileDecoder::seek (ContentTime time, bool accurate) } bool -StringTextFileDecoder::pass () +StringTextFileDecoder::pass (shared_ptr) { if (_next >= _subtitles.size ()) { return true; diff --git a/src/lib/string_text_file_decoder.h b/src/lib/string_text_file_decoder.h index 6a9552bbe..8cdf8cd9e 100644 --- a/src/lib/string_text_file_decoder.h +++ b/src/lib/string_text_file_decoder.h @@ -25,15 +25,14 @@ #include "decoder.h" class StringTextFileContent; -class Log; class StringTextFileDecoder : public Decoder, public StringTextFile { public: - StringTextFileDecoder (boost::shared_ptr, boost::shared_ptr log); + StringTextFileDecoder (boost::shared_ptr); - void seek (ContentTime time, bool accurate); - bool pass (); + void seek (boost::shared_ptr film, ContentTime time, bool accurate); + bool pass (boost::shared_ptr film); private: ContentTimePeriod content_time_period (sub::Subtitle s) const; diff --git a/src/lib/text_decoder.cc b/src/lib/text_decoder.cc index d6cf517c2..74fea6ec3 100644 --- a/src/lib/text_decoder.cc +++ b/src/lib/text_decoder.cc @@ -40,10 +40,9 @@ using boost::function; TextDecoder::TextDecoder ( Decoder* parent, shared_ptr c, - shared_ptr log, ContentTime first ) - : DecoderPart (parent, log) + : DecoderPart (parent) , _content (c) , _position (first) { diff --git a/src/lib/text_decoder.h b/src/lib/text_decoder.h index d45e37fc7..a82f43f51 100644 --- a/src/lib/text_decoder.h +++ b/src/lib/text_decoder.h @@ -41,11 +41,10 @@ public: TextDecoder ( Decoder* parent, boost::shared_ptr, - boost::shared_ptr log, ContentTime first ); - ContentTime position () const { + ContentTime position (boost::shared_ptr) const { return _position; } diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 8cb305463..15445a68a 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -38,7 +38,7 @@ #include "i18n.h" -#define LOG_GENERAL(...) _parent->film()->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); +#define LOG_GENERAL(...) dcpomatic_log->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); int const VideoContentProperty::SIZE = 0; int const VideoContentProperty::FRAME_TYPE = 1; @@ -332,10 +332,9 @@ VideoContent::size_after_crop () const } void -VideoContent::scale_and_crop_to_fit_width () +VideoContent::scale_and_crop_to_fit_width (shared_ptr film) { - shared_ptr film = _parent->film (); - set_scale (VideoContentScale (film->container ())); + set_scale (VideoContentScale(film->container())); int const crop = max (0, int (size().height - double (film->frame_size().height) * size().width / film->frame_size().width)); set_left_crop (0); @@ -345,10 +344,9 @@ VideoContent::scale_and_crop_to_fit_width () } void -VideoContent::scale_and_crop_to_fit_height () +VideoContent::scale_and_crop_to_fit_height (shared_ptr film) { - shared_ptr film = _parent->film (); - set_scale (VideoContentScale (film->container ())); + set_scale (VideoContentScale(film->container())); int const crop = max (0, int (size().width - double (film->frame_size().width) * size().height / film->frame_size().height)); set_left_crop (crop / 2); @@ -359,13 +357,11 @@ VideoContent::scale_and_crop_to_fit_height () /** @param f Frame index within the whole (untrimmed) content */ optional -VideoContent::fade (Frame f) const +VideoContent::fade (shared_ptr film, Frame f) const { DCPOMATIC_ASSERT (f >= 0); - shared_ptr film = _parent->film (); - - double const vfr = _parent->active_video_frame_rate (); + double const vfr = _parent->active_video_frame_rate(film); Frame const ts = _parent->trim_start().frames_round(vfr); if ((f - ts) < fade_in()) { @@ -381,7 +377,7 @@ VideoContent::fade (Frame f) const } string -VideoContent::processing_description () const +VideoContent::processing_description (shared_ptr film) const { string d; char buffer[256]; @@ -417,7 +413,6 @@ VideoContent::processing_description () const d += buffer; } - shared_ptr film = _parent->film (); dcp::Size const container_size = film->frame_size (); dcp::Size const scaled = scale().size (shared_from_this(), container_size, container_size); @@ -547,9 +542,9 @@ VideoContent::take_settings_from (shared_ptr c) } void -VideoContent::modify_position (DCPTime& pos) const +VideoContent::modify_position (shared_ptr film, DCPTime& pos) const { - pos = pos.round (_parent->film()->video_frame_rate()); + pos = pos.round (film->video_frame_rate()); } void diff --git a/src/lib/video_content.h b/src/lib/video_content.h index 774210c13..7ecc2813a 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -156,19 +156,19 @@ public: dcp::Size size_after_3d_split () const; dcp::Size size_after_crop () const; - boost::optional fade (Frame) const; + boost::optional fade (boost::shared_ptr film, Frame) const; - void scale_and_crop_to_fit_width (); - void scale_and_crop_to_fit_height (); + void scale_and_crop_to_fit_width (boost::shared_ptr film); + void scale_and_crop_to_fit_height (boost::shared_ptr film); - std::string processing_description () const; + std::string processing_description (boost::shared_ptr film) const; void set_length (Frame); void take_from_examiner (boost::shared_ptr); void add_properties (std::list &) const; - void modify_position (DCPTime& pos) const; + void modify_position (boost::shared_ptr film, DCPTime& pos) const; void modify_trim_start (ContentTime& pos) const; static boost::shared_ptr from_xml (Content* parent, cxml::ConstNodePtr, int); diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index 3625e074f..813320eb8 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -36,8 +36,8 @@ using std::back_inserter; using boost::shared_ptr; using boost::optional; -VideoDecoder::VideoDecoder (Decoder* parent, shared_ptr c, shared_ptr log) - : DecoderPart (parent, log) +VideoDecoder::VideoDecoder (Decoder* parent, shared_ptr c) + : DecoderPart (parent) , _content (c) { @@ -53,7 +53,7 @@ VideoDecoder::VideoDecoder (Decoder* parent, shared_ptr c, shared * and so on. */ void -VideoDecoder::emit (shared_ptr image, Frame frame) +VideoDecoder::emit (shared_ptr film, shared_ptr image, Frame frame) { if (ignore ()) { return; @@ -95,7 +95,7 @@ VideoDecoder::emit (shared_ptr image, Frame frame) DCPOMATIC_ASSERT (false); } - _position = ContentTime::from_frames (frame, _content->active_video_frame_rate ()); + _position = ContentTime::from_frames (frame, _content->active_video_frame_rate(film)); } void diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h index 3fc30cf9d..0fc7ca5a4 100644 --- a/src/lib/video_decoder.h +++ b/src/lib/video_decoder.h @@ -44,20 +44,19 @@ class Log; class VideoDecoder : public DecoderPart { public: - VideoDecoder (Decoder* parent, boost::shared_ptr c, boost::shared_ptr log); + VideoDecoder (Decoder* parent, boost::shared_ptr c); friend struct video_decoder_fill_test1; friend struct video_decoder_fill_test2; friend struct ffmpeg_pts_offset_test; friend void ffmpeg_decoder_sequential_test_one (boost::filesystem::path file, float fps, int gaps, int video_length); - ContentTime position () const { + ContentTime position (boost::shared_ptr) const { return _position; } void seek (); - - void emit (boost::shared_ptr, Frame frame); + void emit (boost::shared_ptr film, boost::shared_ptr, Frame frame); /** @return true if the emitted data was accepted, false if not */ boost::signals2::signal Data; diff --git a/src/lib/video_mxf_content.cc b/src/lib/video_mxf_content.cc index 8e762ae14..4f69cb2e2 100644 --- a/src/lib/video_mxf_content.cc +++ b/src/lib/video_mxf_content.cc @@ -36,14 +36,14 @@ using std::list; using std::string; using boost::shared_ptr; -VideoMXFContent::VideoMXFContent (shared_ptr film, boost::filesystem::path path) - : Content (film, path) +VideoMXFContent::VideoMXFContent (boost::filesystem::path path) + : Content (path) { } -VideoMXFContent::VideoMXFContent (shared_ptr film, cxml::ConstNodePtr node, int version) - : Content (film, node) +VideoMXFContent::VideoMXFContent (cxml::ConstNodePtr node, int version) + : Content (node) { video = VideoContent::from_xml (this, node, version); } @@ -78,11 +78,11 @@ VideoMXFContent::valid_mxf (boost::filesystem::path path) } void -VideoMXFContent::examine (shared_ptr job) +VideoMXFContent::examine (shared_ptr film, shared_ptr job) { job->set_progress_unknown (); - Content::examine (job); + Content::examine (film, job); video.reset (new VideoContent (this)); shared_ptr examiner (new VideoMXFExaminer (shared_from_this ())); @@ -117,10 +117,10 @@ VideoMXFContent::as_xml (xmlpp::Node* node, bool with_paths) const } DCPTime -VideoMXFContent::full_length () const +VideoMXFContent::full_length (shared_ptr film) const { - FrameRateChange const frc (active_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 (active_video_frame_rate(film), 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/video_mxf_content.h b/src/lib/video_mxf_content.h index 1fa428704..c536cb2aa 100644 --- a/src/lib/video_mxf_content.h +++ b/src/lib/video_mxf_content.h @@ -23,19 +23,19 @@ class VideoMXFContent : public Content { public: - VideoMXFContent (boost::shared_ptr film, boost::filesystem::path path); - VideoMXFContent (boost::shared_ptr film, cxml::ConstNodePtr node, int version); + VideoMXFContent (boost::filesystem::path path); + VideoMXFContent (cxml::ConstNodePtr node, int version); boost::shared_ptr shared_from_this () { return boost::dynamic_pointer_cast (Content::shared_from_this ()); } - void examine (boost::shared_ptr job); + void examine (boost::shared_ptr film, boost::shared_ptr job); std::string summary () const; std::string technical_summary () const; std::string identifier () const; void as_xml (xmlpp::Node* node, bool with_paths) const; - DCPTime full_length () const; + DCPTime full_length (boost::shared_ptr film) const; void add_properties (std::list& p) const; static bool valid_mxf (boost::filesystem::path path); diff --git a/src/lib/video_mxf_decoder.cc b/src/lib/video_mxf_decoder.cc index 194830c63..7d9656dd5 100644 --- a/src/lib/video_mxf_decoder.cc +++ b/src/lib/video_mxf_decoder.cc @@ -31,10 +31,10 @@ using boost::shared_ptr; using boost::optional; -VideoMXFDecoder::VideoMXFDecoder (shared_ptr content, shared_ptr log) +VideoMXFDecoder::VideoMXFDecoder (shared_ptr content) : _content (content) { - video.reset (new VideoDecoder (this, content, log)); + video.reset (new VideoDecoder (this, content)); shared_ptr mono; try { @@ -68,9 +68,9 @@ VideoMXFDecoder::VideoMXFDecoder (shared_ptr content, sha } bool -VideoMXFDecoder::pass () +VideoMXFDecoder::pass (shared_ptr film) { - double const vfr = _content->active_video_frame_rate (); + double const vfr = _content->active_video_frame_rate (film); int64_t const frame = _next.frames_round (vfr); if (frame >= _content->video->length()) { @@ -79,6 +79,7 @@ VideoMXFDecoder::pass () if (_mono_reader) { video->emit ( + film, shared_ptr ( new J2KImageProxy (_mono_reader->get_frame(frame), _size, AV_PIX_FMT_XYZ12LE, optional()) ), @@ -86,12 +87,14 @@ VideoMXFDecoder::pass () ); } else { video->emit ( + film, shared_ptr ( new J2KImageProxy (_stereo_reader->get_frame(frame), _size, dcp::EYE_LEFT, AV_PIX_FMT_XYZ12LE, optional()) ), frame ); video->emit ( + film, shared_ptr ( new J2KImageProxy (_stereo_reader->get_frame(frame), _size, dcp::EYE_RIGHT, AV_PIX_FMT_XYZ12LE, optional()) ), @@ -104,8 +107,8 @@ VideoMXFDecoder::pass () } void -VideoMXFDecoder::seek (ContentTime t, bool accurate) +VideoMXFDecoder::seek (shared_ptr film, ContentTime t, bool accurate) { - Decoder::seek (t, accurate); + Decoder::seek (film, t, accurate); _next = t; } diff --git a/src/lib/video_mxf_decoder.h b/src/lib/video_mxf_decoder.h index 3cbdcfb2d..6b5b328ac 100644 --- a/src/lib/video_mxf_decoder.h +++ b/src/lib/video_mxf_decoder.h @@ -28,10 +28,10 @@ class Log; class VideoMXFDecoder : public Decoder { public: - VideoMXFDecoder (boost::shared_ptr, boost::shared_ptr log); + VideoMXFDecoder (boost::shared_ptr); - bool pass (); - void seek (ContentTime t, bool accurate); + bool pass (boost::shared_ptr film); + void seek (boost::shared_ptr film, ContentTime t, bool accurate); private: -- cgit v1.2.3