projects
/
dcpomatic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0241df1
)
More c++ tidying.
author
Carl Hetherington
<cth@carlh.net>
Mon, 11 Jan 2021 15:46:13 +0000
(16:46 +0100)
committer
Carl Hetherington
<cth@carlh.net>
Mon, 11 Jan 2021 15:46:13 +0000
(16:46 +0100)
src/lib/dcp_encoder.cc
patch
|
blob
|
history
src/lib/encode_server.cc
patch
|
blob
|
history
src/lib/film.cc
patch
|
blob
|
history
src/lib/film.h
patch
|
blob
|
history
src/lib/j2k_encoder.cc
patch
|
blob
|
history
src/lib/util.cc
patch
|
blob
|
history
src/wx/timecode.cc
patch
|
blob
|
history
src/wx/timeline.cc
patch
|
blob
|
history
diff --git
a/src/lib/dcp_encoder.cc
b/src/lib/dcp_encoder.cc
index 0478fcf809ac94e367667204d72b440ac53ca3d4..4b4785cc6e362021cab8c4ba6c8cada370810c23 100644
(file)
--- a/
src/lib/dcp_encoder.cc
+++ b/
src/lib/dcp_encoder.cc
@@
-49,6
+49,7
@@
using std::vector;
using std::shared_ptr;
using std::weak_ptr;
using std::dynamic_pointer_cast;
using std::shared_ptr;
using std::weak_ptr;
using std::dynamic_pointer_cast;
+using std::make_shared;
using boost::optional;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
using boost::optional;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
@@
-90,26
+91,26
@@
DCPEncoder::~DCPEncoder ()
void
DCPEncoder::go ()
{
void
DCPEncoder::go ()
{
- _writer
.reset (new Writer (_film, _job)
);
+ _writer
= make_shared<Writer>(_film, _job
);
_writer->start ();
_writer->start ();
- _j2k_encoder
.reset (new J2KEncoder (_film, _writer)
);
+ _j2k_encoder
= make_shared<J2KEncoder>(_film, _writer
);
_j2k_encoder->begin ();
{
_j2k_encoder->begin ();
{
-
shared_ptr<Job>
job = _job.lock ();
+
auto
job = _job.lock ();
DCPOMATIC_ASSERT (job);
job->sub (_("Encoding"));
}
if (_non_burnt_subtitles) {
DCPOMATIC_ASSERT (job);
job->sub (_("Encoding"));
}
if (_non_burnt_subtitles) {
-
vector<FontData>
fonts = _player->get_subtitle_fonts ();
+
auto
fonts = _player->get_subtitle_fonts ();
if (fonts.size() > 1 && _film->interop()) {
/* Interop will ignore second and subsequent <LoadFont>s so don't even
write them as they upset some validators.
*/
if (fonts.size() > 1 && _film->interop()) {
/* Interop will ignore second and subsequent <LoadFont>s so don't even
write them as they upset some validators.
*/
-
FontData first = fonts.front
();
+
auto first = fonts.front
();
fonts.clear ();
fonts.push_back (first);
}
fonts.clear ();
fonts.push_back (first);
}
@@
-149,7
+150,7
@@
DCPEncoder::audio (shared_ptr<AudioBuffers> data, DCPTime time)
{
_writer->write (data, time);
{
_writer->write (data, time);
-
shared_ptr<Job>
job = _job.lock ();
+
auto
job = _job.lock ();
DCPOMATIC_ASSERT (job);
job->set_progress (float(time.get()) / _film->length().get());
}
DCPOMATIC_ASSERT (job);
job->set_progress (float(time.get()) / _film->length().get());
}
@@
-174,7
+175,7
@@
optional<float>
DCPEncoder::current_rate () const
{
if (!_j2k_encoder) {
DCPEncoder::current_rate () const
{
if (!_j2k_encoder) {
- return
optional<float>()
;
+ return
{}
;
}
return _j2k_encoder->current_encoding_rate ();
}
return _j2k_encoder->current_encoding_rate ();
diff --git
a/src/lib/encode_server.cc
b/src/lib/encode_server.cc
index 6ec3e701ca18a0bb8f9ac5645cb50f81243600cb..92589c573d31429073efa0d530c005195c36f0e6 100644
(file)
--- a/
src/lib/encode_server.cc
+++ b/
src/lib/encode_server.cc
@@
-60,6
+60,7
@@
using std::cout;
using std::cerr;
using std::fixed;
using std::shared_ptr;
using std::cerr;
using std::fixed;
using std::shared_ptr;
+using std::make_shared;
using boost::thread;
using boost::bind;
using boost::scoped_array;
using boost::thread;
using boost::bind;
using boost::scoped_array;
@@
-123,7
+124,7
@@
EncodeServer::process (shared_ptr<Socket> socket, struct timeval& after_read, st
socket->read (reinterpret_cast<uint8_t*> (buffer.get()), length);
string s (buffer.get());
socket->read (reinterpret_cast<uint8_t*> (buffer.get()), length);
string s (buffer.get());
-
shared_ptr<cxml::Document> xml (new cxml::Document ("EncodingRequest")
);
+
auto xml = make_shared<cxml::Document>("EncodingRequest"
);
xml->read_string (s);
/* This is a double-check; the server shouldn't even be on the candidate list
if it is the wrong version, but it doesn't hurt to make sure here.
xml->read_string (s);
/* This is a double-check; the server shouldn't even be on the candidate list
if it is the wrong version, but it doesn't hurt to make sure here.
@@
-134,7
+135,7
@@
EncodeServer::process (shared_ptr<Socket> socket, struct timeval& after_read, st
return -1;
}
return -1;
}
-
shared_ptr<PlayerVideo> pvf (new PlayerVideo (xml, socket)
);
+
auto pvf = make_shared<PlayerVideo>(xml, socket
);
if (!ds.check()) {
throw NetworkError ("Checksums do not match");
if (!ds.check()) {
throw NetworkError ("Checksums do not match");
@@
-144,7
+145,7
@@
EncodeServer::process (shared_ptr<Socket> socket, struct timeval& after_read, st
gettimeofday (&after_read, 0);
gettimeofday (&after_read, 0);
-
ArrayData
encoded = dcp_video_frame.encode_locally ();
+
auto
encoded = dcp_video_frame.encode_locally ();
gettimeofday (&after_encode, 0);
gettimeofday (&after_encode, 0);
@@
-174,7
+175,7
@@
EncodeServer::worker_thread ()
return;
}
return;
}
-
shared_ptr<Socket>
socket = _queue.front ();
+
auto
socket = _queue.front ();
_queue.pop_front ();
lock.unlock ();
_queue.pop_front ();
lock.unlock ();
@@
-207,13
+208,11
@@
EncodeServer::worker_thread ()
struct timeval end;
gettimeofday (&end, 0);
struct timeval end;
gettimeofday (&end, 0);
- shared_ptr<EncodedLogEntry> e (
- new EncodedLogEntry (
- frame, ip,
- seconds(after_read) - seconds(start),
- seconds(after_encode) - seconds(after_read),
- seconds(end) - seconds(after_encode)
- )
+ auto e = make_shared<EncodedLogEntry>(
+ frame, ip,
+ seconds(after_read) - seconds(start),
+ seconds(after_encode) - seconds(after_read),
+ seconds(end) - seconds(after_encode)
);
if (_verbose) {
);
if (_verbose) {
@@
-256,7
+255,7
@@
void
EncodeServer::broadcast_thread ()
try
{
EncodeServer::broadcast_thread ()
try
{
-
boost::asio::ip::address
address = boost::asio::ip::address_v4::any ();
+
auto
address = boost::asio::ip::address_v4::any ();
boost::asio::ip::udp::endpoint listen_endpoint (address, HELLO_PORT);
_broadcast.socket = new boost::asio::ip::udp::socket (_broadcast.io_service);
boost::asio::ip::udp::endpoint listen_endpoint (address, HELLO_PORT);
_broadcast.socket = new boost::asio::ip::udp::socket (_broadcast.io_service);
@@
-284,17
+283,17
@@
EncodeServer::broadcast_received ()
if (strcmp (_broadcast.buffer, DCPOMATIC_HELLO) == 0) {
/* Reply to the client saying what we can do */
xmlpp::Document doc;
if (strcmp (_broadcast.buffer, DCPOMATIC_HELLO) == 0) {
/* Reply to the client saying what we can do */
xmlpp::Document doc;
-
xmlpp::Element*
root = doc.create_root_node ("ServerAvailable");
+
auto
root = doc.create_root_node ("ServerAvailable");
root->add_child("Threads")->add_child_text (raw_convert<string> (_worker_threads.size ()));
root->add_child("Version")->add_child_text (raw_convert<string> (SERVER_LINK_VERSION));
root->add_child("Threads")->add_child_text (raw_convert<string> (_worker_threads.size ()));
root->add_child("Version")->add_child_text (raw_convert<string> (SERVER_LINK_VERSION));
-
string
xml = doc.write_to_string ("UTF-8");
+
auto
xml = doc.write_to_string ("UTF-8");
if (_verbose) {
cout << "Offering services to master " << _broadcast.send_endpoint.address().to_string () << "\n";
}
try {
if (_verbose) {
cout << "Offering services to master " << _broadcast.send_endpoint.address().to_string () << "\n";
}
try {
-
shared_ptr<Socket> socket (new Socket
);
+
auto socket = make_shared<Socket>(
);
socket->connect (boost::asio::ip::tcp::endpoint (_broadcast.send_endpoint.address(), MAIN_SERVER_PRESENCE_PORT));
socket->write (xml.length() + 1);
socket->write ((uint8_t *) xml.c_str(), xml.length() + 1);
socket->connect (boost::asio::ip::tcp::endpoint (_broadcast.send_endpoint.address(), MAIN_SERVER_PRESENCE_PORT));
socket->write (xml.length() + 1);
socket->write ((uint8_t *) xml.c_str(), xml.length() + 1);
@@
-303,7
+302,7
@@
EncodeServer::broadcast_received ()
}
try {
}
try {
-
shared_ptr<Socket> socket (new Socket
);
+
auto socket = make_shared<Socket>(
);
socket->connect (boost::asio::ip::tcp::endpoint (_broadcast.send_endpoint.address(), BATCH_SERVER_PRESENCE_PORT));
socket->write (xml.length() + 1);
socket->write ((uint8_t *) xml.c_str(), xml.length() + 1);
socket->connect (boost::asio::ip::tcp::endpoint (_broadcast.send_endpoint.address(), BATCH_SERVER_PRESENCE_PORT));
socket->write (xml.length() + 1);
socket->write ((uint8_t *) xml.c_str(), xml.length() + 1);
diff --git
a/src/lib/film.cc
b/src/lib/film.cc
index 8bcbaebe5e044c500f2617940419b55715295815..a0f25d84bbeaffda6b64f2fd6711dec15b66cddc 100644
(file)
--- a/
src/lib/film.cc
+++ b/
src/lib/film.cc
@@
-1,5
+1,5
@@
/*
/*
- Copyright (C) 2012-202
0
Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-202
1
Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
This file is part of DCP-o-matic.
@@
-98,6
+98,7
@@
using std::exception;
using std::find;
using std::shared_ptr;
using std::weak_ptr;
using std::find;
using std::shared_ptr;
using std::weak_ptr;
+using std::make_shared;
using std::dynamic_pointer_cast;
using boost::optional;
using boost::is_any_of;
using std::dynamic_pointer_cast;
using boost::optional;
using boost::is_any_of;
@@
-192,16
+193,16
@@
Film::Film (optional<boost::filesystem::path> dir)
boost::filesystem::path p (boost::filesystem::system_complete (dir.get()));
boost::filesystem::path result;
boost::filesystem::path p (boost::filesystem::system_complete (dir.get()));
boost::filesystem::path result;
- for (
boost::filesystem::path::iterator i = p.begin(); i != p.end(); ++i
) {
- if (
*
i == "..") {
+ for (
auto i: p
) {
+ if (i == "..") {
boost::system::error_code ec;
if (boost::filesystem::is_symlink(result, ec) || result.filename() == "..") {
boost::system::error_code ec;
if (boost::filesystem::is_symlink(result, ec) || result.filename() == "..") {
- result /=
*
i;
+ result /= i;
} else {
result = result.parent_path ();
}
} else {
result = result.parent_path ();
}
- } else if (
*
i != ".") {
- result /=
*
i;
+ } else if (i != ".") {
+ result /= i;
}
}
}
}
@@
-209,9
+210,9
@@
Film::Film (optional<boost::filesystem::path> dir)
}
if (_directory) {
}
if (_directory) {
- _log
.reset (new FileLog (file ("log")
));
+ _log
= make_shared<FileLog>(file("log"
));
} else {
} else {
- _log
.reset (new NullLog
);
+ _log
= make_shared<NullLog>(
);
}
_playlist->set_sequence (_sequence);
}
_playlist->set_sequence (_sequence);
@@
-284,7
+285,7
@@
Film::internal_video_asset_filename (DCPTimePeriod p) const
boost::filesystem::path
Film::audio_analysis_path (shared_ptr<const Playlist> playlist) const
{
boost::filesystem::path
Film::audio_analysis_path (shared_ptr<const Playlist> playlist) const
{
-
boost::filesystem::path
p = dir ("analysis");
+
auto
p = dir ("analysis");
Digester digester;
for (auto i: playlist->content ()) {
Digester digester;
for (auto i: playlist->content ()) {
@@
-319,13
+320,13
@@
Film::audio_analysis_path (shared_ptr<const Playlist> playlist) const
boost::filesystem::path
Film::subtitle_analysis_path (shared_ptr<const Content> content) const
{
boost::filesystem::path
Film::subtitle_analysis_path (shared_ptr<const Content> content) const
{
-
boost::filesystem::path
p = dir ("analysis");
+
auto
p = dir ("analysis");
Digester digester;
digester.add (content->digest());
if (!content->text.empty()) {
Digester digester;
digester.add (content->digest());
if (!content->text.empty()) {
-
shared_ptr<TextContent>
tc = content->text.front();
+
auto
tc = content->text.front();
digester.add (tc->x_scale());
digester.add (tc->y_scale());
for (auto i: tc->fonts()) {
digester.add (tc->x_scale());
digester.add (tc->y_scale());
for (auto i: tc->fonts()) {
@@
-338,7
+339,7
@@
Film::subtitle_analysis_path (shared_ptr<const Content> content) const
digester.add (tc->outline_width());
}
digester.add (tc->outline_width());
}
-
shared_ptr<const FFmpegContent>
fc = dynamic_pointer_cast<const FFmpegContent>(content);
+
auto
fc = dynamic_pointer_cast<const FFmpegContent>(content);
if (fc) {
digester.add (fc->subtitle_stream()->identifier());
}
if (fc) {
digester.add (fc->subtitle_stream()->identifier());
}
@@
-359,7
+360,7
@@
Film::make_dcp (bool gui, bool check)
throw BadSettingError (_("name"), _("Cannot contain slashes"));
}
throw BadSettingError (_("name"), _("Cannot contain slashes"));
}
- if (container() ==
0
) {
+ if (container() ==
nullptr
) {
throw MissingSettingError (_("container"));
}
throw MissingSettingError (_("container"));
}
@@
-371,7
+372,7
@@
Film::make_dcp (bool gui, bool check)
throw runtime_error (_("The DCP is empty, perhaps because all the content has zero length."));
}
throw runtime_error (_("The DCP is empty, perhaps because all the content has zero length."));
}
- if (dcp_content_type() ==
0
) {
+ if (dcp_content_type() ==
nullptr
) {
throw MissingSettingError (_("content type"));
}
throw MissingSettingError (_("content type"));
}
@@
-383,7
+384,7
@@
Film::make_dcp (bool gui, bool check)
if (!i->paths_valid()) {
throw runtime_error (_("some of your content is missing"));
}
if (!i->paths_valid()) {
throw runtime_error (_("some of your content is missing"));
}
-
shared_ptr<const DCPContent> dcp = dynamic_pointer_cast<const DCPContent>
(i);
+
auto dcp = dynamic_pointer_cast<const DCPContent>
(i);
if (dcp && dcp->needs_kdm()) {
throw runtime_error (_("Some of your content needs a KDM"));
}
if (dcp && dcp->needs_kdm()) {
throw runtime_error (_("Some of your content needs a KDM"));
}
@@
-409,10
+410,10
@@
Film::make_dcp (bool gui, bool check)
}
LOG_GENERAL ("J2K bandwidth %1", j2k_bandwidth());
}
LOG_GENERAL ("J2K bandwidth %1", j2k_bandwidth());
-
shared_ptr<TranscodeJob> tj (new TranscodeJob (shared_from_this()
));
- tj->set_encoder (
shared_ptr<Encoder> (new DCPEncoder (shared_from_this(), tj)
));
+
auto tj = make_shared<TranscodeJob>(shared_from_this(
));
+ tj->set_encoder (
make_shared<DCPEncoder>(shared_from_this(), tj
));
if (check) {
if (check) {
-
shared_ptr<CheckContentChangeJob> cc (new CheckContentChangeJob(shared_from_this(), tj, gui)
);
+
auto cc = make_shared<CheckContentChangeJob>(shared_from_this(), tj, gui
);
JobManager::instance()->add (cc);
} else {
JobManager::instance()->add (tj);
JobManager::instance()->add (cc);
} else {
JobManager::instance()->add (tj);
@@
-423,15
+424,14
@@
Film::make_dcp (bool gui, bool check)
void
Film::send_dcp_to_tms ()
{
void
Film::send_dcp_to_tms ()
{
- shared_ptr<Job> j (new UploadJob (shared_from_this()));
- JobManager::instance()->add (j);
+ JobManager::instance()->add(make_shared<UploadJob>(shared_from_this()));
}
shared_ptr<xmlpp::Document>
Film::metadata (bool with_content_paths) const
{
}
shared_ptr<xmlpp::Document>
Film::metadata (bool with_content_paths) const
{
-
shared_ptr<xmlpp::Document> doc (new xmlpp::Document
);
-
xmlpp::Element*
root = doc->create_root_node ("Metadata");
+
auto doc = make_shared<xmlpp::Document>(
);
+
auto
root = doc->create_root_node ("Metadata");
root->add_child("Version")->add_child_text (raw_convert<string> (current_state_version));
root->add_child("Name")->add_child_text (_name);
root->add_child("Version")->add_child_text (raw_convert<string> (current_state_version));
root->add_child("Name")->add_child_text (_name);
@@
-465,7
+465,7
@@
Film::metadata (bool with_content_paths) const
root->add_child("ReencodeJ2K")->add_child_text (_reencode_j2k ? "1" : "0");
root->add_child("UserExplicitVideoFrameRate")->add_child_text(_user_explicit_video_frame_rate ? "1" : "0");
for (map<dcp::Marker, DCPTime>::const_iterator i = _markers.begin(); i != _markers.end(); ++i) {
root->add_child("ReencodeJ2K")->add_child_text (_reencode_j2k ? "1" : "0");
root->add_child("UserExplicitVideoFrameRate")->add_child_text(_user_explicit_video_frame_rate ? "1" : "0");
for (map<dcp::Marker, DCPTime>::const_iterator i = _markers.begin(); i != _markers.end(); ++i) {
-
xmlpp::Element*
m = root->add_child("Marker");
+
auto
m = root->add_child("Marker");
m->set_attribute("Type", dcp::marker_to_string(i->first));
m->add_child_text(raw_convert<string>(i->second.get()));
}
m->set_attribute("Type", dcp::marker_to_string(i->first));
m->add_child_text(raw_convert<string>(i->second.get()));
}
@@
-498,8
+498,7
@@
Film::metadata (bool with_content_paths) const
void
Film::write_metadata (boost::filesystem::path path) const
{
void
Film::write_metadata (boost::filesystem::path path) const
{
- shared_ptr<xmlpp::Document> doc = metadata ();
- doc->write_to_file_formatted (path.string());
+ metadata()->write_to_file_formatted(path.string());
}
/** Write state to our `metadata' file */
}
/** Write state to our `metadata' file */
@@
-508,8
+507,7
@@
Film::write_metadata () const
{
DCPOMATIC_ASSERT (directory());
boost::filesystem::create_directories (directory().get());
{
DCPOMATIC_ASSERT (directory());
boost::filesystem::create_directories (directory().get());
- shared_ptr<xmlpp::Document> doc = metadata ();
- doc->write_to_file_formatted (file(metadata_file).string ());
+ metadata()->write_to_file_formatted(file(metadata_file).string());
_dirty = false;
}
_dirty = false;
}
@@
-519,7
+517,7
@@
Film::write_template (boost::filesystem::path path) const
{
boost::filesystem::create_directories (path.parent_path());
shared_ptr<xmlpp::Document> doc = metadata (false);
{
boost::filesystem::create_directories (path.parent_path());
shared_ptr<xmlpp::Document> doc = metadata (false);
-
doc->write_to_file_formatted (path.string
());
+
metadata(false)->write_to_file_formatted(path.string
());
}
/** Read state from our metadata file.
}
/** Read state from our metadata file.
@@
-548,7
+546,7
@@
Film::read_metadata (optional<boost::filesystem::path> path)
throw runtime_error (_("This film was created with a newer version of DCP-o-matic, and it cannot be loaded into this version. Sorry!"));
} else if (_state_version < current_state_version) {
/* This is an older version; save a copy (if we haven't already) */
throw runtime_error (_("This film was created with a newer version of DCP-o-matic, and it cannot be loaded into this version. Sorry!"));
} else if (_state_version < current_state_version) {
/* This is an older version; save a copy (if we haven't already) */
-
boost::filesystem::path
const older = path->parent_path() / String::compose("metadata.%1.xml", _state_version);
+
auto
const older = path->parent_path() / String::compose("metadata.%1.xml", _state_version);
if (!boost::filesystem::is_regular_file(older)) {
try {
boost::filesystem::copy_file(*path, older);
if (!boost::filesystem::is_regular_file(older)) {
try {
boost::filesystem::copy_file(*path, older);
@@
-571,14
+569,14
@@
Film::read_metadata (optional<boost::filesystem::path> path)
{
{
-
optional<string> c = f.optional_string_child
("DCPContentType");
+
auto c = f.optional_string_child
("DCPContentType");
if (c) {
_dcp_content_type = DCPContentType::from_isdcf_name (c.get ());
}
}
{
if (c) {
_dcp_content_type = DCPContentType::from_isdcf_name (c.get ());
}
}
{
-
optional<string> c = f.optional_string_child
("Container");
+
auto c = f.optional_string_child
("Container");
if (c) {
_container = Ratio::from_id (c.get ());
}
if (c) {
_container = Ratio::from_id (c.get ());
}
@@
-616,7
+614,7
@@
Film::read_metadata (optional<boost::filesystem::path> path)
}
if (_audio_processor && !Config::instance()->show_experimental_audio_processors()) {
}
if (_audio_processor && !Config::instance()->show_experimental_audio_processors()) {
-
list<AudioProcessor const *>
ap = AudioProcessor::visible();
+
auto
ap = AudioProcessor::visible();
if (find(ap.begin(), ap.end(), _audio_processor) == ap.end()) {
Config::instance()->set_show_experimental_audio_processors(true);
}
if (find(ap.begin(), ap.end(), _audio_processor) == ap.end()) {
Config::instance()->set_show_experimental_audio_processors(true);
}
@@
-639,22
+637,22
@@
Film::read_metadata (optional<boost::filesystem::path> path)
_content_versions.push_back (i->content());
}
_content_versions.push_back (i->content());
}
-
optional<string>
name_language = f.optional_string_child("NameLanguage");
+
auto
name_language = f.optional_string_child("NameLanguage");
if (name_language) {
_name_language = dcp::LanguageTag (*name_language);
}
if (name_language) {
_name_language = dcp::LanguageTag (*name_language);
}
-
optional<string>
audio_language = f.optional_string_child("AudioLanguage");
+
auto
audio_language = f.optional_string_child("AudioLanguage");
if (audio_language) {
_audio_language = dcp::LanguageTag (*audio_language);
}
if (audio_language) {
_audio_language = dcp::LanguageTag (*audio_language);
}
-
optional<string>
release_territory = f.optional_string_child("ReleaseTerritory");
+
auto
release_territory = f.optional_string_child("ReleaseTerritory");
if (release_territory) {
_release_territory = dcp::LanguageTag::RegionSubtag (*release_territory);
}
_version_number = f.optional_number_child<int>("VersionNumber").get_value_or(0);
if (release_territory) {
_release_territory = dcp::LanguageTag::RegionSubtag (*release_territory);
}
_version_number = f.optional_number_child<int>("VersionNumber").get_value_or(0);
-
optional<string>
status = f.optional_string_child("Status");
+
auto
status = f.optional_string_child("Status");
if (status) {
_status = dcp::string_to_status (*status);
}
if (status) {
_status = dcp::string_to_status (*status);
}
@@
-663,8
+661,8
@@
Film::read_metadata (optional<boost::filesystem::path> path)
_distributor = f.optional_string_child("Distributor").get_value_or("");
_facility = f.optional_string_child("Facility").get_value_or("");
_distributor = f.optional_string_child("Distributor").get_value_or("");
_facility = f.optional_string_child("Facility").get_value_or("");
-
float
value = f.optional_number_child<float>("LuminanceValue").get_value_or(4.5);
-
optional<string>
unit = f.optional_string_child("LuminanceUnit");
+
auto
value = f.optional_number_child<float>("LuminanceValue").get_value_or(4.5);
+
auto
unit = f.optional_string_child("LuminanceUnit");
if (unit) {
_luminance = dcp::Luminance (value, dcp::Luminance::string_to_unit(*unit));
}
if (unit) {
_luminance = dcp::Luminance (value, dcp::Luminance::string_to_unit(*unit));
}
@@
-693,7
+691,7
@@
Film::read_metadata (optional<boost::filesystem::path> path)
optional<dcp::LanguageTag> found_language;
for (auto i: f.node_child("Playlist")->node_children("Content")) {
optional<dcp::LanguageTag> found_language;
for (auto i: f.node_child("Playlist")->node_children("Content")) {
-
cxml::ConstNodePtr
text = i->optional_node_child("Text");
+
auto
text = i->optional_node_child("Text");
if (text && text->optional_string_child("Language") && !found_language) {
try {
found_language = dcp::LanguageTag(text->string_child("Language"));
if (text && text->optional_string_child("Language") && !found_language) {
try {
found_language = dcp::LanguageTag(text->string_child("Language"));
@@
-702,7
+700,7
@@
Film::read_metadata (optional<boost::filesystem::path> path)
}
if (_state_version >= 9) {
}
if (_state_version >= 9) {
-
optional<string>
isdcf_language = f.node_child("ISDCFMetadata")->optional_string_child("SubtitleLanguage");
+
auto
isdcf_language = f.node_child("ISDCFMetadata")->optional_string_child("SubtitleLanguage");
if (isdcf_language && !found_language) {
try {
found_language = dcp::LanguageTag(*isdcf_language);
if (isdcf_language && !found_language) {
try {
found_language = dcp::LanguageTag(*isdcf_language);
@@
-774,7
+772,7
@@
Film::mapped_audio_channels () const
} else {
for (auto i: content ()) {
if (i->audio) {
} else {
for (auto i: content ()) {
if (i->audio) {
-
list<int>
c = i->audio->mapping().mapped_output_channels ();
+
auto
c = i->audio->mapping().mapped_output_channels ();
copy (c.begin(), c.end(), back_inserter (mapped));
}
}
copy (c.begin(), c.end(), back_inserter (mapped));
}
}
@@
-792,7
+790,7
@@
Film::isdcf_name (bool if_created_now) const
{
string d;
{
string d;
-
string
raw_name = name ();
+
auto
raw_name = name ();
/* Split the raw name up into words */
vector<string> words;
/* Split the raw name up into words */
vector<string> words;
@@
-801,16
+799,16
@@
Film::isdcf_name (bool if_created_now) const
string fixed_name;
/* Add each word to fixed_name */
string fixed_name;
/* Add each word to fixed_name */
- for (
vector<string>::const_iterator i = words.begin(); i != words.end(); ++i
) {
- string w =
*
i;
+ for (
auto i: words
) {
+ string w = i;
/* First letter is always capitalised */
w[0] = toupper (w[0]);
/* Count caps in w */
size_t caps = 0;
/* First letter is always capitalised */
w[0] = toupper (w[0]);
/* Count caps in w */
size_t caps = 0;
- for (size_t
i = 0; i < w.size(); ++i
) {
- if (isupper (w[
i
])) {
+ for (size_t
j = 0; j < w.size(); ++j
) {
+ if (isupper (w[
j
])) {
++caps;
}
}
++caps;
}
}
@@
-819,13
+817,13
@@
Film::isdcf_name (bool if_created_now) const
leave it alone.
*/
if (caps == w.size ()) {
leave it alone.
*/
if (caps == w.size ()) {
- for (size_t
i = 1; i < w.size(); ++i
) {
- w[
i] = tolower (w[i
]);
+ for (size_t
j = 1; j < w.size(); ++j
) {
+ w[
j] = tolower (w[j
]);
}
}
}
}
- for (size_t
i = 0; i < w.size(); ++i
) {
- fixed_name += w[
i
];
+ for (size_t
j = 0; j < w.size(); ++j
) {
+ fixed_name += w[
j
];
}
}
}
}
@@
-840,7
+838,7
@@
Film::isdcf_name (bool if_created_now) const
d += "-" + raw_convert<string>(isdcf_metadata().content_version);
}
d += "-" + raw_convert<string>(isdcf_metadata().content_version);
}
-
ISDCFMetadata
const dm = isdcf_metadata ();
+
auto
const dm = isdcf_metadata ();
if (dm.temp_version) {
d += "-Temp";
if (dm.temp_version) {
d += "-Temp";
@@
-882,7
+880,7
@@
Film::isdcf_name (bool if_created_now) const
/* Interior aspect ratio. The standard says we don't do this for trailers, for some strange reason */
if (dcp_content_type() && dcp_content_type()->libdcp_kind() != dcp::TRAILER) {
/* Interior aspect ratio. The standard says we don't do this for trailers, for some strange reason */
if (dcp_content_type() && dcp_content_type()->libdcp_kind() != dcp::TRAILER) {
- Ratio const
* content_ratio = 0
;
+ Ratio const
* content_ratio = nullptr
;
for (auto i: content ()) {
if (i->video) {
/* Here's the first piece of video content */
for (auto i: content ()) {
if (i->video) {
/* Here's the first piece of video content */
@@
-904,8
+902,8
@@
Film::isdcf_name (bool if_created_now) const
for now I'm just appending -CCAP if we have any closed captions.
*/
for now I'm just appending -CCAP if we have any closed captions.
*/
-
bool
burnt_in = true;
-
bool
ccap = false;
+
auto
burnt_in = true;
+
auto
ccap = false;
for (auto i: content()) {
for (auto j: i->text) {
if (j->type() == TEXT_OPEN_SUBTITLE && j->use() && !j->burn()) {
for (auto i: content()) {
for (auto j: i->text) {
if (j->type() == TEXT_OPEN_SUBTITLE && j->use() && !j->burn()) {
@@
-917,7
+915,7
@@
Film::isdcf_name (bool if_created_now) const
}
if (!_subtitle_languages.empty()) {
}
if (!_subtitle_languages.empty()) {
-
string
lang = _subtitle_languages.front().language().get_value_or("en").subtag();
+
auto
lang = _subtitle_languages.front().language().get_value_or("en").subtag();
if (burnt_in) {
transform (lang.begin(), lang.end(), lang.begin(), ::tolower);
} else {
if (burnt_in) {
transform (lang.begin(), lang.end(), lang.begin(), ::tolower);
} else {
@@
-945,9
+943,9
@@
Film::isdcf_name (bool if_created_now) const
/* Count mapped audio channels */
/* Count mapped audio channels */
-
list<int>
mapped = mapped_audio_channels ();
+
auto
mapped = mapped_audio_channels ();
-
pair<int, int>
ch = audio_channel_types (mapped, audio_channels());
+
auto
ch = audio_channel_types (mapped, audio_channels());
if (!ch.first && !ch.second) {
d += "_MOS";
} else if (ch.first) {
if (!ch.first && !ch.second) {
d += "_MOS";
} else if (ch.first) {
@@
-987,9
+985,9
@@
Film::isdcf_name (bool if_created_now) const
d += "-3D";
}
d += "-3D";
}
-
bool
vf = false;
+
auto
vf = false;
for (auto i: content()) {
for (auto i: content()) {
-
shared_ptr<const DCPContent> dc = dynamic_pointer_cast<const DCPContent>
(i);
+
auto dc = dynamic_pointer_cast<const DCPContent>
(i);
if (!dc) {
continue;
}
if (!dc) {
continue;
}
@@
-1254,15
+1252,15
@@
Film::cpls () const
vector<CPLSummary> out;
vector<CPLSummary> out;
-
boost::filesystem::path
const dir = directory().get();
- for (
boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator(dir); i != boost::filesystem::directory_iterator(); ++i
) {
+
auto
const dir = directory().get();
+ for (
auto i: boost::filesystem::directory_iterator(dir)
) {
if (
if (
- boost::filesystem::is_directory (
*
i) &&
- i
->path().leaf() != "j2c" && i->path().leaf() != "video" && i->path().leaf() != "info" && i->
path().leaf() != "analysis"
+ boost::filesystem::is_directory (i) &&
+ i
.path().leaf() != "j2c" && i.path().leaf() != "video" && i.path().leaf() != "info" && i.
path().leaf() != "analysis"
) {
try {
) {
try {
- out.push_back (CPLSummary(
*
i));
+ out.push_back (CPLSummary(i));
} catch (...) {
}
} catch (...) {
}
@@
-1297,7
+1295,7
@@
Film::examine_and_add_content (shared_ptr<Content> content, bool disable_audio_a
run_ffprobe (content->path(0), file("ffprobe.log"));
}
run_ffprobe (content->path(0), file("ffprobe.log"));
}
-
shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), content)
);
+
auto j = make_shared<ExamineContentJob>(shared_from_this(), content
);
_job_connections.push_back (
j->Finished.connect (bind (&Film::maybe_add_content, this, weak_ptr<Job>(j), weak_ptr<Content>(content), disable_audio_analysis))
_job_connections.push_back (
j->Finished.connect (bind (&Film::maybe_add_content, this, weak_ptr<Job>(j), weak_ptr<Content>(content), disable_audio_analysis))
@@
-1309,12
+1307,12
@@
Film::examine_and_add_content (shared_ptr<Content> content, bool disable_audio_a
void
Film::maybe_add_content (weak_ptr<Job> j, weak_ptr<Content> c, bool disable_audio_analysis)
{
void
Film::maybe_add_content (weak_ptr<Job> j, weak_ptr<Content> c, bool disable_audio_analysis)
{
-
shared_ptr<Job>
job = j.lock ();
+
auto
job = j.lock ();
if (!job || !job->finished_ok ()) {
return;
}
if (!job || !job->finished_ok ()) {
return;
}
-
shared_ptr<Content>
content = c.lock ();
+
auto
content = c.lock ();
if (!content) {
return;
}
if (!content) {
return;
}
@@
-1322,7
+1320,7
@@
Film::maybe_add_content (weak_ptr<Job> j, weak_ptr<Content> c, bool disable_audi
add_content (content);
if (Config::instance()->automatic_audio_analysis() && content->audio && !disable_audio_analysis) {
add_content (content);
if (Config::instance()->automatic_audio_analysis() && content->audio && !disable_audio_analysis) {
-
shared_ptr<Playlist> playlist (new Playlist
);
+
auto playlist = make_shared<Playlist>(
);
playlist->add (shared_from_this(), content);
boost::signals2::connection c;
JobManager::instance()->analyse_audio (
playlist->add (shared_from_this(), content);
boost::signals2::connection c;
JobManager::instance()->analyse_audio (
@@
-1429,7
+1427,7
@@
int
Film::best_video_frame_rate () const
{
/* Don't default to anything above 30fps (make the user select that explicitly) */
Film::best_video_frame_rate () const
{
/* Don't default to anything above 30fps (make the user select that explicitly) */
-
int
best = _playlist->best_video_frame_rate ();
+
auto
best = _playlist->best_video_frame_rate ();
if (best > 30) {
best /= 2;
}
if (best > 30) {
best /= 2;
}
@@
-1505,7
+1503,7
@@
Film::check_settings_consistency ()
bool change_made = false;
for (auto i: content()) {
bool change_made = false;
for (auto i: content()) {
-
shared_ptr<DCPContent>
d = dynamic_pointer_cast<DCPContent>(i);
+
auto
d = dynamic_pointer_cast<DCPContent>(i);
if (!d) {
continue;
}
if (!d) {
continue;
}
@@
-1589,7
+1587,7
@@
Film::frame_size () const
dcp::Size
Film::active_area () const
{
dcp::Size
Film::active_area () const
{
-
dcp::Size
const frame = frame_size ();
+
auto
const frame = frame_size ();
dcp::Size active;
for (auto i: content()) {
dcp::Size active;
for (auto i: content()) {
@@
-1630,8
+1628,8
@@
Film::make_kdm (
throw runtime_error (_("Cannot make a KDM as this project is not encrypted."));
}
throw runtime_error (_("Cannot make a KDM as this project is not encrypted."));
}
-
shared_ptr<const dcp::CPL> cpl (new dcp::CPL (cpl_file)
);
-
shared_ptr<const dcp::CertificateChain> signer = Config::instance()->signer_chain
();
+
auto cpl = make_shared<dcp::CPL>(cpl_file
);
+
auto signer = Config::instance()->signer_chain
();
if (!signer->valid ()) {
throw InvalidSignerError ();
}
if (!signer->valid ()) {
throw InvalidSignerError ();
}
@@
-1639,10
+1637,10
@@
Film::make_kdm (
/* Find keys that have been added to imported, encrypted DCP content */
list<dcp::DecryptedKDMKey> imported_keys;
for (auto i: content()) {
/* Find keys that have been added to imported, encrypted DCP content */
list<dcp::DecryptedKDMKey> imported_keys;
for (auto i: content()) {
-
shared_ptr<DCPContent>
d = dynamic_pointer_cast<DCPContent> (i);
+
auto
d = dynamic_pointer_cast<DCPContent> (i);
if (d && d->kdm()) {
dcp::DecryptedKDM kdm (d->kdm().get(), Config::instance()->decryption_chain()->key().get());
if (d && d->kdm()) {
dcp::DecryptedKDM kdm (d->kdm().get(), Config::instance()->decryption_chain()->key().get());
-
list<dcp::DecryptedKDMKey>
keys = kdm.keys ();
+
auto
keys = kdm.keys ();
copy (keys.begin(), keys.end(), back_inserter (imported_keys));
}
}
copy (keys.begin(), keys.end(), back_inserter (imported_keys));
}
}
@@
-1700,7
+1698,7
@@
Film::should_be_enough_disk_space (double& required, double& available, bool& ca
boost::filesystem::path test = internal_video_asset_dir() / "test";
boost::filesystem::path test2 = internal_video_asset_dir() / "test2";
can_hard_link = true;
boost::filesystem::path test = internal_video_asset_dir() / "test";
boost::filesystem::path test2 = internal_video_asset_dir() / "test2";
can_hard_link = true;
-
FILE*
f = fopen_boost (test, "w");
+
auto
f = fopen_boost (test, "w");
if (f) {
fclose (f);
boost::system::error_code ec;
if (f) {
fclose (f);
boost::system::error_code ec;
@@
-1712,7
+1710,7
@@
Film::should_be_enough_disk_space (double& required, double& available, bool& ca
boost::filesystem::remove (test2);
}
boost::filesystem::remove (test2);
}
-
boost::filesystem::space_inf
o s = boost::filesystem::space (internal_video_asset_dir ());
+
aut
o s = boost::filesystem::space (internal_video_asset_dir ());
required = double (required_disk_space ()) / 1073741824.0f;
if (!can_hard_link) {
required *= 2;
required = double (required_disk_space ()) / 1073741824.0f;
if (!can_hard_link) {
required *= 2;
@@
-1766,7
+1764,7
@@
list<DCPTimePeriod>
Film::reels () const
{
list<DCPTimePeriod> p;
Film::reels () const
{
list<DCPTimePeriod> p;
-
DCPTime
const len = length();
+
auto
const len = length();
switch (reel_type ()) {
case REELTYPE_SINGLE:
switch (reel_type ()) {
case REELTYPE_SINGLE:
@@
-1870,7
+1868,7
@@
bool
Film::references_dcp_video () const
{
for (auto i: _playlist->content()) {
Film::references_dcp_video () const
{
for (auto i: _playlist->content()) {
-
shared_ptr<DCPContent>
d = dynamic_pointer_cast<DCPContent>(i);
+
auto
d = dynamic_pointer_cast<DCPContent>(i);
if (d && d->reference_video()) {
return true;
}
if (d && d->reference_video()) {
return true;
}
@@
-1883,7
+1881,7
@@
bool
Film::references_dcp_audio () const
{
for (auto i: _playlist->content()) {
Film::references_dcp_audio () const
{
for (auto i: _playlist->content()) {
-
shared_ptr<DCPContent>
d = dynamic_pointer_cast<DCPContent>(i);
+
auto
d = dynamic_pointer_cast<DCPContent>(i);
if (d && d->reference_audio()) {
return true;
}
if (d && d->reference_audio()) {
return true;
}
@@
-1913,7
+1911,7
@@
Film::closed_caption_tracks () const
for (auto i: content()) {
for (auto j: i->text) {
/* XXX: Empty DCPTextTrack ends up being a magic value here - the "unknown" or "not specified" track */
for (auto i: content()) {
for (auto j: i->text) {
/* XXX: Empty DCPTextTrack ends up being a magic value here - the "unknown" or "not specified" track */
-
DCPTextTrack
dtt = j->dcp_track().get_value_or(DCPTextTrack());
+
auto
dtt = j->dcp_track().get_value_or(DCPTextTrack());
if (j->type() == TEXT_CLOSED_CAPTION && find(tt.begin(), tt.end(), dtt) == tt.end()) {
tt.push_back (dtt);
}
if (j->type() == TEXT_CLOSED_CAPTION && find(tt.begin(), tt.end(), dtt) == tt.end()) {
tt.push_back (dtt);
}
@@
-2028,9
+2026,7
@@
Film::set_luminance (dcp::Luminance l)
void
Film::set_subtitle_language (dcp::LanguageTag language)
{
void
Film::set_subtitle_language (dcp::LanguageTag language)
{
- vector<dcp::LanguageTag> lang;
- lang.push_back (language);
- set_subtitle_languages (lang);
+ set_subtitle_languages ({language});
}
}
@@
-2061,9
+2057,9
@@
Film::set_facility (string f)
optional<DCPTime>
Film::marker (dcp::Marker type) const
{
optional<DCPTime>
Film::marker (dcp::Marker type) const
{
-
map<dcp::Marker, DCPTime>::const_iterator
i = _markers.find (type);
+
auto
i = _markers.find (type);
if (i == _markers.end()) {
if (i == _markers.end()) {
- return
optional<DCPTime>()
;
+ return
{}
;
}
return i->second;
}
}
return i->second;
}
@@
-2071,7
+2067,7
@@
Film::marker (dcp::Marker type) const
shared_ptr<InfoFileHandle>
Film::info_file_handle (DCPTimePeriod period, bool read) const
{
shared_ptr<InfoFileHandle>
Film::info_file_handle (DCPTimePeriod period, bool read) const
{
- return s
hared_ptr<InfoFileHandle> (new InfoFileHandle(_info_file_mutex, info_file(period), read)
);
+ return s
td::make_shared<InfoFileHandle>(_info_file_mutex, info_file(period), read
);
}
InfoFileHandle::InfoFileHandle (boost::mutex& mutex, boost::filesystem::path file, bool read)
}
InfoFileHandle::InfoFileHandle (boost::mutex& mutex, boost::filesystem::path file, bool read)
@@
-2084,7
+2080,7
@@
InfoFileHandle::InfoFileHandle (boost::mutex& mutex, boost::filesystem::path fil
throw OpenFileError (file, errno, OpenFileError::READ);
}
} else {
throw OpenFileError (file, errno, OpenFileError::READ);
}
} else {
-
bool
const exists = boost::filesystem::exists (file);
+
auto
const exists = boost::filesystem::exists (file);
if (exists) {
_handle = fopen_boost (file, "r+b");
} else {
if (exists) {
_handle = fopen_boost (file, "r+b");
} else {
diff --git
a/src/lib/film.h
b/src/lib/film.h
index d794486897d9c8029493b6452912ecf2bc387d01..6828df21aa366cad9e7506cedad0b5925a9d2dff 100644
(file)
--- a/
src/lib/film.h
+++ b/
src/lib/film.h
@@
-67,6
+67,7
@@
struct atmos_encrypted_passthrough_test;
class InfoFileHandle
{
public:
class InfoFileHandle
{
public:
+ InfoFileHandle (boost::mutex& mutex, boost::filesystem::path file, bool read);
~InfoFileHandle ();
FILE* get () const {
~InfoFileHandle ();
FILE* get () const {
@@
-80,8
+81,6
@@
public:
private:
friend class Film;
private:
friend class Film;
- InfoFileHandle (boost::mutex& mutex, boost::filesystem::path file, bool read);
-
boost::mutex::scoped_lock _lock;
FILE* _handle;
boost::filesystem::path _file;
boost::mutex::scoped_lock _lock;
FILE* _handle;
boost::filesystem::path _file;
diff --git
a/src/lib/j2k_encoder.cc
b/src/lib/j2k_encoder.cc
index acd27932e226c87ed8a4572fbfa65b999b1f31ec..7c6e2347733f361c7054f3bd862b7bf1e2d19357 100644
(file)
--- a/
src/lib/j2k_encoder.cc
+++ b/
src/lib/j2k_encoder.cc
@@
-46,6
+46,7
@@
using std::cout;
using std::exception;
using std::shared_ptr;
using std::weak_ptr;
using std::exception;
using std::shared_ptr;
using std::weak_ptr;
+using std::make_shared;
using boost::optional;
using dcp::Data;
using namespace dcpomatic;
using boost::optional;
using dcp::Data;
using namespace dcpomatic;
@@
-83,7
+84,7
@@
J2KEncoder::begin ()
void
J2KEncoder::call_servers_list_changed (weak_ptr<J2KEncoder> encoder)
{
void
J2KEncoder::call_servers_list_changed (weak_ptr<J2KEncoder> encoder)
{
-
shared_ptr<J2KEncoder>
e = encoder.lock ();
+
auto
e = encoder.lock ();
if (e) {
e->servers_list_changed ();
}
if (e) {
e->servers_list_changed ();
}
@@
-126,13
+127,13
@@
J2KEncoder::end ()
So just mop up anything left in the queue here.
*/
So just mop up anything left in the queue here.
*/
- for (
list<shared_ptr<DCPVideo> >::iterator i = _queue.begin(); i != _queue.end(); ++i
) {
- LOG_GENERAL
(N_("Encode left-over frame %1"), (*i)->index
());
+ for (
auto i: _queue
) {
+ LOG_GENERAL
(N_("Encode left-over frame %1"), i->index
());
try {
_writer->write (
try {
_writer->write (
-
shared_ptr<dcp::Data>(new dcp::ArrayData((*i)->encode_locally()
)),
-
(*i)
->index(),
-
(*i)
->eyes()
+
make_shared<dcp::ArrayData>(i->encode_locally(
)),
+
i
->index(),
+
i
->eyes()
);
frame_done ();
} catch (std::exception& e) {
);
frame_done ();
} catch (std::exception& e) {
@@
-205,7
+206,7
@@
J2KEncoder::encode (shared_ptr<PlayerVideo> pv, DCPTime time)
*/
rethrow ();
*/
rethrow ();
-
Frame
const position = time.frames_floor(_film->video_frame_rate());
+
auto
const position = time.frames_floor(_film->video_frame_rate());
if (_writer->can_fake_write (position)) {
/* We can fake-write this frame */
if (_writer->can_fake_write (position)) {
/* We can fake-write this frame */
@@
-224,15
+225,13
@@
J2KEncoder::encode (shared_ptr<PlayerVideo> pv, DCPTime time)
LOG_DEBUG_ENCODE("Frame @ %1 ENCODE", to_string(time));
/* Queue this new frame for encoding */
LOG_TIMING ("add-frame-to-queue queue=%1", _queue.size ());
LOG_DEBUG_ENCODE("Frame @ %1 ENCODE", to_string(time));
/* Queue this new frame for encoding */
LOG_TIMING ("add-frame-to-queue queue=%1", _queue.size ());
- _queue.push_back (shared_ptr<DCPVideo> (
- new DCPVideo (
- pv,
- position,
- _film->video_frame_rate(),
- _film->j2k_bandwidth(),
- _film->resolution()
- )
- ));
+ _queue.push_back (make_shared<DCPVideo>(
+ pv,
+ position,
+ _film->video_frame_rate(),
+ _film->j2k_bandwidth(),
+ _film->resolution()
+ ));
/* The queue might not be empty any more, so notify anything which is
waiting on that.
/* The queue might not be empty any more, so notify anything which is
waiting on that.
@@
-292,7
+291,7
@@
try
}
LOG_TIMING ("encoder-wake thread=%1 queue=%2", thread_id(), _queue.size());
}
LOG_TIMING ("encoder-wake thread=%1 queue=%2", thread_id(), _queue.size());
-
shared_ptr<DCPVideo>
vf = _queue.front ();
+
auto
vf = _queue.front ();
/* We're about to commit to either encoding this frame or putting it back onto the queue,
so we must not be interrupted until one or other of these things have happened. This
/* We're about to commit to either encoding this frame or putting it back onto the queue,
so we must not be interrupted until one or other of these things have happened. This
@@
-311,7
+310,7
@@
try
/* We need to encode this input */
if (server) {
try {
/* We need to encode this input */
if (server) {
try {
- encoded
.reset(new dcp::ArrayData(vf->encode_remotely(server.get()
)));
+ encoded
= make_shared<dcp::ArrayData>(vf->encode_remotely(server.get(
)));
if (remote_backoff > 0) {
LOG_GENERAL ("%1 was lost, but now she is found; removing backoff", server->host_name ());
if (remote_backoff > 0) {
LOG_GENERAL ("%1 was lost, but now she is found; removing backoff", server->host_name ());
@@
-334,7
+333,7
@@
try
} else {
try {
LOG_TIMING ("start-local-encode thread=%1 frame=%2", thread_id(), vf->index());
} else {
try {
LOG_TIMING ("start-local-encode thread=%1 frame=%2", thread_id(), vf->index());
- encoded
.reset(new dcp::ArrayData(vf->encode_locally()
));
+ encoded
= make_shared<dcp::ArrayData>(vf->encode_locally(
));
LOG_TIMING ("finish-local-encode thread=%1 frame=%2", thread_id(), vf->index());
} catch (std::exception& e) {
/* This is very bad, so don't cope with it, just pass it on */
LOG_TIMING ("finish-local-encode thread=%1 frame=%2", thread_id(), vf->index());
} catch (std::exception& e) {
/* This is very bad, so don't cope with it, just pass it on */
@@
-380,14
+379,14
@@
J2KEncoder::servers_list_changed ()
boost::mutex::scoped_lock lm (_threads_mutex);
terminate_threads ();
boost::mutex::scoped_lock lm (_threads_mutex);
terminate_threads ();
- _threads
.reset (new boost::thread_group()
);
+ _threads
= make_shared<boost::thread_group>(
);
/* XXX: could re-use threads */
if (!Config::instance()->only_servers_encode ()) {
for (int i = 0; i < Config::instance()->master_encoding_threads (); ++i) {
#ifdef DCPOMATIC_LINUX
/* XXX: could re-use threads */
if (!Config::instance()->only_servers_encode ()) {
for (int i = 0; i < Config::instance()->master_encoding_threads (); ++i) {
#ifdef DCPOMATIC_LINUX
-
boost::thread*
t = _threads->create_thread(boost::bind(&J2KEncoder::encoder_thread, this, optional<EncodeServerDescription>()));
+
auto
t = _threads->create_thread(boost::bind(&J2KEncoder::encoder_thread, this, optional<EncodeServerDescription>()));
pthread_setname_np (t->native_handle(), "encode-worker");
#else
_threads->create_thread(boost::bind(&J2KEncoder::encoder_thread, this, optional<EncodeServerDescription>()));
pthread_setname_np (t->native_handle(), "encode-worker");
#else
_threads->create_thread(boost::bind(&J2KEncoder::encoder_thread, this, optional<EncodeServerDescription>()));
diff --git
a/src/lib/util.cc
b/src/lib/util.cc
index c7b3281dac4284dc00df042962b2e257b0b36b90..0aa7e7a28c3919b756eca61a839cbaea3a66d8f2 100644
(file)
--- a/
src/lib/util.cc
+++ b/
src/lib/util.cc
@@
-1,5
+1,5
@@
/*
/*
- Copyright (C) 2012-202
0
Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-202
1
Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
This file is part of DCP-o-matic.
@@
-104,6
+104,7
@@
using std::bad_alloc;
using std::set_terminate;
using std::make_pair;
using std::shared_ptr;
using std::set_terminate;
using std::make_pair;
using std::shared_ptr;
+using std::make_shared;
using boost::thread;
using boost::optional;
using boost::lexical_cast;
using boost::thread;
using boost::optional;
using boost::lexical_cast;
@@
-241,7
+242,7
@@
DCPOMATIC_DISABLE_WARNINGS
LONG WINAPI
exception_handler(struct _EXCEPTION_POINTERS * info)
{
LONG WINAPI
exception_handler(struct _EXCEPTION_POINTERS * info)
{
-
FILE*
f = fopen_boost (backtrace_file, "w");
+
auto
f = fopen_boost (backtrace_file, "w");
fprintf (f, "C-style exception %d\n", info->ExceptionRecord->ExceptionCode);
fclose(f);
fprintf (f, "C-style exception %d\n", info->ExceptionRecord->ExceptionCode);
fclose(f);
@@
-370,7
+371,7
@@
DCPOMATIC_ENABLE_WARNINGS
/* Add our library directory to the libltdl search path so that
xmlsec can find xmlsec1-openssl.
*/
/* Add our library directory to the libltdl search path so that
xmlsec can find xmlsec1-openssl.
*/
-
boost::filesystem::path
lib = directory_containing_executable().parent_path();
+
auto
lib = directory_containing_executable().parent_path();
lib /= "Frameworks";
setenv ("LTDL_LIBRARY_PATH", lib.c_str (), 1);
#endif
lib /= "Frameworks";
setenv ("LTDL_LIBRARY_PATH", lib.c_str (), 1);
#endif
@@
-398,7
+399,7
@@
DCPOMATIC_ENABLE_WARNINGS
"Hello dolly", dcp::NONE, dcp::Colour(), dcp::Time(), dcp::Time()
);
subs.push_back (StringText(ss, 0));
"Hello dolly", dcp::NONE, dcp::Colour(), dcp::Time(), dcp::Time()
);
subs.push_back (StringText(ss, 0));
- render_text (subs, list<shared_ptr<Font>
>(), dcp::Size(640, 480), DCPTime(), 24);
+ render_text (subs, list<shared_ptr<Font>>(), dcp::Size(640, 480), DCPTime(), 24);
#endif
Ratio::setup_ratios ();
#endif
Ratio::setup_ratios ();
@@
-479,7
+480,7
@@
digest_head_tail (vector<boost::filesystem::path> files, boost::uintmax_t size)
char* p = buffer.get ();
int i = 0;
while (i < int64_t (files.size()) && to_do > 0) {
char* p = buffer.get ();
int i = 0;
while (i < int64_t (files.size()) && to_do > 0) {
-
FILE*
f = fopen_boost (files[i], "rb");
+
auto
f = fopen_boost (files[i], "rb");
if (!f) {
throw OpenFileError (files[i].string(), errno, OpenFileError::READ);
}
if (!f) {
throw OpenFileError (files[i].string(), errno, OpenFileError::READ);
}
@@
-499,7
+500,7
@@
digest_head_tail (vector<boost::filesystem::path> files, boost::uintmax_t size)
p = buffer.get ();
i = files.size() - 1;
while (i >= 0 && to_do > 0) {
p = buffer.get ();
i = files.size() - 1;
while (i >= 0 && to_do > 0) {
-
FILE*
f = fopen_boost (files[i], "rb");
+
auto
f = fopen_boost (files[i], "rb");
if (!f) {
throw OpenFileError (files[i].string(), errno, OpenFileError::READ);
}
if (!f) {
throw OpenFileError (files[i].string(), errno, OpenFileError::READ);
}
@@
-606,7
+607,7
@@
valid_image_file (boost::filesystem::path f)
return false;
}
return false;
}
-
string
ext = f.extension().string();
+
auto
ext = f.extension().string();
transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
return (
ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" ||
transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
return (
ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" ||
@@
-623,7
+624,7
@@
valid_sound_file (boost::filesystem::path f)
return false;
}
return false;
}
-
string
ext = f.extension().string();
+
auto
ext = f.extension().string();
transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
return (ext == ".wav" || ext == ".mp3" || ext == ".aif" || ext == ".aiff");
}
transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
return (ext == ".wav" || ext == ".mp3" || ext == ".aif" || ext == ".aiff");
}
@@
-631,7
+632,7
@@
valid_sound_file (boost::filesystem::path f)
bool
valid_j2k_file (boost::filesystem::path f)
{
bool
valid_j2k_file (boost::filesystem::path f)
{
-
string
ext = f.extension().string();
+
auto
ext = f.extension().string();
transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
return (ext == ".j2k" || ext == ".j2c" || ext == ".jp2");
}
transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
return (ext == ".j2k" || ext == ".j2c" || ext == ".jp2");
}
@@
-656,7
+657,7
@@
fit_ratio_within (float ratio, dcp::Size full_frame)
void *
wrapped_av_malloc (size_t s)
{
void *
wrapped_av_malloc (size_t s)
{
-
void*
p = av_malloc (s);
+
auto
p = av_malloc (s);
if (!p) {
throw bad_alloc ();
}
if (!p) {
throw bad_alloc ();
}
@@
-845,7
+846,7
@@
audio_channel_types (list<int> mapped, int channels)
shared_ptr<AudioBuffers>
remap (shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping map)
{
shared_ptr<AudioBuffers>
remap (shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping map)
{
-
shared_ptr<AudioBuffers> mapped (new AudioBuffers (output_channels, input->frames()
));
+
auto mapped = make_shared<AudioBuffers>(output_channels, input->frames(
));
mapped->make_silent ();
int to_do = min (map.input_channels(), input->channels());
mapped->make_silent ();
int to_do = min (map.input_channels(), input->channels());
@@
-954,7
+955,7
@@
emit_subtitle_image (ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size
{
/* XXX: this is rather inefficient; decoding the image just to get its size */
FFmpegImageProxy proxy (sub.png_image(), VIDEO_RANGE_FULL);
{
/* XXX: this is rather inefficient; decoding the image just to get its size */
FFmpegImageProxy proxy (sub.png_image(), VIDEO_RANGE_FULL);
-
shared_ptr<Image>
image = proxy.image().image;
+
auto
image = proxy.image().image;
/* set up rect with height and width */
dcpomatic::Rect<double> rect(0, 0, image->size().width / double(size.width), image->size().height / double(size.height));
/* set up rect with height and width */
dcpomatic::Rect<double> rect(0, 0, image->size().width / double(size.width), image->size().height / double(size.height));
@@
-996,7
+997,7
@@
show_jobs_on_console (bool progress)
dcpomatic_sleep_seconds (5);
dcpomatic_sleep_seconds (5);
-
list<shared_ptr<Job> >
jobs = JobManager::instance()->get();
+
auto
jobs = JobManager::instance()->get();
if (!first && progress) {
for (size_t i = 0; i < jobs.size(); ++i) {
if (!first && progress) {
for (size_t i = 0; i < jobs.size(); ++i) {
@@
-1046,11
+1047,11
@@
show_jobs_on_console (bool progress)
void
copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, boost::function<void (float)> progress)
{
void
copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, boost::function<void (float)> progress)
{
-
FILE*
f = fopen_boost (from, "rb");
+
auto
f = fopen_boost (from, "rb");
if (!f) {
throw OpenFileError (from, errno, OpenFileError::READ);
}
if (!f) {
throw OpenFileError (from, errno, OpenFileError::READ);
}
-
FILE*
t = fopen_boost (to, "wb");
+
auto
t = fopen_boost (to, "wb");
if (!t) {
fclose (f);
throw OpenFileError (to, errno, OpenFileError::WRITE);
if (!t) {
fclose (f);
throw OpenFileError (to, errno, OpenFileError::WRITE);
@@
-1059,7
+1060,7
@@
copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, boost::f
/* on the order of a second's worth of copying */
boost::uintmax_t const chunk = 20 * 1024 * 1024;
/* on the order of a second's worth of copying */
boost::uintmax_t const chunk = 20 * 1024 * 1024;
-
uint8_t*
buffer = static_cast<uint8_t*> (malloc(chunk));
+
auto
buffer = static_cast<uint8_t*> (malloc(chunk));
if (!buffer) {
throw std::bad_alloc ();
}
if (!buffer) {
throw std::bad_alloc ();
}
@@
-1132,9
+1133,9
@@
decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm)
return dcp::DecryptedKDM (kdm, Config::instance()->decryption_chain()->key().get());
} catch (dcp::KDMDecryptionError& e) {
/* Try to flesh out the error a bit */
return dcp::DecryptedKDM (kdm, Config::instance()->decryption_chain()->key().get());
} catch (dcp::KDMDecryptionError& e) {
/* Try to flesh out the error a bit */
-
string
const kdm_subject_name = kdm.recipient_x509_subject_name();
+
auto
const kdm_subject_name = kdm.recipient_x509_subject_name();
bool on_chain = false;
bool on_chain = false;
-
shared_ptr<const dcp::CertificateChain>
dc = Config::instance()->decryption_chain();
+
auto
dc = Config::instance()->decryption_chain();
for (auto i: dc->root_to_leaf()) {
if (i.subject() == kdm_subject_name) {
on_chain = true;
for (auto i: dc->root_to_leaf()) {
if (i.subject() == kdm_subject_name) {
on_chain = true;
diff --git
a/src/wx/timecode.cc
b/src/wx/timecode.cc
index 0602358a9788083ac2b7fcfa58b160bb2b379037..c4755e5745063c9a8fb007aa5a39266777bef642 100644
(file)
--- a/
src/wx/timecode.cc
+++ b/
src/wx/timecode.cc
@@
-31,7
+31,7
@@
TimecodeBase::TimecodeBase (wxWindow* parent, bool set_button)
: wxPanel (parent)
, _set_button (0)
{
: wxPanel (parent)
, _set_button (0)
{
-
wxSize
const s = TimecodeBase::size (parent);
+
auto
const s = TimecodeBase::size (parent);
wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST);
wxArrayString list;
wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST);
wxArrayString list;
@@
-46,7
+46,7
@@
TimecodeBase::TimecodeBase (wxWindow* parent, bool set_button)
_sizer = new wxBoxSizer (wxHORIZONTAL);
_editable = new wxPanel (this);
_sizer = new wxBoxSizer (wxHORIZONTAL);
_editable = new wxPanel (this);
-
wxSizer*
editable_sizer = new wxBoxSizer (wxHORIZONTAL);
+
auto
editable_sizer = new wxBoxSizer (wxHORIZONTAL);
_hours = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator);
_hours->SetMaxLength (2);
editable_sizer->Add (_hours);
_hours = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator);
_hours->SetMaxLength (2);
editable_sizer->Add (_hours);
@@
-131,7
+131,7
@@
wxSize
TimecodeBase::size (wxWindow* parent)
{
wxClientDC dc (parent);
TimecodeBase::size (wxWindow* parent)
{
wxClientDC dc (parent);
-
wxSize size = dc.GetTextExtent (wxT
("9999"));
+
auto size = dc.GetTextExtent(wxT
("9999"));
size.SetHeight (-1);
return size;
}
size.SetHeight (-1);
return size;
}
diff --git
a/src/wx/timeline.cc
b/src/wx/timeline.cc
index e5182a0a4018139076f4e01b3e3e6fcea5209d93..3294676fc2f8daaf8d5e0b9ce0704f326b1917c0 100644
(file)
--- a/
src/wx/timeline.cc
+++ b/
src/wx/timeline.cc
@@
-1,5
+1,5
@@
/*
/*
- Copyright (C) 2013-20
18
Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-20
21
Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
This file is part of DCP-o-matic.
@@
-51,6
+51,7
@@
using std::abs;
using std::shared_ptr;
using std::weak_ptr;
using std::dynamic_pointer_cast;
using std::shared_ptr;
using std::weak_ptr;
using std::dynamic_pointer_cast;
+using std::make_shared;
using boost::bind;
using boost::optional;
using namespace dcpomatic;
using boost::bind;
using boost::optional;
using namespace dcpomatic;
@@
-90,7
+91,7
@@
Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr<Film> film, w
_main_canvas->SetDoubleBuffered (true);
#endif
_main_canvas->SetDoubleBuffered (true);
#endif
-
wxSizer*
sizer = new wxBoxSizer (wxHORIZONTAL);
+
auto
sizer = new wxBoxSizer (wxHORIZONTAL);
sizer->Add (_labels_canvas, 0, wxEXPAND);
_labels_canvas->SetMinSize (wxSize (_labels_view->bbox().width, -1));
sizer->Add (_main_canvas, 1, wxEXPAND);
sizer->Add (_labels_canvas, 0, wxEXPAND);
_labels_canvas->SetMinSize (wxSize (_labels_view->bbox().width, -1));
sizer->Add (_main_canvas, 1, wxEXPAND);
@@
-142,7
+143,7
@@
Timeline::paint_labels ()
{
wxPaintDC dc (_labels_canvas);
{
wxPaintDC dc (_labels_canvas);
-
wxGraphicsContext*
gc = wxGraphicsContext::Create (dc);
+
auto
gc = wxGraphicsContext::Create (dc);
if (!gc) {
return;
}
if (!gc) {
return;
}
@@
-162,7
+163,7
@@
Timeline::paint_main ()
wxPaintDC dc (_main_canvas);
_main_canvas->DoPrepareDC (dc);
wxPaintDC dc (_main_canvas);
_main_canvas->DoPrepareDC (dc);
-
wxGraphicsContext*
gc = wxGraphicsContext::Create (dc);
+
auto
gc = wxGraphicsContext::Create (dc);
if (!gc) {
return;
}
if (!gc) {
return;
}
@@
-175,18
+176,18
@@
Timeline::paint_main ()
for (auto i: _views) {
for (auto i: _views) {
-
shared_ptr<TimelineContentView>
ic = dynamic_pointer_cast<TimelineContentView> (i);
+
auto
ic = dynamic_pointer_cast<TimelineContentView> (i);
/* Find areas of overlap with other content views, so that we can plot them */
/* Find areas of overlap with other content views, so that we can plot them */
- list<dcpomatic::Rect<int>
> overlaps;
+ list<dcpomatic::Rect<int>> overlaps;
for (auto j: _views) {
for (auto j: _views) {
-
shared_ptr<TimelineContentView>
jc = dynamic_pointer_cast<TimelineContentView> (j);
+
auto
jc = dynamic_pointer_cast<TimelineContentView> (j);
/* No overlap with non-content views, views no different tracks, audio views or non-active views */
if (!ic || !jc || i == j || ic->track() != jc->track() || ic->track().get_value_or(2) >= 2 || !ic->active() || !jc->active()) {
continue;
}
/* No overlap with non-content views, views no different tracks, audio views or non-active views */
if (!ic || !jc || i == j || ic->track() != jc->track() || ic->track().get_value_or(2) >= 2 || !ic->active() || !jc->active()) {
continue;
}
-
optional<dcpomatic::Rect<int> > r = j->bbox().intersection
(i->bbox());
+
auto r = j->bbox().intersection
(i->bbox());
if (r) {
overlaps.push_back (r.get ());
}
if (r) {
overlaps.push_back (r.get ());
}
@@
-210,11
+211,11
@@
Timeline::paint_main ()
/* Playhead */
/* Playhead */
-
shared_ptr<FilmViewer>
vp = _viewer.lock ();
+
auto
vp = _viewer.lock ();
DCPOMATIC_ASSERT (vp);
gc->SetPen (*wxRED_PEN);
DCPOMATIC_ASSERT (vp);
gc->SetPen (*wxRED_PEN);
-
wxGraphicsPath
path = gc->CreatePath ();
+
auto
path = gc->CreatePath ();
double const ph = vp->position().seconds() * pixels_per_second().get_value_or(0);
path.MoveToPoint (ph, 0);
path.AddLineToPoint (ph, pixels_per_track() * _tracks + 32);
double const ph = vp->position().seconds() * pixels_per_second().get_value_or(0);
path.MoveToPoint (ph, 0);
path.AddLineToPoint (ph, pixels_per_track() * _tracks + 32);
@@
-241,7
+242,7
@@
Timeline::film_change (ChangeType type, Film::Property p)
void
Timeline::recreate_views ()
{
void
Timeline::recreate_views ()
{
-
shared_ptr<const Film>
film = _film.lock ();
+
auto
film = _film.lock ();
if (!film) {
return;
}
if (!film) {
return;
}
@@
-252,19
+253,19
@@
Timeline::recreate_views ()
for (auto i: film->content ()) {
if (i->video) {
for (auto i: film->content ()) {
if (i->video) {
- _views.push_back (
shared_ptr<TimelineView> (new TimelineVideoContentView (*this, i)
));
+ _views.push_back (
make_shared<TimelineVideoContentView>(*this, i
));
}
if (i->audio && !i->audio->mapping().mapped_output_channels().empty ()) {
}
if (i->audio && !i->audio->mapping().mapped_output_channels().empty ()) {
- _views.push_back (
shared_ptr<TimelineView> (new TimelineAudioContentView (*this, i)
));
+ _views.push_back (
make_shared<TimelineAudioContentView>(*this, i
));
}
for (auto j: i->text) {
}
for (auto j: i->text) {
- _views.push_back (
shared_ptr<TimelineView> (new TimelineTextContentView (*this, i, j)
));
+ _views.push_back (
make_shared<TimelineTextContentView>(*this, i, j
));
}
if (i->atmos) {
}
if (i->atmos) {
- _views.push_back (
shared_ptr<TimelineView>(new TimelineAtmosContentView(*this, i)
));
+ _views.push_back (
make_shared<TimelineAtmosContentView>(*this, i
));
}
}
}
}
@@
-303,23
+304,23
@@
place (shared_ptr<const Film> film, TimelineViewList& views, int& tracks)
continue;
}
continue;
}
-
shared_ptr<TimelineContentView>
cv = dynamic_pointer_cast<TimelineContentView> (i);
+
auto
cv = dynamic_pointer_cast<TimelineContentView> (i);
int t = base;
int t = base;
-
shared_ptr<Content>
content = cv->content();
+
auto
content = cv->content();
DCPTimePeriod const content_period (content->position(), content->end(film));
while (true) {
DCPTimePeriod const content_period (content->position(), content->end(film));
while (true) {
-
TimelineViewList::iterator
j = views.begin();
+
auto
j = views.begin();
while (j != views.end()) {
while (j != views.end()) {
-
shared_ptr<T>
test = dynamic_pointer_cast<T> (*j);
+
auto
test = dynamic_pointer_cast<T> (*j);
if (!test) {
++j;
continue;
}
if (!test) {
++j;
continue;
}
-
shared_ptr<Content>
test_content = test->content();
+
auto
test_content = test->content();
if (
test->track() && test->track().get() == t &&
content_period.overlap(DCPTimePeriod(test_content->position(), test_content->end(film)))) {
if (
test->track() && test->track().get() == t &&
content_period.overlap(DCPTimePeriod(test_content->position(), test_content->end(film)))) {
@@
-350,15
+351,15
@@
place (shared_ptr<const Film> film, TimelineViewList& views, int& tracks)
struct AudioMappingComparator {
bool operator()(shared_ptr<TimelineView> a, shared_ptr<TimelineView> b) {
int la = -1;
struct AudioMappingComparator {
bool operator()(shared_ptr<TimelineView> a, shared_ptr<TimelineView> b) {
int la = -1;
-
shared_ptr<TimelineAudioContentView>
cva = dynamic_pointer_cast<TimelineAudioContentView>(a);
+
auto
cva = dynamic_pointer_cast<TimelineAudioContentView>(a);
if (cva) {
if (cva) {
-
list<int>
oc = cva->content()->audio->mapping().mapped_output_channels();
+
auto
oc = cva->content()->audio->mapping().mapped_output_channels();
la = *min_element(boost::begin(oc), boost::end(oc));
}
int lb = -1;
la = *min_element(boost::begin(oc), boost::end(oc));
}
int lb = -1;
-
shared_ptr<TimelineAudioContentView>
cvb = dynamic_pointer_cast<TimelineAudioContentView>(b);
+
auto
cvb = dynamic_pointer_cast<TimelineAudioContentView>(b);
if (cvb) {
if (cvb) {
-
list<int>
oc = cvb->content()->audio->mapping().mapped_output_channels();
+
auto
oc = cvb->content()->audio->mapping().mapped_output_channels();
lb = *min_element(boost::begin(oc), boost::end(oc));
}
return la < lb;
lb = *min_element(boost::begin(oc), boost::end(oc));
}
return la < lb;
@@
-380,13
+381,13
@@
Timeline::assign_tracks ()
Audio N
*/
Audio N
*/
-
shared_ptr<const Film>
film = _film.lock ();
+
auto
film = _film.lock ();
DCPOMATIC_ASSERT (film);
_tracks = 0;
DCPOMATIC_ASSERT (film);
_tracks = 0;
- for (
TimelineViewList::iterator i = _views.begin(); i != _views.end(); ++i
) {
-
shared_ptr<TimelineContentView> c = dynamic_pointer_cast<TimelineContentView> (*
i);
+ for (
auto i: _views
) {
+
auto c = dynamic_pointer_cast<TimelineContentView>(
i);
if (c) {
c->unset_track ();
}
if (c) {
c->unset_track ();
}
@@
-396,7
+397,7
@@
Timeline::assign_tracks ()
bool have_3d = false;
for (auto i: _views) {
bool have_3d = false;
for (auto i: _views) {
-
shared_ptr<TimelineVideoContentView> cv = dynamic_pointer_cast<TimelineVideoContentView>
(i);
+
auto cv = dynamic_pointer_cast<TimelineVideoContentView>
(i);
if (!cv) {
continue;
}
if (!cv) {
continue;
}
@@
-421,7
+422,7
@@
Timeline::assign_tracks ()
bool have_atmos = false;
for (auto i: _views) {
bool have_atmos = false;
for (auto i: _views) {
-
shared_ptr<TimelineAtmosContentView>
cv = dynamic_pointer_cast<TimelineAtmosContentView>(i);
+
auto
cv = dynamic_pointer_cast<TimelineAtmosContentView>(i);
if (cv) {
cv->set_track (_tracks);
have_atmos = true;
if (cv) {
cv->set_track (_tracks);
have_atmos = true;
@@
-436,7
+437,7
@@
Timeline::assign_tracks ()
DCP channel index.
*/
DCP channel index.
*/
-
TimelineViewList
views = _views;
+
auto
views = _views;
sort(views.begin(), views.end(), AudioMappingComparator());
int const audio_tracks = place<TimelineAudioContentView> (film, views, _tracks);
sort(views.begin(), views.end(), AudioMappingComparator());
int const audio_tracks = place<TimelineAudioContentView> (film, views, _tracks);
@@
-458,7
+459,7
@@
Timeline::tracks () const
void
Timeline::setup_scrollbars ()
{
void
Timeline::setup_scrollbars ()
{
-
shared_ptr<const Film>
film = _film.lock ();
+
auto
film = _film.lock ();
if (!film || !_pixels_per_second) {
return;
}
if (!film || !_pixels_per_second) {
return;
}
@@
-475,19
+476,19
@@
shared_ptr<TimelineView>
Timeline::event_to_view (wxMouseEvent& ev)
{
/* Search backwards through views so that we find the uppermost one first */
Timeline::event_to_view (wxMouseEvent& ev)
{
/* Search backwards through views so that we find the uppermost one first */
-
TimelineViewList::reverse_iterator
i = _views.rbegin();
+
auto
i = _views.rbegin();
int vsx, vsy;
_main_canvas->GetViewStart (&vsx, &vsy);
Position<int> const p (ev.GetX() + vsx * _x_scroll_rate, ev.GetY() + vsy * _y_scroll_rate);
while (i != _views.rend() && !(*i)->bbox().contains (p)) {
int vsx, vsy;
_main_canvas->GetViewStart (&vsx, &vsy);
Position<int> const p (ev.GetX() + vsx * _x_scroll_rate, ev.GetY() + vsy * _y_scroll_rate);
while (i != _views.rend() && !(*i)->bbox().contains (p)) {
-
shared_ptr<TimelineContentView> cv = dynamic_pointer_cast<TimelineContentView>
(*i);
+
auto cv = dynamic_pointer_cast<TimelineContentView>
(*i);
++i;
}
if (i == _views.rend ()) {
++i;
}
if (i == _views.rend ()) {
- return
shared_ptr<TimelineView> ()
;
+ return
{}
;
}
return *i;
}
return *i;
@@
-515,8
+516,8
@@
Timeline::left_down (wxMouseEvent& ev)
void
Timeline::left_down_select (wxMouseEvent& ev)
{
void
Timeline::left_down_select (wxMouseEvent& ev)
{
-
shared_ptr<TimelineView>
view = event_to_view (ev);
-
shared_ptr<TimelineContentView> content_view = dynamic_pointer_cast<TimelineContentView>
(view);
+
auto
view = event_to_view (ev);
+
auto content_view = dynamic_pointer_cast<TimelineContentView>
(view);
_down_view.reset ();
_down_view.reset ();
@@
-525,14
+526,14
@@
Timeline::left_down_select (wxMouseEvent& ev)
_down_view_position = content_view->content()->position ();
}
_down_view_position = content_view->content()->position ();
}
- for (
TimelineViewList::iterator i = _views.begin(); i != _views.end(); ++i
) {
-
shared_ptr<TimelineContentView> cv = dynamic_pointer_cast<TimelineContentView> (*
i);
+ for (
auto i: _views
) {
+
auto cv = dynamic_pointer_cast<TimelineContentView>(
i);
if (!cv) {
continue;
}
if (!ev.ShiftDown ()) {
if (!cv) {
continue;
}
if (!ev.ShiftDown ()) {
- cv->set_selected (view ==
*
i);
+ cv->set_selected (view == i);
}
}
}
}
@@
-544,13
+545,13
@@
Timeline::left_down_select (wxMouseEvent& ev)
if (_down_view) {
/* Pre-compute the points that we might snap to */
if (_down_view) {
/* Pre-compute the points that we might snap to */
- for (
TimelineViewList::iterator i = _views.begin(); i != _views.end(); ++i
) {
-
shared_ptr<TimelineContentView> cv = dynamic_pointer_cast<TimelineContentView> (*
i);
+ for (
auto i: _views
) {
+
auto cv = dynamic_pointer_cast<TimelineContentView>(
i);
if (!cv || cv == _down_view || cv->content() == _down_view->content()) {
continue;
}
if (!cv || cv == _down_view || cv->content() == _down_view->content()) {
continue;
}
-
shared_ptr<Film>
film = _film.lock ();
+
auto
film = _film.lock ();
DCPOMATIC_ASSERT (film);
_start_snaps.push_back (cv->content()->position());
DCPOMATIC_ASSERT (film);
_start_snaps.push_back (cv->content()->position());
@@
-627,8
+628,8
@@
Timeline::left_up_zoom (wxMouseEvent& ev)
return;
}
return;
}
-
DCPTime
const time_left = DCPTime::from_seconds((top_left.x + vsx) / *_pixels_per_second);
-
DCPTime
const time_right = DCPTime::from_seconds((bottom_right.x + vsx) / *_pixels_per_second);
+
auto
const time_left = DCPTime::from_seconds((top_left.x + vsx) / *_pixels_per_second);
+
auto
const time_right = DCPTime::from_seconds((bottom_right.x + vsx) / *_pixels_per_second);
set_pixels_per_second (double(GetSize().GetWidth()) / (time_right.seconds() - time_left.seconds()));
double const tracks_top = double(top_left.y - tracks_y_offset()) / _pixels_per_track;
set_pixels_per_second (double(GetSize().GetWidth()) / (time_right.seconds() - time_left.seconds()));
double const tracks_top = double(top_left.y - tracks_y_offset()) / _pixels_per_track;
@@
-712,8
+713,8
@@
Timeline::right_down (wxMouseEvent& ev)
void
Timeline::right_down_select (wxMouseEvent& ev)
{
void
Timeline::right_down_select (wxMouseEvent& ev)
{
-
shared_ptr<TimelineView>
view = event_to_view (ev);
-
shared_ptr<TimelineContentView>
cv = dynamic_pointer_cast<TimelineContentView> (view);
+
auto
view = event_to_view (ev);
+
auto
cv = dynamic_pointer_cast<TimelineContentView> (view);
if (!cv) {
return;
}
if (!cv) {
return;
}
@@
-729,7
+730,7
@@
Timeline::right_down_select (wxMouseEvent& ev)
void
Timeline::maybe_snap (DCPTime a, DCPTime b, optional<DCPTime>& nearest_distance) const
{
void
Timeline::maybe_snap (DCPTime a, DCPTime b, optional<DCPTime>& nearest_distance) const
{
-
DCPTime
const d = a - b;
+
auto
const d = a - b;
if (!nearest_distance || d.abs() < nearest_distance.get().abs()) {
nearest_distance = d;
}
if (!nearest_distance || d.abs() < nearest_distance.get().abs()) {
nearest_distance = d;
}
@@
-744,7
+745,7
@@
Timeline::set_position_from_event (wxMouseEvent& ev, bool force_emit)
double const pps = _pixels_per_second.get ();
double const pps = _pixels_per_second.get ();
-
wxPoint
const p = ev.GetPosition();
+
auto
const p = ev.GetPosition();
if (!_first_move) {
/* We haven't moved yet; in that case, we must move the mouse some reasonable distance
if (!_first_move) {
/* We haven't moved yet; in that case, we must move the mouse some reasonable distance
@@
-761,13
+762,13
@@
Timeline::set_position_from_event (wxMouseEvent& ev, bool force_emit)
return;
}
return;
}
-
DCPTime
new_position = _down_view_position + DCPTime::from_seconds ((p.x - _down_point.x) / pps);
+
auto
new_position = _down_view_position + DCPTime::from_seconds ((p.x - _down_point.x) / pps);
-
shared_ptr<Film>
film = _film.lock ();
+
auto
film = _film.lock ();
DCPOMATIC_ASSERT (film);
if (_snap) {
DCPOMATIC_ASSERT (film);
if (_snap) {
-
DCPTime
const new_end = new_position + _down_view->content()->length_after_trim(film);
+
auto
const new_end = new_position + _down_view->content()->length_after_trim(film);
/* Signed `distance' to nearest thing (i.e. negative is left on the timeline,
positive is right).
*/
/* Signed `distance' to nearest thing (i.e. negative is left on the timeline,
positive is right).
*/
@@
-825,8
+826,8
@@
Timeline::resized ()
void
Timeline::clear_selection ()
{
void
Timeline::clear_selection ()
{
- for (
TimelineViewList::iterator i = _views.begin(); i != _views.end(); ++i
) {
- shared_ptr<TimelineContentView> cv = dynamic_pointer_cast<TimelineContentView>
(*
i);
+ for (
auto i: _views
) {
+ shared_ptr<TimelineContentView> cv = dynamic_pointer_cast<TimelineContentView>
(
i);
if (cv) {
cv->set_selected (false);
}
if (cv) {
cv->set_selected (false);
}
@@
-838,8
+839,8
@@
Timeline::selected_views () const
{
TimelineContentViewList sel;
{
TimelineContentViewList sel;
- for (
TimelineViewList::const_iterator i = _views.begin(); i != _views.end(); ++i
) {
-
shared_ptr<TimelineContentView> cv = dynamic_pointer_cast<TimelineContentView> (*
i);
+ for (
auto i: _views
) {
+
auto cv = dynamic_pointer_cast<TimelineContentView>(
i);
if (cv && cv->selected()) {
sel.push_back (cv);
}
if (cv && cv->selected()) {
sel.push_back (cv);
}
@@
-852,10
+853,9
@@
ContentList
Timeline::selected_content () const
{
ContentList sel;
Timeline::selected_content () const
{
ContentList sel;
- TimelineContentViewList views = selected_views ();
- for (
TimelineContentViewList::const_iterator i = views.begin(); i != views.end(); ++i
) {
- sel.push_back
((*i)->content
());
+ for (
auto i: selected_views()
) {
+ sel.push_back
(i->content
());
}
return sel;
}
return sel;
@@
-864,8
+864,8
@@
Timeline::selected_content () const
void
Timeline::set_selection (ContentList selection)
{
void
Timeline::set_selection (ContentList selection)
{
- for (
TimelineViewList::iterator i = _views.begin(); i != _views.end(); ++i
) {
-
shared_ptr<TimelineContentView> cv = dynamic_pointer_cast<TimelineContentView> (*
i);
+ for (
auto i: _views
) {
+
auto cv = dynamic_pointer_cast<TimelineContentView> (
i);
if (cv) {
cv->set_selected (find (selection.begin(), selection.end(), cv->content ()) != selection.end ());
}
if (cv) {
cv->set_selected (find (selection.begin(), selection.end(), cv->content ()) != selection.end ());
}
@@
-915,7
+915,7
@@
Timeline::tool_clicked (Tool t)
void
Timeline::zoom_all ()
{
void
Timeline::zoom_all ()
{
-
shared_ptr<Film>
film = _film.lock ();
+
auto
film = _film.lock ();
DCPOMATIC_ASSERT (film);
set_pixels_per_second ((_main_canvas->GetSize().GetWidth() - 32) / film->length().seconds());
set_pixels_per_track ((_main_canvas->GetSize().GetHeight() - tracks_y_offset() - _time_axis_view->bbox().height - 32) / _tracks);
DCPOMATIC_ASSERT (film);
set_pixels_per_second ((_main_canvas->GetSize().GetWidth() - 32) / film->length().seconds());
set_pixels_per_track ((_main_canvas->GetSize().GetHeight() - tracks_y_offset() - _time_axis_view->bbox().height - 32) / _tracks);