From d311043bf3c1e3e7f41b314f7ab7c91ed7e5aa7f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 3 Apr 2022 00:04:31 +0200 Subject: [PATCH] C++11 and whitespace cleanups. --- src/lib/active_text.cc | 22 +++-- src/lib/active_text.h | 4 + src/lib/atmos_metadata.cc | 3 +- src/lib/audio_content.cc | 2 +- src/lib/audio_delay.cc | 2 +- src/lib/audio_filter_graph.cc | 10 ++- src/lib/audio_ring_buffers.h | 2 +- src/lib/check_content_change_job.cc | 7 +- src/lib/cinema.h | 2 +- src/lib/config.cc | 42 +++++----- src/lib/config.h | 8 +- src/lib/content.cc | 2 - src/lib/content.h | 7 +- src/lib/cross.h | 2 +- src/lib/dcp_content.cc | 28 +++---- src/lib/dcp_decoder.cc | 120 +++++++++++++++------------ src/lib/dcp_examiner.cc | 26 +++--- src/lib/dcp_video.cc | 4 +- src/lib/dcp_video.h | 4 +- src/lib/decoder_factory.cc | 50 ++++++----- src/lib/dkdm_recipient.cc | 4 +- src/lib/ext.cc | 4 +- src/lib/ffmpeg.cc | 16 ++-- src/lib/ffmpeg_decoder.cc | 2 +- src/lib/ffmpeg_decoder.h | 2 +- src/lib/ffmpeg_encoder.h | 2 +- src/lib/film.cc | 4 +- src/lib/film.h | 6 +- src/lib/frame_rate_change.cc | 8 +- src/lib/image.cc | 41 ++++++++- src/lib/image_content.cc | 38 ++++++--- src/lib/image_decoder.cc | 12 +-- src/lib/image_examiner.cc | 14 ++-- src/lib/image_filename_sorter.cc | 9 +- src/lib/image_proxy.cc | 10 +-- src/lib/internet.cc | 8 +- src/lib/j2k_encoder.cc | 22 ++--- src/lib/j2k_image_proxy.cc | 14 ++-- src/lib/job.cc | 54 ++++++++++-- src/lib/json_server.cc | 19 +++-- src/lib/log.cc | 8 +- src/lib/mid_side_decoder.cc | 2 +- src/lib/nanomsg.cc | 6 +- src/lib/overlaps.cc | 2 +- src/lib/player.cc | 61 +++++++------- src/lib/player.h | 13 ++- src/lib/player_text.cc | 2 +- src/lib/player_video.cc | 19 ++++- src/lib/playlist.cc | 30 +++---- src/wx/recipient_dialog.cc | 16 ++-- src/wx/subtitle_appearance_dialog.cc | 7 +- src/wx/timecode.h | 4 + src/wx/timeline_content_view.cc | 6 +- src/wx/timeline_time_axis_view.h | 2 +- src/wx/wx_util.cc | 2 +- test/dcp_decoder_test.cc | 9 +- test/overlap_video_test.cc | 1 + test/reels_test.cc | 22 ++--- test/test.cc | 2 +- 59 files changed, 499 insertions(+), 351 deletions(-) diff --git a/src/lib/active_text.cc b/src/lib/active_text.cc index 1180ce7b0..1e0fd6adb 100644 --- a/src/lib/active_text.cc +++ b/src/lib/active_text.cc @@ -31,6 +31,7 @@ using std::shared_ptr; using boost::optional; using namespace dcpomatic; + /** Get the open captions that should be burnt into a given period. * @param period Period of interest. * @param always_burn_captions Always burn captions even if their content is not set to burn. @@ -42,9 +43,9 @@ ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const list ps; - for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) { + for (auto const& i: _data) { - shared_ptr caption = i->first.lock (); + auto caption = i.first.lock (); if (!caption) { continue; } @@ -54,9 +55,9 @@ ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const continue; } - for (auto j: i->second) { + for (auto j: i.second) { DCPTimePeriod test (j.from, j.to.get_value_or(DCPTime::max())); - optional overlap = period.overlap (test); + auto overlap = period.overlap (test); if (overlap && overlap->duration() > DCPTime(period.duration().get() / 2)) { ps.push_back (j.subs); } @@ -66,6 +67,7 @@ ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const return ps; } + /** Remove subtitles that finish before a given time from our list. * @param time Time to remove before. */ @@ -75,20 +77,21 @@ ActiveText::clear_before (DCPTime time) boost::mutex::scoped_lock lm (_mutex); Map updated; - for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) { + for (auto const& i: _data) { list as; - for (auto j: i->second) { + for (auto j: i.second) { if (!j.to || j.to.get() >= time) { as.push_back (j); } } if (!as.empty ()) { - updated[i->first] = as; + updated[i.first] = as; } } _data = updated; } + /** Add a new subtitle with a from time. * @param content Content that the subtitle is from. * @param ps Subtitles. @@ -105,6 +108,7 @@ ActiveText::add_from (weak_ptr content, PlayerText ps, DCPTim _data[content].push_back (Period (ps, from)); } + /** Add the to time for the last subtitle added from a piece of content. * @param content Content that the subtitle is from. * @param to To time for the last subtitle submitted to add_from for this content. @@ -126,6 +130,7 @@ ActiveText::add_to (weak_ptr content, DCPTime to) return make_pair (_data[content].back().subs, _data[content].back().from); } + /** @param content Some content. * @return true if we have any active subtitles from this content. */ @@ -134,7 +139,7 @@ ActiveText::have (weak_ptr content) const { boost::mutex::scoped_lock lm (_mutex); - Map::const_iterator i = _data.find(content); + auto i = _data.find(content); if (i == _data.end()) { return false; } @@ -142,6 +147,7 @@ ActiveText::have (weak_ptr content) const return !i->second.empty(); } + void ActiveText::clear () { diff --git a/src/lib/active_text.h b/src/lib/active_text.h index b54957b3f..d5ce4cb07 100644 --- a/src/lib/active_text.h +++ b/src/lib/active_text.h @@ -18,18 +18,22 @@ */ + /** @file src/lib/active_captions.h * @brief ActiveText class. */ + #include "dcpomatic_time.h" #include "player_text.h" #include #include #include + class TextContent; + /** @class ActiveText * @brief A class to maintain information on active subtitles for Player. */ diff --git a/src/lib/atmos_metadata.cc b/src/lib/atmos_metadata.cc index 0fe23f3b0..0ab04a825 100644 --- a/src/lib/atmos_metadata.cc +++ b/src/lib/atmos_metadata.cc @@ -23,6 +23,7 @@ #include +using std::make_shared; using std::shared_ptr; @@ -39,5 +40,5 @@ AtmosMetadata::AtmosMetadata (shared_ptr asset) shared_ptr AtmosMetadata::create (dcp::Fraction edit_rate) const { - return shared_ptr (new dcp::AtmosAsset(edit_rate, _first_frame, _max_channel_count, _max_object_count, _atmos_version)); + return make_shared(edit_rate, _first_frame, _max_channel_count, _max_object_count, _atmos_version); } diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index 748cbb7d0..f2510b494 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -98,7 +98,7 @@ AudioContent::AudioContent (Content* parent, cxml::ConstNodePtr node) } -AudioContent::AudioContent (Content* parent, vector > c) +AudioContent::AudioContent (Content* parent, vector> c) : ContentPart (parent) { auto ref = c[0]->audio; diff --git a/src/lib/audio_delay.cc b/src/lib/audio_delay.cc index 90214470c..d06d9e730 100644 --- a/src/lib/audio_delay.cc +++ b/src/lib/audio_delay.cc @@ -43,7 +43,7 @@ AudioDelay::run (shared_ptr in) /* You can't call this with varying channel counts */ DCPOMATIC_ASSERT (!_tail || in->channels() == _tail->channels()); - shared_ptr out (new AudioBuffers (in->channels(), in->frames())); + auto out = make_shared(in->channels(), in->frames()); if (in->frames() > _samples) { diff --git a/src/lib/audio_filter_graph.cc b/src/lib/audio_filter_graph.cc index fc43b5a34..95f6730cf 100644 --- a/src/lib/audio_filter_graph.cc +++ b/src/lib/audio_filter_graph.cc @@ -18,8 +18,9 @@ */ -#include "audio_filter_graph.h" + #include "audio_buffers.h" +#include "audio_filter_graph.h" #include "compose.hpp" extern "C" { #include @@ -31,9 +32,12 @@ extern "C" { #include "i18n.h" -using std::string; + using std::cout; +using std::make_shared; using std::shared_ptr; +using std::string; + AudioFilterGraph::AudioFilterGraph (int sample_rate, int channels) : _sample_rate (sample_rate) @@ -113,7 +117,7 @@ AudioFilterGraph::process (shared_ptr buffers) the constructor) so we need to create new buffers with some extra silent channels. */ - shared_ptr extended_buffers (new AudioBuffers (process_channels, buffers->frames())); + auto extended_buffers = make_shared(process_channels, buffers->frames()); for (int i = 0; i < buffers->channels(); ++i) { extended_buffers->copy_channel_from (buffers.get(), i, i); } diff --git a/src/lib/audio_ring_buffers.h b/src/lib/audio_ring_buffers.h index 4c90ed791..6fb84e0d7 100644 --- a/src/lib/audio_ring_buffers.h +++ b/src/lib/audio_ring_buffers.h @@ -48,7 +48,7 @@ public: private: mutable boost::mutex _mutex; - std::list, dcpomatic::DCPTime> > _buffers; + std::list, dcpomatic::DCPTime>> _buffers; int _used_in_head = 0; }; diff --git a/src/lib/check_content_change_job.cc b/src/lib/check_content_change_job.cc index e755a3945..16ef8d864 100644 --- a/src/lib/check_content_change_job.cc +++ b/src/lib/check_content_change_job.cc @@ -18,20 +18,23 @@ */ + #include "check_content_change_job.h" -#include "job_manager.h" -#include "examine_content_job.h" #include "content.h" +#include "examine_content_job.h" #include "film.h" +#include "job_manager.h" #include #include "i18n.h" + using std::cout; using std::make_shared; using std::shared_ptr; using std::string; + CheckContentChangeJob::CheckContentChangeJob (shared_ptr film) : Job (film) { diff --git a/src/lib/cinema.h b/src/lib/cinema.h index a89408f3f..c17454db9 100644 --- a/src/lib/cinema.h +++ b/src/lib/cinema.h @@ -76,7 +76,7 @@ public: return _utc_offset_minute; } - std::list > screens () const { + std::list> screens () const { return _screens; } diff --git a/src/lib/config.cc b/src/lib/config.cc index 6e654d5be..b6df1a88d 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -18,21 +18,22 @@ */ + +#include "cinema.h" +#include "colour_conversion.h" +#include "compose.hpp" #include "config.h" +#include "cross.h" +#include "crypto.h" +#include "dcp_content_type.h" +#include "dkdm_recipient.h" +#include "dkdm_wrapper.h" +#include "film.h" #include "filter.h" +#include "log.h" #include "ratio.h" #include "types.h" -#include "log.h" -#include "dcp_content_type.h" -#include "colour_conversion.h" -#include "cinema.h" #include "util.h" -#include "cross.h" -#include "film.h" -#include "dkdm_wrapper.h" -#include "compose.hpp" -#include "crypto.h" -#include "dkdm_recipient.h" #include "zipper.h" #include #include @@ -49,27 +50,30 @@ #include "i18n.h" -using std::vector; + using std::cout; +using std::dynamic_pointer_cast; using std::ifstream; -using std::string; using std::list; -using std::min; +using std::make_shared; using std::max; +using std::min; using std::remove; using std::shared_ptr; -using std::make_shared; -using boost::optional; -using std::dynamic_pointer_cast; +using std::string; +using std::vector; using boost::algorithm::trim; +using boost::optional; using dcp::raw_convert; + Config* Config::_instance = 0; int const Config::_current_version = 3; boost::signals2::signal Config::FailedToLoad; boost::signals2::signal Config::Warning; boost::signals2::signal Config::Bad; + /** Construct default configuration */ Config::Config () /* DKDMs are not considered a thing to reset on set_defaults() */ @@ -477,7 +481,7 @@ try _dkdms = dynamic_pointer_cast (DKDMBase::read (f.node_child("DKDMGroup"))); } else { /* Old-style: one or more DKDM nodes */ - _dkdms.reset (new DKDMGroup ("root")); + _dkdms = make_shared("root"); for (auto i: f.node_children("DKDM")) { _dkdms->add (DKDMBase::read (i)); } @@ -604,7 +608,7 @@ catch (...) { Config * Config::instance () { - if (_instance == 0) { + if (_instance == nullptr) { _instance = new Config; _instance->read (); } @@ -1264,7 +1268,7 @@ Config::read_dkdm_recipients (cxml::Document const & f) { _dkdm_recipients.clear (); for (auto i: f.node_children("DKDMRecipient")) { - _dkdm_recipients.push_back (shared_ptr(new DKDMRecipient(i))); + _dkdm_recipients.push_back (make_shared(i)); } } diff --git a/src/lib/config.h b/src/lib/config.h index 2ad201c35..29f401755 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -147,11 +147,11 @@ public: return _tms_password; } - std::list > cinemas () const { + std::list> cinemas () const { return _cinemas; } - std::list > dkdm_recipients () const { + std::list> dkdm_recipients () const { return _dkdm_recipients; } @@ -1222,8 +1222,8 @@ private: */ boost::optional _default_kdm_directory; bool _upload_after_make_dcp; - std::list > _cinemas; - std::list > _dkdm_recipients; + std::list> _cinemas; + std::list> _dkdm_recipients; std::string _mail_server; int _mail_port; EmailProtocol _mail_protocol; diff --git a/src/lib/content.cc b/src/lib/content.cc index 370139d12..a56891689 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -48,8 +48,6 @@ using std::cout; using std::list; using std::make_shared; -using std::max; -using std::pair; using std::shared_ptr; using std::string; using std::vector; diff --git a/src/lib/content.h b/src/lib/content.h index d17b0d0e5..7fad2ff79 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -27,10 +27,11 @@ #ifndef DCPOMATIC_CONTENT_H #define DCPOMATIC_CONTENT_H -#include "types.h" -#include "signaller.h" -#include "dcpomatic_time.h" + #include "change_signaller.h" +#include "dcpomatic_time.h" +#include "signaller.h" +#include "types.h" #include "user_property.h" #include #include diff --git a/src/lib/cross.h b/src/lib/cross.h index 99c6bc299..83cda4a04 100644 --- a/src/lib/cross.h +++ b/src/lib/cross.h @@ -43,7 +43,7 @@ extern void dcpomatic_sleep_seconds (int); extern void dcpomatic_sleep_milliseconds (int); extern std::string cpu_info (); extern void run_ffprobe (boost::filesystem::path, boost::filesystem::path); -extern std::list > mount_info (); +extern std::list> mount_info (); extern boost::filesystem::path openssl_path (); extern void make_foreground_application (); #ifdef DCPOMATIC_DISK diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index eb1c5f42c..6df0588e9 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2020 Carl Hetherington + Copyright (C) 2014-2022 Carl Hetherington This file is part of DCP-o-matic. @@ -20,19 +20,19 @@ #include "atmos_content.h" -#include "dcp_content.h" -#include "video_content.h" #include "audio_content.h" -#include "dcp_examiner.h" -#include "job.h" -#include "film.h" -#include "config.h" -#include "overlaps.h" #include "compose.hpp" +#include "config.h" +#include "dcp_content.h" #include "dcp_decoder.h" -#include "log.h" +#include "dcp_examiner.h" #include "dcpomatic_log.h" +#include "film.h" +#include "job.h" +#include "log.h" +#include "overlaps.h" #include "text_content.h" +#include "video_content.h" #include #include #include @@ -176,10 +176,10 @@ DCPContent::read_directory (boost::filesystem::path p) bool have_assetmap = false; bool have_metadata = false; - for (directory_iterator i(p); i != directory_iterator(); ++i) { - if (i->path().filename() == "ASSETMAP" || i->path().filename() == "ASSETMAP.xml") { + for (auto i: directory_iterator(p)) { + if (i.path().filename() == "ASSETMAP" || i.path().filename() == "ASSETMAP.xml") { have_assetmap = true; - } else if (i->path().filename() == "metadata.xml") { + } else if (i.path().filename() == "metadata.xml") { have_metadata = true; } } @@ -690,7 +690,7 @@ DCPContent::can_reference_audio (shared_ptr film, string& why_not) c { shared_ptr decoder; try { - decoder.reset (new DCPDecoder (film, shared_from_this(), false, film->tolerant(), shared_ptr())); + decoder = make_shared(film, shared_from_this(), false, film->tolerant(), shared_ptr()); } catch (dcp::ReadError &) { /* We couldn't read the DCP, so it's probably missing */ return false; @@ -725,7 +725,7 @@ DCPContent::can_reference_text (shared_ptr film, TextType type, stri { shared_ptr decoder; try { - decoder.reset (new DCPDecoder (film, shared_from_this(), false, film->tolerant(), shared_ptr())); + decoder = make_shared(film, shared_from_this(), false, film->tolerant(), shared_ptr()); } catch (dcp::ReadError &) { /* We couldn't read the DCP, so it's probably missing */ return false; diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 59b44ae97..85c5d3297 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2020 Carl Hetherington + Copyright (C) 2014-2022 Carl Hetherington This file is part of DCP-o-matic. @@ -18,69 +18,72 @@ */ + #include "atmos_decoder.h" -#include "dcp_decoder.h" -#include "dcp_content.h" #include "audio_content.h" -#include "video_decoder.h" #include "audio_decoder.h" -#include "j2k_image_proxy.h" -#include "text_decoder.h" -#include "ffmpeg_image_proxy.h" -#include "image.h" #include "config.h" +#include "dcp_content.h" +#include "dcp_decoder.h" #include "digester.h" +#include "ffmpeg_image_proxy.h" #include "frame_interval_checker.h" -#include +#include "image.h" +#include "j2k_image_proxy.h" +#include "text_decoder.h" +#include "video_decoder.h" #include -#include +#include +#include #include #include -#include -#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include #include +#include +#include +#include +#include #include -#include -#include #include #include "i18n.h" -using std::list; + using std::cout; +using std::dynamic_pointer_cast; +using std::list; +using std::make_shared; using std::map; +using std::shared_ptr; using std::string; using std::vector; -using std::shared_ptr; -using std::dynamic_pointer_cast; -using std::make_shared; using boost::optional; using namespace dcpomatic; -DCPDecoder::DCPDecoder (shared_ptr film, shared_ptr c, bool fast, bool tolerant, shared_ptr old) - : DCP (c, tolerant) + +DCPDecoder::DCPDecoder (shared_ptr film, shared_ptr content, bool fast, bool tolerant, shared_ptr old) + : DCP (content, tolerant) , Decoder (film) { - if (c->can_be_played()) { - if (c->video) { - video = make_shared(this, c); + if (content->can_be_played()) { + if (content->video) { + video = make_shared(this, content); } - if (c->audio) { - audio = make_shared(this, c->audio, fast); + if (content->audio) { + audio = make_shared(this, content->audio, fast); } - for (auto i: c->text) { + for (auto i: content->text) { /* XXX: this time here should be the time of the first subtitle, not 0 */ text.push_back (make_shared(this, i, ContentTime())); } - if (c->atmos) { - atmos = make_shared(this, c); + if (content->atmos) { + atmos = make_shared(this, content); } } @@ -92,7 +95,7 @@ DCPDecoder::DCPDecoder (shared_ptr film, shared_ptrlazy_digest() == _lazy_digest) { _reels = old->_reels; @@ -142,12 +145,12 @@ DCPDecoder::pass () return true; } - double const vfr = _dcp_content->active_video_frame_rate (film()); + auto 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); + auto const frame = _next.frames_round (vfr); - shared_ptr picture_asset = (*_reel)->main_picture()->asset(); + auto picture_asset = (*_reel)->main_picture()->asset(); DCPOMATIC_ASSERT (picture_asset); /* We must emit texts first as when we emit the video for this frame @@ -156,7 +159,7 @@ DCPDecoder::pass () pass_texts (_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().get_value_or(0); + auto const entry_point = (*_reel)->main_picture()->entry_point().get_value_or(0); if (_mono_reader) { video->emit ( film(), @@ -196,14 +199,14 @@ DCPDecoder::pass () } if (_sound_reader && (_decode_referenced || !_dcp_content->reference_audio())) { - int64_t const entry_point = (*_reel)->main_sound()->entry_point().get_value_or(0); - shared_ptr sf = _sound_reader->get_frame (entry_point + frame); - uint8_t const * from = sf->data (); + auto const entry_point = (*_reel)->main_sound()->entry_point().get_value_or(0); + auto sf = _sound_reader->get_frame (entry_point + frame); + auto from = sf->data (); int const channels = _dcp_content->audio->stream()->channels (); int const frames = sf->size() / (3 * channels); - shared_ptr data (new AudioBuffers (channels, frames)); - float** data_data = data->data(); + auto data = make_shared(channels, frames); + auto data_data = data->data(); for (int i = 0; i < frames; ++i) { for (int j = 0; j < channels; ++j) { data_data[j][i] = static_cast ((from[0] << 8) | (from[1] << 16) | (from[2] << 24)) / static_cast (INT_MAX - 256); @@ -216,7 +219,7 @@ DCPDecoder::pass () if (_atmos_reader) { DCPOMATIC_ASSERT (_atmos_metadata); - int64_t const entry_point = (*_reel)->atmos()->entry_point().get_value_or(0); + auto const entry_point = (*_reel)->atmos()->entry_point().get_value_or(0); atmos->emit (film(), _atmos_reader->get_frame(entry_point + frame), _offset + frame, *_atmos_metadata); } @@ -232,6 +235,7 @@ DCPDecoder::pass () return false; } + void DCPDecoder::pass_texts (ContentTime next, dcp::Size size) { @@ -268,9 +272,9 @@ DCPDecoder::pass_texts ( 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 (film()); + auto 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); + auto const frame = next.frames_round (vfr); if (_decode_referenced || !reference) { auto subs = asset->subtitles_during ( @@ -331,6 +335,7 @@ DCPDecoder::pass_texts ( } } + void DCPDecoder::next_reel () { @@ -339,6 +344,7 @@ DCPDecoder::next_reel () get_readers (); } + void DCPDecoder::get_readers () { @@ -351,9 +357,9 @@ DCPDecoder::get_readers () } if ((*_reel)->main_picture()) { - shared_ptr asset = (*_reel)->main_picture()->asset (); - shared_ptr mono = dynamic_pointer_cast (asset); - shared_ptr stereo = dynamic_pointer_cast (asset); + auto asset = (*_reel)->main_picture()->asset (); + auto mono = dynamic_pointer_cast (asset); + auto stereo = dynamic_pointer_cast (asset); DCPOMATIC_ASSERT (mono || stereo); if (mono) { _mono_reader = mono->start_read (); @@ -377,7 +383,7 @@ DCPDecoder::get_readers () } if ((*_reel)->atmos()) { - shared_ptr asset = (*_reel)->atmos()->asset(); + auto asset = (*_reel)->atmos()->asset(); _atmos_reader = asset->start_read(); _atmos_reader->set_check_hmac (false); _atmos_metadata = AtmosMetadata (asset); @@ -387,6 +393,7 @@ DCPDecoder::get_readers () } } + void DCPDecoder::seek (ContentTime t, bool accurate) { @@ -404,7 +411,7 @@ DCPDecoder::seek (ContentTime t, bool accurate) /* Pre-roll for subs */ - ContentTime pre = t - ContentTime::from_seconds (pre_roll_seconds); + auto pre = t - ContentTime::from_seconds (pre_roll_seconds); if (pre < ContentTime()) { pre = ContentTime (); } @@ -416,7 +423,7 @@ DCPDecoder::seek (ContentTime t, bool accurate) pre >= ContentTime::from_frames ((*_reel)->main_picture()->actual_duration(), _dcp_content->active_video_frame_rate(film())) ) { - ContentTime rd = ContentTime::from_frames ((*_reel)->main_picture()->actual_duration(), _dcp_content->active_video_frame_rate(film())); + auto rd = ContentTime::from_frames ((*_reel)->main_picture()->actual_duration(), _dcp_content->active_video_frame_rate(film())); pre -= rd; t -= rd; next_reel (); @@ -424,7 +431,7 @@ DCPDecoder::seek (ContentTime t, bool accurate) /* Pass texts in the pre-roll */ - double const vfr = _dcp_content->active_video_frame_rate (film()); + auto 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()); pre += ContentTime::from_frames (1, vfr); @@ -444,6 +451,7 @@ DCPDecoder::seek (ContentTime t, bool accurate) _next = t; } + void DCPDecoder::set_decode_referenced (bool r) { @@ -457,12 +465,14 @@ DCPDecoder::set_decode_referenced (bool r) } } + void DCPDecoder::set_forced_reduction (optional reduction) { _forced_reduction = reduction; } + string DCPDecoder::calculate_lazy_digest (shared_ptr c) const { @@ -480,6 +490,7 @@ DCPDecoder::calculate_lazy_digest (shared_ptr c) const return d.get (); } + ContentTime DCPDecoder::position () const { @@ -493,9 +504,8 @@ DCPDecoder::fonts () const vector data; for (auto i: _reels) { if (i->main_subtitle() && i->main_subtitle()->asset()) { - map fm = i->main_subtitle()->asset()->font_data(); - for (map::const_iterator j = fm.begin(); j != fm.end(); ++j) { - data.push_back (FontData(j->first, j->second)); + for (auto const& j: i->main_subtitle()->asset()->font_data()) { + data.push_back (FontData(j.first, j.second)); } } } diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc index 04711130b..cf4835c06 100644 --- a/src/lib/dcp_examiner.cc +++ b/src/lib/dcp_examiner.cc @@ -19,33 +19,33 @@ */ -#include "dcp_examiner.h" +#include "config.h" #include "dcp_content.h" +#include "dcp_examiner.h" #include "dcpomatic_log.h" #include "exceptions.h" #include "image.h" -#include "config.h" #include "util.h" +#include #include #include -#include -#include -#include -#include #include #include #include -#include -#include -#include -#include -#include -#include +#include #include -#include #include #include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include #include "i18n.h" diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc index 3a85a5ac6..4a41e17b9 100644 --- a/src/lib/dcp_video.cc +++ b/src/lib/dcp_video.cc @@ -125,7 +125,7 @@ DCPVideo::convert_to_xyz (shared_ptr frame, dcp::NoteHandler * @return Encoded data. */ ArrayData -DCPVideo::encode_locally () +DCPVideo::encode_locally () const { auto const comment = Config::instance()->dcp_j2k_comment(); @@ -204,7 +204,7 @@ DCPVideo::encode_locally () * @return Encoded data. */ ArrayData -DCPVideo::encode_remotely (EncodeServerDescription serv, int timeout) +DCPVideo::encode_remotely (EncodeServerDescription serv, int timeout) const { boost::asio::io_service io_service; boost::asio::ip::tcp::resolver resolver (io_service); diff --git a/src/lib/dcp_video.h b/src/lib/dcp_video.h index 0bb583c57..862b787d2 100644 --- a/src/lib/dcp_video.h +++ b/src/lib/dcp_video.h @@ -48,8 +48,8 @@ public: DCPVideo (DCPVideo const&) = delete; DCPVideo& operator= (DCPVideo const&) = delete; - dcp::ArrayData encode_locally (); - dcp::ArrayData encode_remotely (EncodeServerDescription, int timeout = 30); + dcp::ArrayData encode_locally () const; + dcp::ArrayData encode_remotely (EncodeServerDescription, int timeout = 30) const; int index () const { return _index; diff --git a/src/lib/decoder_factory.cc b/src/lib/decoder_factory.cc index 1acef6f4f..1bda93c94 100644 --- a/src/lib/decoder_factory.cc +++ b/src/lib/decoder_factory.cc @@ -18,32 +18,36 @@ */ + #include "atmos_mxf_content.h" #include "atmos_mxf_decoder.h" -#include "ffmpeg_content.h" -#include "ffmpeg_decoder.h" #include "dcp_content.h" #include "dcp_decoder.h" +#include "dcp_subtitle_content.h" +#include "dcp_subtitle_decoder.h" +#include "ffmpeg_content.h" +#include "ffmpeg_decoder.h" #include "image_content.h" #include "image_decoder.h" #include "string_text_file_content.h" #include "string_text_file_decoder.h" -#include "dcp_subtitle_content.h" -#include "dcp_subtitle_decoder.h" +#include "timer.h" #include "video_mxf_content.h" #include "video_mxf_decoder.h" -#include "timer.h" + +using std::dynamic_pointer_cast; using std::list; +using std::make_shared; using std::shared_ptr; -using std::dynamic_pointer_cast; + template shared_ptr maybe_cast (shared_ptr d) { if (!d) { - return shared_ptr (); + return {}; } return dynamic_pointer_cast (d); } @@ -55,45 +59,45 @@ maybe_cast (shared_ptr d) shared_ptr decoder_factory (shared_ptr film, shared_ptr content, bool fast, bool tolerant, shared_ptr old_decoder) { - shared_ptr fc = dynamic_pointer_cast (content); + auto fc = dynamic_pointer_cast (content); if (fc) { - return shared_ptr (new FFmpegDecoder(film, fc, fast)); + return make_shared(film, fc, fast); } - shared_ptr dc = dynamic_pointer_cast (content); + auto dc = dynamic_pointer_cast (content); if (dc) { try { - return shared_ptr (new DCPDecoder(film, dc, fast, tolerant, maybe_cast(old_decoder))); + return make_shared(film, dc, fast, tolerant, maybe_cast(old_decoder)); } catch (KDMError& e) { /* This will be found and reported to the user when the content is examined */ - return shared_ptr(); + return {}; } } - shared_ptr ic = dynamic_pointer_cast (content); + auto ic = dynamic_pointer_cast (content); if (ic) { - return shared_ptr (new ImageDecoder(film, ic)); + return make_shared(film, ic); } - shared_ptr rc = dynamic_pointer_cast (content); + auto rc = dynamic_pointer_cast (content); if (rc) { - return shared_ptr (new StringTextFileDecoder(film, rc)); + return make_shared(film, rc); } - shared_ptr dsc = dynamic_pointer_cast (content); + auto dsc = dynamic_pointer_cast (content); if (dsc) { - return shared_ptr (new DCPSubtitleDecoder(film, dsc)); + return make_shared(film, dsc); } - shared_ptr vmc = dynamic_pointer_cast (content); + auto vmc = dynamic_pointer_cast (content); if (vmc) { - return shared_ptr (new VideoMXFDecoder(film, vmc)); + return make_shared(film, vmc); } - shared_ptr amc = dynamic_pointer_cast (content); + auto amc = dynamic_pointer_cast (content); if (amc) { - return shared_ptr (new AtmosMXFDecoder(film, amc)); + return make_shared(film, amc); } - return shared_ptr (); + return {}; } diff --git a/src/lib/dkdm_recipient.cc b/src/lib/dkdm_recipient.cc index b15487c8a..ff19aa265 100644 --- a/src/lib/dkdm_recipient.cc +++ b/src/lib/dkdm_recipient.cc @@ -20,8 +20,8 @@ #include "dkdm_recipient.h" -#include "kdm_with_metadata.h" #include "film.h" +#include "kdm_with_metadata.h" #include @@ -68,7 +68,7 @@ kdm_for_dkdm_recipient ( ) { if (!recipient->recipient) { - return KDMWithMetadataPtr(); + return {}; } dcp::LocalTime const begin(valid_from, recipient->utc_offset_hour, recipient->utc_offset_minute); diff --git a/src/lib/ext.cc b/src/lib/ext.cc index ec34f1472..af5229f72 100644 --- a/src/lib/ext.cc +++ b/src/lib/ext.cc @@ -248,8 +248,8 @@ copy (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_ } set_timestamps_to_now (cr); - for (directory_iterator i = directory_iterator(from); i != directory_iterator(); ++i) { - copy (i->path(), cr, total_remaining, total, copied_files, nanomsg); + for (auto i: directory_iterator(from)) { + copy (i.path(), cr, total_remaining, total, copied_files, nanomsg); } } else { string const write_digest = write (from, cr, total_remaining, total, nanomsg); diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 0f63ea172..77717a38f 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -19,18 +19,18 @@ */ +#include "compose.hpp" +#include "config.h" +#include "dcpomatic_log.h" +#include "digester.h" +#include "exceptions.h" #include "ffmpeg.h" +#include "ffmpeg_audio_stream.h" #include "ffmpeg_content.h" +#include "ffmpeg_subtitle_stream.h" #include "film.h" -#include "exceptions.h" -#include "util.h" #include "log.h" -#include "dcpomatic_log.h" -#include "ffmpeg_subtitle_stream.h" -#include "ffmpeg_audio_stream.h" -#include "digester.h" -#include "compose.hpp" -#include "config.h" +#include "util.h" #include extern "C" { #include diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index d49878217..30a4b1823 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -144,7 +144,7 @@ FFmpegDecoder::flush () auto const f = full_length.frames_round (vfr); auto v = video->position(film()).get_value_or(ContentTime()).frames_round(vfr) + 1; while (v < f) { - video->emit (film(), shared_ptr (new RawImageProxy (_black_image)), v); + video->emit (film(), make_shared(_black_image), v); ++v; } } diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index 29e0d22e6..b4b0faa3b 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -73,7 +73,7 @@ private: void maybe_add_subtitle (); - std::list > _filter_graphs; + std::list> _filter_graphs; boost::mutex _filter_graphs_mutex; dcpomatic::ContentTime _pts_offset; diff --git a/src/lib/ffmpeg_encoder.h b/src/lib/ffmpeg_encoder.h index f450c8022..393a6d72e 100644 --- a/src/lib/ffmpeg_encoder.h +++ b/src/lib/ffmpeg_encoder.h @@ -73,7 +73,7 @@ private: void audio (std::shared_ptr); private: - std::map > _encoders; + std::map> _encoders; }; int _output_audio_channels; diff --git a/src/lib/film.cc b/src/lib/film.cc index d9ed8c530..718d6c61d 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -74,12 +74,12 @@ #include #include #include -#include -#include #include #include #include +#include #include +#include #include "i18n.h" diff --git a/src/lib/film.h b/src/lib/film.h index 55bbb4069..7103f6271 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -18,14 +18,17 @@ */ + /** @file src/film.h * @brief A representation of some audio and video content, and details of * how they should be presented in a DCP. */ + #ifndef DCPOMATIC_FILM_H #define DCPOMATIC_FILM_H + #include "change_signaller.h" #include "dcp_text_track.h" #include "frame_rate_change.h" @@ -45,6 +48,7 @@ #include #include + namespace xmlpp { class Document; } @@ -66,6 +70,7 @@ struct isdcf_name_test; struct recover_test_2d_encrypted; struct atmos_encrypted_passthrough_test; + class InfoFileHandle { public: @@ -413,7 +418,6 @@ public: return _isdcf_date; } - /* SET */ void set_directory (boost::filesystem::path); diff --git a/src/lib/frame_rate_change.cc b/src/lib/frame_rate_change.cc index a1ff2ae65..99424a9c1 100644 --- a/src/lib/frame_rate_change.cc +++ b/src/lib/frame_rate_change.cc @@ -19,18 +19,18 @@ */ -#include "frame_rate_change.h" -#include "types.h" +#include "compose.hpp" #include "content.h" #include "film.h" -#include "compose.hpp" +#include "frame_rate_change.h" +#include "types.h" #include #include "i18n.h" -using std::string; using std::shared_ptr; +using std::string; FrameRateChange::FrameRateChange () diff --git a/src/lib/image.cc b/src/lib/image.cc index a4e04bb62..1adcabc06 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -107,6 +107,7 @@ Image::horizontal_factor (int n) const return lrintf(powf(2.0f, d->log2_chroma_w)); } + /** @param n Component index. * @return Number of samples (i.e. pixels, unless sub-sampled) in each direction for this component. */ @@ -119,19 +120,20 @@ Image::sample_size (int n) const ); } + /** @return Number of planes */ int Image::planes () const { + if (_pixel_format == AV_PIX_FMT_PAL8) { + return 2; + } + auto d = av_pix_fmt_desc_get(_pixel_format); if (!d) { throw PixelFormatError ("planes()", _pixel_format); } - if (_pixel_format == AV_PIX_FMT_PAL8) { - return 2; - } - if ((d->flags & AV_PIX_FMT_FLAG_PLANAR) == 0) { return 1; } @@ -309,12 +311,14 @@ Image::crop_scale_window ( return out; } + shared_ptr Image::convert_pixel_format (dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_format, Alignment out_alignment, bool fast) const { return scale(size(), yuv_to_rgb, out_format, out_alignment, fast); } + /** @param out_size Size to scale to. * @param yuv_to_rgb YUVToRGB transform transform to use, if required. * @param out_format Output pixel format. @@ -373,6 +377,7 @@ Image::scale (dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_fo return scaled; } + /** Blacken a YUV image whose bits per pixel is rounded up to 16 */ void Image::yuv_16_black (uint16_t v, bool alpha) @@ -395,12 +400,14 @@ Image::yuv_16_black (uint16_t v, bool alpha) } } + uint16_t Image::swap_16 (uint16_t v) { return ((v >> 8) & 0xff) | ((v & 0xff) << 8); } + void Image::make_part_black (int const start, int const width) { @@ -471,6 +478,7 @@ Image::make_part_black (int const start, int const width) } } + void Image::make_black () { @@ -586,6 +594,7 @@ Image::make_black () } } + void Image::make_transparent () { @@ -596,6 +605,7 @@ Image::make_transparent () memset (data()[0], 0, sample_size(0).height * stride()[0]); } + void Image::alpha_blend (shared_ptr other, Position position) { @@ -842,6 +852,7 @@ Image::alpha_blend (shared_ptr other, Position position) } } + void Image::copy (shared_ptr other, Position position) { @@ -857,6 +868,7 @@ Image::copy (shared_ptr other, Position position) } } + void Image::read_from_socket (shared_ptr socket) { @@ -870,6 +882,7 @@ Image::read_from_socket (shared_ptr socket) } } + void Image::write_to_socket (shared_ptr socket) const { @@ -883,6 +896,7 @@ Image::write_to_socket (shared_ptr socket) const } } + float Image::bytes_per_pixel (int c) const { @@ -929,6 +943,7 @@ Image::bytes_per_pixel (int c) const return bpp[c]; } + /** Construct a Image of a given size and format, allocating memory * as required. * @@ -1008,6 +1023,7 @@ Image::allocate () } } + Image::Image (Image const & other) : std::enable_shared_from_this(other) , _size (other._size) @@ -1028,6 +1044,7 @@ Image::Image (Image const & other) } } + Image::Image (AVFrame const * frame, Alignment alignment) : _size (frame->width, frame->height) , _pixel_format (static_cast(frame->format)) @@ -1050,6 +1067,7 @@ Image::Image (AVFrame const * frame, Alignment alignment) } } + Image::Image (shared_ptr other, Alignment alignment) : _size (other->_size) , _pixel_format (other->_pixel_format) @@ -1070,6 +1088,7 @@ Image::Image (shared_ptr other, Alignment alignment) } } + Image& Image::operator= (Image const & other) { @@ -1082,6 +1101,7 @@ Image::operator= (Image const & other) return *this; } + void Image::swap (Image & other) { @@ -1097,6 +1117,7 @@ Image::swap (Image & other) std::swap (_alignment, other._alignment); } + Image::~Image () { for (int i = 0; i < planes(); ++i) { @@ -1108,30 +1129,35 @@ Image::~Image () av_free (_stride); } + uint8_t * const * Image::data () const { return _data; } + int const * Image::line_size () const { return _line_size; } + int const * Image::stride () const { return _stride; } + dcp::Size Image::size () const { return _size; } + Image::Alignment Image::alignment () const { @@ -1194,6 +1220,7 @@ operator== (Image const & a, Image const & b) return true; } + /** Fade the image. * @param f Amount to fade by; 0 is black, 1 is no fade. */ @@ -1336,6 +1363,7 @@ Image::memory_used () const return m; } + class Memory { public: @@ -1353,6 +1381,7 @@ public: size_t size; }; + static void png_write_data (png_structp png_ptr, png_bytep data, png_size_t length) { @@ -1373,24 +1402,28 @@ png_write_data (png_structp png_ptr, png_bytep data, png_size_t length) mem->size += length; } + static void png_flush (png_structp) { } + static void png_error_fn (png_structp png_ptr, char const * message) { reinterpret_cast(png_get_error_ptr(png_ptr))->png_error (message); } + void Image::png_error (char const * message) { throw EncodeError (String::compose ("Error during PNG write: %1", message)); } + dcp::ArrayData Image::as_png () const { diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index 517d6792f..9464babd4 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -18,31 +18,35 @@ */ -#include "image_content.h" -#include "video_content.h" -#include "image_examiner.h" + #include "compose.hpp" +#include "exceptions.h" #include "film.h" -#include "job.h" #include "frame_rate_change.h" -#include "exceptions.h" +#include "image_content.h" +#include "image_examiner.h" #include "image_filename_sorter.h" +#include "job.h" +#include "video_content.h" #include #include #include #include "i18n.h" -using std::string; + using std::cout; using std::list; -using std::vector; +using std::make_shared; using std::shared_ptr; +using std::string; +using std::vector; using namespace dcpomatic; + ImageContent::ImageContent (boost::filesystem::path p) { - video.reset (new VideoContent (this)); + video = make_shared(this); if (boost::filesystem::is_regular_file (p) && valid_image_file (p)) { add_path (p); @@ -60,6 +64,7 @@ ImageContent::ImageContent (cxml::ConstNodePtr node, int version) video = VideoContent::from_xml (this, node, version); } + string ImageContent::summary () const { @@ -74,6 +79,7 @@ ImageContent::summary () const return s; } + string ImageContent::technical_summary () const { @@ -89,6 +95,7 @@ ImageContent::technical_summary () const return s; } + void ImageContent::as_xml (xmlpp::Node* node, bool with_paths) const { @@ -100,6 +107,7 @@ ImageContent::as_xml (xmlpp::Node* node, bool with_paths) const } } + void ImageContent::examine (shared_ptr film, shared_ptr job) { @@ -107,9 +115,9 @@ ImageContent::examine (shared_ptr film, shared_ptr job) job->sub (_("Scanning image files")); vector paths; int n = 0; - for (boost::filesystem::directory_iterator i(*_path_to_scan); i != boost::filesystem::directory_iterator(); ++i) { - if (boost::filesystem::is_regular_file (i->path()) && valid_image_file (i->path())) { - paths.push_back (i->path()); + for (auto i: boost::filesystem::directory_iterator(*_path_to_scan)) { + if (boost::filesystem::is_regular_file(i.path()) && valid_image_file (i.path())) { + paths.push_back (i.path()); } ++n; if ((n % 1000) == 0) { @@ -127,11 +135,12 @@ ImageContent::examine (shared_ptr film, shared_ptr job) Content::examine (film, job); - shared_ptr examiner (new ImageExaminer (film, shared_from_this(), job)); + auto examiner = make_shared(film, shared_from_this(), job); video->take_from_examiner (examiner); set_default_colour_conversion (); } + DCPTime ImageContent::full_length (shared_ptr film) const { @@ -139,12 +148,14 @@ ImageContent::full_length (shared_ptr film) const return DCPTime::from_frames (llrint(video->length_after_3d_combine() * frc.factor()), film->video_frame_rate()); } + DCPTime ImageContent::approximate_length () const { return DCPTime::from_frames (video->length_after_3d_combine(), 24); } + string ImageContent::identifier () const { @@ -153,12 +164,14 @@ ImageContent::identifier () const return buffer; } + bool ImageContent::still () const { return number_of_paths() == 1; } + void ImageContent::set_default_colour_conversion () { @@ -181,6 +194,7 @@ ImageContent::set_default_colour_conversion () } } + void ImageContent::add_properties (shared_ptr film, list& p) const { diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index e1106f86d..59dc4e873 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -19,16 +19,16 @@ */ +#include "exceptions.h" +#include "ffmpeg_image_proxy.h" +#include "film.h" +#include "frame_interval_checker.h" +#include "image.h" #include "image_content.h" #include "image_decoder.h" -#include "video_decoder.h" -#include "image.h" -#include "ffmpeg_image_proxy.h" #include "j2k_image_proxy.h" -#include "film.h" -#include "exceptions.h" #include "video_content.h" -#include "frame_interval_checker.h" +#include "video_decoder.h" #include #include diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc index ae12d7adb..2235c2e69 100644 --- a/src/lib/image_examiner.cc +++ b/src/lib/image_examiner.cc @@ -19,16 +19,16 @@ */ -#include "image_content.h" -#include "image_examiner.h" -#include "film.h" -#include "job.h" -#include "exceptions.h" +#include "compose.hpp" #include "config.h" #include "cross.h" -#include "compose.hpp" +#include "exceptions.h" #include "ffmpeg_image_proxy.h" +#include "film.h" #include "image.h" +#include "image_content.h" +#include "image_examiner.h" +#include "job.h" #include #include #include @@ -39,8 +39,8 @@ using std::cout; using std::list; -using std::sort; using std::shared_ptr; +using std::sort; using boost::optional; diff --git a/src/lib/image_filename_sorter.cc b/src/lib/image_filename_sorter.cc index ea5f46da6..ab0d298fc 100644 --- a/src/lib/image_filename_sorter.cc +++ b/src/lib/image_filename_sorter.cc @@ -18,22 +18,25 @@ */ + #include "image_filename_sorter.h" #include #include #include #include + using std::list; using std::string; using dcp::locale_convert; using boost::optional; + bool ImageFilenameSorter::operator() (boost::filesystem::path a, boost::filesystem::path b) { - string an = extract_numbers (a); - string bn = extract_numbers (b); + auto an = extract_numbers (a); + auto bn = extract_numbers (b); int const anl = an.length (); int const bnl = bn.length (); @@ -51,7 +54,7 @@ string ImageFilenameSorter::extract_numbers (boost::filesystem::path p) { string numbers; - string const ps = p.leaf().string(); + auto const ps = p.leaf().string(); for (size_t i = 0; i < ps.size(); ++i) { if (isdigit (ps[i])) { numbers += ps[i]; diff --git a/src/lib/image_proxy.cc b/src/lib/image_proxy.cc index 9e456c941..c426e796f 100644 --- a/src/lib/image_proxy.cc +++ b/src/lib/image_proxy.cc @@ -19,13 +19,13 @@ */ -#include "image_proxy.h" -#include "raw_image_proxy.h" +#include "cross.h" +#include "exceptions.h" #include "ffmpeg_image_proxy.h" -#include "j2k_image_proxy.h" #include "image.h" -#include "exceptions.h" -#include "cross.h" +#include "image_proxy.h" +#include "j2k_image_proxy.h" +#include "raw_image_proxy.h" #include #include #include diff --git a/src/lib/internet.cc b/src/lib/internet.cc index 121d3524c..c0c8232ee 100644 --- a/src/lib/internet.cc +++ b/src/lib/internet.cc @@ -19,10 +19,10 @@ */ -#include "scoped_temporary.h" #include "compose.hpp" -#include "exceptions.h" #include "cross.h" +#include "exceptions.h" +#include "scoped_temporary.h" #include "util.h" #include #include @@ -37,8 +37,8 @@ using std::function; using std::list; using std::string; -using boost::optional; using boost::algorithm::trim; +using boost::optional; static size_t @@ -66,7 +66,7 @@ ls_url (string url) auto const cr = curl_easy_perform (curl); if (cr != CURLE_OK) { - return list(); + return {}; } list result; diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index 5dee5ca35..55961fc6b 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -24,32 +24,32 @@ */ -#include "j2k_encoder.h" -#include "util.h" -#include "film.h" -#include "log.h" -#include "dcpomatic_log.h" +#include "compose.hpp" #include "config.h" -#include "dcp_video.h" #include "cross.h" -#include "writer.h" +#include "dcp_video.h" +#include "dcpomatic_log.h" +#include "encode_server_description.h" #include "encode_server_finder.h" +#include "film.h" +#include "j2k_encoder.h" +#include "log.h" #include "player.h" #include "player_video.h" -#include "encode_server_description.h" -#include "compose.hpp" +#include "util.h" +#include "writer.h" #include #include #include "i18n.h" -using std::list; using std::cout; using std::exception; +using std::list; +using std::make_shared; using std::shared_ptr; using std::weak_ptr; -using std::make_shared; using boost::optional; using dcp::Data; using namespace dcpomatic; diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc index 00d3cf2ef..67083e655 100644 --- a/src/lib/j2k_image_proxy.cc +++ b/src/lib/j2k_image_proxy.cc @@ -19,18 +19,18 @@ */ -#include "j2k_image_proxy.h" +#include "dcpomatic_assert.h" #include "dcpomatic_socket.h" #include "image.h" -#include "dcpomatic_assert.h" +#include "j2k_image_proxy.h" #include "warnings.h" -#include -#include -#include -#include #include -#include #include +#include +#include +#include +#include +#include #include DCPOMATIC_DISABLE_WARNINGS #include diff --git a/src/lib/job.cc b/src/lib/job.cc index 4c8199bdc..50dcc336e 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -18,35 +18,39 @@ */ + /** @file src/job.cc * @brief A parent class to represent long-running tasks which are run in their own thread. */ -#include "job.h" -#include "util.h" + +#include "compose.hpp" #include "cross.h" +#include "dcpomatic_log.h" #include "exceptions.h" #include "film.h" +#include "job.h" #include "log.h" -#include "dcpomatic_log.h" -#include "compose.hpp" +#include "util.h" #include #include -#include -#include #include +#include +#include #include #include "i18n.h" -using std::string; -using std::list; + using std::cout; +using std::function; +using std::list; using std::shared_ptr; +using std::string; using boost::optional; -using std::function; using namespace dcpomatic; + /** @param film Associated film, or 0 */ Job::Job (shared_ptr film) : _film (film) @@ -59,6 +63,7 @@ Job::Job (shared_ptr film) } + Job::~Job () { #ifdef DCPOMATIC_DEBUG @@ -67,6 +72,7 @@ Job::~Job () #endif } + void Job::stop_thread () { @@ -78,6 +84,7 @@ Job::stop_thread () } catch (...) {} } + /** Start the job in a separate thread, returning immediately */ void Job::start () @@ -91,6 +98,7 @@ Job::start () #endif } + /** A wrapper for the ::run() method to catch exceptions */ void Job::run_wrapper () @@ -251,6 +259,7 @@ Job::run_wrapper () } } + /** @return true if this job is new (ie has not started running) */ bool Job::is_new () const @@ -259,6 +268,7 @@ Job::is_new () const return _state == NEW; } + /** @return true if the job is running */ bool Job::running () const @@ -267,6 +277,7 @@ Job::running () const return _state == RUNNING; } + /** @return true if the job has finished (either successfully or unsuccessfully) */ bool Job::finished () const @@ -275,6 +286,7 @@ Job::finished () const return _state == FINISHED_OK || _state == FINISHED_ERROR || _state == FINISHED_CANCELLED; } + /** @return true if the job has finished successfully */ bool Job::finished_ok () const @@ -283,6 +295,7 @@ Job::finished_ok () const return _state == FINISHED_OK; } + /** @return true if the job has finished unsuccessfully */ bool Job::finished_in_error () const @@ -291,6 +304,7 @@ Job::finished_in_error () const return _state == FINISHED_ERROR; } + bool Job::finished_cancelled () const { @@ -298,6 +312,7 @@ Job::finished_cancelled () const return _state == FINISHED_CANCELLED; } + bool Job::paused_by_user () const { @@ -305,6 +320,7 @@ Job::paused_by_user () const return _state == PAUSED_BY_USER; } + bool Job::paused_by_priority () const { @@ -312,6 +328,7 @@ Job::paused_by_priority () const return _state == PAUSED_BY_PRIORITY; } + /** Set the state of this job. * @param s New state. */ @@ -337,6 +354,7 @@ Job::set_state (State s) } } + /** @return DCPTime (in seconds) that this sub-job has been running */ int Job::elapsed_sub_time () const @@ -348,6 +366,7 @@ Job::elapsed_sub_time () const return time (0) - _sub_start_time; } + /** Check to see if this job has been interrupted or paused */ void Job::check_for_interruption_or_pause () @@ -403,6 +422,7 @@ Job::set_progress (float p, bool force) set_progress_common (p); } + void Job::set_progress_common (optional p) { @@ -414,6 +434,7 @@ Job::set_progress_common (optional p) emit (boost::bind (boost::ref (Progress))); } + /** @return fractional progress of the current sub-job, if known */ optional Job::progress () const @@ -422,6 +443,7 @@ Job::progress () const return _progress; } + void Job::sub (string n) { @@ -435,6 +457,7 @@ Job::sub (string n) _sub_start_time = time (0); } + string Job::error_details () const { @@ -442,6 +465,7 @@ Job::error_details () const return _error_details; } + /** @return A summary of any error that the job has generated */ string Job::error_summary () const @@ -450,6 +474,7 @@ Job::error_summary () const return _error_summary; } + /** Set the current error string. * @param s New error string. * @param d New error detail string. @@ -466,6 +491,7 @@ Job::set_error (string s, string d) _error_details = d; } + /** Say that this job's progress will be unknown until further notice */ void Job::set_progress_unknown () @@ -474,6 +500,7 @@ Job::set_progress_unknown () set_progress_common (optional ()); } + /** @return Human-readable status of this job */ string Job::status () const @@ -523,6 +550,7 @@ Job::status () const return s; } + string Job::json_status () const { @@ -547,6 +575,7 @@ Job::json_status () const return ""; } + /** @return An estimate of the remaining time for this sub-job, in seconds */ int Job::remaining_time () const @@ -558,6 +587,7 @@ Job::remaining_time () const return elapsed_sub_time() / progress().get() - elapsed_sub_time(); } + void Job::cancel () { @@ -573,6 +603,7 @@ Job::cancel () _thread.join (); } + /** @return true if the job was paused, false if it was not running */ bool Job::pause_by_user () @@ -596,6 +627,7 @@ Job::pause_by_user () return paused; } + void Job::pause_by_priority () { @@ -605,6 +637,7 @@ Job::pause_by_priority () } } + void Job::resume () { @@ -614,6 +647,7 @@ Job::resume () } } + void Job::when_finished (boost::signals2::connection& connection, function finished) { @@ -625,6 +659,7 @@ Job::when_finished (boost::signals2::connection& connection, function fi } } + optional Job::message () const { @@ -632,6 +667,7 @@ Job::message () const return _message; } + void Job::set_message (string m) { diff --git a/src/lib/json_server.cc b/src/lib/json_server.cc index dd56b3124..8c626ad1f 100644 --- a/src/lib/json_server.cc +++ b/src/lib/json_server.cc @@ -19,12 +19,12 @@ */ -#include "json_server.h" -#include "job_manager.h" -#include "job.h" -#include "util.h" #include "film.h" +#include "job.h" +#include "job_manager.h" +#include "json_server.h" #include "transcode_job.h" +#include "util.h" #include #include #include @@ -32,14 +32,15 @@ #include -using std::string; using std::cout; -using std::map; +using std::dynamic_pointer_cast; using std::list; -using boost::thread; +using std::make_shared; +using std::map; using std::shared_ptr; -using std::dynamic_pointer_cast; +using std::string; using boost::asio::ip::tcp; +using boost::thread; using dcp::raw_convert; @@ -74,7 +75,7 @@ try tcp::acceptor a (io_service, tcp::endpoint (tcp::v4 (), port)); while (true) { try { - shared_ptr s (new tcp::socket (io_service)); + auto s = make_shared(io_service); a.accept (*s); handle (s); } diff --git a/src/lib/log.cc b/src/lib/log.cc index 97b649893..aae492faf 100644 --- a/src/lib/log.cc +++ b/src/lib/log.cc @@ -24,9 +24,9 @@ */ -#include "log.h" -#include "cross.h" #include "config.h" +#include "cross.h" +#include "log.h" #include "string_log_entry.h" #include #include @@ -34,10 +34,10 @@ #include "i18n.h" -using std::string; using std::cout; -using std::shared_ptr; using std::make_shared; +using std::shared_ptr; +using std::string; Log::Log () diff --git a/src/lib/mid_side_decoder.cc b/src/lib/mid_side_decoder.cc index 09b528c81..d3d85622c 100644 --- a/src/lib/mid_side_decoder.cc +++ b/src/lib/mid_side_decoder.cc @@ -19,9 +19,9 @@ */ -#include "mid_side_decoder.h" #include "audio_buffers.h" #include "audio_mapping.h" +#include "mid_side_decoder.h" #include "i18n.h" diff --git a/src/lib/nanomsg.cc b/src/lib/nanomsg.cc index 61e6c08ce..8061e2f84 100644 --- a/src/lib/nanomsg.cc +++ b/src/lib/nanomsg.cc @@ -19,17 +19,17 @@ */ -#include "nanomsg.h" #include "dcpomatic_log.h" #include "exceptions.h" +#include "nanomsg.h" #include #include -#include #include +#include -using std::string; using std::runtime_error; +using std::string; using boost::optional; diff --git a/src/lib/overlaps.cc b/src/lib/overlaps.cc index 536629b33..7a541a7c2 100644 --- a/src/lib/overlaps.cc +++ b/src/lib/overlaps.cc @@ -19,9 +19,9 @@ */ +#include "content.h" #include "overlaps.h" #include "types.h" -#include "content.h" using std::function; diff --git a/src/lib/player.cc b/src/lib/player.cc index 42c22ab7d..6853048de 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -20,46 +20,47 @@ #include "atmos_decoder.h" -#include "player.h" -#include "film.h" #include "audio_buffers.h" +#include "audio_content.h" +#include "audio_decoder.h" +#include "audio_processor.h" +#include "compose.hpp" +#include "config.h" #include "content_audio.h" +#include "content_video.h" #include "dcp_content.h" +#include "dcp_decoder.h" #include "dcpomatic_log.h" -#include "job.h" +#include "decoder.h" +#include "decoder_factory.h" +#include "ffmpeg_content.h" +#include "film.h" +#include "frame_rate_change.h" #include "image.h" -#include "raw_image_proxy.h" -#include "ratio.h" +#include "image_decoder.h" +#include "job.h" #include "log.h" -#include "render_text.h" -#include "config.h" -#include "content_video.h" +#include "piece.h" +#include "player.h" #include "player_video.h" -#include "frame_rate_change.h" -#include "audio_processor.h" #include "playlist.h" +#include "ratio.h" +#include "raw_image_proxy.h" #include "referenced_reel_asset.h" -#include "decoder_factory.h" -#include "decoder.h" -#include "video_decoder.h" -#include "audio_decoder.h" +#include "render_text.h" +#include "shuffler.h" #include "text_content.h" #include "text_decoder.h" -#include "ffmpeg_content.h" -#include "audio_content.h" -#include "dcp_decoder.h" -#include "image_decoder.h" -#include "compose.hpp" -#include "shuffler.h" #include "timer.h" +#include "video_decoder.h" #include +#include +#include #include #include -#include -#include -#include #include #include +#include #include "i18n.h" @@ -70,6 +71,7 @@ using std::dynamic_pointer_cast; using std::list; using std::make_pair; using std::make_shared; +using std::make_shared; using std::max; using std::min; using std::min; @@ -77,7 +79,6 @@ using std::pair; using std::shared_ptr; using std::vector; using std::weak_ptr; -using std::make_shared; using boost::optional; using boost::scoped_ptr; #if BOOST_VERSION >= 106100 @@ -278,9 +279,9 @@ Player::setup_pieces_unlocked () _black = Empty (_film, playlist(), bind(&have_video, _1), _playback_length); _silent = Empty (_film, playlist(), bind(&have_audio, _1), _playback_length); - _next_video_time = boost::optional(); + _next_video_time = boost::none; _next_video_eyes = Eyes::BOTH; - _next_audio_time = boost::optional(); + _next_audio_time = boost::none; } @@ -1251,9 +1252,9 @@ Player::seek (DCPTime time, bool accurate) _next_video_eyes = Eyes::LEFT; _next_audio_time = time; } else { - _next_video_time = optional(); - _next_video_eyes = optional(); - _next_audio_time = optional(); + _next_video_time = boost::none; + _next_video_eyes = boost::none; + _next_audio_time = boost::none; } _black.set_position (time); @@ -1396,7 +1397,7 @@ Player::set_dcp_decode_reduction (optional reduction) optional -Player::content_time_to_dcp (shared_ptr content, ContentTime t) +Player::content_time_to_dcp (shared_ptr content, ContentTime t) { boost::mutex::scoped_lock lm (_mutex); diff --git a/src/lib/player.h b/src/lib/player.h index bedf51d8e..b70ea05dd 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -27,7 +27,6 @@ #include "atmos_metadata.h" #include "audio_merger.h" #include "audio_stream.h" -#include "content.h" #include "content_atmos.h" #include "content_audio.h" #include "content_text.h" @@ -35,7 +34,6 @@ #include "empty.h" #include "film.h" #include "image.h" -#include "piece.h" #include "player_text.h" #include "position_image.h" #include "shuffler.h" @@ -52,11 +50,11 @@ namespace dcpomatic { } class AtmosContent; +class AudioBuffers; +class Content; class PlayerVideo; class Playlist; -class AudioBuffers; class ReferencedReelAsset; -class Shuffler; class PlayerProperty @@ -102,7 +100,7 @@ public: void set_play_referenced (); void set_dcp_decode_reduction (boost::optional reduction); - boost::optional content_time_to_dcp (std::shared_ptr content, dcpomatic::ContentTime t); + boost::optional content_time_to_dcp (std::shared_ptr content, dcpomatic::ContentTime t); boost::signals2::signal Change; @@ -133,7 +131,6 @@ private: void construct (); void setup_pieces (); void setup_pieces_unlocked (); - void flush (); void film_change (ChangeType, Film::Property); void playlist_change (ChangeType); void playlist_content_change (ChangeType, int, bool); @@ -175,7 +172,7 @@ private: /** > 0 if we are suspended (i.e. pass() and seek() do nothing) */ boost::atomic _suspended; - std::list > _pieces; + std::list> _pieces; /** Size of the image we are rendering to; this may be the DCP frame size, or * the size of preview in a window. @@ -210,7 +207,7 @@ private: AudioMerger _audio_merger; std::unique_ptr _shuffler; - std::list, dcpomatic::DCPTime> > _delay; + std::list, dcpomatic::DCPTime>> _delay; class StreamState { diff --git a/src/lib/player_text.cc b/src/lib/player_text.cc index a3b7ec89f..626f8fac3 100644 --- a/src/lib/player_text.cc +++ b/src/lib/player_text.cc @@ -19,8 +19,8 @@ */ -#include "player_text.h" #include "font.h" +#include "player_text.h" using std::list; diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc index 4cc536bb7..081147434 100644 --- a/src/lib/player_video.cc +++ b/src/lib/player_video.cc @@ -18,6 +18,7 @@ */ + #include "content.h" #include "film.h" #include "image.h" @@ -33,17 +34,19 @@ extern "C" { #include #include + using std::cout; using std::dynamic_pointer_cast; +using std::function; using std::make_shared; using std::shared_ptr; using std::string; using std::weak_ptr; using boost::optional; -using std::function; using dcp::Data; using dcp::raw_convert; + PlayerVideo::PlayerVideo ( shared_ptr in, Crop crop, @@ -74,6 +77,7 @@ PlayerVideo::PlayerVideo ( } + PlayerVideo::PlayerVideo (shared_ptr node, shared_ptr socket) { _crop = Crop (node); @@ -103,12 +107,14 @@ PlayerVideo::PlayerVideo (shared_ptr node, shared_ptr socket } } + void PlayerVideo::set_text (PositionImage image) { _text = image; } + shared_ptr PlayerVideo::image (function pixel_format, VideoRange video_range, bool fast) const { @@ -191,6 +197,7 @@ PlayerVideo::make_image (function pixel_format, V } } + void PlayerVideo::add_metadata (xmlpp::Node* node) const { @@ -218,6 +225,7 @@ PlayerVideo::add_metadata (xmlpp::Node* node) const } } + void PlayerVideo::write_to_socket (shared_ptr socket) const { @@ -227,6 +235,7 @@ PlayerVideo::write_to_socket (shared_ptr socket) const } } + bool PlayerVideo::has_j2k () const { @@ -240,6 +249,7 @@ PlayerVideo::has_j2k () const return _crop == Crop() && _out_size == j2k->size() && _inter_size == j2k->size() && !_text && !_fade && !_colour_conversion; } + shared_ptr PlayerVideo::j2k () const { @@ -248,12 +258,14 @@ PlayerVideo::j2k () const return j2k->j2k (); } + Position PlayerVideo::inter_position () const { return Position ((_out_size.width - _inter_size.width) / 2, (_out_size.height - _inter_size.height) / 2); } + /** @return true if this PlayerVideo is definitely the same as another, false if it is probably not */ bool PlayerVideo::same (shared_ptr other) const @@ -284,6 +296,7 @@ PlayerVideo::same (shared_ptr other) const return _in->same (other->_in); } + AVPixelFormat PlayerVideo::force (AVPixelFormat, AVPixelFormat force_to) { @@ -296,6 +309,7 @@ PlayerVideo::keep_xyz_or_rgb (AVPixelFormat p) return p == AV_PIX_FMT_XYZ12LE ? AV_PIX_FMT_XYZ12LE : AV_PIX_FMT_RGB48LE; } + void PlayerVideo::prepare (function pixel_format, VideoRange video_range, Image::Alignment alignment, bool fast, bool proxy_only) { @@ -306,12 +320,14 @@ PlayerVideo::prepare (function pixel_format, Vide } } + size_t PlayerVideo::memory_used () const { return _in->memory_used(); } + /** @return Shallow copy of this; _in and _text are shared between the original and the copy */ shared_ptr PlayerVideo::shallow_copy () const @@ -332,6 +348,7 @@ PlayerVideo::shallow_copy () const ); } + /** Re-read crop, fade, inter/out size, colour conversion and video range from our content. * @return true if this was possible, false if not. */ diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index e8714e9d6..c18a43882 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -19,20 +19,20 @@ */ -#include "playlist.h" -#include "video_content.h" -#include "text_content.h" -#include "ffmpeg_decoder.h" -#include "ffmpeg_content.h" -#include "image_decoder.h" #include "audio_content.h" +#include "compose.hpp" +#include "config.h" #include "content_factory.h" #include "dcp_content.h" +#include "digester.h" +#include "ffmpeg_content.h" +#include "ffmpeg_decoder.h" +#include "image_decoder.h" #include "job.h" -#include "config.h" +#include "playlist.h" +#include "text_content.h" #include "util.h" -#include "digester.h" -#include "compose.hpp" +#include "video_content.h" #include #include #include @@ -41,17 +41,17 @@ #include "i18n.h" -using std::list; using std::cout; -using std::vector; -using std::min; +using std::dynamic_pointer_cast; +using std::list; using std::max; -using std::string; +using std::min; using std::pair; -using boost::optional; using std::shared_ptr; +using std::string; +using std::vector; using std::weak_ptr; -using std::dynamic_pointer_cast; +using boost::optional; using namespace dcpomatic; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; diff --git a/src/wx/recipient_dialog.cc b/src/wx/recipient_dialog.cc index eecb7c040..e833f2e36 100644 --- a/src/wx/recipient_dialog.cc +++ b/src/wx/recipient_dialog.cc @@ -61,7 +61,7 @@ RecipientDialog::RecipientDialog ( : wxDialog (parent, wxID_ANY, title) , _recipient (recipient) { - wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); + auto overall_sizer = new wxBoxSizer (wxVERTICAL); SetSizer (overall_sizer); _sizer = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); @@ -97,14 +97,14 @@ RecipientDialog::RecipientDialog ( ++r; wxClientDC dc (this); - wxFont font = _name->GetFont (); + auto font = _name->GetFont (); font.SetFamily (wxFONTFAMILY_TELETYPE); dc.SetFont (font); - wxSize size = dc.GetTextExtent (wxT ("1234567890123456789012345678")); - size.SetHeight (-1); + auto size = dc.GetTextExtent(wxT("1234567890123456789012345678")); + size.SetHeight (-1); add_label_to_sizer (_sizer, this, _("Recipient certificate"), true, wxGBPosition (r, 0)); - wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL); + auto s = new wxBoxSizer (wxHORIZONTAL); _recipient_thumbprint = new StaticText (this, wxT (""), wxDefaultPosition, size); _recipient_thumbprint->SetFont (font); set_recipient (recipient); @@ -122,7 +122,7 @@ RecipientDialog::RecipientDialog ( overall_sizer->Add (_sizer, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); + auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); if (buttons) { overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); } @@ -186,7 +186,7 @@ RecipientDialog::load_recipient (boost::filesystem::path file) void RecipientDialog::get_recipient_from_file () { - wxFileDialog* d = new wxFileDialog (this, _("Select Certificate File")); + auto d = new wxFileDialog (this, _("Select Certificate File")); if (d->ShowModal () == wxID_OK) { load_recipient (boost::filesystem::path (wx_to_std (d->GetPath ()))); } @@ -199,7 +199,7 @@ RecipientDialog::get_recipient_from_file () void RecipientDialog::setup_sensitivity () { - wxButton* ok = dynamic_cast (FindWindowById (wxID_OK, this)); + auto ok = dynamic_cast (FindWindowById (wxID_OK, this)); if (ok) { ok->Enable (static_cast(_recipient) && !_name->GetValue().IsEmpty()); } diff --git a/src/wx/subtitle_appearance_dialog.cc b/src/wx/subtitle_appearance_dialog.cc index b5ab8c2db..5ae9f5da4 100644 --- a/src/wx/subtitle_appearance_dialog.cc +++ b/src/wx/subtitle_appearance_dialog.cc @@ -39,11 +39,12 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS +using std::dynamic_pointer_cast; using std::map; -using std::string; +using std::make_shared; using std::shared_ptr; +using std::string; using boost::bind; -using std::dynamic_pointer_cast; using boost::optional; using namespace dcpomatic; #if BOOST_VERSION >= 106100 @@ -68,7 +69,7 @@ SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr /* XXX: assuming that all FFmpeg streams have bitmap subs */ if (_stream->colours().empty()) { _job_manager_connection = JobManager::instance()->ActiveJobsChanged.connect(boost::bind(&SubtitleAppearanceDialog::active_jobs_changed, this, _1)); - _job = JobManager::instance()->add(shared_ptr(new ExamineFFmpegSubtitlesJob(film, ff))); + _job = JobManager::instance()->add(make_shared(film, ff)); } } diff --git a/src/wx/timecode.h b/src/wx/timecode.h index c31a6740c..84ef5cc1b 100644 --- a/src/wx/timecode.h +++ b/src/wx/timecode.h @@ -18,9 +18,11 @@ */ + #ifndef DCPOMATIC_WX_TIMECODE_H #define DCPOMATIC_WX_TIMECODE_H + #include "wx_util.h" #include "lib/dcpomatic_time.h" #include "lib/types.h" @@ -28,6 +30,7 @@ #include #include + class TimecodeBase : public wxPanel { public: @@ -58,6 +61,7 @@ protected: bool _ignore_changed = false; }; + template class Timecode : public TimecodeBase { diff --git a/src/wx/timeline_content_view.cc b/src/wx/timeline_content_view.cc index 677b83bdd..481e8100d 100644 --- a/src/wx/timeline_content_view.cc +++ b/src/wx/timeline_content_view.cc @@ -95,7 +95,7 @@ TimelineContentView::track () const } void -TimelineContentView::do_paint (wxGraphicsContext* gc, list > overlaps) +TimelineContentView::do_paint (wxGraphicsContext* gc, list> overlaps) { DCPOMATIC_ASSERT (_track); @@ -105,8 +105,8 @@ TimelineContentView::do_paint (wxGraphicsContext* gc, list return; } - DCPTime const position = cont->position (); - DCPTime const len = cont->length_after_trim (film); + auto const position = cont->position (); + auto const len = cont->length_after_trim (film); wxColour selected (background_colour().Red() / 2, background_colour().Green() / 2, background_colour().Blue() / 2); diff --git a/src/wx/timeline_time_axis_view.h b/src/wx/timeline_time_axis_view.h index 5477e61f1..100228ae8 100644 --- a/src/wx/timeline_time_axis_view.h +++ b/src/wx/timeline_time_axis_view.h @@ -29,7 +29,7 @@ public: void set_y (int y); private: - void do_paint (wxGraphicsContext* gc, std::list > overlaps); + void do_paint (wxGraphicsContext* gc, std::list> overlaps); int _y; ///< y position in tracks (not pixels) }; diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index fad3779bd..493743d4a 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -297,7 +297,7 @@ checked_set (wxChoice* widget, string value) void -checked_set (wxChoice* widget, vector > items) +checked_set (wxChoice* widget, vector> items) { vector> current; for (unsigned int i = 0; i < widget->GetCount(); ++i) { diff --git a/test/dcp_decoder_test.cc b/test/dcp_decoder_test.cc index 66cd402c4..5d4d1e0ca 100644 --- a/test/dcp_decoder_test.cc +++ b/test/dcp_decoder_test.cc @@ -25,14 +25,15 @@ */ -#include "lib/film.h" +#include "lib/config.h" +#include "lib/content_factory.h" #include "lib/dcp_content.h" #include "lib/dcp_decoder.h" -#include "lib/content_factory.h" -#include "lib/player.h" #include "lib/examine_content_job.h" +#include "lib/film.h" #include "lib/job_manager.h" -#include "lib/config.h" +#include "lib/piece.h" +#include "lib/player.h" #include "test.h" #include #include diff --git a/test/overlap_video_test.cc b/test/overlap_video_test.cc index 3c969921d..c23444c4a 100644 --- a/test/overlap_video_test.cc +++ b/test/overlap_video_test.cc @@ -23,6 +23,7 @@ #include "lib/content_factory.h" #include "lib/dcpomatic_time.h" #include "lib/film.h" +#include "lib/piece.h" #include "lib/player.h" #include "lib/video_content.h" #include "test.h" diff --git a/test/reels_test.cc b/test/reels_test.cc index db974d384..618a5b29b 100644 --- a/test/reels_test.cc +++ b/test/reels_test.cc @@ -25,27 +25,27 @@ */ -#include "lib/film.h" -#include "lib/ratio.h" +#include "lib/content_factory.h" +#include "lib/dcp_content.h" +#include "lib/dcp_content_type.h" #include "lib/ffmpeg_content.h" +#include "lib/film.h" #include "lib/image_content.h" -#include "lib/dcp_content_type.h" -#include "lib/dcp_content.h" -#include "lib/video_content.h" +#include "lib/ratio.h" #include "lib/string_text_file_content.h" -#include "lib/content_factory.h" +#include "lib/video_content.h" #include "test.h" #include #include -using std::list; using std::cout; -using std::vector; -using std::string; -using std::shared_ptr; -using std::make_shared; using std::function; +using std::list; +using std::make_shared; +using std::shared_ptr; +using std::string; +using std::vector; using namespace dcpomatic; diff --git a/test/test.cc b/test/test.cc index 4ea709c81..89ee7f619 100644 --- a/test/test.cc +++ b/test/test.cc @@ -369,7 +369,7 @@ rms_error (boost::filesystem::path ref, boost::filesystem::path check) auto check_image = check_proxy.image(Image::Alignment::COMPACT).image; BOOST_REQUIRE_EQUAL (ref_image->pixel_format(), check_image->pixel_format()); - AVPixelFormat const format = ref_image->pixel_format(); + auto const format = ref_image->pixel_format(); BOOST_REQUIRE (ref_image->size() == check_image->size()); int const width = ref_image->size().width; -- 2.30.2