diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-05-01 01:31:35 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-05-01 01:31:35 +0200 |
| commit | 8963f0007af1a312017b9627c18b82ec2a577591 (patch) | |
| tree | baeb6f2c17da72248408b8c1d695242b44edda9e /src/lib | |
| parent | 29f84e2b8785585885e0658bdf9938967547460f (diff) | |
C++11 tidying.
Diffstat (limited to 'src/lib')
62 files changed, 412 insertions, 234 deletions
diff --git a/src/lib/analytics.cc b/src/lib/analytics.cc index f20b213e4..ac0abc222 100644 --- a/src/lib/analytics.cc +++ b/src/lib/analytics.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,33 +18,37 @@ */ + #include "analytics.h" -#include "exceptions.h" #include "compose.hpp" +#include "exceptions.h" #include "warnings.h" #include <dcp/raw_convert.h> #include <libcxml/cxml.h> DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> DCPOMATIC_ENABLE_WARNINGS -#include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> +#include <boost/filesystem.hpp> #include "i18n.h" + using std::string; using dcp::raw_convert; using boost::algorithm::trim; + Analytics* Analytics::_instance; int const Analytics::_current_version = 1; + Analytics::Analytics () - : _successful_dcp_encodes (0) { } + void Analytics::successful_dcp_encode () { @@ -81,11 +85,12 @@ Analytics::successful_dcp_encode () } } + void Analytics::write () const { xmlpp::Document doc; - xmlpp::Element* root = doc.create_root_node ("Analytics"); + auto root = doc.create_root_node ("Analytics"); root->add_child("Version")->add_child_text(raw_convert<string>(_current_version)); root->add_child("SuccessfulDCPEncodes")->add_child_text(raw_convert<string>(_successful_dcp_encodes)); @@ -99,6 +104,7 @@ Analytics::write () const } } + void Analytics::read () try @@ -110,6 +116,7 @@ try /* Never mind */ } + Analytics* Analytics::instance () { diff --git a/src/lib/analytics.h b/src/lib/analytics.h index be41e3a1b..c0a3e17ef 100644 --- a/src/lib/analytics.h +++ b/src/lib/analytics.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018-2019 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,10 +18,12 @@ */ -#include "state.h" + #include "signaller.h" +#include "state.h" #include <boost/signals2.hpp> + class Analytics : public State, public Signaller { public: @@ -37,7 +39,7 @@ public: static Analytics* instance (); private: - int _successful_dcp_encodes; + int _successful_dcp_encodes = 0; static Analytics* _instance; static int const _current_version; diff --git a/src/lib/audio_delay.cc b/src/lib/audio_delay.cc index 167c522e8..90214470c 100644 --- a/src/lib/audio_delay.cc +++ b/src/lib/audio_delay.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,20 +18,25 @@ */ + #include "audio_delay.h" #include "audio_buffers.h" #include "dcpomatic_assert.h" #include <iostream> + using std::cout; +using std::make_shared; using std::shared_ptr; + AudioDelay::AudioDelay (int samples) : _samples (samples) { } + shared_ptr<AudioBuffers> AudioDelay::run (shared_ptr<const AudioBuffers> in) { @@ -55,7 +60,7 @@ AudioDelay::run (shared_ptr<const AudioBuffers> in) /* Keep tail */ if (!_tail) { - _tail.reset (new AudioBuffers (in->channels(), _samples)); + _tail = make_shared<AudioBuffers>(in->channels(), _samples); } _tail->copy_from (in.get(), _samples, in->frames() - _samples, 0); @@ -66,7 +71,7 @@ AudioDelay::run (shared_ptr<const AudioBuffers> in) out->copy_from (_tail.get(), out->frames(), 0, 0); } else { out->make_silent (); - _tail.reset (new AudioBuffers (out->channels(), _samples)); + _tail = make_shared<AudioBuffers>(out->channels(), _samples); _tail->make_silent (); } @@ -80,6 +85,7 @@ AudioDelay::run (shared_ptr<const AudioBuffers> in) return out; } + void AudioDelay::flush () { diff --git a/src/lib/audio_delay.h b/src/lib/audio_delay.h index 3731013e5..5f3f89a65 100644 --- a/src/lib/audio_delay.h +++ b/src/lib/audio_delay.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -24,8 +24,9 @@ class AudioBuffers; + /** @class AudioDelay - * @brief An audio delay line. + * @brief An audio delay line */ class AudioDelay { diff --git a/src/lib/audio_point.cc b/src/lib/audio_point.cc index 722673b96..abf8485e3 100644 --- a/src/lib/audio_point.cc +++ b/src/lib/audio_point.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "audio_point.h" #include "warnings.h" #include <dcp/raw_convert.h> @@ -25,9 +26,11 @@ DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> DCPOMATIC_ENABLE_WARNINGS + using std::string; using dcp::raw_convert; + AudioPoint::AudioPoint () { for (int i = 0; i < COUNT; ++i) { @@ -35,12 +38,14 @@ AudioPoint::AudioPoint () } } + AudioPoint::AudioPoint (cxml::ConstNodePtr node) { - _data[PEAK] = node->number_child<float> ("Peak"); - _data[RMS] = node->number_child<float> ("RMS"); + _data[PEAK] = node->number_child<float>("Peak"); + _data[RMS] = node->number_child<float>("RMS"); } + AudioPoint::AudioPoint (AudioPoint const & other) { for (int i = 0; i < COUNT; ++i) { @@ -48,6 +53,7 @@ AudioPoint::AudioPoint (AudioPoint const & other) } } + AudioPoint & AudioPoint::operator= (AudioPoint const & other) { @@ -62,9 +68,10 @@ AudioPoint::operator= (AudioPoint const & other) return *this; } + void AudioPoint::as_xml (xmlpp::Element* parent) const { - parent->add_child ("Peak")->add_child_text (raw_convert<string> (_data[PEAK])); - parent->add_child ("RMS")->add_child_text (raw_convert<string> (_data[RMS])); + parent->add_child("Peak")->add_child_text(raw_convert<string>(_data[PEAK])); + parent->add_child("RMS")->add_child_text(raw_convert<string>(_data[RMS])); } diff --git a/src/lib/audio_point.h b/src/lib/audio_point.h index 91f0cb0e9..e7c232728 100644 --- a/src/lib/audio_point.h +++ b/src/lib/audio_point.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,15 +18,19 @@ */ + #ifndef DCPOMATIC_AUDIO_POINT_H #define DCPOMATIC_AUDIO_POINT_H + #include <libcxml/cxml.h> + namespace xmlpp { class Element; } + class AudioPoint { public: @@ -51,4 +55,5 @@ private: float _data[COUNT]; }; + #endif diff --git a/src/lib/audio_processor.cc b/src/lib/audio_processor.cc index 6cccbdc80..1eb796b38 100644 --- a/src/lib/audio_processor.cc +++ b/src/lib/audio_processor.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,41 +18,47 @@ */ + #include "audio_processor.h" +#include "config.h" #include "mid_side_decoder.h" #include "upmixer_a.h" #include "upmixer_b.h" -#include "config.h" + using std::string; using std::list; + list<AudioProcessor const *> AudioProcessor::_all; list<AudioProcessor const *> AudioProcessor::_non_experimental; + void AudioProcessor::setup_audio_processors () { - AudioProcessor* mid_side = new MidSideDecoder (); + auto mid_side = new MidSideDecoder (); _all.push_back (mid_side); _non_experimental.push_back (mid_side); - _all.push_back (new UpmixerA (48000)); - _all.push_back (new UpmixerB (48000)); + _all.push_back (new UpmixerA(48000)); + _all.push_back (new UpmixerB(48000)); } + AudioProcessor const * AudioProcessor::from_id (string id) { - for (list<AudioProcessor const *>::const_iterator i = _all.begin(); i != _all.end(); ++i) { - if ((*i)->id() == id) { - return *i; + for (auto i: _all) { + if (i->id() == id) { + return i; } } - return 0; + return nullptr; } + list<AudioProcessor const *> AudioProcessor::visible () { @@ -63,6 +69,7 @@ AudioProcessor::visible () return _non_experimental; } + list<AudioProcessor const *> AudioProcessor::all () { diff --git a/src/lib/audio_processor.h b/src/lib/audio_processor.h index e2f1c48eb..ca80c92b2 100644 --- a/src/lib/audio_processor.h +++ b/src/lib/audio_processor.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,21 +18,26 @@ */ + /** @file src/lib/audio_processor.h * @brief AudioProcessor class. */ + #ifndef DCPOMATIC_AUDIO_PROCESSOR_H #define DCPOMATIC_AUDIO_PROCESSOR_H + #include "types.h" #include <list> #include <string> #include <vector> + class AudioBuffers; class AudioMapping; + /** @class AudioProcessor * @brief A parent class for processors of audio data. * @@ -70,4 +75,5 @@ private: static std::list<AudioProcessor const *> _non_experimental; }; + #endif diff --git a/src/lib/butler.cc b/src/lib/butler.cc index 6de5d5790..b2128efdb 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -37,7 +37,7 @@ using std::weak_ptr; using std::shared_ptr; using boost::bind; using boost::optional; -using boost::function; +using std::function; using namespace dcpomatic; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; diff --git a/src/lib/butler.h b/src/lib/butler.h index ac83cecec..29966b956 100644 --- a/src/lib/butler.h +++ b/src/lib/butler.h @@ -40,7 +40,7 @@ public: std::shared_ptr<Player> player, AudioMapping map, int audio_channels, - boost::function<AVPixelFormat (AVPixelFormat)> pixel_format, + std::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool aligned, bool fast @@ -119,7 +119,7 @@ private: bool _disable_audio; - boost::function<AVPixelFormat (AVPixelFormat)> _pixel_format; + std::function<AVPixelFormat (AVPixelFormat)> _pixel_format; VideoRange _video_range; bool _aligned; bool _fast; diff --git a/src/lib/cross.h b/src/lib/cross.h index bdcae3537..b70d84a0e 100644 --- a/src/lib/cross.h +++ b/src/lib/cross.h @@ -31,7 +31,6 @@ #include <boost/filesystem.hpp> #include <boost/thread/mutex.hpp> #include <boost/optional.hpp> -#include <boost/function.hpp> #ifdef DCPOMATIC_WINDOWS #define WEXITSTATUS(w) (w) diff --git a/src/lib/cross_linux.cc b/src/lib/cross_linux.cc index 816573230..a3dbdebf2 100644 --- a/src/lib/cross_linux.cc +++ b/src/lib/cross_linux.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,20 +18,20 @@ */ -#include "cross.h" + #include "compose.hpp" -#include "log.h" -#include "dcpomatic_log.h" #include "config.h" -#include "exceptions.h" +#include "cross.h" +#include "dcpomatic_log.h" #include "dcpomatic_log.h" +#include "exceptions.h" +#include "log.h" #include <dcp/raw_convert.h> #include <glib.h> extern "C" { #include <libavformat/avio.h> } #include <boost/algorithm/string.hpp> -#include <boost/function.hpp> #if BOOST_VERSION >= 106100 #include <boost/dll/runtime_symbol_info.hpp> #endif @@ -46,19 +46,21 @@ extern "C" { #include "i18n.h" -using std::pair; -using std::list; -using std::ifstream; -using std::string; -using std::wstring; -using std::make_pair; -using std::vector; + using std::cerr; using std::cout; +using std::function; +using std::ifstream; +using std::list; +using std::make_pair; +using std::pair; using std::runtime_error; using std::shared_ptr; +using std::string; +using std::vector; +using std::wstring; using boost::optional; -using boost::function; + /** @param s Number of seconds to sleep for */ void @@ -67,12 +69,14 @@ dcpomatic_sleep_seconds (int s) sleep (s); } + void dcpomatic_sleep_milliseconds (int ms) { usleep (ms * 1000); } + /** @return A string of CPU information (model name etc.) */ string cpu_info () @@ -97,6 +101,7 @@ cpu_info () return info; } + boost::filesystem::path resources_path () { @@ -135,12 +140,13 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out) } } -list<pair<string, string> > + +list<pair<string, string>> mount_info () { - list<pair<string, string> > m; + list<pair<string, string>> m; - FILE* f = setmntent ("/etc/mtab", "r"); + auto f = setmntent ("/etc/mtab", "r"); if (!f) { return m; } @@ -176,7 +182,7 @@ directory_containing_executable () boost::filesystem::path openssl_path () { - boost::filesystem::path p = directory_containing_executable() / "dcpomatic2_openssl"; + auto p = directory_containing_executable() / "dcpomatic2_openssl"; if (boost::filesystem::is_regular_file(p)) { return p; } @@ -201,26 +207,30 @@ disk_writer_path () FILE * fopen_boost (boost::filesystem::path p, string t) { - return fopen (p.c_str(), t.c_str ()); + return fopen(p.c_str(), t.c_str()); } + int dcpomatic_fseek (FILE* stream, int64_t offset, int whence) { return fseek (stream, offset, whence); } + void Waker::nudge () { } + Waker::Waker () { } + Waker::~Waker () { @@ -230,7 +240,7 @@ Waker::~Waker () void start_tool (string executable) { - boost::filesystem::path batch = directory_containing_executable() / executable; + auto batch = directory_containing_executable() / executable; pid_t pid = fork (); if (pid == 0) { @@ -260,6 +270,7 @@ thread_id () return (uint64_t) pthread_self (); } + int avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags) { @@ -273,6 +284,7 @@ home_directory () return getenv("HOME"); } + /** @return true if this process is a 32-bit one running on a 64-bit-capable OS */ bool running_32_on_64 () @@ -283,10 +295,10 @@ running_32_on_64 () static -vector<pair<string, string> > +vector<pair<string, string>> get_mounts (string prefix) { - vector<pair<string, string> > mounts; + vector<pair<string, string>> mounts; std::ifstream f("/proc/mounts"); string line; @@ -382,6 +394,7 @@ unprivileged () bool PrivilegeEscalator::test = false; + PrivilegeEscalator::~PrivilegeEscalator () { if (!test) { @@ -389,6 +402,7 @@ PrivilegeEscalator::~PrivilegeEscalator () } } + PrivilegeEscalator::PrivilegeEscalator () { if (!test) { @@ -399,6 +413,7 @@ PrivilegeEscalator::PrivilegeEscalator () } } + boost::filesystem::path config_path () { @@ -415,6 +430,7 @@ disk_write_finished () } + string dcpomatic::get_process_id () { diff --git a/src/lib/cross_osx.cc b/src/lib/cross_osx.cc index bd31541c5..58ec8e3c4 100644 --- a/src/lib/cross_osx.cc +++ b/src/lib/cross_osx.cc @@ -65,7 +65,7 @@ using std::runtime_error; using std::map; using std::shared_ptr; using boost::optional; -using boost::function; +using std::function; /** @param s Number of seconds to sleep for */ void diff --git a/src/lib/curl_uploader.cc b/src/lib/curl_uploader.cc index 1fd8ced01..82dca98f8 100644 --- a/src/lib/curl_uploader.cc +++ b/src/lib/curl_uploader.cc @@ -29,7 +29,7 @@ using std::string; using std::cout; -using boost::function; +using std::function; static size_t read_callback (void* ptr, size_t size, size_t nmemb, void* object) diff --git a/src/lib/curl_uploader.h b/src/lib/curl_uploader.h index 9fb3022f2..14cbce363 100644 --- a/src/lib/curl_uploader.h +++ b/src/lib/curl_uploader.h @@ -24,7 +24,7 @@ class CurlUploader : public Uploader { public: - CurlUploader (boost::function<void (std::string)> set_status, boost::function<void (float)> set_progress); + CurlUploader (std::function<void (std::string)> set_status, std::function<void (float)> set_progress); ~CurlUploader (); size_t read_callback (void* ptr, size_t size, size_t nmemb); diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 0da42502f..f6a74501c 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -56,7 +56,7 @@ using std::string; using std::vector; using boost::scoped_ptr; using boost::optional; -using boost::function; +using std::function; using std::dynamic_pointer_cast; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index 136c527a5..69520fbd6 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -176,7 +176,7 @@ private: std::list<dcpomatic::DCPTimePeriod> reels (std::shared_ptr<const Film> film) const; bool can_reference ( std::shared_ptr<const Film> film, - boost::function <bool (std::shared_ptr<const Content>)>, + std::function <bool (std::shared_ptr<const Content>)>, std::string overlapping, std::string& why_not ) const; diff --git a/src/lib/dcp_subtitle.cc b/src/lib/dcp_subtitle.cc index 6f579b2d3..0943a6b08 100644 --- a/src/lib/dcp_subtitle.cc +++ b/src/lib/dcp_subtitle.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "dcp_subtitle.h" #include "exceptions.h" #include "compose.hpp" @@ -26,9 +27,12 @@ #include "i18n.h" -using std::string; + using std::exception; using std::shared_ptr; +using std::string; +using std::make_shared; + shared_ptr<dcp::SubtitleAsset> DCPSubtitle::load (boost::filesystem::path file) const @@ -38,21 +42,21 @@ DCPSubtitle::load (boost::filesystem::path file) const string smpte_error; try { - sc.reset (new dcp::InteropSubtitleAsset (file)); + sc = make_shared<dcp::InteropSubtitleAsset>(file); } catch (exception& e) { interop_error = e.what (); } if (!sc) { try { - sc.reset (new dcp::SMPTESubtitleAsset (file)); + sc = make_shared<dcp::SMPTESubtitleAsset>(file); } catch (exception& e) { smpte_error = e.what(); } } if (!sc) { - throw FileError (String::compose (_("Could not read subtitles (%1 / %2)"), interop_error, smpte_error), file); + throw FileError(String::compose(_("Could not read subtitles (%1 / %2)"), interop_error, smpte_error), file); } return sc; diff --git a/src/lib/dcp_subtitle.h b/src/lib/dcp_subtitle.h index 9cd0685aa..2011759aa 100644 --- a/src/lib/dcp_subtitle.h +++ b/src/lib/dcp_subtitle.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,19 +18,24 @@ */ + #ifndef DCPOMATIC_DCP_SUBTITLE_H #define DCPOMATIC_DCP_SUBTITLE_H + #include <boost/filesystem.hpp> + namespace dcp { class SubtitleAsset; } + class DCPSubtitle { protected: std::shared_ptr<dcp::SubtitleAsset> load (boost::filesystem::path) const; }; + #endif diff --git a/src/lib/dcpomatic_log.cc b/src/lib/dcpomatic_log.cc index a64dc907c..cffc79830 100644 --- a/src/lib/dcpomatic_log.cc +++ b/src/lib/dcpomatic_log.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,8 +18,10 @@ */ + #include "dcpomatic_log.h" #include "null_log.h" + /** The current log; set up by the front-ends when they have a Film to log into */ std::shared_ptr<Log> dcpomatic_log (new NullLog()); diff --git a/src/lib/dcpomatic_log.h b/src/lib/dcpomatic_log.h index 605f95122..6a1c3a6ec 100644 --- a/src/lib/dcpomatic_log.h +++ b/src/lib/dcpomatic_log.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,12 +18,15 @@ */ + #include "log.h" #include "compose.hpp" + /** The current log; set up by the front-ends when they have a Film to log into */ extern std::shared_ptr<Log> dcpomatic_log; + #define LOG_GENERAL(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_GENERAL); #define LOG_GENERAL_NC(...) dcpomatic_log->log(__VA_ARGS__, LogEntry::TYPE_GENERAL); #define LOG_ERROR(...) dcpomatic_log->log(String::compose(__VA_ARGS__), LogEntry::TYPE_ERROR); diff --git a/src/lib/decoder_part.cc b/src/lib/decoder_part.cc index 2bab1603e..bcddcb785 100644 --- a/src/lib/decoder_part.cc +++ b/src/lib/decoder_part.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,10 +18,10 @@ */ + #include "decoder_part.h" #include "decoder.h" -using std::shared_ptr; DecoderPart::DecoderPart (Decoder* parent) : _parent (parent) diff --git a/src/lib/decoder_part.h b/src/lib/decoder_part.h index 96225f3dd..57ddee781 100644 --- a/src/lib/decoder_part.h +++ b/src/lib/decoder_part.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,16 +18,20 @@ */ + #ifndef DCPOMATIC_DECODER_PART_H #define DCPOMATIC_DECODER_PART_H + #include "dcpomatic_time.h" #include <boost/optional.hpp> + class Decoder; class Log; class Film; + class DecoderPart { public: @@ -52,4 +56,5 @@ private: bool _ignore; }; + #endif diff --git a/src/lib/ffmpeg_audio_stream.cc b/src/lib/ffmpeg_audio_stream.cc index 32828f13a..91020e288 100644 --- a/src/lib/ffmpeg_audio_stream.cc +++ b/src/lib/ffmpeg_audio_stream.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "ffmpeg_audio_stream.h" #include <dcp/raw_convert.h> #include "warnings.h" @@ -26,37 +27,40 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include <libcxml/cxml.h> + using std::string; using boost::optional; using dcp::raw_convert; using namespace dcpomatic; + FFmpegAudioStream::FFmpegAudioStream (cxml::ConstNodePtr node, int version) : FFmpegStream (node) , AudioStream ( - node->number_child<int> ("FrameRate"), - node->optional_number_child<Frame>("Length").get_value_or (0), - AudioMapping (node->node_child ("Mapping"), version) + node->number_child<int>("FrameRate"), + node->optional_number_child<Frame>("Length").get_value_or(0), + AudioMapping (node->node_child("Mapping"), version) ) { - optional<ContentTime::Type> const f = node->optional_number_child<ContentTime::Type> ("FirstAudio"); + optional<ContentTime::Type> const f = node->optional_number_child<ContentTime::Type>("FirstAudio"); if (f) { - first_audio = ContentTime (f.get ()); + first_audio = ContentTime(f.get()); } codec_name = node->optional_string_child("CodecName"); } + void FFmpegAudioStream::as_xml (xmlpp::Node* root) const { FFmpegStream::as_xml (root); - root->add_child("FrameRate")->add_child_text (raw_convert<string> (frame_rate ())); - root->add_child("Length")->add_child_text (raw_convert<string> (length ())); + root->add_child("FrameRate")->add_child_text(raw_convert<string>(frame_rate())); + root->add_child("Length")->add_child_text(raw_convert<string>(length())); mapping().as_xml (root->add_child("Mapping")); if (first_audio) { - root->add_child("FirstAudio")->add_child_text (raw_convert<string> (first_audio.get().get ())); + root->add_child("FirstAudio")->add_child_text(raw_convert<string>(first_audio.get().get())); } if (codec_name) { - root->add_child("CodecName")->add_child_text (codec_name.get()); + root->add_child("CodecName")->add_child_text(codec_name.get()); } } diff --git a/src/lib/ffmpeg_audio_stream.h b/src/lib/ffmpeg_audio_stream.h index 65c4aba5e..a5ed90c97 100644 --- a/src/lib/ffmpeg_audio_stream.h +++ b/src/lib/ffmpeg_audio_stream.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,12 +18,15 @@ */ -#include "ffmpeg_stream.h" + #include "audio_stream.h" #include "dcpomatic_time.h" +#include "ffmpeg_stream.h" + struct ffmpeg_pts_offset_test; + class FFmpegAudioStream : public FFmpegStream, public AudioStream { public: @@ -61,3 +64,4 @@ private: , AudioStream (0, 0, 0) {} }; + diff --git a/src/lib/file_group.cc b/src/lib/file_group.cc index aaf94acf4..7dae1da92 100644 --- a/src/lib/file_group.cc +++ b/src/lib/file_group.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,51 +18,49 @@ */ + /** @file src/lib/file_group.cc * @brief FileGroup class. */ -#include "file_group.h" -#include "exceptions.h" -#include "cross.h" + #include "compose.hpp" +#include "cross.h" #include "dcpomatic_assert.h" +#include "exceptions.h" +#include "file_group.h" #include <sndfile.h> #include <cstdio> + using std::vector; + /** Construct a FileGroup with no files */ FileGroup::FileGroup () - : _current_path (0) - , _current_file (0) - , _current_size (0) - , _position (0) { } + /** Construct a FileGroup with a single file */ FileGroup::FileGroup (boost::filesystem::path p) - : _current_path (0) - , _current_file (0) - , _current_size (0) { _paths.push_back (p); ensure_open_path (0); seek (0, SEEK_SET); } + /** Construct a FileGroup with multiple files */ FileGroup::FileGroup (vector<boost::filesystem::path> const & p) : _paths (p) - , _current_path (0) - , _current_file (0) { ensure_open_path (0); seek (0, SEEK_SET); } + /** Destroy a FileGroup, closing any open file */ FileGroup::~FileGroup () { @@ -71,6 +69,7 @@ FileGroup::~FileGroup () } } + void FileGroup::set_paths (vector<boost::filesystem::path> const & p) { @@ -79,6 +78,7 @@ FileGroup::set_paths (vector<boost::filesystem::path> const & p) seek (0, SEEK_SET); } + /** Ensure that the given path index in the content is the _current_file */ void FileGroup::ensure_open_path (size_t p) const @@ -94,12 +94,13 @@ FileGroup::ensure_open_path (size_t p) const _current_path = p; _current_file = fopen_boost (_paths[_current_path], "rb"); - if (_current_file == 0) { + if (!_current_file) { throw OpenFileError (_paths[_current_path], errno, OpenFileError::READ); } _current_size = boost::filesystem::file_size (_paths[_current_path]); } + int64_t FileGroup::seek (int64_t pos, int whence) const { @@ -138,6 +139,7 @@ FileGroup::seek (int64_t pos, int whence) const return _position; } + /** Try to read some data from the current position into a buffer. * @param buffer Buffer to write data into. * @param amount Number of bytes to read. @@ -195,6 +197,7 @@ FileGroup::read (uint8_t* buffer, int amount) const return read; } + /** @return Combined length of all the files */ int64_t FileGroup::length () const diff --git a/src/lib/file_group.h b/src/lib/file_group.h index a696343a0..9521da7ec 100644 --- a/src/lib/file_group.h +++ b/src/lib/file_group.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,16 +18,20 @@ */ + /** @file src/lib/file_group.h * @brief FileGroup class. */ + #ifndef DCPOMATIC_FILE_GROUP_H #define DCPOMATIC_FILE_GROUP_H + #include <boost/filesystem.hpp> #include <vector> + /** @class FileGroup * @brief A class to make a list of files behave like they were concatenated. */ @@ -53,10 +57,11 @@ private: std::vector<boost::filesystem::path> _paths; /** Index of path that we are currently reading from */ - mutable size_t _current_path; - mutable FILE* _current_file; - mutable size_t _current_size; - mutable int64_t _position; + mutable size_t _current_path = 0; + mutable FILE* _current_file = nullptr; + mutable size_t _current_size = 0; + mutable int64_t _position = 0; }; + #endif diff --git a/src/lib/frame_interval_checker.cc b/src/lib/frame_interval_checker.cc index dcb9aeaf5..e40958a42 100644 --- a/src/lib/frame_interval_checker.cc +++ b/src/lib/frame_interval_checker.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,12 +18,16 @@ */ + #include "frame_interval_checker.h" + using namespace dcpomatic; + int const FrameIntervalChecker::_frames = 16; + void FrameIntervalChecker::feed (ContentTime time, double frame_rate) { @@ -39,6 +43,7 @@ FrameIntervalChecker::feed (ContentTime time, double frame_rate) _last = time; } + FrameIntervalChecker::Guess FrameIntervalChecker::guess () const { @@ -46,7 +51,7 @@ FrameIntervalChecker::guess () const /* How soon can you land? * I can't tell. * You can tell me, I'm a doctor. - * Nom I mean I'm just not sure. + * No I mean I'm just not sure. * Can't you take a guess? * Well, not for another two hours. * You can't take a guess for another two hours? diff --git a/src/lib/internet.cc b/src/lib/internet.cc index 943363d1a..ca72399f3 100644 --- a/src/lib/internet.cc +++ b/src/lib/internet.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2019 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "scoped_temporary.h" #include "compose.hpp" #include "exceptions.h" @@ -25,7 +26,6 @@ #include "util.h" #include <curl/curl.h> #include <zip.h> -#include <boost/function.hpp> #include <boost/optional.hpp> #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> @@ -33,12 +33,14 @@ #include "i18n.h" -using std::string; + +using std::function; using std::list; +using std::string; using boost::optional; -using boost::function; using boost::algorithm::trim; + static size_t ls_url_data (void* buffer, size_t size, size_t nmemb, void* output) { @@ -50,17 +52,18 @@ ls_url_data (void* buffer, size_t size, size_t nmemb, void* output) return nmemb; } + list<string> ls_url (string url) { - CURL* curl = curl_easy_init (); + auto curl = curl_easy_init (); curl_easy_setopt (curl, CURLOPT_URL, url.c_str()); curl_easy_setopt (curl, CURLOPT_DIRLISTONLY, 1); string ls; curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, ls_url_data); curl_easy_setopt (curl, CURLOPT_WRITEDATA, &ls); - CURLcode const cr = curl_easy_perform (curl); + auto const cr = curl_easy_perform (curl); if (cr != CURLE_OK) { return list<string>(); @@ -80,20 +83,22 @@ ls_url (string url) return result; } + static size_t get_from_url_data (void* buffer, size_t size, size_t nmemb, void* stream) { - FILE* f = reinterpret_cast<FILE*> (stream); + auto f = reinterpret_cast<FILE*> (stream); return fwrite (buffer, size, nmemb, f); } + optional<string> get_from_url (string url, bool pasv, bool skip_pasv_ip, ScopedTemporary& temp) { - CURL* curl = curl_easy_init (); + auto curl = curl_easy_init (); curl_easy_setopt (curl, CURLOPT_URL, url.c_str()); - FILE* f = temp.open ("wb"); + auto f = temp.open ("wb"); curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, get_from_url_data); curl_easy_setopt (curl, CURLOPT_WRITEDATA, f); curl_easy_setopt (curl, CURLOPT_FTP_USE_EPSV, 0); @@ -124,7 +129,7 @@ optional<string> get_from_url (string url, bool pasv, bool skip_pasv_ip, function<optional<string> (boost::filesystem::path)> load) { ScopedTemporary temp; - optional<string> e = get_from_url (url, pasv, skip_pasv_ip, temp); + auto e = get_from_url (url, pasv, skip_pasv_ip, temp); if (e) { return e; } @@ -141,7 +146,7 @@ get_from_zip_url (string url, string file, bool pasv, bool skip_pasv_ip, functio { /* Download the ZIP file to temp_zip */ ScopedTemporary temp_zip; - optional<string> e = get_from_url (url, pasv, skip_pasv_ip, temp_zip); + auto e = get_from_url (url, pasv, skip_pasv_ip, temp_zip); if (e) { return e; } @@ -154,19 +159,19 @@ get_from_zip_url (string url, string file, bool pasv, bool skip_pasv_ip, functio Centos 6, Centos 7, Debian 7 and Debian 8. */ - FILE* zip_file = fopen_boost (temp_zip.file (), "rb"); + auto zip_file = fopen_boost (temp_zip.file (), "rb"); if (!zip_file) { return optional<string> (_("Could not open downloaded ZIP file")); } - zip_source_t* zip_source = zip_source_filep_create (zip_file, 0, -1, 0); + auto zip_source = zip_source_filep_create (zip_file, 0, -1, 0); if (!zip_source) { return optional<string> (_("Could not open downloaded ZIP file")); } zip_error_t error; zip_error_init (&error); - zip_t* zip = zip_open_from_source (zip_source, ZIP_RDONLY, &error); + auto zip = zip_open_from_source (zip_source, ZIP_RDONLY, &error); if (!zip) { return String::compose (_("Could not open downloaded ZIP file (%1:%2: %3)"), error.zip_err, error.sys_err, error.str ? error.str : ""); } @@ -181,7 +186,7 @@ get_from_zip_url (string url, string file, bool pasv, bool skip_pasv_ip, functio } ScopedTemporary temp_cert; - FILE* f = temp_cert.open ("wb"); + auto f = temp_cert.open ("wb"); char buffer[4096]; while (true) { int const N = zip_fread (file_in_zip, buffer, sizeof (buffer)); diff --git a/src/lib/internet.h b/src/lib/internet.h index 8aa7264c6..25513e666 100644 --- a/src/lib/internet.h +++ b/src/lib/internet.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -19,12 +19,13 @@ */ #include <boost/optional.hpp> -#include <boost/function.hpp> #include <boost/filesystem.hpp> + class ScopedTemporary; + boost::optional<std::string> get_from_url (std::string url, bool pasv, bool skip_pasv_ip, ScopedTemporary& temp); -boost::optional<std::string> get_from_url (std::string url, bool pasv, bool skip_pasv_ip, boost::function<boost::optional<std::string> (boost::filesystem::path)> load); -boost::optional<std::string> get_from_zip_url (std::string url, std::string file, bool pasv, bool skip_pasv_ip, boost::function<boost::optional<std::string> (boost::filesystem::path)> load); +boost::optional<std::string> get_from_url (std::string url, bool pasv, bool skip_pasv_ip, std::function<boost::optional<std::string> (boost::filesystem::path)> load); +boost::optional<std::string> get_from_zip_url (std::string url, std::string file, bool pasv, bool skip_pasv_ip, std::function<boost::optional<std::string> (boost::filesystem::path)> load); std::list<std::string> ls_url (std::string url); diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc index fcd1689cb..144da396d 100644 --- a/src/lib/j2k_image_proxy.cc +++ b/src/lib/j2k_image_proxy.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "j2k_image_proxy.h" #include "dcpomatic_socket.h" #include "image.h" @@ -38,17 +39,20 @@ DCPOMATIC_ENABLE_WARNINGS #include "i18n.h" -using std::string; + using std::cout; +using std::dynamic_pointer_cast; +using std::make_pair; +using std::make_shared; using std::max; using std::pair; -using std::make_pair; using std::shared_ptr; +using std::string; using boost::optional; -using std::dynamic_pointer_cast; using dcp::ArrayData; using dcp::raw_convert; + /** Construct a J2KImageProxy from a JPEG2000 file */ J2KImageProxy::J2KImageProxy (boost::filesystem::path path, dcp::Size size, AVPixelFormat pixel_format) : _data (new dcp::ArrayData(path)) @@ -100,9 +104,9 @@ J2KImageProxy::J2KImageProxy ( J2KImageProxy::J2KImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> socket) : _error (false) { - _size = dcp::Size (xml->number_child<int> ("Width"), xml->number_child<int> ("Height")); - if (xml->optional_number_child<int> ("Eye")) { - _eye = static_cast<dcp::Eye> (xml->number_child<int> ("Eye")); + _size = dcp::Size (xml->number_child<int>("Width"), xml->number_child<int>("Height")); + if (xml->optional_number_child<int>("Eye")) { + _eye = static_cast<dcp::Eye>(xml->number_child<int>("Eye")); } shared_ptr<ArrayData> data(new ArrayData(xml->number_child<int>("Size"))); /* This only matters when we are using J2KImageProxy for the preview, which @@ -114,6 +118,7 @@ J2KImageProxy::J2KImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> soc _data = data; } + int J2KImageProxy::prepare (optional<dcp::Size> target_size) const { @@ -139,7 +144,7 @@ J2KImageProxy::prepare (optional<dcp::Size> target_size) const try { /* XXX: should check that potentially trashing _data here doesn't matter */ - shared_ptr<dcp::OpenJPEGImage> decompressed = dcp::decompress_j2k (const_cast<uint8_t*>(_data->data()), _data->size(), reduce); + auto decompressed = dcp::decompress_j2k (const_cast<uint8_t*>(_data->data()), _data->size(), reduce); _image.reset (new Image (_pixel_format, decompressed->size(), true)); int const shift = 16 - decompressed->precision (0); @@ -155,7 +160,7 @@ J2KImageProxy::prepare (optional<dcp::Size> target_size) const int* decomp_1 = decompressed->data (1); int* decomp_2 = decompressed->data (2); for (int y = 0; y < decompressed->size().height; ++y) { - uint16_t* q = (uint16_t *) (_image->data()[0] + y * _image->stride()[0]); + auto q = reinterpret_cast<uint16_t *>(_image->data()[0] + y * _image->stride()[0]); for (int x = 0; x < width; ++x) { *q++ = decomp_0[p] << shift; *q++ = decomp_1[p] << shift; @@ -164,7 +169,7 @@ J2KImageProxy::prepare (optional<dcp::Size> target_size) const } } } catch (dcp::J2KDecompressionError& e) { - _image.reset (new Image (_pixel_format, _size, true)); + _image = make_shared<Image>(_pixel_format, _size, true); _image->make_black (); _error = true; } @@ -191,25 +196,27 @@ J2KImageProxy::image (optional<dcp::Size> target_size) const void J2KImageProxy::add_metadata (xmlpp::Node* node) const { - node->add_child("Type")->add_child_text (N_("J2K")); - node->add_child("Width")->add_child_text (raw_convert<string> (_size.width)); - node->add_child("Height")->add_child_text (raw_convert<string> (_size.height)); + node->add_child("Type")->add_child_text(N_("J2K")); + node->add_child("Width")->add_child_text(raw_convert<string>(_size.width)); + node->add_child("Height")->add_child_text(raw_convert<string>(_size.height)); if (_eye) { - node->add_child("Eye")->add_child_text (raw_convert<string> (static_cast<int> (_eye.get ()))); + node->add_child("Eye")->add_child_text(raw_convert<string>(static_cast<int>(_eye.get()))); } - node->add_child("Size")->add_child_text (raw_convert<string>(_data->size())); + node->add_child("Size")->add_child_text(raw_convert<string>(_data->size())); } + void J2KImageProxy::write_to_socket (shared_ptr<Socket> socket) const { socket->write (_data->data(), _data->size()); } + bool J2KImageProxy::same (shared_ptr<const ImageProxy> other) const { - shared_ptr<const J2KImageProxy> jp = dynamic_pointer_cast<const J2KImageProxy> (other); + auto jp = dynamic_pointer_cast<const J2KImageProxy>(other); if (!jp) { return false; } @@ -217,6 +224,7 @@ J2KImageProxy::same (shared_ptr<const ImageProxy> other) const return *_data == *jp->_data; } + J2KImageProxy::J2KImageProxy (ArrayData data, dcp::Size size, AVPixelFormat pixel_format) : _data (new ArrayData(data)) , _size (size) @@ -227,6 +235,7 @@ J2KImageProxy::J2KImageProxy (ArrayData data, dcp::Size size, AVPixelFormat pixe DCPOMATIC_ASSERT (_pixel_format == AV_PIX_FMT_RGB48 || _pixel_format == AV_PIX_FMT_XYZ12LE); } + size_t J2KImageProxy::memory_used () const { diff --git a/src/lib/j2k_image_proxy.h b/src/lib/j2k_image_proxy.h index 437a563eb..5235d8e42 100644 --- a/src/lib/j2k_image_proxy.h +++ b/src/lib/j2k_image_proxy.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2017 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,16 +18,19 @@ */ + #include "image_proxy.h" #include <dcp/array_data.h> #include <dcp/util.h> #include <boost/thread/mutex.hpp> + namespace dcp { class MonoPictureFrame; class StereoPictureFrame; } + class J2KImageProxy : public ImageProxy { public: diff --git a/src/lib/job.cc b/src/lib/job.cc index b0ca8a737..52558046a 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -44,7 +44,7 @@ using std::list; using std::cout; using std::shared_ptr; using boost::optional; -using boost::function; +using std::function; using namespace dcpomatic; /** @param film Associated film, or 0 */ diff --git a/src/lib/job.h b/src/lib/job.h index 6d8435c60..96f0acbe5 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -86,7 +86,7 @@ public: return _film; } - void when_finished (boost::signals2::connection& connection, boost::function<void()> finished); + void when_finished (boost::signals2::connection& connection, std::function<void()> finished); boost::signals2::signal<void()> Progress; /** Emitted from the UI thread when the job is finished */ diff --git a/src/lib/job_manager.cc b/src/lib/job_manager.cc index 4ed360bed..d8c0b02f2 100644 --- a/src/lib/job_manager.cc +++ b/src/lib/job_manager.cc @@ -34,13 +34,13 @@ using std::dynamic_pointer_cast; +using std::function; using std::list; using std::make_shared; using std::shared_ptr; using std::string; using std::weak_ptr; using boost::bind; -using boost::function; using boost::optional; diff --git a/src/lib/job_manager.h b/src/lib/job_manager.h index 4fe1e45d6..ff5800aa8 100644 --- a/src/lib/job_manager.h +++ b/src/lib/job_manager.h @@ -70,14 +70,14 @@ public: std::shared_ptr<const Playlist> playlist, bool from_zero, boost::signals2::connection& connection, - boost::function<void()> ready + std::function<void()> ready ); void analyse_subtitles ( std::shared_ptr<const Film> film, std::shared_ptr<Content> content, boost::signals2::connection& connection, - boost::function<void()> ready + std::function<void()> ready ); boost::signals2::signal<void (std::weak_ptr<Job>)> JobAdded; diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc index fbd2e4bd4..3159b4c72 100644 --- a/src/lib/kdm_with_metadata.cc +++ b/src/lib/kdm_with_metadata.cc @@ -27,8 +27,6 @@ #include "config.h" #include "dcpomatic_log.h" #include "emailer.h" -#include <boost/function.hpp> -#include <boost/function.hpp> #include "i18n.h" @@ -38,7 +36,7 @@ using std::cout; using std::list; using std::shared_ptr; using boost::optional; -using boost::function; +using std::function; int @@ -46,7 +44,7 @@ write_files ( list<KDMWithMetadataPtr> kdms, boost::filesystem::path directory, dcp::NameFormat name_format, - boost::function<bool (boost::filesystem::path)> confirm_overwrite + std::function<bool (boost::filesystem::path)> confirm_overwrite ) { int written = 0; diff --git a/src/lib/kdm_with_metadata.h b/src/lib/kdm_with_metadata.h index 99c2ef8dc..3e0b7e554 100644 --- a/src/lib/kdm_with_metadata.h +++ b/src/lib/kdm_with_metadata.h @@ -75,7 +75,7 @@ typedef std::shared_ptr<KDMWithMetadata> KDMWithMetadataPtr; int write_files ( std::list<KDMWithMetadataPtr> screen_kdms, boost::filesystem::path directory, - dcp::NameFormat name_format, boost::function<bool (boost::filesystem::path)> confirm_overwrite + dcp::NameFormat name_format, std::function<bool (boost::filesystem::path)> confirm_overwrite ); @@ -90,7 +90,7 @@ int write_directories ( boost::filesystem::path directory, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, - boost::function<bool (boost::filesystem::path)> confirm_overwrite + std::function<bool (boost::filesystem::path)> confirm_overwrite ); @@ -99,7 +99,7 @@ int write_zip_files ( boost::filesystem::path directory, dcp::NameFormat container_name_format, dcp::NameFormat filename_format, - boost::function<bool (boost::filesystem::path)> confirm_overwrite + std::function<bool (boost::filesystem::path)> confirm_overwrite ); diff --git a/src/lib/overlaps.cc b/src/lib/overlaps.cc index 32801de39..09e7f63ac 100644 --- a/src/lib/overlaps.cc +++ b/src/lib/overlaps.cc @@ -23,7 +23,7 @@ #include "content.h" using std::shared_ptr; -using boost::function; +using std::function; using namespace dcpomatic; ContentList overlaps (shared_ptr<const Film> film, ContentList cl, function<bool (shared_ptr<const Content>)> part, DCPTime from, DCPTime to) diff --git a/src/lib/overlaps.h b/src/lib/overlaps.h index 60c0cd537..6c5a85a8b 100644 --- a/src/lib/overlaps.h +++ b/src/lib/overlaps.h @@ -29,5 +29,5 @@ class Film; * ContentList */ ContentList overlaps ( - std::shared_ptr<const Film> film, ContentList cl, boost::function<bool (std::shared_ptr<const Content>)> part, dcpomatic::DCPTime from, dcpomatic::DCPTime to + std::shared_ptr<const Film> film, ContentList cl, std::function<bool (std::shared_ptr<const Content>)> part, dcpomatic::DCPTime from, dcpomatic::DCPTime to ); diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc index f91b990c8..e473b8750 100644 --- a/src/lib/player_video.cc +++ b/src/lib/player_video.cc @@ -41,7 +41,7 @@ using std::shared_ptr; using std::string; using std::weak_ptr; using boost::optional; -using boost::function; +using std::function; using dcp::Data; using dcp::raw_convert; diff --git a/src/lib/player_video.h b/src/lib/player_video.h index df0007ddf..f29684832 100644 --- a/src/lib/player_video.h +++ b/src/lib/player_video.h @@ -71,8 +71,8 @@ public: void set_text (PositionImage); - void prepare (boost::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool aligned, bool fast); - std::shared_ptr<Image> image (boost::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool aligned, bool fast) const; + void prepare (std::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool aligned, bool fast); + std::shared_ptr<Image> image (std::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool aligned, bool fast) const; static AVPixelFormat force (AVPixelFormat, AVPixelFormat); static AVPixelFormat keep_xyz_or_rgb (AVPixelFormat); @@ -118,7 +118,7 @@ public: } private: - void make_image (boost::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool aligned, bool fast) const; + void make_image (std::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool aligned, bool fast) const; std::shared_ptr<const ImageProxy> _in; Crop _crop; diff --git a/src/lib/position_image.cc b/src/lib/position_image.cc index c342e1866..9ba2e9c3f 100644 --- a/src/lib/position_image.cc +++ b/src/lib/position_image.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,11 +18,10 @@ */ + #include "position_image.h" #include "image.h" -#include <iostream> -using std::cout; bool PositionImage::same (PositionImage const & other) const diff --git a/src/lib/position_image.h b/src/lib/position_image.h index b78effbd5..2b7e7080a 100644 --- a/src/lib/position_image.h +++ b/src/lib/position_image.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #ifndef DCPOMATIC_POSITION_IMAGE_H #define DCPOMATIC_POSITION_IMAGE_H @@ -28,6 +29,7 @@ class Image; + class PositionImage { public: @@ -44,4 +46,5 @@ public: bool same (PositionImage const & other) const; }; + #endif diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index a3d499abe..0b367ae38 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -744,7 +744,7 @@ ReelWriter::create_reel ( } void -ReelWriter::calculate_digests (boost::function<void (float)> set_progress) +ReelWriter::calculate_digests (std::function<void (float)> set_progress) try { if (_picture_asset) { diff --git a/src/lib/reel_writer.h b/src/lib/reel_writer.h index 5eb0e1b08..804a93c05 100644 --- a/src/lib/reel_writer.h +++ b/src/lib/reel_writer.h @@ -81,7 +81,7 @@ public: bool ensure_subtitles, std::set<DCPTextTrack> ensure_closed_captions ); - void calculate_digests (boost::function<void (float)> set_progress); + void calculate_digests (std::function<void (float)> set_progress); Frame start () const; diff --git a/src/lib/rgba.cc b/src/lib/rgba.cc index 1076af433..4d2c28085 100644 --- a/src/lib/rgba.cc +++ b/src/lib/rgba.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "rgba.h" #include "warnings.h" DCPOMATIC_DISABLE_WARNINGS @@ -25,26 +26,30 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS #include <boost/lexical_cast.hpp> + using std::string; using boost::lexical_cast; + RGBA::RGBA (cxml::ConstNodePtr node) { - r = node->number_child<int> ("R"); - g = node->number_child<int> ("G"); - b = node->number_child<int> ("B"); - a = node->number_child<int> ("A"); + r = node->number_child<int>("R"); + g = node->number_child<int>("G"); + b = node->number_child<int>("B"); + a = node->number_child<int>("A"); } + void RGBA::as_xml (xmlpp::Node* parent) const { - parent->add_child("R")->add_child_text (lexical_cast<string> (int (r))); - parent->add_child("G")->add_child_text (lexical_cast<string> (int (g))); - parent->add_child("B")->add_child_text (lexical_cast<string> (int (b))); - parent->add_child("A")->add_child_text (lexical_cast<string> (int (a))); + parent->add_child("R")->add_child_text(lexical_cast<string>(int(r))); + parent->add_child("G")->add_child_text(lexical_cast<string>(int(g))); + parent->add_child("B")->add_child_text(lexical_cast<string>(int(b))); + parent->add_child("A")->add_child_text(lexical_cast<string>(int(a))); } + bool RGBA::operator< (RGBA const & other) const { diff --git a/src/lib/rgba.h b/src/lib/rgba.h index c9521f311..96fed710e 100644 --- a/src/lib/rgba.h +++ b/src/lib/rgba.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,25 +18,22 @@ */ + #ifndef DCPOMATIC_RGBA_H #define DCPOMATIC_RGBA_H + #include <libcxml/cxml.h> #include <stdint.h> + /** @class RGBA * @brief A 32-bit RGBA colour. */ - class RGBA { public: - RGBA () - : r (0) - , g (0) - , b (0) - , a (0) - {} + RGBA () {} RGBA (uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_) : r (r_) @@ -49,12 +46,13 @@ public: void as_xml (xmlpp::Node* parent) const; - uint8_t r; - uint8_t g; - uint8_t b; - uint8_t a; + uint8_t r = 0; + uint8_t g = 0; + uint8_t b = 0; + uint8_t a = 0; bool operator< (RGBA const & other) const; }; + #endif diff --git a/src/lib/shuffler.cc b/src/lib/shuffler.cc index a13e7f6de..5a4faf4d1 100644 --- a/src/lib/shuffler.cc +++ b/src/lib/shuffler.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "shuffler.h" #include "content_video.h" #include "dcpomatic_assert.h" @@ -25,14 +26,17 @@ #include <string> #include <iostream> + using std::make_pair; +using std::shared_ptr; using std::string; using std::weak_ptr; -using std::shared_ptr; using boost::optional; + int const Shuffler::_max_size = 64; + struct Comparator { bool operator()(Shuffler::Store const & a, Shuffler::Store const & b) { @@ -43,6 +47,7 @@ struct Comparator } }; + void Shuffler::video (weak_ptr<Piece> weak_piece, ContentVideo video) { @@ -54,7 +59,7 @@ Shuffler::video (weak_ptr<Piece> weak_piece, ContentVideo video) return; } - shared_ptr<Piece> piece = weak_piece.lock (); + auto piece = weak_piece.lock (); DCPOMATIC_ASSERT (piece); if (!_last && video.eyes == Eyes::LEFT) { @@ -103,6 +108,7 @@ Shuffler::video (weak_ptr<Piece> weak_piece, ContentVideo video) } } + void Shuffler::clear () { @@ -111,6 +117,7 @@ Shuffler::clear () _last = optional<ContentVideo>(); } + void Shuffler::flush () { diff --git a/src/lib/shuffler.h b/src/lib/shuffler.h index b0a416b80..2b37b70a1 100644 --- a/src/lib/shuffler.h +++ b/src/lib/shuffler.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,14 +18,18 @@ */ + #include "types.h" #include "content_video.h" #include <boost/signals2.hpp> + struct shuffler_test5; + class Piece; + class Shuffler { public: diff --git a/src/lib/text_decoder.cc b/src/lib/text_decoder.cc index 099e3ee74..0a7bdf95d 100644 --- a/src/lib/text_decoder.cc +++ b/src/lib/text_decoder.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2017 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "text_decoder.h" #include "text_content.h" #include "util.h" @@ -27,6 +28,7 @@ #include <boost/algorithm/string.hpp> #include <iostream> + using std::list; using std::cout; using std::string; @@ -34,9 +36,10 @@ using std::min; using std::max; using std::shared_ptr; using boost::optional; -using boost::function; +using std::function; using namespace dcpomatic; + TextDecoder::TextDecoder ( Decoder* parent, shared_ptr<const TextContent> c, @@ -49,6 +52,7 @@ TextDecoder::TextDecoder ( } + /** Called by subclasses when an image subtitle is starting. * @param from From time of the subtitle. * @param image Subtitle image. @@ -63,6 +67,7 @@ TextDecoder::emit_bitmap_start (ContentTime from, shared_ptr<Image> image, dcpom _position = from; } + void TextDecoder::emit_plain_start (ContentTime from, list<dcp::SubtitleString> s) { @@ -97,6 +102,7 @@ TextDecoder::emit_plain_start (ContentTime from, list<dcp::SubtitleString> s) _position = from; } + void TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & subtitle) { @@ -250,12 +256,14 @@ TextDecoder::emit_plain_start (ContentTime from, sub::Subtitle const & subtitle) emit_plain_start (from, out); } + void TextDecoder::emit_stop (ContentTime to) { Stop (to); } + void TextDecoder::emit_plain (ContentTimePeriod period, list<dcp::SubtitleString> s) { @@ -263,6 +271,7 @@ TextDecoder::emit_plain (ContentTimePeriod period, list<dcp::SubtitleString> s) emit_stop (period.to); } + void TextDecoder::emit_plain (ContentTimePeriod period, sub::Subtitle const & s) { @@ -270,6 +279,7 @@ TextDecoder::emit_plain (ContentTimePeriod period, sub::Subtitle const & s) emit_stop (period.to); } + /* @param rect Area expressed as a fraction of the video frame that this subtitle * is for (e.g. a width of 0.5 means the width of the subtitle is half the width * of the video frame) @@ -281,6 +291,7 @@ TextDecoder::emit_bitmap (ContentTimePeriod period, shared_ptr<Image> image, dcp emit_stop (period.to); } + void TextDecoder::seek () { diff --git a/src/lib/text_decoder.h b/src/lib/text_decoder.h index 3fb27b653..6e96b6b91 100644 --- a/src/lib/text_decoder.h +++ b/src/lib/text_decoder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,9 +18,11 @@ */ + #ifndef DCPOMATIC_CAPTION_DECODER_H #define DCPOMATIC_CAPTION_DECODER_H + #include "decoder.h" #include "rect.h" #include "types.h" @@ -29,12 +31,14 @@ #include <dcp/subtitle_string.h> #include <boost/signals2.hpp> + namespace sub { class Subtitle; } class Image; + class TextDecoder : public DecoderPart { public: @@ -71,4 +75,5 @@ private: boost::optional<dcpomatic::ContentTime> _position; }; + #endif diff --git a/src/lib/text_ring_buffers.cc b/src/lib/text_ring_buffers.cc index ba727cc41..e2be7bf41 100644 --- a/src/lib/text_ring_buffers.cc +++ b/src/lib/text_ring_buffers.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,12 +18,15 @@ */ + #include "text_ring_buffers.h" + using std::pair; using boost::optional; using namespace dcpomatic; + void TextRingBuffers::put (PlayerText text, DCPTextTrack track, DCPTimePeriod period) { @@ -31,19 +34,21 @@ TextRingBuffers::put (PlayerText text, DCPTextTrack track, DCPTimePeriod period) _data.push_back (Data(text, track, period)); } + optional<TextRingBuffers::Data> TextRingBuffers::get () { boost::mutex::scoped_lock lm (_mutex); - if (_data.empty ()) { - return optional<Data>(); + if (_data.empty()) { + return {}; } - Data r = _data.front (); - _data.pop_front (); + auto r = _data.front(); + _data.pop_front(); return r; } + void TextRingBuffers::clear () { diff --git a/src/lib/text_ring_buffers.h b/src/lib/text_ring_buffers.h index 7d685d824..2014dacc5 100644 --- a/src/lib/text_ring_buffers.h +++ b/src/lib/text_ring_buffers.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,14 +18,17 @@ */ + #ifndef DCPOMATIC_TEXT_RING_BUFFERS_H #define DCPOMATIC_TEXT_RING_BUFFERS_H -#include "player_text.h" + #include "dcp_text_track.h" +#include "player_text.h" #include <boost/thread.hpp> #include <utility> + class TextRingBuffers { public: @@ -52,4 +55,5 @@ private: std::list<Data> _data; }; + #endif diff --git a/src/lib/uploader.cc b/src/lib/uploader.cc index 9618e5beb..c5448e469 100644 --- a/src/lib/uploader.cc +++ b/src/lib/uploader.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,15 +18,18 @@ */ + #include "uploader.h" #include "dcpomatic_assert.h" #include "compose.hpp" #include "i18n.h" + using std::string; using std::shared_ptr; -using boost::function; +using std::function; + Uploader::Uploader (function<void (string)> set_status, function<void (float)> set_progress) : _set_progress (set_progress) @@ -35,6 +38,7 @@ Uploader::Uploader (function<void (string)> set_status, function<void (float)> s _set_status (_("connecting")); } + boost::uintmax_t Uploader::count_file_sizes (boost::filesystem::path directory) const { @@ -42,40 +46,43 @@ Uploader::count_file_sizes (boost::filesystem::path directory) const boost::uintmax_t size = 0; - for (directory_iterator i = directory_iterator (directory); i != directory_iterator (); ++i) { - if (is_directory (i->path ())) { - size += count_file_sizes (i->path ()); + for (auto i: directory_iterator(directory)) { + if (is_directory (i.path())) { + size += count_file_sizes (i.path()); } else { - size += file_size (*i); + size += file_size (i); } } return size; } + void Uploader::upload (boost::filesystem::path directory) { boost::uintmax_t transferred = 0; - upload_directory (directory.parent_path (), directory, transferred, count_file_sizes (directory)); + upload_directory (directory.parent_path(), directory, transferred, count_file_sizes(directory)); } + void Uploader::upload_directory (boost::filesystem::path base, boost::filesystem::path directory, boost::uintmax_t& transferred, boost::uintmax_t total_size) { using namespace boost::filesystem; - create_directory (remove_prefix (base, directory)); - for (directory_iterator i = directory_iterator (directory); i != directory_iterator (); ++i) { - if (is_directory (i->path ())) { - upload_directory (base, i->path (), transferred, total_size); + create_directory (remove_prefix(base, directory)); + for (auto i: directory_iterator(directory)) { + if (is_directory(i.path())) { + upload_directory (base, i.path(), transferred, total_size); } else { - _set_status (String::compose (_("copying %1"), i->path().leaf ())); - upload_file (i->path (), remove_prefix (base, i->path ()), transferred, total_size); + _set_status (String::compose(_("copying %1"), i.path().leaf())); + upload_file (i.path(), remove_prefix (base, i.path()), transferred, total_size); } } } + boost::filesystem::path Uploader::remove_prefix (boost::filesystem::path prefix, boost::filesystem::path target) const { @@ -83,8 +90,8 @@ Uploader::remove_prefix (boost::filesystem::path prefix, boost::filesystem::path path result; - path::iterator i = target.begin (); - for (path::iterator j = prefix.begin (); j != prefix.end(); ++j) { + auto i = target.begin (); + for (auto j = prefix.begin (); j != prefix.end(); ++j) { DCPOMATIC_ASSERT (*i == *j); ++i; } diff --git a/src/lib/uploader.h b/src/lib/uploader.h index f57ed8c4f..a68be8dd0 100644 --- a/src/lib/uploader.h +++ b/src/lib/uploader.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,18 +18,21 @@ */ + #ifndef DCPOMATIC_UPLOADER_H #define DCPOMATIC_UPLOADER_H + #include <boost/filesystem.hpp> -#include <boost/function.hpp> + class Job; + class Uploader { public: - Uploader (boost::function<void (std::string)> set_status, boost::function<void (float)> set_progress); + Uploader (std::function<void (std::string)> set_status, std::function<void (float)> set_progress); virtual ~Uploader () {} void upload (boost::filesystem::path directory); @@ -39,14 +42,14 @@ protected: virtual void create_directory (boost::filesystem::path directory) = 0; virtual void upload_file (boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t& transferred, boost::uintmax_t total_size) = 0; - boost::function<void (float)> _set_progress; + std::function<void (float)> _set_progress; private: void upload_directory (boost::filesystem::path base, boost::filesystem::path directory, boost::uintmax_t& transferred, boost::uintmax_t total_size); boost::uintmax_t count_file_sizes (boost::filesystem::path) const; boost::filesystem::path remove_prefix (boost::filesystem::path prefix, boost::filesystem::path target) const; - boost::function<void (std::string)> _set_status; + std::function<void (std::string)> _set_status; }; #endif diff --git a/src/lib/upmixer_b.cc b/src/lib/upmixer_b.cc index 317108f41..3b0c2d94f 100644 --- a/src/lib/upmixer_b.cc +++ b/src/lib/upmixer_b.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,17 +18,21 @@ */ + #include "upmixer_b.h" #include "audio_buffers.h" #include "audio_mapping.h" #include "i18n.h" + using std::string; +using std::make_shared; using std::min; using std::vector; using std::shared_ptr; + UpmixerB::UpmixerB (int sampling_rate) : _lfe (0.01, 150.0 / sampling_rate) , _delay (0.02 * sampling_rate) @@ -36,6 +40,7 @@ UpmixerB::UpmixerB (int sampling_rate) } + string UpmixerB::name () const { @@ -49,25 +54,28 @@ UpmixerB::id () const return N_("stereo-5.1-upmix-b"); } + int UpmixerB::out_channels () const { return 6; } + shared_ptr<AudioProcessor> UpmixerB::clone (int sampling_rate) const { - return shared_ptr<AudioProcessor> (new UpmixerB (sampling_rate)); + return make_shared<UpmixerB>(sampling_rate); } + shared_ptr<AudioBuffers> UpmixerB::run (shared_ptr<const AudioBuffers> in, int channels) { - shared_ptr<AudioBuffers> out (new AudioBuffers (channels, in->frames())); + auto out = make_shared<AudioBuffers>(channels, in->frames()); /* L + R minus 6dB (in terms of amplitude) */ - shared_ptr<AudioBuffers> in_LR = in->channel(0); + auto in_LR = in->channel(0); in_LR->accumulate_frames (in->channel(1).get(), in->frames(), 0, 0); in_LR->apply_gain (-6); @@ -94,7 +102,7 @@ UpmixerB::run (shared_ptr<const AudioBuffers> in, int channels) shared_ptr<AudioBuffers> S; if (channels > 4) { /* Ls is L - R with some delay */ - shared_ptr<AudioBuffers> sub (new AudioBuffers (1, in->frames())); + auto sub = make_shared<AudioBuffers>(1, in->frames()); sub->copy_channel_from (in.get(), 0, 0); float* p = sub->data (0); float const * q = in->data (1); @@ -113,6 +121,7 @@ UpmixerB::run (shared_ptr<const AudioBuffers> in, int channels) return out; } + void UpmixerB::flush () { @@ -120,6 +129,7 @@ UpmixerB::flush () _delay.flush (); } + void UpmixerB::make_audio_mapping_default (AudioMapping& mapping) const { @@ -130,11 +140,12 @@ UpmixerB::make_audio_mapping_default (AudioMapping& mapping) const } } + vector<NamedChannel> UpmixerB::input_names () const { - vector<NamedChannel> n; - n.push_back (NamedChannel(_("Upmix L"), 0)); - n.push_back (NamedChannel(_("Upmix R"), 1)); - return n; + return { + NamedChannel(_("Upmix L"), 0), + NamedChannel(_("Upmix R"), 1) + }; } diff --git a/src/lib/upmixer_b.h b/src/lib/upmixer_b.h index c4c4fd1ac..fc30e2a28 100644 --- a/src/lib/upmixer_b.h +++ b/src/lib/upmixer_b.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,14 +18,17 @@ */ + /** @file src/lib/upmixer_b.h * @brief UpmixerB class. */ + #include "audio_processor.h" #include "audio_filter.h" #include "audio_delay.h" + class UpmixerB : public AudioProcessor { public: @@ -44,3 +47,4 @@ private: LowPassAudioFilter _lfe; AudioDelay _delay; }; + diff --git a/src/lib/util.cc b/src/lib/util.cc index 8a039764d..2b686da69 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -1040,7 +1040,7 @@ show_jobs_on_console (bool progress) /** XXX: could use mmap? */ void -copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, boost::function<void (float)> progress) +copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::function<void (float)> progress) { auto f = fopen_boost (from, "rb"); if (!f) { diff --git a/src/lib/util.h b/src/lib/util.h index a6b010e43..fa0d9fdf2 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -118,7 +118,7 @@ extern size_t utf8_strlen (std::string s); extern std::string day_of_week_to_string (boost::gregorian::greg_weekday d); extern void emit_subtitle_image (dcpomatic::ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size size, std::shared_ptr<TextDecoder> decoder); extern bool show_jobs_on_console (bool progress); -extern void copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, boost::function<void (float)>); +extern void copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::function<void (float)>); extern dcp::Size scale_for_display (dcp::Size s, dcp::Size display_container, dcp::Size film_container); extern dcp::DecryptedKDM decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm); extern boost::filesystem::path default_font_file (); diff --git a/src/lib/writer.cc b/src/lib/writer.cc index b749968a7..bc299414b 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -546,7 +546,7 @@ Writer::calculate_digests () pool.create_thread (boost::bind (&boost::asio::io_service::run, &service)); } - boost::function<void (float)> set_progress; + std::function<void (float)> set_progress; if (job) { set_progress = boost::bind (&Writer::set_digest_progress, this, job.get(), _1); } else { @@ -948,7 +948,7 @@ Writer::set_digest_progress (Job* job, float progress) /** Calculate hashes for any referenced MXF assets which do not already have one */ void -Writer::calculate_referenced_digests (boost::function<void (float)> set_progress) +Writer::calculate_referenced_digests (std::function<void (float)> set_progress) try { for (auto const& i: _reel_assets) { diff --git a/src/lib/writer.h b/src/lib/writer.h index 0ff011fa1..1e25c3bdf 100644 --- a/src/lib/writer.h +++ b/src/lib/writer.h @@ -128,7 +128,7 @@ private: size_t video_reel (int frame) const; void set_digest_progress (Job* job, float progress); void write_cover_sheet (boost::filesystem::path output_dcp); - void calculate_referenced_digests (boost::function<void (float)> set_progress); + void calculate_referenced_digests (std::function<void (float)> set_progress); void write_hanging_text (ReelWriter& reel); void calculate_digests (); |
