From bb949ec65adf95f4a2c7dd5ee7e97b9daaaf3d3f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 16 Feb 2021 10:40:12 +0100 Subject: [PATCH] C++11 tidying. --- src/lib/audio_ring_buffers.cc | 19 +++++--- src/lib/audio_ring_buffers.h | 13 ++++-- src/lib/decoder.cc | 16 +++++-- src/lib/decoder.h | 29 ++++++++---- src/lib/digester.cc | 12 ++++- src/lib/digester.h | 10 ++-- src/lib/frame_interval_checker.h | 11 +++-- src/lib/job_manager.cc | 80 +++++++++++++++++++------------- src/lib/job_manager.h | 20 +++++--- src/lib/playlist.cc | 44 ++++++++++++++---- src/lib/playlist.h | 17 +++++-- src/lib/ratio.cc | 44 +++++++++++------- src/lib/ratio.h | 13 ++++-- src/tools/dcpomatic.cc | 12 +++-- src/wx/content_widget.h | 5 +- src/wx/timeline_view.cc | 16 +++++-- src/wx/timeline_view.h | 16 +++++-- src/wx/video_view.cc | 16 ++++--- src/wx/video_view.h | 25 ++++++---- 19 files changed, 287 insertions(+), 131 deletions(-) diff --git a/src/lib/audio_ring_buffers.cc b/src/lib/audio_ring_buffers.cc index 289045ff5..1a216ab33 100644 --- a/src/lib/audio_ring_buffers.cc +++ b/src/lib/audio_ring_buffers.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016-2019 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + #include "audio_ring_buffers.h" #include "dcpomatic_assert.h" #include "exceptions.h" #include + using std::min; using std::cout; using std::make_pair; @@ -32,12 +34,13 @@ using std::shared_ptr; using boost::optional; using namespace dcpomatic; + AudioRingBuffers::AudioRingBuffers () - : _used_in_head (0) { } + /** @param frame_rate Frame rate in use; this is only used to check timing consistency of the incoming data */ void AudioRingBuffers::put (shared_ptr data, DCPTime time, int frame_rate) @@ -56,6 +59,7 @@ AudioRingBuffers::put (shared_ptr data, DCPTime time, int fr _buffers.push_back(make_pair(data, time)); } + /** @return time of the returned data; if it's not set this indicates an underrun */ optional AudioRingBuffers::get (float* out, int channels, int frames) @@ -75,7 +79,7 @@ AudioRingBuffers::get (float* out, int channels, int frames) return time; } - pair, DCPTime> front = _buffers.front (); + auto front = _buffers.front (); if (!time) { time = front.second + DCPTime::from_frames(_used_in_head, 48000); } @@ -103,16 +107,18 @@ AudioRingBuffers::get (float* out, int channels, int frames) return time; } + optional AudioRingBuffers::peek () const { boost::mutex::scoped_lock lm (_mutex); if (_buffers.empty()) { - return optional(); + return {}; } return _buffers.front().second; } + void AudioRingBuffers::clear () { @@ -121,13 +127,14 @@ AudioRingBuffers::clear () _used_in_head = 0; } + Frame AudioRingBuffers::size () const { boost::mutex::scoped_lock lm (_mutex); Frame s = 0; - for (list, DCPTime> >::const_iterator i = _buffers.begin(); i != _buffers.end(); ++i) { - s += i->first->frames(); + for (auto const& i: _buffers) { + s += i.first->frames(); } return s - _used_in_head; } diff --git a/src/lib/audio_ring_buffers.h b/src/lib/audio_ring_buffers.h index 2cfc0a30b..be8a616e2 100644 --- a/src/lib/audio_ring_buffers.h +++ b/src/lib/audio_ring_buffers.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016-2019 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,20 +18,26 @@ */ + #ifndef DCPOMATIC_AUDIO_RING_BUFFERS_H #define DCPOMATIC_AUDIO_RING_BUFFERS_H + #include "audio_buffers.h" #include "types.h" #include "dcpomatic_time.h" #include #include -class AudioRingBuffers : public boost::noncopyable + +class AudioRingBuffers { public: AudioRingBuffers (); + AudioRingBuffers (AudioBuffers const&) = delete; + AudioRingBuffers& operator= (AudioBuffers const&) = delete; + void put (std::shared_ptr data, dcpomatic::DCPTime time, int frame_rate); boost::optional get (float* out, int channels, int frames); boost::optional peek () const; @@ -42,7 +48,8 @@ public: private: mutable boost::mutex _mutex; std::list, dcpomatic::DCPTime> > _buffers; - int _used_in_head; + int _used_in_head = 0; }; + #endif diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index bf0bd1a26..5d1915128 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2018 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "decoder.h" #include "video_decoder.h" #include "audio_decoder.h" @@ -25,24 +26,27 @@ #include #include + using std::cout; using boost::optional; using std::shared_ptr; using std::weak_ptr; using namespace dcpomatic; + Decoder::Decoder (weak_ptr film) : WeakConstFilm (film) { } + /** @return Earliest time of content that the next pass() will emit */ ContentTime Decoder::position () const { optional pos; - shared_ptr f = film(); + auto f = film(); if (video && !video->ignore() && (!pos || video->position(f).get_value_or(ContentTime()) < *pos)) { pos = video->position(f); @@ -70,6 +74,7 @@ Decoder::position () const return pos.get_value_or(ContentTime()); } + void Decoder::seek (ContentTime, bool) { @@ -84,12 +89,13 @@ Decoder::seek (ContentTime, bool) } } + shared_ptr Decoder::only_text () const { DCPOMATIC_ASSERT (text.size() < 2); - if (text.empty ()) { - return shared_ptr (); + if (text.empty()) { + return {}; } - return text.front (); + return text.front(); } diff --git a/src/lib/decoder.h b/src/lib/decoder.h index da5be4af6..a672e8a10 100644 --- a/src/lib/decoder.h +++ b/src/lib/decoder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2020 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,39 +18,47 @@ */ + /** @file src/decoder.h * @brief Decoder class. */ + #ifndef DCPOMATIC_DECODER_H #define DCPOMATIC_DECODER_H -#include "types.h" + +#include "dcpomatic_time.h" #include "film.h" #include "font_data.h" -#include "dcpomatic_time.h" +#include "types.h" #include "weak_film.h" #include -class Decoded; -class VideoDecoder; -class AudioDecoder; -class TextDecoder; + class AtmosDecoder; +class AudioDecoder; +class Decoded; class DecoderPart; +class TextDecoder; +class VideoDecoder; + /** @class Decoder. * @brief Parent class for decoders of content. */ -class Decoder : public boost::noncopyable, public WeakConstFilm +class Decoder : public WeakConstFilm { public: Decoder (std::weak_ptr film); virtual ~Decoder () {} + Decoder (Decoder const&) = delete; + Decoder& operator= (Decoder const&) = delete; + std::shared_ptr video; std::shared_ptr audio; - std::list > text; + std::list> text; std::shared_ptr atmos; std::shared_ptr only_text () const; @@ -64,8 +72,9 @@ public: virtual dcpomatic::ContentTime position () const; virtual std::vector fonts () const { - return std::vector(); + return {}; } }; + #endif diff --git a/src/lib/digester.cc b/src/lib/digester.cc index 452452ba4..8542c75a1 100644 --- a/src/lib/digester.cc +++ b/src/lib/digester.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2016 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,39 +18,46 @@ */ + #include "digester.h" #include "dcpomatic_assert.h" #include #include #include + using std::string; using std::hex; using std::setfill; using std::setw; + Digester::Digester () { md5_init (&_context); } + Digester::~Digester () { get (); } + void Digester::add (void const * data, size_t size) { - md5_update (&_context, size, reinterpret_cast (data)); + md5_update (&_context, size, reinterpret_cast(data)); } + void Digester::add (string const & s) { add (s.c_str(), s.length()); } + string Digester::get () const { @@ -69,6 +76,7 @@ Digester::get () const return _digest.get (); } + void Digester::get (uint8_t* buffer) const { diff --git a/src/lib/digester.h b/src/lib/digester.h index 6cdaf2331..e4daabd68 100644 --- a/src/lib/digester.h +++ b/src/lib/digester.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2016 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,17 +18,21 @@ */ + #include -#include #include #include -class Digester : public boost::noncopyable + +class Digester { public: Digester (); ~Digester (); + Digester (Digester const&) = delete; + Digester& operator= (Digester const&) = delete; + void add (void const * data, size_t size); template diff --git a/src/lib/frame_interval_checker.h b/src/lib/frame_interval_checker.h index a8db31a49..e8f537c1a 100644 --- a/src/lib/frame_interval_checker.h +++ b/src/lib/frame_interval_checker.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,14 +18,19 @@ */ + #include "dcpomatic_time.h" #include -#include #include -class FrameIntervalChecker : public boost::noncopyable + +class FrameIntervalChecker { public: + FrameIntervalChecker () {} + FrameIntervalChecker (FrameIntervalChecker const &) = delete; + FrameIntervalChecker& operator= (FrameIntervalChecker const &) = delete; + void feed (dcpomatic::ContentTime time, double frame_rate); enum Guess diff --git a/src/lib/job_manager.cc b/src/lib/job_manager.cc index 1724879d0..2839bce30 100644 --- a/src/lib/job_manager.cc +++ b/src/lib/job_manager.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2020 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,38 +18,41 @@ */ + /** @file src/job_manager.cc * @brief A simple scheduler for jobs. */ -#include "job_manager.h" -#include "job.h" -#include "cross.h" + #include "analyse_audio_job.h" #include "analyse_subtitles_job.h" +#include "cross.h" #include "film.h" +#include "job.h" +#include "job_manager.h" #include -#include -using std::string; + +using std::dynamic_pointer_cast; using std::list; -using std::cout; +using std::make_shared; using std::shared_ptr; +using std::string; using std::weak_ptr; +using boost::bind; using boost::function; -using std::dynamic_pointer_cast; using boost::optional; -using boost::bind; -JobManager* JobManager::_instance = 0; + +JobManager* JobManager::_instance = nullptr; + JobManager::JobManager () - : _terminate (false) - , _paused (false) { } + void JobManager::start () { @@ -59,6 +62,7 @@ JobManager::start () #endif } + JobManager::~JobManager () { boost::this_thread::disable_interruption dis; @@ -78,6 +82,7 @@ JobManager::~JobManager () } catch (...) {} } + shared_ptr JobManager::add (shared_ptr j) { @@ -87,39 +92,42 @@ JobManager::add (shared_ptr j) _empty_condition.notify_all (); } - emit (boost::bind (boost::ref (JobAdded), weak_ptr (j))); + emit (boost::bind(boost::ref(JobAdded), weak_ptr(j))); return j; } + shared_ptr JobManager::add_after (shared_ptr after, shared_ptr j) { { boost::mutex::scoped_lock lm (_mutex); - list >::iterator i = find (_jobs.begin(), _jobs.end(), after); + auto i = find (_jobs.begin(), _jobs.end(), after); DCPOMATIC_ASSERT (i != _jobs.end()); _jobs.insert (i, j); _empty_condition.notify_all (); } - emit (boost::bind (boost::ref (JobAdded), weak_ptr (j))); + emit (boost::bind(boost::ref(JobAdded), weak_ptr(j))); return j; } -list > + +list> JobManager::get () const { boost::mutex::scoped_lock lm (_mutex); return _jobs; } + bool JobManager::work_to_do () const { boost::mutex::scoped_lock lm (_mutex); - list >::const_iterator i = _jobs.begin(); + auto i = _jobs.begin(); while (i != _jobs.end() && (*i)->finished()) { ++i; } @@ -127,12 +135,13 @@ JobManager::work_to_do () const return i != _jobs.end (); } + bool JobManager::errors () const { boost::mutex::scoped_lock lm (_mutex); for (auto i: _jobs) { - if (i->finished_in_error ()) { + if (i->finished_in_error()) { return true; } } @@ -140,6 +149,7 @@ JobManager::errors () const return false; } + void JobManager::scheduler () { @@ -183,22 +193,24 @@ JobManager::scheduler () } } + void JobManager::job_finished () { { boost::mutex::scoped_lock lm (_mutex); - emit (boost::bind (boost::ref (ActiveJobsChanged), _last_active_job, optional())); + emit (boost::bind(boost::ref (ActiveJobsChanged), _last_active_job, optional())); _last_active_job = optional(); } _empty_condition.notify_all (); } + JobManager * JobManager::instance () { - if (_instance == 0) { + if (!_instance) { _instance = new JobManager (); _instance->start (); } @@ -206,13 +218,15 @@ JobManager::instance () return _instance; } + void JobManager::drop () { delete _instance; - _instance = 0; + _instance = nullptr; } + void JobManager::analyse_audio ( shared_ptr film, @@ -226,7 +240,7 @@ JobManager::analyse_audio ( boost::mutex::scoped_lock lm (_mutex); for (auto i: _jobs) { - shared_ptr a = dynamic_pointer_cast (i); + auto a = dynamic_pointer_cast (i); if (a && a->path() == film->audio_analysis_path(playlist) && !i->finished_cancelled()) { i->when_finished (connection, ready); return; @@ -239,7 +253,7 @@ JobManager::analyse_audio ( { boost::mutex::scoped_lock lm (_mutex); - job.reset (new AnalyseAudioJob (film, playlist, from_zero)); + job = make_shared (film, playlist, from_zero); connection = job->Finished.connect (ready); _jobs.push_back (job); _empty_condition.notify_all (); @@ -261,7 +275,7 @@ JobManager::analyse_subtitles ( boost::mutex::scoped_lock lm (_mutex); for (auto i: _jobs) { - shared_ptr a = dynamic_pointer_cast (i); + auto a = dynamic_pointer_cast (i); if (a && a->path() == film->subtitle_analysis_path(content)) { i->when_finished (connection, ready); return; @@ -274,13 +288,13 @@ JobManager::analyse_subtitles ( { boost::mutex::scoped_lock lm (_mutex); - job.reset (new AnalyseSubtitlesJob(film, content)); + job = make_shared(film, content); connection = job->Finished.connect (ready); _jobs.push_back (job); _empty_condition.notify_all (); } - emit (boost::bind (boost::ref (JobAdded), weak_ptr (job))); + emit (boost::bind(boost::ref(JobAdded), weak_ptr(job))); } @@ -291,8 +305,8 @@ JobManager::increase_priority (shared_ptr job) { boost::mutex::scoped_lock lm (_mutex); - list >::iterator last = _jobs.end (); - for (list >::iterator i = _jobs.begin(); i != _jobs.end(); ++i) { + auto last = _jobs.end (); + for (auto i = _jobs.begin(); i != _jobs.end(); ++i) { if (*i == job && last != _jobs.end()) { swap (*i, *last); changed = true; @@ -307,6 +321,7 @@ JobManager::increase_priority (shared_ptr job) } } + void JobManager::priority_changed () { @@ -330,9 +345,10 @@ JobManager::priority_changed () } } - emit (boost::bind (boost::ref (JobsReordered))); + emit (boost::bind(boost::ref(JobsReordered))); } + void JobManager::decrease_priority (shared_ptr job) { @@ -340,8 +356,8 @@ JobManager::decrease_priority (shared_ptr job) { boost::mutex::scoped_lock lm (_mutex); - for (list >::iterator i = _jobs.begin(); i != _jobs.end(); ++i) { - list >::iterator next = i; + for (auto i = _jobs.begin(); i != _jobs.end(); ++i) { + auto next = i; ++next; if (*i == job && next != _jobs.end()) { swap (*i, *next); @@ -356,6 +372,7 @@ JobManager::decrease_priority (shared_ptr job) } } + void JobManager::pause () { @@ -374,6 +391,7 @@ JobManager::pause () _paused = true; } + void JobManager::resume () { diff --git a/src/lib/job_manager.h b/src/lib/job_manager.h index 461688845..4fe1e45d6 100644 --- a/src/lib/job_manager.h +++ b/src/lib/job_manager.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2020 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,10 +18,12 @@ */ + /** @file src/job_manager.h * @brief A simple scheduler for jobs. */ + #include "signaller.h" #include #include @@ -29,23 +31,29 @@ #include #include + class Job; class Film; class Playlist; class Content; struct threed_test7; + extern bool wait_for_jobs (); + /** @class JobManager * @brief A simple scheduler for jobs. */ -class JobManager : public Signaller, public boost::noncopyable +class JobManager : public Signaller { public: + JobManager (JobManager const&) = delete; + JobManager& operator= (JobManager const&) = delete; + std::shared_ptr add (std::shared_ptr); std::shared_ptr add_after (std::shared_ptr after, std::shared_ptr j); - std::list > get () const; + std::list> get () const; bool work_to_do () const; bool errors () const; void increase_priority (std::shared_ptr); @@ -94,10 +102,10 @@ private: mutable boost::mutex _mutex; boost::condition _empty_condition; /** List of jobs in the order that they will be executed */ - std::list > _jobs; + std::list> _jobs; std::list _connections; - bool _terminate; - bool _paused; + bool _terminate = false; + bool _paused = false; std::shared_ptr _paused_job; boost::optional _last_active_job; diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 20534e467..e8714e9d6 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2018 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "playlist.h" #include "video_content.h" #include "text_content.h" @@ -39,6 +40,7 @@ #include "i18n.h" + using std::list; using std::cout; using std::vector; @@ -55,13 +57,13 @@ using namespace dcpomatic; using namespace boost::placeholders; #endif + Playlist::Playlist () - : _sequence (true) - , _sequencing (false) { } + Playlist::~Playlist () { boost::mutex::scoped_lock lm (_mutex); @@ -69,6 +71,7 @@ Playlist::~Playlist () disconnect (); } + void Playlist::content_change (weak_ptr weak_film, ChangeType type, weak_ptr content, int property, bool frequent) { @@ -117,6 +120,7 @@ Playlist::content_change (weak_ptr weak_film, ChangeType type, weak_ ContentChange (type, content, property, frequent); } + void Playlist::maybe_sequence (shared_ptr film) { @@ -126,7 +130,7 @@ Playlist::maybe_sequence (shared_ptr film) _sequencing = true; - ContentList cont = content (); + auto cont = content (); /* Keep track of the content that we've set the position of so that we don't do it twice. @@ -171,6 +175,7 @@ Playlist::maybe_sequence (shared_ptr film) _sequencing = false; } + string Playlist::video_identifier () const { @@ -193,6 +198,7 @@ Playlist::video_identifier () const return digester.get (); } + /** @param film Film that this Playlist is for. * @param node <Playlist> node. * @param version Metadata version number. @@ -227,7 +233,7 @@ Playlist::set_from_xml (shared_ptr film, cxml::ConstNodePtr node, in } /* ...or have a start trim which is an integer number of frames */ - ContentTime const old_trim = content->trim_start(); + auto const old_trim = content->trim_start(); content->set_trim_start(old_trim); if (old_trim != content->trim_start()) { string note = _("Your project contains video content whose trim was not aligned to a frame boundary."); @@ -255,6 +261,7 @@ Playlist::set_from_xml (shared_ptr film, cxml::ConstNodePtr node, in reconnect (film); } + /** @param node <Playlist> node. * @param with_content_paths true to include <Path> nodes in <Content> nodes, false to omit them. */ @@ -266,6 +273,7 @@ Playlist::as_xml (xmlpp::Node* node, bool with_content_paths) } } + void Playlist::add (shared_ptr film, shared_ptr c) { @@ -283,6 +291,7 @@ Playlist::add (shared_ptr film, shared_ptr c) LengthChange (); } + void Playlist::remove (shared_ptr c) { @@ -316,6 +325,7 @@ Playlist::remove (shared_ptr c) LengthChange (); } + void Playlist::remove (ContentList c) { @@ -325,7 +335,7 @@ Playlist::remove (ContentList c) boost::mutex::scoped_lock lm (_mutex); for (auto i: c) { - ContentList::iterator j = _content.begin (); + auto j = _content.begin (); while (j != _content.end() && *j != i) { ++j; } @@ -343,6 +353,7 @@ Playlist::remove (ContentList c) LengthChange (); } + class FrameRateCandidate { public: @@ -355,6 +366,7 @@ public: int dcp; }; + /** @return the best frame rate from Config::_allowed_dcp_frame_rates for the content in this list */ int Playlist::best_video_frame_rate () const @@ -412,6 +424,7 @@ Playlist::best_video_frame_rate () const return best->dcp; } + /** @return length of the playlist from time 0 to the last thing on the playlist */ DCPTime Playlist::length (shared_ptr film) const @@ -424,6 +437,7 @@ Playlist::length (shared_ptr film) const return len; } + /** @return position of the first thing on the playlist, if it's not empty */ optional Playlist::start () const @@ -441,6 +455,7 @@ Playlist::start () const return start; } + /** Must be called with a lock held on _mutex */ void Playlist::disconnect () @@ -452,6 +467,7 @@ Playlist::disconnect () _content_connections.clear (); } + /** Must be called with a lock held on _mutex */ void Playlist::reconnect (shared_ptr film) @@ -463,6 +479,7 @@ Playlist::reconnect (shared_ptr film) } } + DCPTime Playlist::video_end (shared_ptr film) const { @@ -476,6 +493,7 @@ Playlist::video_end (shared_ptr film) const return end; } + DCPTime Playlist::text_end (shared_ptr film) const { @@ -489,10 +507,11 @@ Playlist::text_end (shared_ptr film) const return end; } + FrameRateChange Playlist::active_frame_rate_change (DCPTime t, int dcp_video_frame_rate) const { - ContentList cont = content (); + auto cont = content (); for (ContentList::const_reverse_iterator i = cont.rbegin(); i != cont.rend(); ++i) { if (!(*i)->video) { continue; @@ -515,12 +534,14 @@ Playlist::active_frame_rate_change (DCPTime t, int dcp_video_frame_rate) const return FrameRateChange (dcp_video_frame_rate, dcp_video_frame_rate); } + void Playlist::set_sequence (bool s) { _sequence = s; } + bool ContentSorter::operator() (shared_ptr a, shared_ptr b) { @@ -539,6 +560,7 @@ ContentSorter::operator() (shared_ptr a, shared_ptr b) return a->digest() < b->digest(); } + /** @return content in ascending order of position */ ContentList Playlist::content () const @@ -547,10 +569,11 @@ Playlist::content () const return _content; } + void Playlist::repeat (shared_ptr film, ContentList c, int n) { - pair range (DCPTime::max (), DCPTime ()); + pair range (DCPTime::max(), DCPTime()); for (auto i: c) { range.first = min (range.first, i->position ()); range.second = max (range.second, i->position ()); @@ -580,6 +603,7 @@ Playlist::repeat (shared_ptr film, ContentList c, int n) Change (ChangeType::DONE); } + void Playlist::move_earlier (shared_ptr film, shared_ptr c) { @@ -603,6 +627,7 @@ Playlist::move_earlier (shared_ptr film, shared_ptr c) c->set_position (film, p); } + void Playlist::move_later (shared_ptr film, shared_ptr c) { @@ -627,6 +652,7 @@ Playlist::move_later (shared_ptr film, shared_ptr c) c->set_position (film, c->position() + next_c->length_after_trim(film)); } + int64_t Playlist::required_disk_space (shared_ptr film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const { @@ -649,6 +675,7 @@ Playlist::required_disk_space (shared_ptr film, int j2k_bandwidth, i return video + audio + 65536; } + string Playlist::content_summary (shared_ptr film, DCPTimePeriod period) const { @@ -674,6 +701,7 @@ Playlist::content_summary (shared_ptr film, DCPTimePeriod period) co return best_summary; } + pair Playlist::speed_up_range (int dcp_video_frame_rate) const { diff --git a/src/lib/playlist.h b/src/lib/playlist.h index 91f39bf6b..0dd2370a8 100644 --- a/src/lib/playlist.h +++ b/src/lib/playlist.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2020 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,9 +18,11 @@ */ + #ifndef DCPOMATIC_PLAYLIST_H #define DCPOMATIC_PLAYLIST_H + #include "change_signaller.h" #include "frame_rate_change.h" #include "util.h" @@ -29,23 +31,29 @@ #include #include + class Film; + struct ContentSorter { bool operator() (std::shared_ptr a, std::shared_ptr b); }; + /** @class Playlist * @brief A set of Content objects with knowledge of how they should be arranged into * a DCP. */ -class Playlist : public boost::noncopyable +class Playlist { public: Playlist (); ~Playlist (); + Playlist (Playlist const&) = delete; + Playlist& operator= (Playlist const&) = delete; + void as_xml (xmlpp::Node *, bool with_content_paths); void set_from_xml (std::shared_ptr film, cxml::ConstNodePtr node, int version, std::list& notes); @@ -91,9 +99,10 @@ private: mutable boost::mutex _mutex; /** List of content. Kept sorted in position order. */ ContentList _content; - bool _sequence; - bool _sequencing; + bool _sequence = true; + bool _sequencing = false; std::list _content_connections; }; + #endif diff --git a/src/lib/ratio.cc b/src/lib/ratio.cc index 93ad5755d..5ba79c28b 100644 --- a/src/lib/ratio.cc +++ b/src/lib/ratio.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2018 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "ratio.h" #include "util.h" #include "config.h" @@ -26,27 +27,31 @@ #include "i18n.h" + using std::string; using std::vector; using boost::optional; + vector Ratio::_ratios; + void Ratio::setup_ratios () { - _ratios.push_back (new Ratio (float(1290) / 1080, "119", _("1.19"), optional(), "119")); - _ratios.push_back (new Ratio (float(1440) / 1080, "133", _("1.33 (4:3)"), optional(), "133")); - _ratios.push_back (new Ratio (float(1485) / 1080, "138", _("1.38 (Academy)"), optional(), "137")); - _ratios.push_back (new Ratio (float(1544) / 1080, "143", _("1.43 (IMAX)"), optional(), "143")); - _ratios.push_back (new Ratio (float(1800) / 1080, "166", _("1.66"), optional(), "166")); - _ratios.push_back (new Ratio (float(1920) / 1080, "178", _("1.78 (16:9 or HD)"), optional(), "178")); - _ratios.push_back (new Ratio (float(1998) / 1080, "185", _("1.85 (Flat)"), string(_("DCI Flat")), "F")); - _ratios.push_back (new Ratio (float(2048) / 872, "235", _("2.35 (35mm Scope)"), optional(), "S")); - _ratios.push_back (new Ratio (float(2048) / 858, "239", _("2.39 (Scope)"), string(_("DCI Scope")), "S")); - _ratios.push_back (new Ratio (float(2048) / 1080, "190", _("1.90 (Full frame)"), string(_("Full frame")), "C")); + _ratios.push_back (new Ratio(float(1290) / 1080, "119", _("1.19"), optional(), "119")); + _ratios.push_back (new Ratio(float(1440) / 1080, "133", _("1.33 (4:3)"), optional(), "133")); + _ratios.push_back (new Ratio(float(1485) / 1080, "138", _("1.38 (Academy)"), optional(), "137")); + _ratios.push_back (new Ratio(float(1544) / 1080, "143", _("1.43 (IMAX)"), optional(), "143")); + _ratios.push_back (new Ratio(float(1800) / 1080, "166", _("1.66"), optional(), "166")); + _ratios.push_back (new Ratio(float(1920) / 1080, "178", _("1.78 (16:9 or HD)"), optional(), "178")); + _ratios.push_back (new Ratio(float(1998) / 1080, "185", _("1.85 (Flat)"), string(_("DCI Flat")), "F")); + _ratios.push_back (new Ratio(float(2048) / 872, "235", _("2.35 (35mm Scope)"), optional(), "S")); + _ratios.push_back (new Ratio(float(2048) / 858, "239", _("2.39 (Scope)"), string(_("DCI Scope")), "S")); + _ratios.push_back (new Ratio(float(2048) / 1080, "190", _("1.90 (Full frame)"), string(_("Full frame")), "C")); } + Ratio const * Ratio::from_id (string i) { @@ -55,7 +60,7 @@ Ratio::from_id (string i) i = "138"; } - vector::iterator j = _ratios.begin (); + auto j = _ratios.begin (); while (j != _ratios.end() && (*j)->id() != i) { ++j; } @@ -67,30 +72,32 @@ Ratio::from_id (string i) return *j; } + /** @return Ratio corresponding to a given fractional ratio (+/- 0.01), or 0 */ Ratio const * Ratio::from_ratio (float r) { - vector::iterator j = _ratios.begin (); - while (j != _ratios.end() && fabs ((*j)->ratio() - r) > 0.01) { + auto j = _ratios.begin (); + while (j != _ratios.end() && fabs((*j)->ratio() - r) > 0.01) { ++j; } if (j == _ratios.end ()) { - return 0; + return nullptr; } return *j; } + Ratio const * Ratio::nearest_from_ratio (float r) { - Ratio const * nearest = 0; + Ratio const * nearest = nullptr; float distance = FLT_MAX; - for (vector::iterator i = _ratios.begin (); i != _ratios.end(); ++i) { - float const d = fabs ((*i)->ratio() - r); + for (auto i = _ratios.begin(); i != _ratios.end(); ++i) { + float const d = fabs((*i)->ratio() - r); if (d < distance) { distance = d; nearest = *i; @@ -113,6 +120,7 @@ Ratio::containers () return r; } + string Ratio::container_nickname () const { diff --git a/src/lib/ratio.h b/src/lib/ratio.h index 40f596ab8..016a22edc 100644 --- a/src/lib/ratio.h +++ b/src/lib/ratio.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2018 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,17 +18,20 @@ */ + #ifndef DCPOMATIC_RATIO_H #define DCPOMATIC_RATIO_H + #include #include #include + /** @class Ratio * @brief Description of an image ratio. */ -class Ratio : public boost::noncopyable +class Ratio { public: Ratio (float ratio, std::string id, std::string in, boost::optional cn, std::string d) @@ -39,6 +42,9 @@ public: , _isdcf_name (d) {} + Ratio (Ratio const&) = delete; + Ratio& operator= (Ratio const&) = delete; + std::string id () const { return _id; } @@ -50,7 +56,7 @@ public: std::string container_nickname () const; bool used_for_container () const { - return static_cast (_container_nickname); + return static_cast(_container_nickname); } std::string isdcf_name () const { @@ -85,4 +91,5 @@ private: static std::vector _ratios; }; + #endif diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 7815541d2..559853c40 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -102,7 +102,6 @@ DCPOMATIC_ENABLE_WARNINGS #include #endif #include -#include #include #include #include @@ -135,7 +134,7 @@ using namespace boost::placeholders; #endif using dcp::raw_convert; -class FilmChangedClosingDialog : public boost::noncopyable +class FilmChangedClosingDialog { public: explicit FilmChangedClosingDialog (string name) @@ -159,6 +158,9 @@ public: _dialog->Destroy (); } + FilmChangedClosingDialog (FilmChangedClosingDialog const&) = delete; + FilmChangedClosingDialog& operator= (FilmChangedClosingDialog const&) = delete; + int run () { return _dialog->ShowModal (); @@ -168,7 +170,8 @@ private: wxMessageDialog* _dialog; }; -class FilmChangedDuplicatingDialog : public boost::noncopyable + +class FilmChangedDuplicatingDialog { public: explicit FilmChangedDuplicatingDialog (string name) @@ -192,6 +195,9 @@ public: _dialog->Destroy (); } + FilmChangedDuplicatingDialog (FilmChangedDuplicatingDialog const&) = delete; + FilmChangedDuplicatingDialog& operator= (FilmChangedDuplicatingDialog const&) = delete; + int run () { return _dialog->ShowModal (); diff --git a/src/wx/content_widget.h b/src/wx/content_widget.h index 1a9c85dde..2a2bc9cf7 100644 --- a/src/wx/content_widget.h +++ b/src/wx/content_widget.h @@ -43,7 +43,7 @@ * @param V Data type of state as used by the view. */ template -class ContentWidget : public boost::noncopyable +class ContentWidget { public: /** @param parent Parent window. @@ -84,6 +84,9 @@ public: _button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ContentWidget::button_clicked, this)); } + ContentWidget (ContentWidget const&) = delete; + ContentWidget& operator= (ContentWidget const&) = delete; + /** @return the widget that we are wrapping */ T* wrapped () const { diff --git a/src/wx/timeline_view.cc b/src/wx/timeline_view.cc index fb23fa7b1..10d6dc5be 100644 --- a/src/wx/timeline_view.cc +++ b/src/wx/timeline_view.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2015 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,15 @@ */ + #include "timeline_view.h" #include "timeline.h" + using std::list; using namespace dcpomatic; + /** @class TimelineView * @brief Parent class for components of the timeline (e.g. a piece of content or an axis). */ @@ -33,22 +36,25 @@ TimelineView::TimelineView (Timeline& t) } + void -TimelineView::paint (wxGraphicsContext* g, list > overlaps) +TimelineView::paint (wxGraphicsContext* g, list> overlaps) { _last_paint_bbox = bbox (); do_paint (g, overlaps); } + void TimelineView::force_redraw () { - _timeline.force_redraw (_last_paint_bbox.extended (4)); - _timeline.force_redraw (bbox().extended (4)); + _timeline.force_redraw (_last_paint_bbox.extended(4)); + _timeline.force_redraw (bbox().extended(4)); } + int TimelineView::time_x (DCPTime t) const { - return t.seconds() * _timeline.pixels_per_second().get_value_or (0); + return t.seconds() * _timeline.pixels_per_second().get_value_or(0); } diff --git a/src/wx/timeline_view.h b/src/wx/timeline_view.h index bfd1de8b7..c40cf78ff 100644 --- a/src/wx/timeline_view.h +++ b/src/wx/timeline_view.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2015 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,25 +18,31 @@ */ + #ifndef DCPOMATIC_TIMELINE_VIEW_H #define DCPOMATIC_TIMELINE_VIEW_H + #include "lib/rect.h" #include "lib/dcpomatic_time.h" -#include + class wxGraphicsContext; class Timeline; + /** @class TimelineView * @brief Parent class for components of the timeline (e.g. a piece of content or an axis). */ -class TimelineView : public boost::noncopyable +class TimelineView { public: explicit TimelineView (Timeline& t); virtual ~TimelineView () {} + TimelineView (TimelineView const&) = delete; + TimelineView& operator= (TimelineView const&) = delete; + void paint (wxGraphicsContext* g, std::list > overlaps); void force_redraw (); @@ -53,6 +59,8 @@ private: dcpomatic::Rect _last_paint_bbox; }; -typedef std::vector > TimelineViewList; + +typedef std::vector> TimelineViewList; + #endif diff --git a/src/wx/video_view.cc b/src/wx/video_view.cc index 68a15e2e0..5f44c37d6 100644 --- a/src/wx/video_view.cc +++ b/src/wx/video_view.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019 Carl Hetherington + Copyright (C) 2019-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "video_view.h" #include "wx_util.h" #include "film_viewer.h" @@ -29,19 +30,15 @@ using std::pair; using std::shared_ptr; using boost::optional; + VideoView::VideoView (FilmViewer* viewer) : _viewer (viewer) , _state_timer ("viewer") - , _video_frame_rate (0) - , _eyes (Eyes::LEFT) - , _three_d (false) - , _dropped (0) - , _errored (0) - , _gets (0) { } + void VideoView::clear () { @@ -50,6 +47,7 @@ VideoView::clear () _player_video.second = dcpomatic::DCPTime (); } + /** Could be called from any thread. * @param non_blocking true to return false quickly if no video is available quickly. * @return FAIL if there's no frame, AGAIN if the method should be called again, or SUCCESS @@ -94,12 +92,14 @@ VideoView::get_next_frame (bool non_blocking) return SUCCESS; } + dcpomatic::DCPTime VideoView::one_video_frame () const { return dcpomatic::DCPTime::from_frames (1, video_frame_rate()); } + /** @return Time in ms until the next frame is due, or empty if nothing is due */ optional VideoView::time_until_next_frame () const @@ -117,6 +117,7 @@ VideoView::time_until_next_frame () const return (next.seconds() - time.seconds()) * 1000; } + void VideoView::start () { @@ -125,6 +126,7 @@ VideoView::start () _errored = 0; } + bool VideoView::reset_metadata (shared_ptr film, dcp::Size player_video_container_size) { diff --git a/src/wx/video_view.h b/src/wx/video_view.h index 3b596197e..d3a15d38c 100644 --- a/src/wx/video_view.h +++ b/src/wx/video_view.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2019 Carl Hetherington + Copyright (C) 2019-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,16 +18,18 @@ */ + #ifndef DCPOMATIC_VIDEO_VIEW_H #define DCPOMATIC_VIDEO_VIEW_H + #include "lib/dcpomatic_time.h" #include "lib/timer.h" #include "lib/types.h" #include "lib/exception_store.h" #include #include -#include + class Image; class wxWindow; @@ -35,12 +37,16 @@ class FilmViewer; class Player; class PlayerVideo; -class VideoView : public ExceptionStore, public boost::noncopyable + +class VideoView : public ExceptionStore { public: VideoView (FilmViewer* viewer); virtual ~VideoView () {} + VideoView (VideoView const&) = delete; + VideoView& operator= (VideoView const&) = delete; + /** @return the thing displaying the image */ virtual wxWindow* get () const = 0; /** Re-make and display the image from the current _player_video */ @@ -156,15 +162,16 @@ private: mutable boost::mutex _mutex; std::pair, dcpomatic::DCPTime> _player_video; - int _video_frame_rate; + int _video_frame_rate = 0; /** length of the film we are playing, or 0 if there is none */ dcpomatic::DCPTime _length; - Eyes _eyes; - bool _three_d; + Eyes _eyes = Eyes::LEFT; + bool _three_d = false; - int _dropped; - int _errored; - int _gets; + int _dropped = 0; + int _errored = 0; + int _gets = 0; }; + #endif -- 2.30.2