From: Carl Hetherington Date: Thu, 29 Apr 2021 07:14:20 +0000 (+0200) Subject: C++11 tidying. X-Git-Tag: v2.15.141~14 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=39fb8198febde1937019db1c300ec363aab5aa56 C++11 tidying. --- diff --git a/src/lib/cross_common.cc b/src/lib/cross_common.cc index f8556b1fd..2e48bf3e0 100644 --- a/src/lib/cross_common.cc +++ b/src/lib/cross_common.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,6 +18,7 @@ */ + #include "cross.h" #include "compose.hpp" #include "dcpomatic_log.h" @@ -30,8 +31,10 @@ DCPOMATIC_ENABLE_WARNINGS #include "i18n.h" + using std::string; + Drive::Drive (string xml) { cxml::Document doc; @@ -50,7 +53,7 @@ string Drive::as_xml () const { xmlpp::Document doc; - xmlpp::Element* root = doc.create_root_node ("Drive"); + auto root = doc.create_root_node ("Drive"); root->add_child("Device")->add_child_text(_device); for (auto i: _mount_points) { root->add_child("MountPoint")->add_child_text(i.string()); @@ -91,6 +94,7 @@ Drive::description () const return String::compose(_("%1 (%2 GB) [%3]"), name, gb, _device); } + string Drive::log_summary () const { diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 566ed2935..f9b0d9a57 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -67,7 +67,6 @@ using namespace dcpomatic; DCPDecoder::DCPDecoder (shared_ptr film, shared_ptr c, bool fast, bool tolerant, shared_ptr old) : DCP (c, tolerant) , Decoder (film) - , _decode_referenced (false) { if (c->can_be_played()) { if (c->video) { @@ -125,7 +124,6 @@ DCPDecoder::DCPDecoder (shared_ptr film, shared_ptr + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,10 +18,12 @@ */ + /** @file src/dcp_decoder.h * @brief A decoder of existing DCPs. */ + #include "atmos_metadata.h" #include "decoder.h" #include "dcp.h" @@ -30,6 +32,7 @@ #include #include + namespace dcp { class Reel; } @@ -38,6 +41,7 @@ class DCPContent; class Log; struct dcp_subtitle_within_dcp_test; + class DCPDecoder : public DCP, public Decoder { public: @@ -56,16 +60,16 @@ public: void set_decode_referenced (bool r); void set_forced_reduction (boost::optional reduction); - bool pass (); - void seek (dcpomatic::ContentTime t, bool accurate); + bool pass () override; + void seek (dcpomatic::ContentTime t, bool accurate) override; - std::vector fonts () const; + std::vector fonts () const override; std::string lazy_digest () const { return _lazy_digest; } - dcpomatic::ContentTime position () const; + dcpomatic::ContentTime position () const override; private: friend struct dcp_subtitle_within_dcp_test; @@ -89,7 +93,7 @@ private: std::vector>::iterator _reel; /** Offset of _reel from the start of the content in frames */ - int64_t _offset; + int64_t _offset = 0; /** Reader for current mono picture asset, if applicable */ std::shared_ptr _mono_reader; /** Reader for current stereo picture asset, if applicable */ @@ -99,7 +103,7 @@ private: std::shared_ptr _atmos_reader; boost::optional _atmos_metadata; - bool _decode_referenced; + bool _decode_referenced = false; boost::optional _forced_reduction; std::string _lazy_digest; diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_subtitle_decoder.cc index 1b144f204..024d62f34 100644 --- a/src/lib/dcp_subtitle_decoder.cc +++ b/src/lib/dcp_subtitle_decoder.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2020 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,14 @@ */ + #include "dcp_subtitle_decoder.h" #include "dcp_subtitle_content.h" #include #include #include + using std::cout; using std::list; using std::map; @@ -31,13 +33,15 @@ using std::string; using std::vector; using std::shared_ptr; using std::dynamic_pointer_cast; +using std::make_shared; using boost::bind; using namespace dcpomatic; + DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr film, shared_ptr content) : Decoder (film) { - shared_ptr c (load (content->path (0))); + auto c = load (content->path(0)); c->fix_empty_font_ids (); _subtitles = c->subtitles (); _next = _subtitles.begin (); @@ -46,11 +50,11 @@ DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr film, shared_ptr< if (_next != _subtitles.end()) { first = content_time_period(*_next).from; } - text.push_back (shared_ptr (new TextDecoder (this, content->only_text(), first))); + text.push_back (make_shared(this, content->only_text(), first)); - map fm = c->font_data(); - for (map::const_iterator j = fm.begin(); j != fm.end(); ++j) { - _fonts.push_back (FontData(j->first, j->second)); + auto fm = c->font_data(); + for (auto const& i: fm) { + _fonts.push_back (FontData(i.first, i.second)); } /* Add a default font for any LoadFont nodes in our file which we haven't yet found fonts for */ @@ -61,6 +65,7 @@ DCPSubtitleDecoder::DCPSubtitleDecoder (shared_ptr film, shared_ptr< } } + void DCPSubtitleDecoder::seek (ContentTime time, bool accurate) { @@ -73,6 +78,7 @@ DCPSubtitleDecoder::seek (ContentTime time, bool accurate) } } + bool DCPSubtitleDecoder::pass () { @@ -89,7 +95,7 @@ DCPSubtitleDecoder::pass () list s; list i; - ContentTimePeriod const p = content_time_period (*_next); + auto const p = content_time_period (*_next); while (_next != _subtitles.end () && content_time_period (*_next) == p) { auto ns = dynamic_pointer_cast(*_next); @@ -113,6 +119,7 @@ DCPSubtitleDecoder::pass () return false; } + ContentTimePeriod DCPSubtitleDecoder::content_time_period (shared_ptr s) const { diff --git a/src/lib/dcp_subtitle_decoder.h b/src/lib/dcp_subtitle_decoder.h index a9540c3cf..95e783d06 100644 --- a/src/lib/dcp_subtitle_decoder.h +++ b/src/lib/dcp_subtitle_decoder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2020 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,15 @@ */ + #include "text_decoder.h" #include "dcp_subtitle.h" #include "font_data.h" + class DCPSubtitleContent; + class DCPSubtitleDecoder : public DCPSubtitle, public Decoder { public: diff --git a/src/lib/dcpomatic_time.cc b/src/lib/dcpomatic_time.cc index 8abd77555..ac797f8f4 100644 --- a/src/lib/dcpomatic_time.cc +++ b/src/lib/dcpomatic_time.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,26 +18,31 @@ */ + #include "dcpomatic_time.h" #include + using std::string; using namespace dcpomatic; + template <> Time::Time (DCPTime d, FrameRateChange f) - : _t (llrint (d.get() * f.speed_up)) + : _t (llrint(d.get() * f.speed_up)) { } + template <> Time::Time (ContentTime d, FrameRateChange f) - : _t (llrint (d.get() / f.speed_up)) + : _t (llrint(d.get() / f.speed_up)) { } + DCPTime dcpomatic::min (DCPTime a, DCPTime b) { @@ -48,6 +53,7 @@ dcpomatic::min (DCPTime a, DCPTime b) return b; } + DCPTime dcpomatic::max (DCPTime a, DCPTime b) { @@ -58,6 +64,7 @@ dcpomatic::max (DCPTime a, DCPTime b) return b; } + ContentTime dcpomatic::min (ContentTime a, ContentTime b) { @@ -68,6 +75,7 @@ dcpomatic::min (ContentTime a, ContentTime b) return b; } + ContentTime dcpomatic::max (ContentTime a, ContentTime b) { @@ -78,6 +86,7 @@ dcpomatic::max (ContentTime a, ContentTime b) return b; } + string dcpomatic::to_string (ContentTime t) { @@ -90,6 +99,7 @@ dcpomatic::to_string (ContentTime t) return buffer; } + string dcpomatic::to_string (DCPTime t) { @@ -102,6 +112,7 @@ dcpomatic::to_string (DCPTime t) return buffer; } + string dcpomatic::to_string (DCPTimePeriod p) { diff --git a/src/lib/dolby_cp750.cc b/src/lib/dolby_cp750.cc index 380ab0564..667168722 100644 --- a/src/lib/dolby_cp750.cc +++ b/src/lib/dolby_cp750.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,15 @@ */ + #include "dolby_cp750.h" #include "i18n.h" + using namespace std; + DolbyCP750::DolbyCP750 () : CinemaSoundProcessor ("dolby_cp750", _("Dolby CP650 or CP750"), 4.0f, 20, 3.33333333333333333) { diff --git a/src/lib/dolby_cp750.h b/src/lib/dolby_cp750.h index 3162a962d..92f8ec446 100644 --- a/src/lib/dolby_cp750.h +++ b/src/lib/dolby_cp750.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,15 @@ */ + /** @file src/lib/dolby_cp750.h * @brief DolbyCP750 class. */ + #include "cinema_sound_processor.h" + class DolbyCP750 : public CinemaSoundProcessor { public: diff --git a/src/lib/empty.cc b/src/lib/empty.cc index 0cf2b85dc..f6dcad96f 100644 --- a/src/lib/empty.cc +++ b/src/lib/empty.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Carl Hetherington + Copyright (C) 2017-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "empty.h" #include "film.h" #include "playlist.h" @@ -28,29 +29,32 @@ #include "piece.h" #include + using std::cout; using std::list; using std::shared_ptr; using std::dynamic_pointer_cast; -using boost::function; +using std::function; using namespace dcpomatic; + Empty::Empty (shared_ptr film, shared_ptr playlist, function)> part, DCPTime length) { list full; for (auto i: playlist->content()) { if (part(i)) { - full.push_back (DCPTimePeriod (i->position(), i->end(film))); + full.push_back (DCPTimePeriod(i->position(), i->end(film))); } } _periods = subtract (DCPTimePeriod(DCPTime(), length), coalesce(full)); - if (!_periods.empty ()) { + if (!_periods.empty()) { _position = _periods.front().from; } } + void Empty::set_position (DCPTime position) { @@ -70,6 +74,7 @@ Empty::set_position (DCPTime position) } } + DCPTimePeriod Empty::period_at_position () const { @@ -82,6 +87,7 @@ Empty::period_at_position () const DCPOMATIC_ASSERT (false); } + bool Empty::done () const { diff --git a/src/lib/empty.h b/src/lib/empty.h index 443d3322b..145b84091 100644 --- a/src/lib/empty.h +++ b/src/lib/empty.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,25 +18,29 @@ */ + #ifndef DCPOMATIC_EMPTY_H #define DCPOMATIC_EMPTY_H + #include "playlist.h" #include "dcpomatic_time.h" #include "content_part.h" #include + struct empty_test1; struct empty_test2; struct empty_test3; struct empty_test_with_overlapping_content; struct player_subframe_test; + class Empty { public: Empty () {} - Empty (std::shared_ptr film, std::shared_ptr playlist, boost::function)> part, dcpomatic::DCPTime length); + Empty (std::shared_ptr film, std::shared_ptr playlist, std::function)> part, dcpomatic::DCPTime length); dcpomatic::DCPTime position () const { return _position; @@ -59,4 +63,5 @@ private: dcpomatic::DCPTime _position; }; + #endif diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 147bb384f..9d7e15557 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -81,7 +81,6 @@ using namespace dcpomatic; FFmpegDecoder::FFmpegDecoder (shared_ptr film, shared_ptr c, bool fast) : FFmpeg (c) , Decoder (film) - , _have_current_subtitle (false) { if (c->video && c->video->use()) { video = make_shared(this, c); diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index e18d5e8eb..d19a9f703 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -46,8 +46,8 @@ class FFmpegDecoder : public FFmpeg, public Decoder public: FFmpegDecoder (std::shared_ptr film, std::shared_ptr, bool fast); - bool pass (); - void seek (dcpomatic::ContentTime time, bool); + bool pass () override; + void seek (dcpomatic::ContentTime time, bool) override; private: friend struct ::ffmpeg_pts_offset_test; @@ -77,7 +77,7 @@ private: dcpomatic::ContentTime _pts_offset; boost::optional _current_subtitle_to; /** true if we have a subtitle which has not had emit_stop called for it yet */ - bool _have_current_subtitle; + bool _have_current_subtitle = false; std::shared_ptr _black_image; diff --git a/src/lib/font.cc b/src/lib/font.cc index aa9a8aaef..a2dc1945f 100644 --- a/src/lib/font.cc +++ b/src/lib/font.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,31 +18,35 @@ */ -#include "font.h" + #include "dcpomatic_assert.h" +#include "font.h" #include "warnings.h" DCPOMATIC_DISABLE_WARNINGS #include DCPOMATIC_ENABLE_WARNINGS + using std::string; using namespace dcpomatic; + Font::Font (cxml::NodePtr node) - : _id (node->string_child ("Id")) + : _id (node->string_child("Id")) { for (auto i: node->node_children("File")) { - string variant = i->optional_string_attribute("Variant").get_value_or ("Normal"); + string variant = i->optional_string_attribute("Variant").get_value_or("Normal"); if (variant == "Normal") { _file = i->content(); } } } + void Font::as_xml (xmlpp::Node* node) { - node->add_child("Id")->add_child_text (_id); + node->add_child("Id")->add_child_text(_id); if (_file) { node->add_child("File")->add_child_text(_file->string()); } @@ -59,6 +63,7 @@ dcpomatic::operator== (Font const & a, Font const & b) return a.file() == b.file(); } + bool dcpomatic::operator!= (Font const & a, Font const & b) { diff --git a/src/lib/font.h b/src/lib/font.h index 5876bf8a4..ed3ecc38f 100644 --- a/src/lib/font.h +++ b/src/lib/font.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,17 +18,21 @@ */ + #ifndef DCPOMATIC_FONT_H #define DCPOMATIC_FONT_H + #include #include #include #include #include + namespace dcpomatic { + class Font { public: @@ -60,9 +64,11 @@ private: boost::optional _file; }; + bool operator!= (Font const & a, Font const & b); bool operator== (Font const & a, Font const & b); + } #endif diff --git a/src/lib/hints.cc b/src/lib/hints.cc index 52debf3ef..4d3b2d95e 100644 --- a/src/lib/hints.cc +++ b/src/lib/hints.cc @@ -18,6 +18,7 @@ */ + #include "dcp_content_type.h" #include "hints.h" #include "types.h" @@ -45,6 +46,7 @@ #include "i18n.h" + using std::cout; using std::make_shared; using std::max; @@ -82,12 +84,14 @@ Hints::Hints (weak_ptr weak_film) } + void Hints::start () { _thread = boost::thread (bind(&Hints::thread, this)); } + Hints::~Hints () { boost::this_thread::disable_interruption dis; @@ -256,7 +260,7 @@ Hints::check_big_font_files () for (auto i: film()->content()) { for (auto j: i->text) { for (auto k: j->fonts()) { - optional const p = k->file (); + auto const p = k->file (); if (p && boost::filesystem::file_size(p.get()) >= (MAX_FONT_FILE_SIZE - SIZE_SLACK)) { big_font_files = true; } @@ -276,7 +280,7 @@ Hints::check_vob () { int vob = 0; for (auto i: film()->content()) { - if (boost::algorithm::starts_with (i->path(0).filename().string(), "VTS_")) { + if (boost::algorithm::starts_with(i->path(0).filename().string(), "VTS_")) { ++vob; } } @@ -330,8 +334,8 @@ Hints::check_loudness () ch = ch.substr (0, ch.length() - 2); - if (!ch.empty ()) { - hint (String::compose ( + if (!ch.empty()) { + hint(String::compose( _("Your audio level is very high (on %1). You should reduce the gain of your audio content."), ch ) @@ -445,7 +449,7 @@ try bool ccap_mxf_too_big = false; bool subs_mxf_too_big = false; - boost::filesystem::path dcp_dir = film->dir("hints") / dcpomatic::get_process_id(); + auto dcp_dir = film->dir("hints") / dcpomatic::get_process_id(); boost::filesystem::remove_all (dcp_dir); _writer->finish (film->dir("hints") / dcpomatic::get_process_id()); @@ -491,6 +495,7 @@ catch (...) store_current (); } + void Hints::hint (string h) { diff --git a/src/lib/hints.h b/src/lib/hints.h index 06155f434..81a37a3c4 100644 --- a/src/lib/hints.h +++ b/src/lib/hints.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016-2020 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "audio_analyser.h" #include "signaller.h" #include "player_text.h" diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index 2f7416c62..2e0a98092 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -18,6 +18,7 @@ */ + #include "image_content.h" #include "image_decoder.h" #include "video_decoder.h" @@ -33,20 +34,22 @@ #include "i18n.h" + using std::cout; using std::make_shared; using std::shared_ptr; using dcp::Size; using namespace dcpomatic; + ImageDecoder::ImageDecoder (shared_ptr film, shared_ptr c) : Decoder (film) , _image_content (c) - , _frame_video_position (0) { video = make_shared(this, c); } + bool ImageDecoder::pass () { @@ -80,6 +83,7 @@ ImageDecoder::pass () return false; } + void ImageDecoder::seek (ContentTime time, bool accurate) { diff --git a/src/lib/image_decoder.h b/src/lib/image_decoder.h index d575f9021..067a24720 100644 --- a/src/lib/image_decoder.h +++ b/src/lib/image_decoder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,15 @@ */ + #include "decoder.h" + class ImageContent; class Log; class ImageProxy; + class ImageDecoder : public Decoder { public: @@ -33,12 +36,12 @@ public: return _image_content; } - bool pass (); - void seek (dcpomatic::ContentTime, bool); + bool pass () override; + void seek (dcpomatic::ContentTime, bool) override; private: std::shared_ptr _image_content; std::shared_ptr _image; - Frame _frame_video_position; + Frame _frame_video_position = 0; }; diff --git a/src/lib/kdm_recipient.cc b/src/lib/kdm_recipient.cc index d05192ac6..cde41e22d 100644 --- a/src/lib/kdm_recipient.cc +++ b/src/lib/kdm_recipient.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + #include "kdm_recipient.h" + KDMRecipient::KDMRecipient (cxml::ConstNodePtr node) : name (node->string_child("Name")) - , notes (node->optional_string_child("Notes").get_value_or ("")) + , notes (node->optional_string_child("Notes").get_value_or("")) { if (node->optional_string_child("Certificate")) { recipient = dcp::Certificate (node->string_child("Certificate")); diff --git a/src/lib/kdm_recipient.h b/src/lib/kdm_recipient.h index e92fc3c48..85352f0ee 100644 --- a/src/lib/kdm_recipient.h +++ b/src/lib/kdm_recipient.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,9 +18,11 @@ */ + #ifndef DCPOMATIC_KDM_RECIPIENT_H #define DCPOMATIC_KDM_RECIPIENT_H + #include "warnings.h" #include #include @@ -30,6 +32,7 @@ DCPOMATIC_ENABLE_WARNINGS #include #include + class KDMRecipient { public: @@ -50,4 +53,5 @@ public: boost::optional recipient; }; + #endif diff --git a/src/lib/scp_uploader.cc b/src/lib/scp_uploader.cc index 0926ffa9f..9c349f233 100644 --- a/src/lib/scp_uploader.cc +++ b/src/lib/scp_uploader.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "scp_uploader.h" #include "exceptions.h" #include "job.h" @@ -29,52 +30,55 @@ #include "i18n.h" -using std::string; + +using std::function; using std::min; using std::shared_ptr; -using boost::function; +using std::string; + SCPUploader::SCPUploader (function set_status, function set_progress) : Uploader (set_status, set_progress) { _session = ssh_new (); if (!_session) { - throw NetworkError (_("could not start SSH session")); + throw NetworkError (String::compose(_("SSH error [%1]"), "ssh_new")); } - ssh_options_set (_session, SSH_OPTIONS_HOST, Config::instance()->tms_ip().c_str ()); - ssh_options_set (_session, SSH_OPTIONS_USER, Config::instance()->tms_user().c_str ()); + ssh_options_set (_session, SSH_OPTIONS_HOST, Config::instance()->tms_ip().c_str()); + ssh_options_set (_session, SSH_OPTIONS_USER, Config::instance()->tms_user().c_str()); int const port = 22; ssh_options_set (_session, SSH_OPTIONS_PORT, &port); int r = ssh_connect (_session); if (r != SSH_OK) { - throw NetworkError (String::compose (_("Could not connect to server %1 (%2)"), Config::instance()->tms_ip(), ssh_get_error (_session))); + throw NetworkError (String::compose(_("Could not connect to server %1 (%2)"), Config::instance()->tms_ip(), ssh_get_error(_session))); } DCPOMATIC_DISABLE_WARNINGS r = ssh_is_server_known (_session); if (r == SSH_SERVER_ERROR) { - throw NetworkError (String::compose (_("SSH error (%1)"), ssh_get_error (_session))); + throw NetworkError (String::compose(_("SSH error [%1] (%2)"), "ssh_is_server_known", ssh_get_error(_session))); } DCPOMATIC_ENABLE_WARNINGS r = ssh_userauth_password (_session, 0, Config::instance()->tms_password().c_str ()); if (r != SSH_AUTH_SUCCESS) { - throw NetworkError (String::compose (_("Failed to authenticate with server (%1)"), ssh_get_error (_session))); + throw NetworkError (String::compose(_("Failed to authenticate with server (%1)"), ssh_get_error(_session))); } - _scp = ssh_scp_new (_session, SSH_SCP_WRITE | SSH_SCP_RECURSIVE, Config::instance()->tms_path().c_str ()); + _scp = ssh_scp_new (_session, SSH_SCP_WRITE | SSH_SCP_RECURSIVE, Config::instance()->tms_path().c_str()); if (!_scp) { - throw NetworkError (String::compose (_("could not start SCP session (%1)"), ssh_get_error (_session))); + throw NetworkError (String::compose(_("SSH error [%1] (%2)"), "ssh_scp_new", ssh_get_error(_session))); } r = ssh_scp_init (_scp); if (r != SSH_OK) { - throw NetworkError (String::compose (_("Could not start SCP session (%1)"), ssh_get_error (_session))); + throw NetworkError (String::compose(_("SSH error [%1] (%2)"), "ssh_scp_init", ssh_get_error(_session))); } } + SCPUploader::~SCPUploader () { ssh_scp_free (_scp); @@ -82,26 +86,28 @@ SCPUploader::~SCPUploader () ssh_free (_session); } + void SCPUploader::create_directory (boost::filesystem::path directory) { /* Use generic_string so that we get forward-slashes in the path, even on Windows */ int const r = ssh_scp_push_directory (_scp, directory.generic_string().c_str(), S_IRWXU); if (r != SSH_OK) { - throw NetworkError (String::compose (_("Could not create remote directory %1 (%2)"), directory, ssh_get_error (_session))); + throw NetworkError (String::compose(_("Could not create remote directory %1 (%2)"), directory, ssh_get_error(_session))); } } + void SCPUploader::upload_file (boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t& transferred, boost::uintmax_t total_size) { - boost::uintmax_t to_do = boost::filesystem::file_size (from); + auto to_do = boost::filesystem::file_size (from); /* Use generic_string so that we get forward-slashes in the path, even on Windows */ ssh_scp_push_file (_scp, to.generic_string().c_str(), to_do, S_IRUSR | S_IWUSR); - FILE* f = fopen_boost (from, "rb"); - if (f == 0) { - throw NetworkError (String::compose (_("Could not open %1 to send"), from)); + auto f = fopen_boost (from, "rb"); + if (f == nullptr) { + throw NetworkError (String::compose(_("Could not open %1 to send"), from)); } boost::uintmax_t buffer_size = 64 * 1024; @@ -118,7 +124,7 @@ SCPUploader::upload_file (boost::filesystem::path from, boost::filesystem::path int const r = ssh_scp_write (_scp, buffer, t); if (r != SSH_OK) { fclose (f); - throw NetworkError (String::compose (_("Could not write to remote file (%1)"), ssh_get_error (_session))); + throw NetworkError (String::compose(_("Could not write to remote file (%1)"), ssh_get_error(_session))); } to_do -= t; transferred += t; diff --git a/src/lib/scp_uploader.h b/src/lib/scp_uploader.h index 5c90db927..e6bf7da2b 100644 --- a/src/lib/scp_uploader.h +++ b/src/lib/scp_uploader.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,18 +18,20 @@ */ + #include "uploader.h" #include + class SCPUploader : public Uploader { public: - SCPUploader (boost::function set_status, boost::function set_progress); + SCPUploader (std::function set_status, std::function set_progress); ~SCPUploader (); protected: - virtual void create_directory (boost::filesystem::path directory); - virtual void upload_file (boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t& transferred, boost::uintmax_t total_size); + virtual void create_directory (boost::filesystem::path directory) override; + virtual void upload_file (boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t& transferred, boost::uintmax_t total_size) override; private: ssh_session _session; diff --git a/src/lib/spl.cc b/src/lib/spl.cc index 1677e626f..8d0dcc6fc 100644 --- a/src/lib/spl.cc +++ b/src/lib/spl.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018-2019 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "content_store.h" #include "spl.h" #include "warnings.h" @@ -28,11 +29,13 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include + using std::cout; using std::string; using std::shared_ptr; using dcp::raw_convert; + void SPL::read (boost::filesystem::path path, ContentStore* store) { @@ -43,7 +46,7 @@ SPL::read (boost::filesystem::path path, ContentStore* store) _id = doc.string_child("Id"); _name = doc.string_child("Name"); for (auto i: doc.node_children("Entry")) { - shared_ptr c = store->get(i->string_child("Digest")); + auto c = store->get(i->string_child("Digest")); if (c) { add (SPLEntry(c)); } else { @@ -52,11 +55,12 @@ SPL::read (boost::filesystem::path path, ContentStore* store) } } + void SPL::write (boost::filesystem::path path) const { xmlpp::Document doc; - xmlpp::Element* root = doc.create_root_node ("SPL"); + auto root = doc.create_root_node ("SPL"); root->add_child("Id")->add_child_text (_id); root->add_child("Name")->add_child_text (_name); for (auto i: _spl) { diff --git a/src/lib/usl.cc b/src/lib/usl.cc index b8a9a71f0..063cc8d61 100644 --- a/src/lib/usl.cc +++ b/src/lib/usl.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,10 +18,12 @@ */ + #include "usl.h" #include "i18n.h" + USL::USL () : CinemaSoundProcessor ("usl", _("USL"), 5.5f, 10, 3.33333333333333333) { diff --git a/src/lib/usl.h b/src/lib/usl.h index 260eb3c80..896fcf971 100644 --- a/src/lib/usl.h +++ b/src/lib/usl.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,12 +18,15 @@ */ + /** @file src/lib/usl.h * @brief USL class. */ + #include "cinema_sound_processor.h" + class USL : public CinemaSoundProcessor { public: diff --git a/src/lib/video_mxf_decoder.cc b/src/lib/video_mxf_decoder.cc index 6e194a6df..d3fe2b897 100644 --- a/src/lib/video_mxf_decoder.cc +++ b/src/lib/video_mxf_decoder.cc @@ -18,6 +18,7 @@ */ + #include "video_mxf_decoder.h" #include "video_decoder.h" #include "video_mxf_content.h" @@ -29,19 +30,22 @@ #include #include + +using std::make_shared; using std::shared_ptr; using boost::optional; using namespace dcpomatic; + VideoMXFDecoder::VideoMXFDecoder (shared_ptr film, shared_ptr content) : Decoder (film) , _content (content) { - video.reset (new VideoDecoder (this, content)); + video = make_shared(this, content); shared_ptr mono; try { - mono.reset (new dcp::MonoPictureAsset (_content->path(0))); + mono = make_shared(_content->path(0)); } catch (dcp::MXFFileError& e) { /* maybe it's stereo */ } catch (dcp::ReadError& e) { @@ -50,7 +54,7 @@ VideoMXFDecoder::VideoMXFDecoder (shared_ptr film, shared_ptr stereo; try { - stereo.reset (new dcp::StereoPictureAsset (_content->path(0))); + stereo = make_shared(_content->path(0)); } catch (dcp::MXFFileError& e) { if (!mono) { throw; @@ -70,11 +74,12 @@ VideoMXFDecoder::VideoMXFDecoder (shared_ptr film, shared_ptractive_video_frame_rate (film()); - int64_t const frame = _next.frames_round (vfr); + auto const vfr = _content->active_video_frame_rate (film()); + auto const frame = _next.frames_round (vfr); if (frame >= _content->video->length()) { return true; @@ -83,24 +88,18 @@ VideoMXFDecoder::pass () if (_mono_reader) { video->emit ( film(), - shared_ptr ( - new J2KImageProxy (_mono_reader->get_frame(frame), _size, AV_PIX_FMT_XYZ12LE, optional()) - ), + std::make_shared(_mono_reader->get_frame(frame), _size, AV_PIX_FMT_XYZ12LE, optional()), frame ); } else { video->emit ( film(), - shared_ptr ( - new J2KImageProxy (_stereo_reader->get_frame(frame), _size, dcp::Eye::LEFT, AV_PIX_FMT_XYZ12LE, optional()) - ), + std::make_shared(_stereo_reader->get_frame(frame), _size, dcp::Eye::LEFT, AV_PIX_FMT_XYZ12LE, optional()), frame ); video->emit ( film(), - shared_ptr ( - new J2KImageProxy (_stereo_reader->get_frame(frame), _size, dcp::Eye::RIGHT, AV_PIX_FMT_XYZ12LE, optional()) - ), + std::make_shared(_stereo_reader->get_frame(frame), _size, dcp::Eye::RIGHT, AV_PIX_FMT_XYZ12LE, optional()), frame ); } @@ -109,6 +108,7 @@ VideoMXFDecoder::pass () return false; } + void VideoMXFDecoder::seek (ContentTime t, bool accurate) { diff --git a/src/lib/video_mxf_decoder.h b/src/lib/video_mxf_decoder.h index ae5d2fb78..774e269c6 100644 --- a/src/lib/video_mxf_decoder.h +++ b/src/lib/video_mxf_decoder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,20 +18,23 @@ */ + #include "decoder.h" #include #include + class VideoMXFContent; class Log; + class VideoMXFDecoder : public Decoder { public: VideoMXFDecoder (std::shared_ptr film, std::shared_ptr); - bool pass (); - void seek (dcpomatic::ContentTime t, bool accurate); + bool pass () override; + void seek (dcpomatic::ContentTime t, bool accurate) override; private: diff --git a/src/wx/batch_job_view.cc b/src/wx/batch_job_view.cc index 07e330c4c..06f698874 100644 --- a/src/wx/batch_job_view.cc +++ b/src/wx/batch_job_view.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2017 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,56 +18,65 @@ */ + #include "batch_job_view.h" #include "dcpomatic_button.h" #include "lib/job_manager.h" #include #include + using std::list; using std::shared_ptr; + BatchJobView::BatchJobView (shared_ptr job, wxWindow* parent, wxWindow* container, wxFlexGridSizer* table) : JobView (job, parent, container, table) { } + int BatchJobView::insert_position () const { return _table->GetEffectiveRowsCount() * _table->GetEffectiveColsCount(); } + void BatchJobView::finish_setup (wxWindow* parent, wxSizer* sizer) { _higher_priority = new Button (parent, _("Higher priority")); - _higher_priority->Bind (wxEVT_BUTTON, boost::bind (&BatchJobView::higher_priority_clicked, this)); + _higher_priority->Bind (wxEVT_BUTTON, boost::bind(&BatchJobView::higher_priority_clicked, this)); sizer->Add (_higher_priority, 1, wxALIGN_CENTER_VERTICAL); _lower_priority = new Button (parent, _("Lower priority")); - _lower_priority->Bind (wxEVT_BUTTON, boost::bind (&BatchJobView::lower_priority_clicked, this)); + _lower_priority->Bind (wxEVT_BUTTON, boost::bind(&BatchJobView::lower_priority_clicked, this)); sizer->Add (_lower_priority, 1, wxALIGN_CENTER_VERTICAL); } + + void BatchJobView::higher_priority_clicked () { JobManager::instance()->increase_priority (_job); } + void BatchJobView::lower_priority_clicked () { JobManager::instance()->decrease_priority (_job); } + void BatchJobView::job_list_changed () { bool high = false; bool low = false; - list > jobs = JobManager::instance()->get(); - if (!jobs.empty ()) { + auto jobs = JobManager::instance()->get(); + if (!jobs.empty()) { if (_job != jobs.front()) { high = true; } diff --git a/src/wx/batch_job_view.h b/src/wx/batch_job_view.h index 688e6c374..6d9ccba31 100644 --- a/src/wx/batch_job_view.h +++ b/src/wx/batch_job_view.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2017 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,8 +18,10 @@ */ + #include "job_view.h" + class BatchJobView : public JobView { public: diff --git a/src/wx/content_properties_dialog.cc b/src/wx/content_properties_dialog.cc index 2e0e360d9..bc835edaf 100644 --- a/src/wx/content_properties_dialog.cc +++ b/src/wx/content_properties_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2018 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "content_properties_dialog.h" #include "wx_util.h" #include "static_text.h" @@ -26,6 +27,7 @@ #include "lib/audio_content.h" #include + using std::string; using std::list; using std::pair; @@ -33,10 +35,11 @@ using std::map; using std::shared_ptr; using std::dynamic_pointer_cast; + ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptr film, shared_ptr content) : TableDialog (parent, _("Content Properties"), 2, 1, false) { - map > grouped; + map> grouped; for (auto i: content->user_properties(film)) { if (grouped.find(i.category) == grouped.end()) { grouped[i.category] = list (); @@ -50,16 +53,17 @@ ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptr > const & groups, UserProperty::Category category) +ContentPropertiesDialog::maybe_add_group (map> const & groups, UserProperty::Category category) { - map >::const_iterator i = groups.find (category); + auto i = groups.find (category); if (i == groups.end()) { return; } @@ -80,7 +84,7 @@ ContentPropertiesDialog::maybe_add_group (mapSetFont (font); diff --git a/src/wx/content_properties_dialog.h b/src/wx/content_properties_dialog.h index 9faccb4b7..c7efa4497 100644 --- a/src/wx/content_properties_dialog.h +++ b/src/wx/content_properties_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2018 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,15 +18,18 @@ */ + #include "table_dialog.h" #include "lib/user_property.h" #include #include + class Content; class Film; class UserProperty; + class ContentPropertiesDialog : public TableDialog { public: diff --git a/src/wx/dkdm_dialog.cc b/src/wx/dkdm_dialog.cc index c46fed760..68fe4bae1 100644 --- a/src/wx/dkdm_dialog.cc +++ b/src/wx/dkdm_dialog.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,6 +18,7 @@ */ + #include "dkdm_dialog.h" #include "wx_util.h" #include "recipients_panel.h" @@ -37,6 +38,7 @@ #include #include + using std::string; using std::exception; using std::map; @@ -59,9 +61,9 @@ DKDMDialog::DKDMDialog (wxWindow* parent, shared_ptr film) , _film (film) { /* Main sizers */ - wxBoxSizer* horizontal = new wxBoxSizer (wxHORIZONTAL); - wxBoxSizer* left = new wxBoxSizer (wxVERTICAL); - wxBoxSizer* right = new wxBoxSizer (wxVERTICAL); + auto horizontal = new wxBoxSizer (wxHORIZONTAL); + auto left = new wxBoxSizer (wxVERTICAL); + auto right = new wxBoxSizer (wxVERTICAL); horizontal->Add (left, 1, wxEXPAND | wxRIGHT, DCPOMATIC_SIZER_X_GAP * 4); horizontal->Add (right, 1, wxEXPAND); @@ -71,7 +73,7 @@ DKDMDialog::DKDMDialog (wxWindow* parent, shared_ptr film) subheading_font.SetWeight (wxFONTWEIGHT_BOLD); /* Sub-heading: Screens */ - wxStaticText* h = new StaticText (this, _("Recipients")); + auto h = new StaticText (this, _("Recipients")); h->SetFont (subheading_font); left->Add (h, 0, wxBOTTOM, DCPOMATIC_SIZER_Y_GAP); _recipients = new RecipientsPanel (this); @@ -112,7 +114,7 @@ DKDMDialog::DKDMDialog (wxWindow* parent, shared_ptr film) /* Make an overall sizer to get a nice border */ - wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); + auto overall_sizer = new wxBoxSizer (wxVERTICAL); overall_sizer->Add (horizontal, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER); /* Bind */ @@ -128,6 +130,7 @@ DKDMDialog::DKDMDialog (wxWindow* parent, shared_ptr film) overall_sizer->SetSizeHints (this); } + void DKDMDialog::setup_sensitivity () { @@ -136,25 +139,27 @@ DKDMDialog::setup_sensitivity () _make->Enable (!_recipients->recipients().empty() && _timing->valid() && _cpl->has_selected()); } + bool DKDMDialog::confirm_overwrite (boost::filesystem::path path) { return confirm_dialog ( this, - wxString::Format (_("File %s already exists. Do you want to overwrite it?"), std_to_wx(path.string()).data()) + wxString::Format(_("File %s already exists. Do you want to overwrite it?"), std_to_wx(path.string()).data()) ); } + void DKDMDialog::make_clicked () { - shared_ptr film = _film.lock (); + auto film = _film.lock (); DCPOMATIC_ASSERT (film); list kdms; try { for (auto i: _recipients->recipients()) { - KDMWithMetadataPtr p = kdm_for_dkdm_recipient (film, _cpl->cpl(), i, _timing->from(), _timing->until()); + auto p = kdm_for_dkdm_recipient (film, _cpl->cpl(), i, _timing->from(), _timing->until()); if (p) { kdms.push_back (p); } @@ -171,17 +176,17 @@ DKDMDialog::make_clicked () return; } - pair, int> result = _output->make (kdms, film->name(), bind(&DKDMDialog::confirm_overwrite, this, _1)); + auto result = _output->make (kdms, film->name(), bind(&DKDMDialog::confirm_overwrite, this, _1)); if (result.first) { JobManager::instance()->add (result.first); } if (result.second > 0) { /* XXX: proper plural form support in wxWidgets? */ - wxString s = result.second == 1 ? _("%d DKDM written to %s") : _("%d DKDMs written to %s"); + auto s = result.second == 1 ? _("%d DKDM written to %s") : _("%d DKDMs written to %s"); message_dialog ( this, - wxString::Format (s, result.second, std_to_wx(_output->directory().string()).data()) + wxString::Format(s, result.second, std_to_wx(_output->directory().string()).data()) ); } } diff --git a/src/wx/dkdm_dialog.h b/src/wx/dkdm_dialog.h index 4235de511..7b20e88ec 100644 --- a/src/wx/dkdm_dialog.h +++ b/src/wx/dkdm_dialog.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 @@ */ + #include "wx_util.h" #include #include + class Film; class ScreensPanel; class RecipientsPanel; @@ -30,6 +32,7 @@ class DKDMOutputPanel; class KDMCPLPanel; struct CPLSummary; + class DKDMDialog : public wxDialog { public: diff --git a/src/wx/dolby_doremi_certificate_panel.h b/src/wx/dolby_doremi_certificate_panel.h index 665281073..2ff05ddec 100644 --- a/src/wx/dolby_doremi_certificate_panel.h +++ b/src/wx/dolby_doremi_certificate_panel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,13 +18,15 @@ */ + #include "download_certificate_panel.h" + class DolbyDoremiCertificatePanel : public DownloadCertificatePanel { public: DolbyDoremiCertificatePanel (DownloadCertificateDialog* dialog); - void do_download (); - wxString name () const; + void do_download () override; + wxString name () const override; }; diff --git a/src/wx/download_certificate_panel.cc b/src/wx/download_certificate_panel.cc index ae62f1a0a..b9680e298 100644 --- a/src/wx/download_certificate_panel.cc +++ b/src/wx/download_certificate_panel.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2020 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "wx_util.h" #include "download_certificate_panel.h" #include "download_certificate_dialog.h" @@ -28,10 +29,12 @@ #include #include + using std::string; using boost::function; using boost::optional; + DownloadCertificatePanel::DownloadCertificatePanel (DownloadCertificateDialog* dialog) : wxPanel (dialog->notebook(), wxID_ANY) , _dialog (dialog) @@ -59,11 +62,11 @@ optional DownloadCertificatePanel::load_certificate (boost::filesystem::path file) { try { - _certificate = dcp::Certificate (dcp::file_to_string (file)); + _certificate = dcp::Certificate (dcp::file_to_string(file)); } catch (dcp::MiscError& e) { return String::compose(wx_to_std(_("Could not read certificate file (%1)")), e.what()); } - return optional(); + return {}; } @@ -75,7 +78,7 @@ DownloadCertificatePanel::load_certificate_from_chain (boost::filesystem::path f } catch (dcp::MiscError& e) { return String::compose(wx_to_std(_("Could not read certificate file (%1)")), e.what()); } - return optional(); + return {}; } @@ -83,6 +86,7 @@ optional DownloadCertificatePanel::certificate () const { return _certificate; + } void @@ -93,11 +97,12 @@ DownloadCertificatePanel::download () /* Hack: without this the SetLabel() above has no visible effect */ wxMilliSleep (200); - signal_manager->when_idle (boost::bind (&DownloadCertificatePanel::do_download, this)); + signal_manager->when_idle (boost::bind(&DownloadCertificatePanel::do_download, this)); } + bool DownloadCertificatePanel::ready_to_download () const { - return !_serial->IsEmpty (); + return !_serial->IsEmpty(); } diff --git a/src/wx/download_certificate_panel.h b/src/wx/download_certificate_panel.h index ba355f813..25271c770 100644 --- a/src/wx/download_certificate_panel.h +++ b/src/wx/download_certificate_panel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,9 +18,11 @@ */ + #ifndef DCPOMATIC_DOWNLOAD_CERTIFICATE_PANEL_H #define DCPOMATIC_DOWNLOAD_CERTIFICATE_PANEL_H + #include "lib/warnings.h" #include DCPOMATIC_DISABLE_WARNINGS @@ -28,8 +30,10 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include + class DownloadCertificateDialog; + class DownloadCertificatePanel : public wxPanel { public: @@ -54,4 +58,5 @@ private: boost::optional _certificate; }; + #endif diff --git a/src/wx/email_dialog.cc b/src/wx/email_dialog.cc index 4d3ae4fe1..65fb47473 100644 --- a/src/wx/email_dialog.cc +++ b/src/wx/email_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,37 +18,42 @@ */ + #include "email_dialog.h" #include "wx_util.h" + using std::string; using std::shared_ptr; using boost::optional; + EmailDialog::EmailDialog (wxWindow* parent) : TableDialog (parent, _("Email address"), 2, 1, true) { add (_("Email address"), true); - _email = add (new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (400, -1))); + _email = add (new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(400, -1))); layout (); _email->SetFocus (); } + void EmailDialog::set (string address) { - _email->SetValue (std_to_wx (address)); + _email->SetValue (std_to_wx(address)); } + optional EmailDialog::get () const { - string s = wx_to_std (_email->GetValue ()); - if (s.empty ()) { + auto s = wx_to_std (_email->GetValue ()); + if (s.empty()) { /* Invalid email address */ - return optional (); + return {}; } return s; diff --git a/src/wx/email_dialog.h b/src/wx/email_dialog.h index 932dd8714..3f622f87d 100644 --- a/src/wx/email_dialog.h +++ b/src/wx/email_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,9 +18,11 @@ */ + #include "table_dialog.h" #include + class EmailDialog : public TableDialog { public: @@ -32,3 +34,4 @@ public: private: wxTextCtrl* _email; }; + diff --git a/src/wx/html_dialog.cc b/src/wx/html_dialog.cc index 978330187..dcae84cd9 100644 --- a/src/wx/html_dialog.cc +++ b/src/wx/html_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "html_dialog.h" #include "wx_util.h" #include "lib/cross.h" @@ -29,14 +30,16 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include + #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif + HTMLDialog::HTMLDialog (wxWindow* parent, wxString title, wxString html) : wxDialog (parent, wxID_ANY, title) { - wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); + auto sizer = new wxBoxSizer (wxVERTICAL); wxFileSystem::AddHandler(new wxMemoryFSHandler); @@ -46,7 +49,7 @@ HTMLDialog::HTMLDialog (wxWindow* parent, wxString title, wxString html) wxBitmap(std_to_wx(boost::filesystem::path(resources_path() / "me.jpg").string()), wxBITMAP_TYPE_JPEG), wxBITMAP_TYPE_JPEG ); - wxHtmlWindow* h = new wxHtmlWindow (this); + auto h = new wxHtmlWindow (this); h->SetPage (html); sizer->Add (h, 1, wxEXPAND | wxALL, 6); @@ -62,6 +65,7 @@ HTMLDialog::HTMLDialog (wxWindow* parent, wxString title, wxString html) SetSize (h->GetInternalRepresentation()->GetWidth(), h->GetInternalRepresentation()->GetHeight() + 64); } + void HTMLDialog::link_clicked (wxHtmlLinkEvent& ev) { diff --git a/src/wx/html_dialog.h b/src/wx/html_dialog.h index 9da4c8215..2b6924179 100644 --- a/src/wx/html_dialog.h +++ b/src/wx/html_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,13 +18,16 @@ */ + #include "lib/warnings.h" DCPOMATIC_DISABLE_WARNINGS #include DCPOMATIC_ENABLE_WARNINGS + class wxHtmlLinkEvent; + class HTMLDialog : public wxDialog { public: diff --git a/src/wx/move_to_dialog.cc b/src/wx/move_to_dialog.cc index 542655477..fdd118520 100644 --- a/src/wx/move_to_dialog.cc +++ b/src/wx/move_to_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,15 +18,18 @@ */ + #include "move_to_dialog.h" #include "lib/film.h" #include + using std::list; using std::shared_ptr; using boost::optional; using namespace dcpomatic; + MoveToDialog::MoveToDialog (wxWindow* parent, optional position, shared_ptr film) : TableDialog (parent, _("Move content"), 2, 0, true) , _film (film) @@ -49,13 +52,14 @@ MoveToDialog::MoveToDialog (wxWindow* parent, optional position, shared } } + DCPTime MoveToDialog::position () const { - shared_ptr film = _film.lock (); + auto film = _film.lock (); DCPOMATIC_ASSERT (film); - list reels = film->reels (); - list::const_iterator i = reels.begin (); + auto reels = film->reels (); + auto i = reels.begin (); for (int j = 0; j < _reel->GetValue() - 1; ++j) { DCPOMATIC_ASSERT (i != reels.end()); ++i; diff --git a/src/wx/move_to_dialog.h b/src/wx/move_to_dialog.h index 61520a71f..16267bc9b 100644 --- a/src/wx/move_to_dialog.h +++ b/src/wx/move_to_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,13 +18,16 @@ */ + #include "table_dialog.h" #include "lib/dcpomatic_time.h" #include + class Film; class wxSpinCtrl; + class MoveToDialog : public TableDialog { public: diff --git a/src/wx/name_format_editor.cc b/src/wx/name_format_editor.cc index 5755d75f4..b2c11b50c 100644 --- a/src/wx/name_format_editor.cc +++ b/src/wx/name_format_editor.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016-2018 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,18 +18,21 @@ */ + #include "name_format_editor.h" #include "wx_util.h" #include "static_text.h" #include "lib/util.h" + using std::string; + NameFormatEditor::NameFormatEditor (wxWindow* parent, dcp::NameFormat name, dcp::NameFormat::Map titles, dcp::NameFormat::Map examples, string suffix) - : _panel (new wxPanel (parent)) - , _example (new StaticText (_panel, "")) - , _sizer (new wxBoxSizer (wxVERTICAL)) - , _specification (new wxTextCtrl (_panel, wxID_ANY, "")) + : _panel (new wxPanel(parent)) + , _example (new StaticText(_panel, "")) + , _sizer (new wxBoxSizer(wxVERTICAL)) + , _specification (new wxTextCtrl(_panel, wxID_ANY, "")) , _name (name) , _examples (examples) , _suffix (suffix) @@ -40,22 +43,23 @@ NameFormatEditor::NameFormatEditor (wxWindow* parent, dcp::NameFormat name, dcp: } _panel->SetSizer (_sizer); - for (dcp::NameFormat::Map::const_iterator i = titles.begin(); i != titles.end(); ++i) { - wxStaticText* t = new StaticText (_panel, std_to_wx (String::compose ("%%%1 %2", i->first, i->second))); + for (auto const& i: titles) { + auto t = new StaticText (_panel, std_to_wx (String::compose ("%%%1 %2", i.first, i.second))); _sizer->Add (t); - wxFont font = t->GetFont(); + auto font = t->GetFont(); font.SetStyle (wxFONTSTYLE_ITALIC); font.SetPointSize (font.GetPointSize() - 1); t->SetFont (font); t->SetForegroundColour (wxColour (0, 0, 204)); } - _specification->SetValue (std_to_wx (_name.specification ())); - _specification->Bind (wxEVT_TEXT, boost::bind (&NameFormatEditor::changed, this)); + _specification->SetValue (std_to_wx (_name.specification())); + _specification->Bind (wxEVT_TEXT, boost::bind(&NameFormatEditor::changed, this)); update_example (); } + void NameFormatEditor::changed () { @@ -63,6 +67,7 @@ NameFormatEditor::changed () Changed (); } + void NameFormatEditor::update_example () { @@ -70,9 +75,9 @@ NameFormatEditor::update_example () return; } - _name.set_specification (careful_string_filter (wx_to_std (_specification->GetValue ()))); + _name.set_specification (careful_string_filter(wx_to_std(_specification->GetValue()))); - wxString example = wxString::Format (_("e.g. %s"), std_to_wx (_name.get (_examples, _suffix))); + auto example = wxString::Format (_("e.g. %s"), std_to_wx (_name.get (_examples, _suffix))); wxString wrapped; for (size_t i = 0; i < example.Length(); ++i) { if (i > 0 && (i % 40) == 0) { diff --git a/src/wx/name_format_editor.h b/src/wx/name_format_editor.h index e3728615f..596b42740 100644 --- a/src/wx/name_format_editor.h +++ b/src/wx/name_format_editor.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,9 +18,11 @@ */ + #ifndef DCPOMATIC_NAME_FORMAT_EDITOR_H #define DCPOMATIC_NAME_FORMAT_EDITOR_H + #include "lib/compose.hpp" #include "lib/warnings.h" #include @@ -29,6 +31,7 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include + class NameFormatEditor { public: @@ -59,4 +62,5 @@ private: std::string _suffix; }; + #endif diff --git a/src/wx/normal_job_view.cc b/src/wx/normal_job_view.cc index 6c9c08fa7..6d2b7e9f2 100644 --- a/src/wx/normal_job_view.cc +++ b/src/wx/normal_job_view.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2017 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,20 +18,23 @@ */ + #include "normal_job_view.h" #include "dcpomatic_button.h" #include "lib/job.h" #include + using std::shared_ptr; + NormalJobView::NormalJobView (shared_ptr job, wxWindow* parent, wxWindow* container, wxFlexGridSizer* table) : JobView (job, parent, container, table) - , _pause (0) { } + void NormalJobView::finish_setup (wxWindow* parent, wxSizer* sizer) { @@ -41,11 +44,13 @@ NormalJobView::finish_setup (wxWindow* parent, wxSizer* sizer) } int + NormalJobView::insert_position () const { return 0; } + void NormalJobView::pause_clicked () { @@ -58,6 +63,7 @@ NormalJobView::pause_clicked () } } + void NormalJobView::finished () { diff --git a/src/wx/normal_job_view.h b/src/wx/normal_job_view.h index ea1a014f4..acd8111b6 100644 --- a/src/wx/normal_job_view.h +++ b/src/wx/normal_job_view.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,10 +18,13 @@ */ + #include "job_view.h" + class wxSizer; + class NormalJobView : public JobView { public: @@ -35,5 +38,5 @@ private: void pause_clicked (); void finished (); - wxButton* _pause; + wxButton* _pause = nullptr; }; diff --git a/src/wx/paste_dialog.cc b/src/wx/paste_dialog.cc index cd4518881..429e8fe6e 100644 --- a/src/wx/paste_dialog.cc +++ b/src/wx/paste_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,9 +18,11 @@ */ + #include "paste_dialog.h" #include "check_box.h" + PasteDialog::PasteDialog (wxWindow* parent, bool video, bool audio, bool text) : TableDialog (parent, _("Paste"), 1, 0, true) { @@ -37,18 +39,21 @@ PasteDialog::PasteDialog (wxWindow* parent, bool video, bool audio, bool text) layout (); } + bool PasteDialog::video () const { return _video->GetValue (); } + bool PasteDialog::audio () const { return _audio->GetValue (); } + bool PasteDialog::text () const { diff --git a/src/wx/paste_dialog.h b/src/wx/paste_dialog.h index 792195947..1f447d3f8 100644 --- a/src/wx/paste_dialog.h +++ b/src/wx/paste_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,8 +18,10 @@ */ + #include "table_dialog.h" + class PasteDialog : public TableDialog { public: diff --git a/src/wx/qube_certificate_panel.cc b/src/wx/qube_certificate_panel.cc index c67cc46f2..e1c6bfb41 100644 --- a/src/wx/qube_certificate_panel.cc +++ b/src/wx/qube_certificate_panel.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 "qube_certificate_panel.h" #include "download_certificate_dialog.h" #include "wx_util.h" @@ -26,6 +27,7 @@ #include "lib/config.h" #include + using std::string; using std::list; using boost::optional; @@ -33,8 +35,10 @@ using boost::optional; using namespace boost::placeholders; #endif + static string const base = "ftp://certificates.qubecinema.com/"; + QubeCertificatePanel::QubeCertificatePanel (DownloadCertificateDialog* dialog, string type) : DownloadCertificatePanel (dialog) , _type (type) @@ -42,16 +46,17 @@ QubeCertificatePanel::QubeCertificatePanel (DownloadCertificateDialog* dialog, s } + void QubeCertificatePanel::do_download () { - list files = ls_url(String::compose("%1SMPTE-%2/", base, _type)); + auto files = ls_url(String::compose("%1SMPTE-%2/", base, _type)); if (files.empty()) { error_dialog (this, _("Could not read certificates from Qube server.")); return; } - string const serial = wx_to_std(_serial->GetValue()); + auto const serial = wx_to_std(_serial->GetValue()); optional name; for (auto i: files) { if (boost::algorithm::starts_with(i, String::compose("%1-%2-", _type, serial))) { @@ -66,7 +71,7 @@ QubeCertificatePanel::do_download () return; } - optional error = get_from_url (String::compose("%1SMPTE-%2/%3", base, _type, *name), true, false, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1)); + auto error = get_from_url (String::compose("%1SMPTE-%2/%3", base, _type, *name), true, false, boost::bind(&DownloadCertificatePanel::load_certificate, this, _1)); if (error) { _dialog->message()->SetLabel(wxT("")); @@ -77,6 +82,7 @@ QubeCertificatePanel::do_download () } } + wxString QubeCertificatePanel::name () const { diff --git a/src/wx/qube_certificate_panel.h b/src/wx/qube_certificate_panel.h index 89c67f60e..a9053dd1b 100644 --- a/src/wx/qube_certificate_panel.h +++ b/src/wx/qube_certificate_panel.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,15 +18,17 @@ */ + #include "download_certificate_panel.h" + class QubeCertificatePanel : public DownloadCertificatePanel { public: QubeCertificatePanel (DownloadCertificateDialog* dialog, std::string type); - void do_download (); - wxString name () const; + void do_download () override; + wxString name () const override; private: std::string _type; diff --git a/src/wx/rename_template_dialog.cc b/src/wx/rename_template_dialog.cc index 970c85a8b..714e08057 100644 --- a/src/wx/rename_template_dialog.cc +++ b/src/wx/rename_template_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,24 +18,28 @@ */ + #include "rename_template_dialog.h" + RenameTemplateDialog::RenameTemplateDialog (wxWindow* parent) : TableDialog (parent, _("Rename template"), 2, 1, true) { add (_("New name"), true); - _name = add (new wxTextCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (300, -1))); + _name = add (new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300, -1))); layout (); _name->SetFocus (); } + wxString RenameTemplateDialog::get () const { return _name->GetValue (); } + void RenameTemplateDialog::set (wxString s) { diff --git a/src/wx/rename_template_dialog.h b/src/wx/rename_template_dialog.h index 4ad4ee4c4..d4304ff45 100644 --- a/src/wx/rename_template_dialog.h +++ b/src/wx/rename_template_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,8 +18,10 @@ */ + #include "table_dialog.h" + class RenameTemplateDialog : public TableDialog { public: diff --git a/src/wx/self_dkdm_dialog.cc b/src/wx/self_dkdm_dialog.cc index 71ea089dd..157912d37 100644 --- a/src/wx/self_dkdm_dialog.cc +++ b/src/wx/self_dkdm_dialog.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 "self_dkdm_dialog.h" #include "wx_util.h" #include "kdm_output_panel.h" @@ -42,6 +43,7 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include + using std::string; using std::map; using std::list; @@ -52,18 +54,19 @@ using std::make_pair; using std::shared_ptr; using boost::bind; + SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, std::shared_ptr film) : wxDialog (parent, wxID_ANY, _("Make DKDM for DCP-o-matic")) { /* Main sizer */ - wxBoxSizer* vertical = new wxBoxSizer (wxVERTICAL); + auto vertical = new wxBoxSizer (wxVERTICAL); /* Font for sub-headings */ wxFont subheading_font (*wxNORMAL_FONT); subheading_font.SetWeight (wxFONTWEIGHT_BOLD); /* Sub-heading: CPL */ - wxStaticText* h = new StaticText (this, _("CPL")); + auto h = new StaticText (this, _("CPL")); h->SetFont (subheading_font); vertical->Add (h); _cpl = new KDMCPLPanel (this, film->cpls ()); @@ -77,7 +80,7 @@ SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, std::shared_ptr fi _internal = new wxRadioButton (this, wxID_ANY, _("Save to KDM Creator tool's list")); vertical->Add (_internal, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP); - wxBoxSizer* w = new wxBoxSizer (wxHORIZONTAL); + auto w = new wxBoxSizer (wxHORIZONTAL); _write_to = new wxRadioButton (this, wxID_ANY, _("Write to")); w->Add (_write_to, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, DCPOMATIC_SIZER_GAP); @@ -96,10 +99,10 @@ SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, std::shared_ptr fi /* Make an overall sizer to get a nice border, and put some buttons in */ - wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL); + auto overall_sizer = new wxBoxSizer (wxVERTICAL); overall_sizer->Add (vertical, 0, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER); - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); + auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); if (buttons) { overall_sizer->Add (buttons, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_Y_GAP); } @@ -122,43 +125,48 @@ SelfDKDMDialog::SelfDKDMDialog (wxWindow* parent, std::shared_ptr fi _write_to->Bind (wxEVT_RADIOBUTTON, bind (&SelfDKDMDialog::dkdm_write_type_changed, this)); } + void SelfDKDMDialog::dkdm_write_type_changed () { setup_sensitivity (); - if (_internal->GetValue ()) { - Config::instance()->set_last_dkdm_write_type (Config::DKDM_WRITE_INTERNAL); - } else if (_write_to->GetValue ()) { - Config::instance()->set_last_dkdm_write_type (Config::DKDM_WRITE_FILE); + if (_internal->GetValue()) { + Config::instance()->set_last_dkdm_write_type(Config::DKDM_WRITE_INTERNAL); + } else if (_write_to->GetValue()) { + Config::instance()->set_last_dkdm_write_type(Config::DKDM_WRITE_FILE); } } + void SelfDKDMDialog::setup_sensitivity () { _folder->Enable (_write_to->GetValue ()); - wxButton* ok = dynamic_cast (FindWindowById (wxID_OK, this)); + auto ok = dynamic_cast(FindWindowById(wxID_OK, this)); if (ok) { ok->Enable (_cpl->has_selected ()); } } + boost::filesystem::path SelfDKDMDialog::cpl () const { return _cpl->cpl (); } + bool SelfDKDMDialog::internal () const { return _internal->GetValue (); } + boost::filesystem::path SelfDKDMDialog::directory () const { - return wx_to_std (_folder->GetPath ()); + return wx_to_std (_folder->GetPath()); } diff --git a/src/wx/self_dkdm_dialog.h b/src/wx/self_dkdm_dialog.h index 20c138c41..151231a00 100644 --- a/src/wx/self_dkdm_dialog.h +++ b/src/wx/self_dkdm_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "wx_util.h" #include "lib/warnings.h" #include @@ -27,11 +28,13 @@ DCPOMATIC_ENABLE_WARNINGS #include #include + class Film; class KDMCPLPanel; class wxDirPickerCtrl; class DirPickerCtrl; + class SelfDKDMDialog : public wxDialog { public: diff --git a/src/wx/standard_controls.cc b/src/wx/standard_controls.cc index c78844ca1..1e4ecc8d7 100644 --- a/src/wx/standard_controls.cc +++ b/src/wx/standard_controls.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,13 +18,16 @@ */ -#include "standard_controls.h" + #include "film_viewer.h" -#include +#include "standard_controls.h" #include +#include + using std::shared_ptr; + StandardControls::StandardControls (wxWindow* parent, shared_ptr viewer, bool editor_controls) : Controls (parent, viewer, editor_controls) , _play_button (new wxToggleButton(this, wxID_ANY, _("Play"))) @@ -33,6 +36,7 @@ StandardControls::StandardControls (wxWindow* parent, shared_ptr vie _play_button->Bind (wxEVT_TOGGLEBUTTON, boost::bind(&StandardControls::play_clicked, this)); } + void StandardControls::started () { @@ -40,6 +44,7 @@ StandardControls::started () _play_button->SetValue (true); } + void StandardControls::stopped () { @@ -47,12 +52,14 @@ StandardControls::stopped () _play_button->SetValue (false); } + void StandardControls::play_clicked () { check_play_state (); } + void StandardControls::check_play_state () { @@ -67,6 +74,7 @@ StandardControls::check_play_state () } } + void StandardControls::setup_sensitivity () { @@ -75,6 +83,7 @@ StandardControls::setup_sensitivity () _play_button->Enable (_film && !_film->content().empty() && !active_job); } + void StandardControls::play () { @@ -82,6 +91,7 @@ StandardControls::play () play_clicked (); } + void StandardControls::stop () { diff --git a/src/wx/standard_controls.h b/src/wx/standard_controls.h index eac47726b..191924509 100644 --- a/src/wx/standard_controls.h +++ b/src/wx/standard_controls.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,8 +18,10 @@ */ + #include "controls.h" + class StandardControls : public Controls { public: diff --git a/src/wx/suspender.cc b/src/wx/suspender.cc index 6cd78326a..88128874c 100644 --- a/src/wx/suspender.cc +++ b/src/wx/suspender.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,8 +18,10 @@ */ + #include "suspender.h" + Suspender::Suspender(boost::function handler) : _handler (handler) , _count (0) @@ -27,29 +29,34 @@ Suspender::Suspender(boost::function handler) } + Suspender::Block::Block (Suspender* s) : _suspender (s) { _suspender->increment (); } + Suspender::Block::~Block () { _suspender->decrement (); } + Suspender::Block Suspender::block () { return Block (this); } + void Suspender::increment () { ++_count; } + void Suspender::decrement () { @@ -62,6 +69,7 @@ Suspender::decrement () } } + bool Suspender::check (int property) { diff --git a/src/wx/suspender.h b/src/wx/suspender.h index 3538951a8..947d7a367 100644 --- a/src/wx/suspender.h +++ b/src/wx/suspender.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,9 +18,11 @@ */ + #include #include + class Suspender { public: diff --git a/src/wx/templates_dialog.cc b/src/wx/templates_dialog.cc index e8f9b8a2b..259989d47 100644 --- a/src/wx/templates_dialog.cc +++ b/src/wx/templates_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "templates_dialog.h" #include "wx_util.h" #include "rename_template_dialog.h" @@ -25,19 +26,21 @@ #include "lib/config.h" #include + using std::string; using boost::bind; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif + TemplatesDialog::TemplatesDialog (wxWindow* parent) : wxDialog (parent, wxID_ANY, _("Templates")) { _sizer = new wxBoxSizer (wxVERTICAL); SetSizer (_sizer); - wxSizer* hs = new wxBoxSizer (wxHORIZONTAL); + auto hs = new wxBoxSizer (wxHORIZONTAL); _list = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxSize (200, 100), wxLC_REPORT | wxLC_SINGLE_SEL); wxListItem ip; @@ -49,7 +52,7 @@ TemplatesDialog::TemplatesDialog (wxWindow* parent) hs->Add (_list, 1, wxEXPAND, DCPOMATIC_SIZER_GAP); { - wxSizer* s = new wxBoxSizer (wxVERTICAL); + auto s = new wxBoxSizer (wxVERTICAL); _rename = new Button (this, _("Rename...")); s->Add (_rename, 0, wxTOP | wxBOTTOM, 2); _remove = new Button (this, _("Remove")); @@ -59,23 +62,24 @@ TemplatesDialog::TemplatesDialog (wxWindow* parent) _sizer->Add (hs, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); - wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE); + auto buttons = CreateSeparatedButtonSizer (wxCLOSE); if (buttons) { _sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); } - _rename->Bind (wxEVT_BUTTON, bind (&TemplatesDialog::rename_clicked, this)); - _remove->Bind (wxEVT_BUTTON, bind (&TemplatesDialog::remove_clicked, this)); + _rename->Bind (wxEVT_BUTTON, bind(&TemplatesDialog::rename_clicked, this)); + _remove->Bind (wxEVT_BUTTON, bind(&TemplatesDialog::remove_clicked, this)); - _list->Bind (wxEVT_LIST_ITEM_SELECTED, bind (&TemplatesDialog::selection_changed, this)); - _list->Bind (wxEVT_LIST_ITEM_DESELECTED, bind (&TemplatesDialog::selection_changed, this)); - _list->Bind (wxEVT_SIZE, bind (&TemplatesDialog::resized, this, _1)); - _config_connection = Config::instance()->Changed.connect (bind (&TemplatesDialog::refresh, this)); + _list->Bind (wxEVT_LIST_ITEM_SELECTED, bind(&TemplatesDialog::selection_changed, this)); + _list->Bind (wxEVT_LIST_ITEM_DESELECTED, bind(&TemplatesDialog::selection_changed, this)); + _list->Bind (wxEVT_SIZE, bind(&TemplatesDialog::resized, this, _1)); + _config_connection = Config::instance()->Changed.connect (bind(&TemplatesDialog::refresh, this)); refresh (); selection_changed (); } + void TemplatesDialog::refresh () { @@ -90,12 +94,14 @@ TemplatesDialog::refresh () } } + void TemplatesDialog::layout () { _sizer->Layout (); } + void TemplatesDialog::selection_changed () { @@ -104,6 +110,7 @@ TemplatesDialog::selection_changed () _remove->Enable (i >= 0); } + void TemplatesDialog::rename_clicked () { @@ -118,7 +125,7 @@ TemplatesDialog::rename_clicked () li.m_mask = wxLIST_MASK_TEXT; _list->GetItem (li); - RenameTemplateDialog* d = new RenameTemplateDialog (this); + auto d = new RenameTemplateDialog (this); d->set (li.m_text); if (d->ShowModal() == wxID_OK) { if (!d->get().IsEmpty()) { @@ -131,6 +138,7 @@ TemplatesDialog::rename_clicked () d->Destroy (); } + void TemplatesDialog::remove_clicked () { @@ -145,12 +153,13 @@ TemplatesDialog::remove_clicked () li.m_mask = wxLIST_MASK_TEXT; _list->GetItem (li); - Config::instance()->delete_template (wx_to_std (li.m_text)); + Config::instance()->delete_template (wx_to_std(li.m_text)); _list->DeleteItem (i); selection_changed (); } + void TemplatesDialog::resized (wxSizeEvent& ev) { diff --git a/src/wx/templates_dialog.h b/src/wx/templates_dialog.h index 4a55e0beb..119eb42cf 100644 --- a/src/wx/templates_dialog.h +++ b/src/wx/templates_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "lib/warnings.h" DCPOMATIC_DISABLE_WARNINGS #include @@ -25,6 +26,7 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include + class TemplatesDialog : public wxDialog { public: diff --git a/src/wx/timeline_atmos_content_view.cc b/src/wx/timeline_atmos_content_view.cc index f982921ed..ec0f06ec1 100644 --- a/src/wx/timeline_atmos_content_view.cc +++ b/src/wx/timeline_atmos_content_view.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,10 +18,13 @@ */ + #include "timeline_atmos_content_view.h" + using std::shared_ptr; + /** @class TimelineAtmosContentView * @brief Timeline view for AtmosContent. */ @@ -32,12 +35,14 @@ TimelineAtmosContentView::TimelineAtmosContentView (Timeline& tl, shared_ptr + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,8 +18,10 @@ */ + #include "timeline_content_view.h" + /** @class TimelineAtmosContentView * @brief Timeline view for AtmosContent. */ @@ -29,9 +31,10 @@ public: TimelineAtmosContentView (Timeline& tl, std::shared_ptr c); private: - bool active () const { + bool active () const override { return true; } - wxColour background_colour () const; - wxColour foreground_colour () const; + + wxColour background_colour () const override; + wxColour foreground_colour () const override; }; diff --git a/src/wx/timeline_audio_content_view.h b/src/wx/timeline_audio_content_view.h index d5a966ad5..5b8d6cdc2 100644 --- a/src/wx/timeline_audio_content_view.h +++ b/src/wx/timeline_audio_content_view.h @@ -18,8 +18,10 @@ */ + #include "timeline_content_view.h" + /** @class TimelineAudioContentView * @brief Timeline view for AudioContent. */ @@ -29,10 +31,10 @@ public: TimelineAudioContentView (Timeline& tl, std::shared_ptr c); private: - bool active () const { + bool active () const override { return true; } - wxColour background_colour () const; - wxColour foreground_colour () const; - wxString label () const; + wxColour background_colour () const override; + wxColour foreground_colour () const override; + wxString label () const override; }; diff --git a/src/wx/timeline_content_view.h b/src/wx/timeline_content_view.h index e9b294854..7087e9641 100644 --- a/src/wx/timeline_content_view.h +++ b/src/wx/timeline_content_view.h @@ -18,9 +18,11 @@ */ + #ifndef DCPOMATIC_TIMELINE_CONTENT_VIEW_H #define DCPOMATIC_TIMELINE_CONTENT_VIEW_H + #include "lib/change_signaller.h" #include "lib/types.h" #include "lib/warnings.h" @@ -32,6 +34,7 @@ DCPOMATIC_ENABLE_WARNINGS class Content; + /** @class TimelineContentView * @brief Parent class for views of pieces of content. */ @@ -40,7 +43,7 @@ class TimelineContentView : public TimelineView public: TimelineContentView (Timeline& tl, std::shared_ptr c); - dcpomatic::Rect bbox () const; + dcpomatic::Rect bbox () const override; void set_selected (bool s); bool selected () const; @@ -60,7 +63,7 @@ protected: private: - void do_paint (wxGraphicsContext* gc, std::list > overlaps); + void do_paint (wxGraphicsContext* gc, std::list> overlaps) override; int y_pos (int t) const; void content_change (ChangeType type, int p); @@ -70,6 +73,8 @@ private: boost::signals2::scoped_connection _content_connection; }; -typedef std::vector > TimelineContentViewList; + +typedef std::vector> TimelineContentViewList; + #endif diff --git a/src/wx/timeline_dialog.cc b/src/wx/timeline_dialog.cc index 5be006b60..975f7cd9d 100644 --- a/src/wx/timeline_dialog.cc +++ b/src/wx/timeline_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2019 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,17 +18,19 @@ */ + +#include "content_panel.h" #include "film_editor.h" #include "timeline_dialog.h" #include "wx_util.h" -#include "content_panel.h" -#include "lib/playlist.h" -#include "lib/cross.h" #include "lib/compose.hpp" +#include "lib/cross.h" +#include "lib/playlist.h" #include #include #include + using std::list; using std::cout; using std::string; @@ -38,6 +40,7 @@ using std::weak_ptr; using namespace boost::placeholders; #endif + TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr film, weak_ptr viewer) : wxDialog ( cp->window(), @@ -81,7 +84,7 @@ TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr film, weak_pt sizer->Add (&_timeline, 1, wxEXPAND | wxALL, 12); #ifdef DCPOMATIC_LINUX - wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE); + auto buttons = CreateSeparatedButtonSizer (wxCLOSE); if (buttons) { sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); } @@ -97,6 +100,7 @@ TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr film, weak_pt _film_changed_connection = film->Change.connect (bind (&TimelineDialog::film_change, this, _1, _2)); } + void TimelineDialog::film_change (ChangeType type, Film::Property p) { @@ -114,23 +118,25 @@ TimelineDialog::film_change (ChangeType type, Film::Property p) } } + void TimelineDialog::set_selection (ContentList selection) { _timeline.set_selection (selection); } + void TimelineDialog::tool_clicked (wxCommandEvent& ev) { - Timeline::Tool t = (Timeline::Tool) ev.GetId(); + Timeline::Tool t = static_cast(ev.GetId()); _timeline.tool_clicked (t); if (t == Timeline::SNAP) { - _timeline.set_snap (_toolbar->GetToolState ((int) t)); + _timeline.set_snap (_toolbar->GetToolState(static_cast(t))); } else if (t == Timeline::SEQUENCE) { auto film = _film.lock (); if (film) { - film->set_sequence (_toolbar->GetToolState ((int) t)); + film->set_sequence (_toolbar->GetToolState(static_cast(t))); } } } diff --git a/src/wx/timeline_dialog.h b/src/wx/timeline_dialog.h index 97ddca964..17128e108 100644 --- a/src/wx/timeline_dialog.h +++ b/src/wx/timeline_dialog.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2019 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,14 @@ */ + #include #include "timeline.h" + class Playlist; + class TimelineDialog : public wxDialog { public: diff --git a/src/wx/timeline_labels_view.h b/src/wx/timeline_labels_view.h index 2ff1fa6a8..fb80b1bf3 100644 --- a/src/wx/timeline_labels_view.h +++ b/src/wx/timeline_labels_view.h @@ -30,7 +30,7 @@ class TimelineLabelsView : public TimelineView public: explicit TimelineLabelsView (Timeline& tl); - dcpomatic::Rect bbox () const; + dcpomatic::Rect bbox () const override; void set_video_tracks (int n); void set_audio_tracks (int n); @@ -38,7 +38,7 @@ public: void set_atmos (bool s); private: - void do_paint (wxGraphicsContext* gc, std::list> overlaps); + void do_paint (wxGraphicsContext* gc, std::list> overlaps) override; int _width = 0; int _video_tracks = 0; diff --git a/src/wx/timeline_reels_view.h b/src/wx/timeline_reels_view.h index a6c73100f..357fe2ce4 100644 --- a/src/wx/timeline_reels_view.h +++ b/src/wx/timeline_reels_view.h @@ -27,11 +27,11 @@ class TimelineReelsView : public TimelineView public: TimelineReelsView (Timeline& tl, int y); - dcpomatic::Rect bbox () const; + dcpomatic::Rect bbox () const override; void set_y (int y); private: - void do_paint (wxGraphicsContext* gc, std::list> overlaps); + void do_paint (wxGraphicsContext* gc, std::list> overlaps) override; int _y; }; diff --git a/src/wx/timeline_video_content_view.h b/src/wx/timeline_video_content_view.h index 2269a2930..fa8ddf54c 100644 --- a/src/wx/timeline_video_content_view.h +++ b/src/wx/timeline_video_content_view.h @@ -18,8 +18,10 @@ */ + #include "timeline_content_view.h" + /** @class TimelineVideoContentView * @brief Timeline view for VideoContent. */ @@ -29,7 +31,7 @@ public: TimelineVideoContentView (Timeline& tl, std::shared_ptr c); private: - bool active () const; - wxColour background_colour () const; - wxColour foreground_colour () const; + bool active () const override; + wxColour background_colour () const override; + wxColour foreground_colour () const override; }; diff --git a/src/wx/timeline_view.h b/src/wx/timeline_view.h index c40cf78ff..f3aa4d5e6 100644 --- a/src/wx/timeline_view.h +++ b/src/wx/timeline_view.h @@ -43,13 +43,13 @@ public: TimelineView (TimelineView const&) = delete; TimelineView& operator= (TimelineView const&) = delete; - void paint (wxGraphicsContext* g, std::list > overlaps); + void paint (wxGraphicsContext* g, std::list> overlaps); void force_redraw (); virtual dcpomatic::Rect bbox () const = 0; protected: - virtual void do_paint (wxGraphicsContext *, std::list > overlaps) = 0; + virtual void do_paint (wxGraphicsContext *, std::list> overlaps) = 0; int time_x (dcpomatic::DCPTime t) const; diff --git a/src/wx/try_unmount_dialog.cc b/src/wx/try_unmount_dialog.cc index 44d970919..ffa4af535 100644 --- a/src/wx/try_unmount_dialog.cc +++ b/src/wx/try_unmount_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,23 +18,25 @@ */ + #include "try_unmount_dialog.h" #include "wx_util.h" #include "static_text.h" #include + TryUnmountDialog::TryUnmountDialog (wxWindow* parent, wxString description) : wxDialog (parent, wxID_ANY, _("DCP-o-matic Disk Writer")) { - wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); - wxStaticText* text = new StaticText (this, wxEmptyString); + auto sizer = new wxBoxSizer (wxVERTICAL); + auto text = new StaticText (this, wxEmptyString); sizer->Add (text, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); text->SetLabelMarkup ( wxString::Format(_("The drive %s is mounted.\n\nIt must be unmounted before DCP-o-matic can write to it.\n\nShould DCP-o-matic try to unmount it now?"), description) ); - wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); + auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); if (buttons) { sizer->Add(buttons, wxSizerFlags().Expand().DoubleBorder()); } diff --git a/src/wx/try_unmount_dialog.h b/src/wx/try_unmount_dialog.h index de686f14c..cb01a2afb 100644 --- a/src/wx/try_unmount_dialog.h +++ b/src/wx/try_unmount_dialog.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,11 +18,13 @@ */ + #include "lib/warnings.h" DCPOMATIC_DISABLE_WARNINGS #include DCPOMATIC_ENABLE_WARNINGS + class TryUnmountDialog : public wxDialog { public: diff --git a/src/wx/video_waveform_plot.cc b/src/wx/video_waveform_plot.cc index 7293af690..2e45f3493 100644 --- a/src/wx/video_waveform_plot.cc +++ b/src/wx/video_waveform_plot.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2018 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,13 @@ */ -#include "video_waveform_plot.h" + #include "film_viewer.h" +#include "video_waveform_plot.h" #include "wx_util.h" -#include "lib/image.h" -#include "lib/film.h" #include "lib/dcp_video.h" +#include "lib/film.h" +#include "lib/image.h" #include "lib/player_video.h" #include #include @@ -32,12 +33,14 @@ #include #include + using std::cout; -using std::min; +using std::make_shared; using std::max; +using std::min; +using std::shared_ptr; using std::string; using std::weak_ptr; -using std::shared_ptr; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif @@ -52,28 +55,25 @@ int const VideoWaveformPlot::_x_axis_width = 52; VideoWaveformPlot::VideoWaveformPlot (wxWindow* parent, weak_ptr film, weak_ptr viewer) : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE) , _film (film) - , _dirty (true) - , _enabled (false) - , _component (0) - , _contrast (0) { #ifndef __WXOSX__ SetDoubleBuffered (true); #endif - shared_ptr fv = viewer.lock (); + auto fv = viewer.lock (); DCPOMATIC_ASSERT (fv); - _viewer_connection = fv->ImageChanged.connect (boost::bind (&VideoWaveformPlot::set_image, this, _1)); + _viewer_connection = fv->ImageChanged.connect (boost::bind(&VideoWaveformPlot::set_image, this, _1)); - Bind (wxEVT_PAINT, boost::bind (&VideoWaveformPlot::paint, this)); - Bind (wxEVT_SIZE, boost::bind (&VideoWaveformPlot::sized, this, _1)); - Bind (wxEVT_MOTION, boost::bind (&VideoWaveformPlot::mouse_moved, this, _1)); + Bind (wxEVT_PAINT, boost::bind(&VideoWaveformPlot::paint, this)); + Bind (wxEVT_SIZE, boost::bind(&VideoWaveformPlot::sized, this, _1)); + Bind (wxEVT_MOTION, boost::bind(&VideoWaveformPlot::mouse_moved, this, _1)); SetMinSize (wxSize (640, 512)); SetBackgroundColour (wxColour (0, 0, 0)); } + void VideoWaveformPlot::paint () { @@ -88,7 +88,7 @@ VideoWaveformPlot::paint () return; } - wxGraphicsContext* gc = wxGraphicsContext::Create (dc); + auto gc = wxGraphicsContext::Create (dc); if (!gc) { return; } @@ -119,7 +119,7 @@ VideoWaveformPlot::paint () } for (int i = 0; i < label_gaps + 1; ++i) { - wxGraphicsPath p = gc->CreatePath (); + auto p = gc->CreatePath (); int const y = _vertical_margin + height - (i * height / label_gaps) - 1; p.MoveToPoint (label_width + 8, y); p.AddLineToPoint (_x_axis_width - 4, y); @@ -133,7 +133,7 @@ VideoWaveformPlot::paint () } else if (n < 1000) { x += extra[2]; } - gc->DrawText (std_to_wx (locale_convert (n)), x, y - (label_height / 2)); + gc->DrawText (std_to_wx(locale_convert(n)), x, y - (label_height / 2)); } wxImage waveform (_waveform->size().width, height, _waveform->data()[0], true); @@ -143,6 +143,7 @@ VideoWaveformPlot::paint () delete gc; } + void VideoWaveformPlot::create_waveform () { @@ -152,9 +153,9 @@ VideoWaveformPlot::create_waveform () return; } - dcp::Size const image_size = _image->size(); + auto const image_size = _image->size(); int const waveform_height = GetSize().GetHeight() - _vertical_margin * 2; - _waveform.reset (new Image (AV_PIX_FMT_RGB24, dcp::Size (image_size.width, waveform_height), true)); + _waveform = make_shared(AV_PIX_FMT_RGB24, dcp::Size (image_size.width, waveform_height), true); for (int x = 0; x < image_size.width; ++x) { @@ -185,11 +186,6 @@ VideoWaveformPlot::create_waveform () ); } -static void -note () -{ - -} void VideoWaveformPlot::set_image (shared_ptr image) @@ -201,23 +197,26 @@ VideoWaveformPlot::set_image (shared_ptr image) /* We must copy the PlayerVideo here as we will call ::image() on it, potentially with a different pixel_format than was used when ::prepare() was called. */ - _image = DCPVideo::convert_to_xyz (image->shallow_copy(), boost::bind(¬e)); + _image = DCPVideo::convert_to_xyz (image->shallow_copy(), [](dcp::NoteType, string) {}); _dirty = true; Refresh (); } + void VideoWaveformPlot::sized (wxSizeEvent &) { _dirty = true; } + void VideoWaveformPlot::set_enabled (bool e) { _enabled = e; } + void VideoWaveformPlot::set_component (int c) { @@ -226,6 +225,7 @@ VideoWaveformPlot::set_component (int c) Refresh (); } + /** Set `contrast', i.e. a fudge multiplication factor to make low-level signals easier to see, * between 0 and 256. */ @@ -237,6 +237,7 @@ VideoWaveformPlot::set_contrast (int b) Refresh (); } + void VideoWaveformPlot::mouse_moved (wxMouseEvent& ev) { @@ -249,18 +250,18 @@ VideoWaveformPlot::mouse_moved (wxMouseEvent& ev) _dirty = false; } - shared_ptr film = _film.lock (); + auto film = _film.lock (); if (!film) { return; } - dcp::Size const full = film->frame_size (); + auto const full = film->frame_size (); - double const xs = static_cast (full.width) / _waveform->size().width; + auto const xs = static_cast (full.width) / _waveform->size().width; int const x1 = max (0, min (full.width - 1, int (floor (ev.GetPosition().x - _x_axis_width - 0.5) * xs))); int const x2 = max (0, min (full.width - 1, int (floor (ev.GetPosition().x - _x_axis_width + 0.5) * xs))); - double const ys = static_cast (_pixel_values) / _waveform->size().height; + auto const ys = static_cast (_pixel_values) / _waveform->size().height; int const fy = _waveform->size().height - (ev.GetPosition().y - _vertical_margin); int const y1 = max (0, min (_pixel_values - 1, int (floor (fy - 0.5) * ys))); int const y2 = max (0, min (_pixel_values - 1, int (floor (fy + 0.5) * ys))); diff --git a/src/wx/video_waveform_plot.h b/src/wx/video_waveform_plot.h index 037ff0cbf..36ec63d8a 100644 --- a/src/wx/video_waveform_plot.h +++ b/src/wx/video_waveform_plot.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,14 @@ */ + #include "lib/warnings.h" DCPOMATIC_DISABLE_WARNINGS #include DCPOMATIC_ENABLE_WARNINGS #include + namespace dcp { class OpenJPEGImage; } @@ -33,6 +35,7 @@ class Image; class Film; class FilmViewer; + class VideoWaveformPlot : public wxPanel { public: @@ -59,10 +62,10 @@ private: std::weak_ptr _film; std::shared_ptr _image; std::shared_ptr _waveform; - bool _dirty; - bool _enabled; - int _component; - int _contrast; + bool _dirty = true; + bool _enabled = false; + int _component = 0; + int _contrast = 0; static int const _vertical_margin; static int const _pixel_values; diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 8ef32fca3..1a34e5fa8 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.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. @@ -105,6 +105,7 @@ add_label_to_sizer (wxSizer* s, wxWindow* p, wxString t, bool left, int prop, in return m; } + wxStaticText * #ifdef __WXOSX__ add_label_to_sizer (wxSizer* s, wxStaticText* t, bool left, int prop, int flags) @@ -119,6 +120,7 @@ add_label_to_sizer (wxSizer* s, wxStaticText* t, bool, int prop, int flags) return t; } + wxStaticText * add_label_to_sizer (wxGridBagSizer* s, wxWindow* p, wxString t, bool left, wxGBPosition pos, wxGBSpan span) { @@ -131,6 +133,7 @@ add_label_to_sizer (wxGridBagSizer* s, wxWindow* p, wxString t, bool left, wxGBP return m; } + wxStaticText * #ifdef __WXOSX__ add_label_to_sizer (wxGridBagSizer* s, wxStaticText* t, bool left, wxGBPosition pos, wxGBSpan span) @@ -146,6 +149,7 @@ add_label_to_sizer (wxGridBagSizer* s, wxStaticText* t, bool, wxGBPosition pos, return t; } + /** Pop up an error dialogue box. * @param parent Parent. * @param m Message. @@ -164,6 +168,7 @@ error_dialog (wxWindow* parent, wxString m, optional e) d->Destroy (); } + /** Pop up an error dialogue box. * @param parent Parent. * @param m Message. @@ -176,11 +181,12 @@ message_dialog (wxWindow* parent, wxString m) d->Destroy (); } + /** @return true if the user answered "yes" */ bool confirm_dialog (wxWindow* parent, wxString m) { - wxMessageDialog* d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxYES_NO | wxICON_QUESTION); + auto d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxYES_NO | wxICON_QUESTION); int const r = d->ShowModal (); d->Destroy (); return r == wxID_YES; @@ -193,9 +199,10 @@ confirm_dialog (wxWindow* parent, wxString m) string wx_to_std (wxString s) { - return string (s.ToUTF8 ()); + return string (s.ToUTF8()); } + /** @param s STL string. * @return Corresponding wxWidgets string. */ @@ -205,12 +212,14 @@ std_to_wx (string s) return wxString (s.c_str(), wxConvUTF8); } + string string_client_data (wxClientData* o) { return wx_to_std (dynamic_cast(o)->GetData()); } + void checked_set (FilePickerCtrl* widget, boost::filesystem::path value) { @@ -225,6 +234,7 @@ checked_set (FilePickerCtrl* widget, boost::filesystem::path value) } } + void checked_set (wxDirPickerCtrl* widget, boost::filesystem::path value) { @@ -239,6 +249,7 @@ checked_set (wxDirPickerCtrl* widget, boost::filesystem::path value) } } + void checked_set (wxSpinCtrl* widget, int value) { @@ -247,6 +258,7 @@ checked_set (wxSpinCtrl* widget, int value) } } + void checked_set (wxSpinCtrlDouble* widget, double value) { @@ -256,6 +268,7 @@ checked_set (wxSpinCtrlDouble* widget, double value) } } + void checked_set (wxChoice* widget, int value) { @@ -264,6 +277,7 @@ checked_set (wxChoice* widget, int value) } } + void checked_set (wxChoice* widget, string value) { @@ -281,15 +295,16 @@ checked_set (wxChoice* widget, string value) } } + void checked_set (wxChoice* widget, vector > items) { - vector > current; + vector> current; for (unsigned int i = 0; i < widget->GetCount(); ++i) { current.push_back ( - make_pair ( - wx_to_std (widget->GetString (i)), - string_client_data (widget->GetClientObject (i)) + make_pair( + wx_to_std(widget->GetString(i)), + string_client_data(widget->GetClientObject(i)) ) ); } @@ -304,6 +319,7 @@ checked_set (wxChoice* widget, vector > items) } } + void checked_set (wxTextCtrl* widget, string value) { @@ -312,6 +328,7 @@ checked_set (wxTextCtrl* widget, string value) } } + void checked_set (PasswordEntry* entry, string value) { @@ -320,6 +337,7 @@ checked_set (PasswordEntry* entry, string value) } } + void checked_set (wxTextCtrl* widget, wxString value) { @@ -328,6 +346,7 @@ checked_set (wxTextCtrl* widget, wxString value) } } + void checked_set (wxStaticText* widget, string value) { @@ -336,6 +355,7 @@ checked_set (wxStaticText* widget, string value) } } + void checked_set (wxStaticText* widget, wxString value) { @@ -344,6 +364,7 @@ checked_set (wxStaticText* widget, wxString value) } } + void checked_set (wxCheckBox* widget, bool value) { @@ -352,6 +373,7 @@ checked_set (wxCheckBox* widget, bool value) } } + void checked_set (wxRadioButton* widget, bool value) { @@ -360,6 +382,7 @@ checked_set (wxRadioButton* widget, bool value) } } + void dcpomatic_setup_i18n () { @@ -408,24 +431,28 @@ dcpomatic_setup_i18n () } } + int wx_get (wxSpinCtrl* w) { return w->GetValue (); } + int wx_get (wxChoice* w) { return w->GetSelection (); } + double wx_get (wxSpinCtrlDouble* w) { return w->GetValue (); } + /** @param s String of the form Context|String * @return translation, or String if no translation is available. */ @@ -444,6 +471,7 @@ context_translation (wxString s) return t; } + wxString time_to_timecode (DCPTime t, double fps) { @@ -458,23 +486,24 @@ time_to_timecode (DCPTime t, double fps) return wxString::Format (wxT("%02d:%02d:%02d.%02d"), h, m, s, f); } + void setup_audio_channels_choice (wxChoice* choice, int minimum) { - vector > items; + vector> items; for (int i = minimum; i <= 16; i += 2) { if (i == 2) { - items.push_back (make_pair (wx_to_std (_("2 - stereo")), locale_convert (i))); + items.push_back (make_pair(wx_to_std(_("2 - stereo")), locale_convert(i))); } else if (i == 4) { - items.push_back (make_pair (wx_to_std (_("4 - L/C/R/Lfe")), locale_convert (i))); + items.push_back (make_pair(wx_to_std(_("4 - L/C/R/Lfe")), locale_convert(i))); } else if (i == 6) { - items.push_back (make_pair (wx_to_std (_("6 - 5.1")), locale_convert (i))); + items.push_back (make_pair(wx_to_std(_("6 - 5.1")), locale_convert(i))); } else if (i == 8) { - items.push_back (make_pair (wx_to_std (_("8 - 5.1/HI/VI")), locale_convert (i))); + items.push_back (make_pair(wx_to_std(_("8 - 5.1/HI/VI")), locale_convert(i))); } else if (i == 12) { - items.push_back (make_pair (wx_to_std (_("12 - 7.1/HI/VI")), locale_convert (i))); + items.push_back (make_pair(wx_to_std(_("12 - 7.1/HI/VI")), locale_convert(i))); } else { - items.push_back (make_pair (locale_convert (i), locale_convert (i))); + items.push_back (make_pair(locale_convert (i), locale_convert(i))); } } @@ -512,6 +541,7 @@ maybe_show_splash () return splash; } + double calculate_mark_interval (double mark_interval) { @@ -616,7 +646,7 @@ bitmap_path (string name) base = resources_path(); #endif - boost::filesystem::path p = base / String::compose("%1.png", name); + auto p = base / String::compose("%1.png", name); return std_to_wx (p.string()); } diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index 4131ec0f7..97ddd5151 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.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,13 +18,16 @@ */ + /** @file src/wx/wx_util.h * @brief Some utility functions and classes. */ + #ifndef DCPOMATIC_WX_UTIL_H #define DCPOMATIC_WX_UTIL_H + #include "lib/dcpomatic_time.h" #include "lib/warnings.h" DCPOMATIC_DISABLE_WARNINGS @@ -35,6 +38,7 @@ DCPOMATIC_ENABLE_WARNINGS #include #include + class FilePickerCtrl; class wxDirPickerCtrl; class wxSpinCtrl; @@ -43,6 +47,7 @@ class wxGridBagSizer; class wxSplashScreen; class PasswordEntry; + #define DCPOMATIC_SIZER_X_GAP 8 #define DCPOMATIC_SIZER_Y_GAP 8 #define DCPOMATIC_SIZER_GAP 8 @@ -65,12 +70,14 @@ class PasswordEntry; #define DCPOMATIC_RTAUDIO_API RtAudio::MACOSX_CORE #endif + /** i18n macro to support strings like Context|String * so that `String' can be translated to different things * in different contexts. */ #define S_(x) context_translation(x) + extern void error_dialog (wxWindow *, wxString, boost::optional e = boost::optional()); extern void message_dialog (wxWindow *, wxString); extern bool confirm_dialog (wxWindow *, wxString); @@ -93,6 +100,7 @@ extern bool report_errors_from_last_job (wxWindow* parent); extern wxString bitmap_path (std::string name); extern wxSize small_button_size (wxWindow* parent, wxString text); + struct Offset { Offset (wxString n, int h, int m) @@ -132,4 +140,5 @@ extern double wx_get (wxSpinCtrlDouble* widget); #define DCPOMATIC_USE_OWN_PICKER #endif + #endif diff --git a/test/4k_test.cc b/test/4k_test.cc index f3ce0bfcc..4db576cfc 100644 --- a/test/4k_test.cc +++ b/test/4k_test.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,6 +18,7 @@ */ + /** @defgroup completedcp Complete builds of DCPs */ /** @file test/4k_test.cc @@ -27,6 +28,7 @@ * The output is checked against test/data/4k_test. */ + #include #include "lib/film.h" #include "lib/ffmpeg_content.h" @@ -36,9 +38,11 @@ #include "lib/dcpomatic_log.h" #include "test.h" + using std::shared_ptr; using std::make_shared; + BOOST_AUTO_TEST_CASE (fourk_test) { auto film = new_test_film ("4k_test"); @@ -58,8 +62,8 @@ BOOST_AUTO_TEST_CASE (fourk_test) dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE }); - boost::filesystem::path p (test_film_dir ("4k_test")); + boost::filesystem::path p (test_film_dir("4k_test")); p /= film->dcp_name (); - check_dcp ("test/data/4k_test", p.string ()); + check_dcp ("test/data/4k_test", p.string()); } diff --git a/test/audio_analysis_test.cc b/test/audio_analysis_test.cc index 9da286746..e131ce57c 100644 --- a/test/audio_analysis_test.cc +++ b/test/audio_analysis_test.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,6 +18,7 @@ */ + /** @defgroup selfcontained Self-contained tests of single classes / method sets */ /** @file test/audio_analysis_test.cc @@ -25,36 +26,38 @@ * @ingroup selfcontained */ -#include -#include "lib/audio_analysis.h" + +#include "test.h" #include "lib/analyse_audio_job.h" -#include "lib/film.h" -#include "lib/ffmpeg_content.h" +#include "lib/audio_analysis.h" +#include "lib/audio_content.h" +#include "lib/content_factory.h" #include "lib/dcp_content_type.h" #include "lib/ffmpeg_content.h" -#include "lib/ratio.h" +#include "lib/ffmpeg_content.h" +#include "lib/film.h" #include "lib/job_manager.h" -#include "lib/audio_content.h" -#include "lib/content_factory.h" #include "lib/playlist.h" -#include "test.h" +#include "lib/ratio.h" +#include #include -using std::vector; + +using std::make_shared; using std::shared_ptr; +using std::vector; using namespace dcpomatic; -static float -random_float () -{ - return (float (rand ()) / RAND_MAX) * 2 - 1; -} BOOST_AUTO_TEST_CASE (audio_analysis_serialisation_test) { int const channels = 3; int const points = 4096; + auto random_float = []() { + return (float (rand ()) / RAND_MAX) * 2 - 1; + }; + AudioAnalysis a (3); for (int i = 0; i < channels; ++i) { for (int j = 0; j < points; ++j) { @@ -67,7 +70,7 @@ BOOST_AUTO_TEST_CASE (audio_analysis_serialisation_test) vector peak; for (int i = 0; i < channels; ++i) { - peak.push_back (AudioAnalysis::PeakTime (random_float(), DCPTime (rand()))); + peak.push_back (AudioAnalysis::PeakTime(random_float(), DCPTime(rand()))); } a.set_sample_peak (peak); @@ -96,58 +99,52 @@ BOOST_AUTO_TEST_CASE (audio_analysis_serialisation_test) BOOST_CHECK_EQUAL (a.sample_rate(), 48000); } -static void -finished () -{ - -} BOOST_AUTO_TEST_CASE (audio_analysis_test) { - shared_ptr film = new_test_film ("audio_analysis_test"); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); - film->set_container (Ratio::from_id ("185")); + auto film = new_test_film ("audio_analysis_test"); + film->set_dcp_content_type (DCPContentType::from_isdcf_name("FTR")); + film->set_container (Ratio::from_id("185")); film->set_name ("audio_analysis_test"); boost::filesystem::path p = TestPaths::private_data() / "betty_L.wav"; - shared_ptr c (new FFmpegContent(p)); + auto c = make_shared(p); film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs()); - shared_ptr job (new AnalyseAudioJob (film, film->playlist(), false)); - job->Finished.connect (boost::bind (&finished)); + auto job = make_shared(film, film->playlist(), false); JobManager::instance()->add (job); BOOST_REQUIRE (!wait_for_jobs()); } + /** Check that audio analysis works (i.e. runs without error) with a -ve delay */ BOOST_AUTO_TEST_CASE (audio_analysis_negative_delay_test) { - shared_ptr film = new_test_film ("audio_analysis_negative_delay_test"); + auto film = new_test_film ("audio_analysis_negative_delay_test"); film->set_name ("audio_analysis_negative_delay_test"); - shared_ptr c (new FFmpegContent(TestPaths::private_data() / "boon_telly.mkv")); + auto c = make_shared(TestPaths::private_data() / "boon_telly.mkv"); film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs()); c->audio->set_delay (-250); - shared_ptr job (new AnalyseAudioJob (film, film->playlist(), false)); - job->Finished.connect (boost::bind (&finished)); + auto job = make_shared(film, film->playlist(), false); JobManager::instance()->add (job); BOOST_REQUIRE (!wait_for_jobs()); } + /** Check audio analysis that is incorrect in 2e98263 */ BOOST_AUTO_TEST_CASE (audio_analysis_test2) { - shared_ptr film = new_test_film ("audio_analysis_test2"); + auto film = new_test_film ("audio_analysis_test2"); film->set_name ("audio_analysis_test2"); - shared_ptr c (new FFmpegContent(TestPaths::private_data() / "3d_thx_broadway_2010_lossless.m2ts")); + auto c = make_shared(TestPaths::private_data() / "3d_thx_broadway_2010_lossless.m2ts"); film->examine_and_add_content (c); BOOST_REQUIRE (!wait_for_jobs()); - shared_ptr job (new AnalyseAudioJob (film, film->playlist(), false)); - job->Finished.connect (boost::bind (&finished)); + auto job = make_shared(film, film->playlist(), false); JobManager::instance()->add (job); BOOST_REQUIRE (!wait_for_jobs()); } @@ -161,57 +158,60 @@ analysis_finished () done = true; } + /* Test a case which was reported to throw an exception; analysing * a 12-channel DCP's audio. */ BOOST_AUTO_TEST_CASE (audio_analysis_test3) { - shared_ptr film = new_test_film ("analyse_audio_test"); + auto film = new_test_film ("analyse_audio_test"); film->set_container (Ratio::from_id ("185")); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); + film->set_dcp_content_type (DCPContentType::from_isdcf_name("TLR")); film->set_name ("frobozz"); - shared_ptr content (new FFmpegContent("test/data/white.wav")); + auto content = make_shared("test/data/white.wav"); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); film->set_audio_channels (12); boost::signals2::connection connection; - JobManager::instance()->analyse_audio (film, film->playlist(), false, connection, boost::bind (&analysis_finished)); + JobManager::instance()->analyse_audio(film, film->playlist(), false, connection, boost::bind(&analysis_finished)); BOOST_REQUIRE (!wait_for_jobs()); BOOST_CHECK (done); } + /** Run an audio analysis that triggered an exception in the audio decoder at one point */ BOOST_AUTO_TEST_CASE (analyse_audio_test4) { - shared_ptr film = new_test_film ("analyse_audio_test"); + auto film = new_test_film ("analyse_audio_test"); film->set_container (Ratio::from_id ("185")); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR")); + film->set_dcp_content_type (DCPContentType::from_isdcf_name("TLR")); film->set_name ("frobozz"); - shared_ptr content = content_factory(TestPaths::private_data() / "20 The Wedding Convoy Song.m4a").front(); + auto content = content_factory(TestPaths::private_data() / "20 The Wedding Convoy Song.m4a").front(); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); - shared_ptr playlist (new Playlist); + auto playlist = make_shared(); playlist->add (film, content); boost::signals2::connection c; - JobManager::instance()->analyse_audio (film, playlist, false, c, boost::bind (&finished)); + JobManager::instance()->analyse_audio(film, playlist, false, c, []() {}); BOOST_CHECK (!wait_for_jobs ()); } + BOOST_AUTO_TEST_CASE (analyse_audio_leqm_test) { - shared_ptr film = new_test_film2 ("analyse_audio_leqm_test"); + auto film = new_test_film2 ("analyse_audio_leqm_test"); film->set_audio_channels (2); - shared_ptr content = content_factory(TestPaths::private_data() / "betty_stereo_48k.wav").front(); + auto content = content_factory(TestPaths::private_data() / "betty_stereo_48k.wav").front(); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); - shared_ptr playlist (new Playlist); + auto playlist = make_shared(); playlist->add (film, content); boost::signals2::connection c; - JobManager::instance()->analyse_audio (film, playlist, false, c, boost::bind (&finished)); + JobManager::instance()->analyse_audio(film, playlist, false, c, []() {}); BOOST_CHECK (!wait_for_jobs()); AudioAnalysis analysis(film->audio_analysis_path(playlist)); diff --git a/test/audio_filter_test.cc b/test/audio_filter_test.cc index 13b098910..d4fc550f1 100644 --- a/test/audio_filter_test.cc +++ b/test/audio_filter_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,17 +18,22 @@ */ + /** @file test/audio_filter_test.cc * @brief Test AudioFilter, LowPassAudioFilter, HighPassAudioFilter classes. * @ingroup selfcontained */ + #include #include "lib/audio_filter.h" #include "lib/audio_buffers.h" + +using std::make_shared; using std::shared_ptr; + static void audio_filter_impulse_test_one (AudioFilter& f, int block_size, int num_blocks) { @@ -36,12 +41,12 @@ audio_filter_impulse_test_one (AudioFilter& f, int block_size, int num_blocks) for (int i = 0; i < num_blocks; ++i) { - shared_ptr in (new AudioBuffers (1, block_size)); + auto in = make_shared(1, block_size); for (int j = 0; j < block_size; ++j) { in->data()[0][j] = c + j; } - shared_ptr out = f.run (in); + auto out = f.run (in); for (int j = 0; j < out->frames(); ++j) { BOOST_CHECK_EQUAL (out->data()[0][j], c + j); @@ -51,6 +56,7 @@ audio_filter_impulse_test_one (AudioFilter& f, int block_size, int num_blocks) } } + /** Create a filter with an impulse as a kernel and check that it * passes data through unaltered. */ @@ -70,6 +76,7 @@ BOOST_AUTO_TEST_CASE (audio_filter_impulse_kernel_test) audio_filter_impulse_test_one (f, 2048, 1); } + /** Create filters and pass them impulses as input and check that * the filter kernels comes back. */ @@ -77,11 +84,11 @@ BOOST_AUTO_TEST_CASE (audio_filter_impulse_input_test) { LowPassAudioFilter lpf (0.02, 0.3); - shared_ptr in (new AudioBuffers (1, 1751)); + auto in = make_shared(1, 1751); in->make_silent (); in->data(0)[0] = 1; - shared_ptr out = lpf.run (in); + auto out = lpf.run (in); for (int j = 0; j < out->frames(); ++j) { if (j <= lpf._M) { BOOST_CHECK_EQUAL (out->data(0)[j], lpf._ir[j]); @@ -92,7 +99,7 @@ BOOST_AUTO_TEST_CASE (audio_filter_impulse_input_test) HighPassAudioFilter hpf (0.02, 0.3); - in.reset (new AudioBuffers (1, 9133)); + in = make_shared(1, 9133); in->make_silent (); in->data(0)[0] = 1; diff --git a/test/audio_processor_delay_test.cc b/test/audio_processor_delay_test.cc index 6fd644a7e..47a1cc8ad 100644 --- a/test/audio_processor_delay_test.cc +++ b/test/audio_processor_delay_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,27 +18,33 @@ */ + /** @file test/audio_processor_delay_test.cc * @brief Test the AudioDelay class. * @ingroup selfcontained */ -#include "lib/audio_delay.h" + #include "lib/audio_buffers.h" +#include "lib/audio_delay.h" #include #include #include + using std::cerr; using std::cout; +using std::make_shared; using std::shared_ptr; + #define CHECK_SAMPLE(c,f,r) \ if (fabs(out->data(c)[f] - (r)) > 0.1) { \ cerr << "Sample " << f << " at line " << __LINE__ << " is " << out->data(c)[f] << " not " << r << "; difference is " << fabs(out->data(c)[f] - (r)) << "\n"; \ BOOST_REQUIRE (fabs(out->data(c)[f] - (r)) <= 0.1); \ } + /** Block size greater than delay */ BOOST_AUTO_TEST_CASE (audio_processor_delay_test1) { @@ -46,14 +52,14 @@ BOOST_AUTO_TEST_CASE (audio_processor_delay_test1) int const C = 2; - shared_ptr in (new AudioBuffers (C, 256)); + auto in = make_shared(C, 256); for (int i = 0; i < C; ++i) { for (int j = 0; j < 256; ++j) { in->data(i)[j] = j; } } - shared_ptr out = delay.run (in); + auto out = delay.run (in); BOOST_REQUIRE_EQUAL (out->frames(), in->frames()); /* Silence at the start */ @@ -86,6 +92,7 @@ BOOST_AUTO_TEST_CASE (audio_processor_delay_test1) } } + /** Block size less than delay */ BOOST_AUTO_TEST_CASE (audio_processor_delay_test2) { @@ -96,14 +103,14 @@ BOOST_AUTO_TEST_CASE (audio_processor_delay_test2) /* Feeding 4 blocks of 64 should give silence each time */ for (int i = 0; i < 4; ++i) { - shared_ptr in (new AudioBuffers (C, 64)); + auto in = make_shared(C, 64); for (int j = 0; j < C; ++j) { for (int k = 0; k < 64; ++k) { in->data(j)[k] = k + i * 64; } } - shared_ptr out = delay.run (in); + auto out = delay.run (in); BOOST_REQUIRE_EQUAL (out->frames(), in->frames()); /* Check for silence */ @@ -117,9 +124,9 @@ BOOST_AUTO_TEST_CASE (audio_processor_delay_test2) /* Now feed 4 blocks of silence and we should see the data */ for (int i = 0; i < 4; ++i) { /* Feed some silence */ - shared_ptr in (new AudioBuffers (C, 64)); + auto in = make_shared(C, 64); in->make_silent (); - shared_ptr out = delay.run (in); + auto out = delay.run (in); /* Should now see the delayed data */ for (int j = 0; j < C; ++j) { diff --git a/test/butler_test.cc b/test/butler_test.cc index 016767e1c..dbd7a287e 100644 --- a/test/butler_test.cc +++ b/test/butler_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Carl Hetherington + Copyright (C) 2017-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "lib/butler.h" #include "lib/film.h" #include "lib/dcp_content_type.h" @@ -28,34 +29,37 @@ #include "test.h" #include + +using std::make_shared; using std::shared_ptr; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif using namespace dcpomatic; + BOOST_AUTO_TEST_CASE (butler_test1) { - shared_ptr film = new_test_film ("butler_test1"); - film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); + auto film = new_test_film ("butler_test1"); + film->set_dcp_content_type (DCPContentType::from_isdcf_name("FTR")); film->set_name ("butler_test1"); film->set_container (Ratio::from_id ("185")); - shared_ptr video = content_factory("test/data/flat_red.png").front (); + auto video = content_factory("test/data/flat_red.png").front(); film->examine_and_add_content (video); - shared_ptr audio = content_factory("test/data/staircase.wav").front (); + auto audio = content_factory("test/data/staircase.wav").front(); film->examine_and_add_content (audio); BOOST_REQUIRE (!wait_for_jobs ()); film->set_audio_channels (6); /* This is the map of the player output (5.1) to the butler output (also 5.1) */ - AudioMapping map = AudioMapping (6, 6); + auto map = AudioMapping (6, 6); for (int i = 0; i < 6; ++i) { map.set (i, i, 1); } - Butler butler (film, shared_ptr(new Player(film)), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, false); + Butler butler (film, make_shared(film), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, false); BOOST_CHECK (butler.get_video(true, 0).second == DCPTime()); BOOST_CHECK (butler.get_video(true, 0).second == DCPTime::from_frames(1, 24)); @@ -63,7 +67,7 @@ BOOST_AUTO_TEST_CASE (butler_test1) /* XXX: check the frame contents */ float buffer[256 * 6]; - BOOST_REQUIRE (butler.get_audio (buffer, 256) == DCPTime()); + BOOST_REQUIRE (butler.get_audio(buffer, 256) == DCPTime()); for (int i = 0; i < 256; ++i) { BOOST_REQUIRE_EQUAL (buffer[i * 6 + 0], 0); BOOST_REQUIRE_EQUAL (buffer[i * 6 + 1], 0); diff --git a/test/client_server_test.cc b/test/client_server_test.cc index 3dceb31b0..f518f9383 100644 --- a/test/client_server_test.cc +++ b/test/client_server_test.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 @@ */ + /** @file test/client_server_test.cc * @brief Test the server class. * @ingroup feature @@ -27,28 +28,31 @@ * encoded data to check that they are the same. */ -#include "lib/encode_server.h" -#include "lib/image.h" + #include "lib/cross.h" #include "lib/dcp_video.h" -#include "lib/player_video.h" -#include "lib/raw_image_proxy.h" -#include "lib/j2k_image_proxy.h" +#include "lib/dcpomatic_log.h" +#include "lib/encode_server.h" #include "lib/encode_server_description.h" #include "lib/file_log.h" -#include "lib/dcpomatic_log.h" +#include "lib/image.h" +#include "lib/j2k_image_proxy.h" +#include "lib/player_video.h" +#include "lib/raw_image_proxy.h" #include "test.h" #include #include + using std::list; +using std::make_shared; using std::shared_ptr; using std::weak_ptr; -using std::make_shared; using boost::thread; using boost::optional; using dcp::ArrayData; + void do_remote_encode (shared_ptr frame, EncodeServerDescription description, ArrayData locally_encoded) { @@ -59,6 +63,7 @@ do_remote_encode (shared_ptr frame, EncodeServerDescription descriptio BOOST_CHECK_EQUAL (memcmp (locally_encoded.data(), remotely_encoded.data(), locally_encoded.size()), 0); } + BOOST_AUTO_TEST_CASE (client_server_test_rgb) { auto image = make_shared(AV_PIX_FMT_RGB24, dcp::Size (1998, 1080), true); @@ -145,6 +150,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_rgb) delete server; } + BOOST_AUTO_TEST_CASE (client_server_test_yuv) { auto image = make_shared(AV_PIX_FMT_YUV420P, dcp::Size (1998, 1080), true); @@ -227,6 +233,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_yuv) delete server; } + BOOST_AUTO_TEST_CASE (client_server_test_j2k) { auto image = make_shared(AV_PIX_FMT_YUV420P, dcp::Size (1998, 1080), true); diff --git a/test/config_test.cc b/test/config_test.cc index 67c00cf41..d78b9357b 100644 --- a/test/config_test.cc +++ b/test/config_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,13 +18,16 @@ */ + #include "lib/config.h" #include "test.h" #include #include + using std::ofstream; + static void rewrite_bad_config () { diff --git a/test/crypto_test.cc b/test/crypto_test.cc index 26c6748b8..53451b352 100644 --- a/test/crypto_test.cc +++ b/test/crypto_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,15 +18,18 @@ */ + #include "lib/crypto.h" #include "lib/exceptions.h" #include "test.h" #include #include + using std::string; using std::list; + BOOST_AUTO_TEST_CASE (crypto_test) { dcp::ArrayData key (dcpomatic::crypto_key_length()); @@ -34,7 +37,7 @@ BOOST_AUTO_TEST_CASE (crypto_test) RAND_bytes (key.data(), dcpomatic::crypto_key_length()); - dcp::ArrayData ciphertext = dcpomatic::encrypt ("Can you see any fish?", key, iv); + auto ciphertext = dcpomatic::encrypt ("Can you see any fish?", key, iv); BOOST_REQUIRE_EQUAL (dcpomatic::decrypt (ciphertext, key, iv), "Can you see any fish?"); key.data()[5]++; diff --git a/test/disk_writer_test.cc b/test/disk_writer_test.cc index 37c8f42d5..1146c2e1b 100644 --- a/test/disk_writer_test.cc +++ b/test/disk_writer_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. diff --git a/test/empty_test.cc b/test/empty_test.cc index 8a42bd6b8..b186954b3 100644 --- a/test/empty_test.cc +++ b/test/empty_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017-2020 Carl Hetherington + Copyright (C) 2017-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,22 +18,25 @@ */ + /** @file test/empty_test.cc * @brief Test the creation of Empty objects. * @ingroup feature */ -#include "lib/film.h" + #include "lib/dcp_content_type.h" -#include "lib/ratio.h" -#include "lib/video_content.h" -#include "lib/image_content.h" +#include "lib/decoder.h" #include "lib/empty.h" +#include "lib/film.h" +#include "lib/image_content.h" #include "lib/player.h" -#include "lib/decoder.h" +#include "lib/ratio.h" +#include "lib/video_content.h" #include "test.h" #include + using std::list; using std::make_shared; using std::shared_ptr; @@ -42,18 +45,20 @@ using namespace boost::placeholders; #endif using namespace dcpomatic; + bool has_video (shared_ptr content) { return static_cast(content->video); } + BOOST_AUTO_TEST_CASE (empty_test1) { - shared_ptr film = new_test_film2 ("empty_test1"); + auto film = new_test_film2 ("empty_test1"); film->set_sequence (false); - shared_ptr contentA (new ImageContent("test/data/simple_testcard_640x480.png")); - shared_ptr contentB (new ImageContent("test/data/simple_testcard_640x480.png")); + auto contentA = make_shared("test/data/simple_testcard_640x480.png"); + auto contentB = make_shared("test/data/simple_testcard_640x480.png"); film->examine_and_add_content (contentA); film->examine_and_add_content (contentB); @@ -65,13 +70,13 @@ BOOST_AUTO_TEST_CASE (empty_test1) * A A A B */ contentA->video->set_length (3); - contentA->set_position (film, DCPTime::from_frames (2, vfr)); + contentA->set_position (film, DCPTime::from_frames(2, vfr)); contentB->video->set_length (1); - contentB->set_position (film, DCPTime::from_frames (7, vfr)); + contentB->set_position (film, DCPTime::from_frames(7, vfr)); Empty black (film, film->playlist(), bind(&has_video, _1), film->playlist()->length(film)); BOOST_REQUIRE_EQUAL (black._periods.size(), 2U); - list::const_iterator i = black._periods.begin(); + auto i = black._periods.begin(); BOOST_CHECK (i->from == DCPTime::from_frames(0, vfr)); BOOST_CHECK (i->to == DCPTime::from_frames(2, vfr)); ++i; @@ -79,13 +84,14 @@ BOOST_AUTO_TEST_CASE (empty_test1) BOOST_CHECK (i->to == DCPTime::from_frames(7, vfr)); } + /** Some tests where the first empty period is not at time 0 */ BOOST_AUTO_TEST_CASE (empty_test2) { - shared_ptr film = new_test_film2 ("empty_test2"); + auto film = new_test_film2 ("empty_test2"); film->set_sequence (false); - shared_ptr contentA (new ImageContent("test/data/simple_testcard_640x480.png")); - shared_ptr contentB (new ImageContent("test/data/simple_testcard_640x480.png")); + auto contentA = make_shared("test/data/simple_testcard_640x480.png"); + auto contentB = make_shared("test/data/simple_testcard_640x480.png"); film->examine_and_add_content (contentA); film->examine_and_add_content (contentB); @@ -117,13 +123,14 @@ BOOST_AUTO_TEST_CASE (empty_test2) BOOST_CHECK (black.done ()); } + /** Test for when the film's playlist is not the same as the one passed into Empty */ BOOST_AUTO_TEST_CASE (empty_test3) { - shared_ptr film = new_test_film2 ("empty_test3"); + auto film = new_test_film2 ("empty_test3"); film->set_sequence (false); - shared_ptr contentA (new ImageContent("test/data/simple_testcard_640x480.png")); - shared_ptr contentB (new ImageContent("test/data/simple_testcard_640x480.png")); + auto contentA = make_shared("test/data/simple_testcard_640x480.png"); + auto contentB = make_shared("test/data/simple_testcard_640x480.png"); film->examine_and_add_content (contentA); film->examine_and_add_content (contentB); @@ -139,7 +146,7 @@ BOOST_AUTO_TEST_CASE (empty_test3) contentB->video->set_length (1); contentB->set_position (film, DCPTime::from_frames(7, vfr)); - shared_ptr playlist (new Playlist); + auto playlist = make_shared(); playlist->add (film, contentB); Empty black (film, playlist, bind(&has_video, _1), playlist->length(film)); BOOST_REQUIRE_EQUAL (black._periods.size(), 1U); @@ -150,6 +157,7 @@ BOOST_AUTO_TEST_CASE (empty_test3) BOOST_CHECK (black.position() == DCPTime::from_frames(0, vfr)); } + BOOST_AUTO_TEST_CASE (empty_test_with_overlapping_content) { auto film = new_test_film2 ("empty_test_with_overlapping_content"); diff --git a/test/ffmpeg_decoder_sequential_test.cc b/test/ffmpeg_decoder_sequential_test.cc index f81ebda9c..b2069a8b1 100644 --- a/test/ffmpeg_decoder_sequential_test.cc +++ b/test/ffmpeg_decoder_sequential_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,12 +18,14 @@ */ + /** @file test/ffmpeg_decoder_sequential_test.cc * @brief Check that the FFmpeg decoder and Player produce sequential frames without gaps or dropped frames; * Also that the decoder picks up frame rates correctly. * @ingroup feature */ + #include "lib/ffmpeg_content.h" #include "lib/ffmpeg_decoder.h" #include "lib/content_video.h" @@ -36,9 +38,11 @@ #include #include -using std::cout; + using std::cerr; +using std::cout; using std::list; +using std::make_shared; using std::shared_ptr; using boost::optional; using boost::bind; @@ -47,9 +51,11 @@ using namespace boost::placeholders; #endif using namespace dcpomatic; + static DCPTime next; static DCPTime frame; + static void check (shared_ptr, DCPTime time) { @@ -57,18 +63,19 @@ check (shared_ptr, DCPTime time) next += frame; } + void ffmpeg_decoder_sequential_test_one (boost::filesystem::path file, float fps, int video_length) { - boost::filesystem::path path = TestPaths::private_data() / file; + auto path = TestPaths::private_data() / file; BOOST_REQUIRE (boost::filesystem::exists (path)); - shared_ptr film = new_test_film ("ffmpeg_decoder_sequential_test_" + file.string()); - shared_ptr content (new FFmpegContent(path)); + auto film = new_test_film ("ffmpeg_decoder_sequential_test_" + file.string()); + auto content = make_shared(path); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); film->write_metadata (); - shared_ptr player (new Player(film)); + auto player = make_shared(film); BOOST_REQUIRE (content->video_frame_rate()); BOOST_CHECK_CLOSE (content->video_frame_rate().get(), fps, 0.01); @@ -81,6 +88,7 @@ ffmpeg_decoder_sequential_test_one (boost::filesystem::path file, float fps, int BOOST_REQUIRE (next == DCPTime::from_frames (video_length, film->video_frame_rate())); } + BOOST_AUTO_TEST_CASE (ffmpeg_decoder_sequential_test) { ffmpeg_decoder_sequential_test_one ("boon_telly.mkv", 29.97, 6912); diff --git a/test/ffmpeg_pts_offset_test.cc b/test/ffmpeg_pts_offset_test.cc index 134881c0d..4aa4c1d9a 100644 --- a/test/ffmpeg_pts_offset_test.cc +++ b/test/ffmpeg_pts_offset_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/ffmpeg_pts_offset_test.cc * @brief Check the computation of _pts_offset in FFmpegDecoder. * @ingroup selfcontained */ + #include #include "lib/film.h" #include "lib/ffmpeg_decoder.h" @@ -31,17 +33,20 @@ #include "lib/audio_content.h" #include "test.h" + +using std::make_shared; using std::shared_ptr; using namespace dcpomatic; + BOOST_AUTO_TEST_CASE (ffmpeg_pts_offset_test) { - shared_ptr film = new_test_film ("ffmpeg_pts_offset_test"); - shared_ptr content (new FFmpegContent ("test/data/test.mp4")); + auto film = new_test_film ("ffmpeg_pts_offset_test"); + auto content = make_shared("test/data/test.mp4"); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); - content->audio.reset (new AudioContent (content.get())); + content->audio = make_shared(content.get()); content->audio->add_stream (shared_ptr (new FFmpegAudioStream)); content->_video_frame_rate = 24; diff --git a/test/isdcf_name_test.cc b/test/isdcf_name_test.cc index cf39c112e..a41bf84b3 100644 --- a/test/isdcf_name_test.cc +++ b/test/isdcf_name_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2019 Carl Hetherington + Copyright (C) 2014-2021 Carl Hetherington This file is part of DCP-o-matic. diff --git a/test/job_test.cc b/test/job_test.cc index c834ec12e..7fb240843 100644 --- a/test/job_test.cc +++ b/test/job_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,18 +18,23 @@ */ + /** @file test/job_test.cc * @brief Test Job and JobManager. * @ingroup selfcontained */ -#include + +#include "lib/cross.h" #include "lib/job.h" #include "lib/job_manager.h" -#include "lib/cross.h" +#include -using std::string; + +using std::make_shared; using std::shared_ptr; +using std::string; + class TestJob : public Job { @@ -71,12 +76,13 @@ public: } }; + BOOST_AUTO_TEST_CASE (job_manager_test) { shared_ptr film; /* Single job */ - shared_ptr a (new TestJob (film)); + auto a = make_shared(film); JobManager::instance()->add (a); dcpomatic_sleep_seconds (1); diff --git a/test/markers_test.cc b/test/markers_test.cc index 70f4cad82..844f25660 100644 --- a/test/markers_test.cc +++ b/test/markers_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. diff --git a/test/pixel_formats_test.cc b/test/pixel_formats_test.cc index 952cc0af9..f59c594e9 100644 --- a/test/pixel_formats_test.cc +++ b/test/pixel_formats_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + /** @file src/pixel_formats_test.cc * @brief Make sure that Image::sample_size() and Image::bytes_per_pixel() return the right * things for various pixel formats. @@ -25,6 +26,7 @@ * @see test/image_test.cc */ + #include #include extern "C" { @@ -34,9 +36,11 @@ extern "C" { #include "lib/image.h" #include + using std::list; using std::cout; + /** @struct Case * @brief A test case for pixel_formats_test. */ @@ -63,33 +67,34 @@ struct Case BOOST_AUTO_TEST_CASE (pixel_formats_test) { - list cases; - cases.push_back(Case(AV_PIX_FMT_RGB24, 1, 480, 480, 480, 3, 0, 0 )); - cases.push_back(Case(AV_PIX_FMT_RGBA, 1, 480, 480, 480, 4, 0, 0 )); - cases.push_back(Case(AV_PIX_FMT_YUV420P, 3, 480, 240, 240, 1, 0.5, 0.5)); - cases.push_back(Case(AV_PIX_FMT_YUV422P, 3, 480, 480, 480, 1, 0.5, 0.5)); - cases.push_back(Case(AV_PIX_FMT_YUV422P10LE, 3, 480, 480, 480, 2, 1, 1 )); - cases.push_back(Case(AV_PIX_FMT_YUV422P16LE, 3, 480, 480, 480, 2, 1, 1 )); - cases.push_back(Case(AV_PIX_FMT_UYVY422, 1, 480, 480, 480, 2, 0, 0 )); - cases.push_back(Case(AV_PIX_FMT_YUV444P, 3, 480, 480, 480, 1, 1, 1 )); - cases.push_back(Case(AV_PIX_FMT_YUV444P9BE, 3, 480, 480, 480, 2, 2, 2 )); - cases.push_back(Case(AV_PIX_FMT_YUV444P9LE, 3, 480, 480, 480, 2, 2, 2 )); - cases.push_back(Case(AV_PIX_FMT_YUV444P10BE, 3, 480, 480, 480, 2, 2, 2 )); - cases.push_back(Case(AV_PIX_FMT_YUV444P10LE, 3, 480, 480, 480, 2, 2, 2 )); - - for (list::iterator i = cases.begin(); i != cases.end(); ++i) { - AVFrame* f = av_frame_alloc (); + list cases = { + { AV_PIX_FMT_RGB24, 1, 480, 480, 480, 3, 0, 0 }, + { AV_PIX_FMT_RGBA, 1, 480, 480, 480, 4, 0, 0 }, + { AV_PIX_FMT_YUV420P, 3, 480, 240, 240, 1, 0.5, 0.5}, + { AV_PIX_FMT_YUV422P, 3, 480, 480, 480, 1, 0.5, 0.5}, + { AV_PIX_FMT_YUV422P10LE, 3, 480, 480, 480, 2, 1, 1 }, + { AV_PIX_FMT_YUV422P16LE, 3, 480, 480, 480, 2, 1, 1 }, + { AV_PIX_FMT_UYVY422, 1, 480, 480, 480, 2, 0, 0 }, + { AV_PIX_FMT_YUV444P, 3, 480, 480, 480, 1, 1, 1 }, + { AV_PIX_FMT_YUV444P9BE, 3, 480, 480, 480, 2, 2, 2 }, + { AV_PIX_FMT_YUV444P9LE, 3, 480, 480, 480, 2, 2, 2 }, + { AV_PIX_FMT_YUV444P10BE, 3, 480, 480, 480, 2, 2, 2 }, + { AV_PIX_FMT_YUV444P10LE, 3, 480, 480, 480, 2, 2, 2 } + }; + + for (auto const& i: cases) { + auto f = av_frame_alloc (); f->width = 640; f->height = 480; - f->format = static_cast (i->format); + f->format = static_cast (i.format); av_frame_get_buffer (f, true); Image t (f); - BOOST_CHECK_EQUAL(t.planes(), i->planes); - BOOST_CHECK_EQUAL(t.sample_size(0).height, i->lines[0]); - BOOST_CHECK_EQUAL(t.sample_size(1).height, i->lines[1]); - BOOST_CHECK_EQUAL(t.sample_size(2).height, i->lines[2]); - BOOST_CHECK_EQUAL(t.bytes_per_pixel(0), i->bpp[0]); - BOOST_CHECK_EQUAL(t.bytes_per_pixel(1), i->bpp[1]); - BOOST_CHECK_EQUAL(t.bytes_per_pixel(2), i->bpp[2]); + BOOST_CHECK_EQUAL(t.planes(), i.planes); + BOOST_CHECK_EQUAL(t.sample_size(0).height, i.lines[0]); + BOOST_CHECK_EQUAL(t.sample_size(1).height, i.lines[1]); + BOOST_CHECK_EQUAL(t.sample_size(2).height, i.lines[2]); + BOOST_CHECK_EQUAL(t.bytes_per_pixel(0), i.bpp[0]); + BOOST_CHECK_EQUAL(t.bytes_per_pixel(1), i.bpp[1]); + BOOST_CHECK_EQUAL(t.bytes_per_pixel(2), i.bpp[2]); } } diff --git a/test/rect_test.cc b/test/rect_test.cc index f603b1230..24df33316 100644 --- a/test/rect_test.cc +++ b/test/rect_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,29 +18,34 @@ */ + /** @file test/rect_test.cc * @brief Test dcpomatic::Rect class. * @ingroup selfcontained */ + #include "lib/rect.h" #include #include + using boost::optional; + BOOST_AUTO_TEST_CASE (rect_test1) { dcpomatic::Rect a (0, 0, 100, 100); dcpomatic::Rect b (200, 200, 100, 100); - optional > c = a.intersection (b); + auto c = a.intersection (b); BOOST_CHECK (!c); } + BOOST_AUTO_TEST_CASE (rect_test2) { dcpomatic::Rect a (0, 330, 100, 85); - a.extend (dcpomatic::Rect (50, 235, 100, 85)); + a.extend (dcpomatic::Rect(50, 235, 100, 85)); BOOST_CHECK_EQUAL (a.x, 0); BOOST_CHECK_EQUAL (a.y, 235); BOOST_CHECK_EQUAL (a.width, 150); diff --git a/test/silence_padding_test.cc b/test/silence_padding_test.cc index 328f9bef7..e4c640792 100644 --- a/test/silence_padding_test.cc +++ b/test/silence_padding_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/silence_padding_test.cc * @brief Test the padding (with silence) of a mono source to a 6-channel DCP. * @ingroup feature */ + #include "lib/ffmpeg_content.h" #include "lib/film.h" #include "lib/dcp_content_type.h" @@ -37,11 +39,13 @@ #include #include + using std::make_shared; using std::string; using std::shared_ptr; using boost::lexical_cast; + static void test_silence_padding (int channels) { @@ -120,6 +124,7 @@ test_silence_padding (int channels) } + BOOST_AUTO_TEST_CASE (silence_padding_test) { for (int i = 1; i < MAX_DCP_AUDIO_CHANNELS; ++i) { @@ -127,6 +132,7 @@ BOOST_AUTO_TEST_CASE (silence_padding_test) } } + /** Test a situation that used to crash because of a sub-sample rounding confusion * caused by a trim. */ diff --git a/test/threed_test.cc b/test/threed_test.cc index a4889645f..f98464fb5 100644 --- a/test/threed_test.cc +++ b/test/threed_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2019 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/threed_test.cc * @brief Create some 3D DCPs (without comparing the results to anything). * @ingroup completedcp */ + #include "lib/config.h" #include "lib/content_factory.h" #include "lib/cross.h" diff --git a/test/time_calculation_test.cc b/test/time_calculation_test.cc index d0cf63bb2..ffe77c2b7 100644 --- a/test/time_calculation_test.cc +++ b/test/time_calculation_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2016 Carl Hetherington + Copyright (C) 2015-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/time_calculation_test.cc * @brief Test calculation of timings when frame rates change. * @ingroup feature */ + #include "lib/film.h" #include "lib/ffmpeg_content.h" #include "lib/video_content.h" @@ -31,11 +33,14 @@ #include "test.h" #include -using std::string; + using std::list; +using std::make_shared; using std::shared_ptr; +using std::string; using namespace dcpomatic; + static string const xml = "" "FFmpeg" "0" @@ -125,15 +130,16 @@ static string const xml = "" "0" ""; + BOOST_AUTO_TEST_CASE (ffmpeg_time_calculation_test) { - shared_ptr film = new_test_film ("ffmpeg_time_calculation_test"); + auto film = new_test_film ("ffmpeg_time_calculation_test"); - shared_ptr doc (new cxml::Document); + auto doc = make_shared(); doc->read_string (xml); list notes; - shared_ptr content (new FFmpegContent(doc, film->state_version(), notes)); + auto content = make_shared(doc, film->state_version(), notes); /* 25fps content, 25fps DCP */ film->set_video_frame_rate (25); @@ -177,20 +183,21 @@ BOOST_AUTO_TEST_CASE (ffmpeg_time_calculation_test) } + /** Test Player::dcp_to_content_video */ BOOST_AUTO_TEST_CASE (player_time_calculation_test1) { - shared_ptr film = new_test_film ("player_time_calculation_test1"); + auto film = new_test_film ("player_time_calculation_test1"); - shared_ptr doc (new cxml::Document); + auto doc = make_shared(); doc->read_string (xml); list notes; - shared_ptr content (new FFmpegContent(doc, film->state_version(), notes)); + auto content = make_shared(doc, film->state_version(), notes); film->set_sequence (false); film->add_content (content); - shared_ptr player (new Player(film)); + auto player = make_shared(film); /* Position 0, no trim, content rate = DCP rate */ content->set_position (film, DCPTime()); @@ -386,17 +393,17 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1) /** Test Player::content_video_to_dcp */ BOOST_AUTO_TEST_CASE (player_time_calculation_test2) { - shared_ptr film = new_test_film ("player_time_calculation_test2"); + auto film = new_test_film ("player_time_calculation_test2"); - shared_ptr doc (new cxml::Document); + auto doc = make_shared(); doc->read_string (xml); list notes; - shared_ptr content (new FFmpegContent(doc, film->state_version(), notes)); + auto content = make_shared(doc, film->state_version(), notes); film->set_sequence (false); film->add_content (content); - shared_ptr player (new Player(film)); + auto player = make_shared(film); /* Position 0, no trim, content rate = DCP rate */ content->set_position (film, DCPTime()); @@ -562,18 +569,18 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2) /** Test Player::dcp_to_content_audio */ BOOST_AUTO_TEST_CASE (player_time_calculation_test3) { - shared_ptr film = new_test_film ("player_time_calculation_test3"); + auto film = new_test_film ("player_time_calculation_test3"); - shared_ptr doc (new cxml::Document); + auto doc = make_shared(); doc->read_string (xml); list notes; - shared_ptr content (new FFmpegContent(doc, film->state_version(), notes)); - AudioStreamPtr stream = content->audio->streams().front(); + auto content = make_shared(doc, film->state_version(), notes); + auto stream = content->audio->streams().front(); film->set_sequence (false); film->add_content (content); - shared_ptr player (new Player(film)); + auto player = make_shared(film); /* Position 0, no trim, video/audio content rate = video/audio DCP rate */ content->set_position (film, DCPTime()); @@ -583,7 +590,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3) stream->_frame_rate = 48000; player->setup_pieces (); BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U); - shared_ptr piece = player->_pieces.front (); + auto piece = player->_pieces.front (); BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0); BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.5)), 24000); BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.0)), 144000); diff --git a/test/torture_test.cc b/test/torture_test.cc index 6b8cbffbf..c9bffaac7 100644 --- a/test/torture_test.cc +++ b/test/torture_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Carl Hetherington + Copyright (C) 2017-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,11 +18,13 @@ */ + /** @file test/torture_test.cc * @brief Tricky arrangements of content whose resulting DCPs are checked programmatically. * @ingroup completedcp */ + #include "lib/audio_content.h" #include "lib/film.h" #include "lib/dcp_content_type.h" @@ -41,12 +43,14 @@ #include #include + using std::list; using std::cout; using std::shared_ptr; using std::dynamic_pointer_cast; using namespace dcpomatic; + /** Test start/end trim and positioning of some audio content */ BOOST_AUTO_TEST_CASE (torture_test1) { @@ -63,7 +67,7 @@ BOOST_AUTO_TEST_CASE (torture_test1) staircase->audio->set_gain (20 * log10(2)); /* And again at an offset of 50000 samples, trimmed both start and end, with a gain of exactly 2 (linear) */ - staircase = content_factory("test/data/staircase.wav").front (); + staircase = content_factory("test/data/staircase.wav").front(); film->examine_and_add_content (staircase); BOOST_REQUIRE (!wait_for_jobs()); staircase->set_position (film, DCPTime::from_frames(50000, film->audio_frame_rate())); diff --git a/test/video_level_test.cc b/test/video_level_test.cc index 22bec742a..acf7fb4e2 100644 --- a/test/video_level_test.cc +++ b/test/video_level_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -199,7 +199,7 @@ static pair pixel_range (shared_ptr film, shared_ptr content) { - shared_ptr decoder(new FFmpegDecoder(film, content, false)); + auto decoder = make_shared(film, content, false); decoder->video->Data.connect (bind(&video_handler, _1)); content_video = boost::none; while (!content_video) { @@ -214,7 +214,7 @@ static pair pixel_range (shared_ptr film, shared_ptr content) { - shared_ptr decoder(new ImageDecoder(film, content)); + auto decoder = make_shared(film, content); decoder->video->Data.connect (bind(&video_handler, _1)); content_video = boost::none; while (!content_video) { @@ -232,9 +232,9 @@ pixel_range (boost::filesystem::path dcp_path) dcp::DCP dcp (dcp_path); dcp.read (); - shared_ptr picture = dynamic_pointer_cast(dcp.cpls().front()->reels().front()->main_picture()->asset()); + auto picture = dynamic_pointer_cast(dcp.cpls().front()->reels().front()->main_picture()->asset()); BOOST_REQUIRE (picture); - shared_ptr frame = picture->start_read()->get_frame(0)->xyz_image(); + auto frame = picture->start_read()->get_frame(0)->xyz_image(); int const width = frame->size().width; int const height = frame->size().height; @@ -267,8 +267,8 @@ static shared_ptr movie_V (string name) { - shared_ptr film = new_test_film2 (name); - shared_ptr content = dynamic_pointer_cast(content_factory("test/data/rgb_grey_testcard.mp4").front()); + auto film = new_test_film2 (name); + auto content = dynamic_pointer_cast(content_factory("test/data/rgb_grey_testcard.mp4").front()); BOOST_REQUIRE (content); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); @@ -285,8 +285,8 @@ static shared_ptr movie_VoF (string name) { - shared_ptr film = new_test_film2 (name); - shared_ptr content = dynamic_pointer_cast(content_factory("test/data/rgb_grey_testcard.mp4").front()); + auto film = new_test_film2 (name); + auto content = dynamic_pointer_cast(content_factory("test/data/rgb_grey_testcard.mp4").front()); BOOST_REQUIRE (content); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); @@ -304,8 +304,8 @@ static shared_ptr movie_F (string name) { - shared_ptr film = new_test_film2 (name); - shared_ptr content = dynamic_pointer_cast(content_factory("test/data/rgb_grey_testcard.mov").front()); + auto film = new_test_film2 (name); + auto content = dynamic_pointer_cast(content_factory("test/data/rgb_grey_testcard.mov").front()); BOOST_REQUIRE (content); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); @@ -322,8 +322,8 @@ static shared_ptr movie_FoV (string name) { - shared_ptr film = new_test_film2 (name); - shared_ptr content = dynamic_pointer_cast(content_factory("test/data/rgb_grey_testcard.mov").front()); + auto film = new_test_film2 (name); + auto content = dynamic_pointer_cast(content_factory("test/data/rgb_grey_testcard.mov").front()); BOOST_REQUIRE (content); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); @@ -341,8 +341,8 @@ static shared_ptr image_F (string name) { - shared_ptr film = new_test_film2 (name); - shared_ptr content = dynamic_pointer_cast(content_factory("test/data/rgb_grey_testcard.png").front()); + auto film = new_test_film2 (name); + auto content = dynamic_pointer_cast(content_factory("test/data/rgb_grey_testcard.png").front()); BOOST_REQUIRE (content); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); @@ -359,8 +359,8 @@ static shared_ptr image_FoV (string name) { - shared_ptr film = new_test_film2 (name); - shared_ptr content = dynamic_pointer_cast(content_factory("test/data/rgb_grey_testcard.png").front()); + auto film = new_test_film2 (name); + auto content = dynamic_pointer_cast(content_factory("test/data/rgb_grey_testcard.png").front()); BOOST_REQUIRE (content); film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); @@ -379,9 +379,9 @@ shared_ptr dcp_F (string name) { boost::filesystem::path const dcp = "test/data/RgbGreyTestcar_TST-1_F_MOS_2K_20201115_SMPTE_OV"; - shared_ptr film = new_test_film2 (name); - shared_ptr content(new DCPContent(dcp)); - film->examine_and_add_content (shared_ptr(new DCPContent(dcp))); + auto film = new_test_film2 (name); + auto content = make_shared(dcp); + film->examine_and_add_content (content); BOOST_REQUIRE (!wait_for_jobs()); auto range = pixel_range (dcp); @@ -411,11 +411,9 @@ static pair V_movie_range (shared_ptr film) { - shared_ptr job (new TranscodeJob(film)); + auto job = make_shared(film); job->set_encoder ( - shared_ptr( - new FFmpegEncoder (film, job, film->file("export.mov"), ExportFormat::PRORES, true, false, false, 23) - ) + make_shared(film, job, film->file("export.mov"), ExportFormat::PRORES, true, false, false, 23) ); JobManager::instance()->add (job); BOOST_REQUIRE (!wait_for_jobs()); diff --git a/test/zipper_test.cc b/test/zipper_test.cc index c3f6ef728..1b8c386f4 100644 --- a/test/zipper_test.cc +++ b/test/zipper_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,18 +18,21 @@ */ + /** @file test/zipper_test.cc * @brief Test Zipper class. * @ingroup selfcontained */ -#include "lib/zipper.h" + #include "lib/exceptions.h" +#include "lib/zipper.h" #include "test.h" #include #include #include + /** Basic test of Zipper working normally */ BOOST_AUTO_TEST_CASE (zipper_test1) {