diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-06-21 01:14:06 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-06-21 01:14:06 +0100 |
| commit | 5a5324ed3a381a86dfe0a6e3932c1d58fdcd596f (patch) | |
| tree | 769dca1358e35017ce5a5b3ab2dfafe2b24d61ed /src/lib | |
| parent | 4e83acad0c2a5c528709a175a80261b8147d3b49 (diff) | |
Use make_shared<>.
Diffstat (limited to 'src/lib')
46 files changed, 189 insertions, 99 deletions
diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index 8d0accf0f..ffe7c0fc7 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -36,6 +36,7 @@ extern "C" { #endif } #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <iostream> #include "i18n.h" @@ -46,6 +47,7 @@ using std::min; using std::cout; using boost::shared_ptr; using boost::dynamic_pointer_cast; +using boost::make_shared; int const AnalyseAudioJob::_num_points = 1024; @@ -90,7 +92,7 @@ AnalyseAudioJob::json_name () const void AnalyseAudioJob::run () { - shared_ptr<Player> player (new Player (_film, _playlist)); + shared_ptr<Player> player = make_shared<Player> (_film, _playlist); player->set_ignore_video (); player->set_fast (); player->set_play_referenced (); diff --git a/src/lib/atmos_mxf_content.cc b/src/lib/atmos_mxf_content.cc index f8cc05178..870fca56e 100644 --- a/src/lib/atmos_mxf_content.cc +++ b/src/lib/atmos_mxf_content.cc @@ -25,12 +25,14 @@ #include <dcp/atmos_asset.h> #include <dcp/exceptions.h> #include <libxml++/libxml++.h> +#include <boost/make_shared.hpp> #include "i18n.h" using std::list; using std::string; using boost::shared_ptr; +using boost::make_shared; AtmosMXFContent::AtmosMXFContent (shared_ptr<const Film> film, boost::filesystem::path path) : Content (film, path) @@ -48,7 +50,7 @@ bool AtmosMXFContent::valid_mxf (boost::filesystem::path path) { try { - shared_ptr<dcp::AtmosAsset> a (new dcp::AtmosAsset (path)); + shared_ptr<dcp::AtmosAsset> a = make_shared<dcp::AtmosAsset> (path); return true; } catch (dcp::MXFFileError& e) { @@ -64,7 +66,7 @@ AtmosMXFContent::examine (shared_ptr<Job> job) { job->set_progress_unknown (); Content::examine (job); - shared_ptr<dcp::AtmosAsset> a (new dcp::AtmosAsset (path(0))); + shared_ptr<dcp::AtmosAsset> a = make_shared<dcp::AtmosAsset> (path(0)); { boost::mutex::scoped_lock lm (_mutex); diff --git a/src/lib/audio_analysis.cc b/src/lib/audio_analysis.cc index 1863e38ee..b133dec3d 100644 --- a/src/lib/audio_analysis.cc +++ b/src/lib/audio_analysis.cc @@ -27,6 +27,7 @@ #include <libxml++/libxml++.h> #include <boost/filesystem.hpp> #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <stdint.h> #include <cmath> #include <cstdio> @@ -41,6 +42,7 @@ using std::cout; using std::max; using std::list; using boost::shared_ptr; +using boost::make_shared; using boost::dynamic_pointer_cast; AudioAnalysis::AudioAnalysis (int channels) @@ -112,7 +114,7 @@ AudioAnalysis::points (int c) const void AudioAnalysis::write (boost::filesystem::path filename) { - shared_ptr<xmlpp::Document> doc (new xmlpp::Document); + shared_ptr<xmlpp::Document> doc = make_shared<xmlpp::Document> (); xmlpp::Element* root = doc->create_root_node ("AudioAnalysis"); BOOST_FOREACH (vector<AudioPoint>& i, _data) { diff --git a/src/lib/audio_buffers.cc b/src/lib/audio_buffers.cc index 2ab8e187e..4c3c2d4a7 100644 --- a/src/lib/audio_buffers.cc +++ b/src/lib/audio_buffers.cc @@ -20,6 +20,7 @@ #include "audio_buffers.h" #include "dcpomatic_assert.h" +#include <boost/make_shared.hpp> #include <cassert> #include <cstring> #include <cmath> @@ -27,6 +28,7 @@ using std::bad_alloc; using boost::shared_ptr; +using boost::make_shared; /** Construct an AudioBuffers. Audio data is undefined after this constructor. * @param channels Number of channels. @@ -305,7 +307,7 @@ AudioBuffers::apply_gain (float dB) shared_ptr<AudioBuffers> AudioBuffers::channel (int c) const { - shared_ptr<AudioBuffers> o (new AudioBuffers (1, frames ())); + shared_ptr<AudioBuffers> o = make_shared<AudioBuffers> (1, frames ()); o->copy_channel_from (this, c, 0); return o; } @@ -320,7 +322,7 @@ AudioBuffers::copy_channel_from (AudioBuffers const * from, int from_channel, in shared_ptr<AudioBuffers> AudioBuffers::clone () const { - shared_ptr<AudioBuffers> b (new AudioBuffers (channels (), frames ())); + shared_ptr<AudioBuffers> b = make_shared<AudioBuffers> (channels (), frames ()); b->copy_from (this, frames (), 0, 0); return b; } diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index 7a4ca63a9..57f878b71 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -75,6 +75,7 @@ AudioContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version) return shared_ptr<AudioContent> (); } + /* Can't use make_shared here as the constructor is private */ return shared_ptr<AudioContent> (new AudioContent (parent, node)); } diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index 8c395cb89..fa9fe9711 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -23,6 +23,7 @@ #include "audio_decoder_stream.h" #include "audio_content.h" #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <iostream> #include "i18n.h" @@ -30,13 +31,14 @@ using std::cout; using std::map; using boost::shared_ptr; +using boost::make_shared; AudioDecoder::AudioDecoder (Decoder* parent, shared_ptr<const AudioContent> content, bool fast, shared_ptr<Log> log) : _ignore (false) , _fast (fast) { BOOST_FOREACH (AudioStreamPtr i, content->streams ()) { - _streams[i] = shared_ptr<AudioDecoderStream> (new AudioDecoderStream (content, i, parent, fast, log)); + _streams[i] = make_shared<AudioDecoderStream> (content, i, parent, fast, log); } } diff --git a/src/lib/audio_decoder_stream.cc b/src/lib/audio_decoder_stream.cc index 1bfc65871..527610cdf 100644 --- a/src/lib/audio_decoder_stream.cc +++ b/src/lib/audio_decoder_stream.cc @@ -28,6 +28,7 @@ #include "log.h" #include "audio_content.h" #include "compose.hpp" +#include <boost/make_shared.hpp> #include <iostream> #include "i18n.h" @@ -39,6 +40,7 @@ using std::min; using std::max; using boost::optional; using boost::shared_ptr; +using boost::make_shared; AudioDecoderStream::AudioDecoderStream (shared_ptr<const AudioContent> content, AudioStreamPtr stream, Decoder* decoder, bool fast, shared_ptr<Log> log) : _content (content) @@ -56,7 +58,7 @@ AudioDecoderStream::AudioDecoderStream (shared_ptr<const AudioContent> content, void AudioDecoderStream::reset_decoded () { - _decoded = ContentAudio (shared_ptr<AudioBuffers> (new AudioBuffers (_stream->channels(), 0)), 0); + _decoded = ContentAudio (make_shared<AudioBuffers> (_stream->channels(), 0), 0); } ContentAudio @@ -118,7 +120,7 @@ AudioDecoderStream::get (Frame frame, Frame length, bool accurate) Frame const to_return = max ((Frame) 0, min (available, length)); /* Copy our data to the output */ - shared_ptr<AudioBuffers> out (new AudioBuffers (_decoded.audio->channels(), to_return)); + shared_ptr<AudioBuffers> out = make_shared<AudioBuffers> (_decoded.audio->channels(), to_return); out->copy_from (_decoded.audio.get(), to_return, decoded_offset, 0); Frame const remaining = max ((Frame) 0, available - to_return); @@ -157,7 +159,7 @@ AudioDecoderStream::audio (shared_ptr<const AudioBuffers> data, ContentTime time Frame const delta_frames = delta.frames_round (frame_rate); if (delta_frames > 0) { /* This data comes after the seek time. Pad the data with some silence. */ - shared_ptr<AudioBuffers> padded (new AudioBuffers (data->channels(), data->frames() + delta_frames)); + shared_ptr<AudioBuffers> padded = make_shared<AudioBuffers> (data->channels(), data->frames() + delta_frames); padded->make_silent (); padded->copy_from (data.get(), data->frames(), 0, delta_frames); data = padded; @@ -172,7 +174,7 @@ AudioDecoderStream::audio (shared_ptr<const AudioBuffers> data, ContentTime time */ return; } - shared_ptr<AudioBuffers> trimmed (new AudioBuffers (data->channels(), to_keep)); + shared_ptr<AudioBuffers> trimmed = make_shared<AudioBuffers> (data->channels(), to_keep); trimmed->copy_from (data.get(), to_keep, to_discard, 0); data = trimmed; time += ContentTime::from_frames (to_discard, frame_rate); diff --git a/src/lib/audio_delay.cc b/src/lib/audio_delay.cc index 893773ddd..e33d9879b 100644 --- a/src/lib/audio_delay.cc +++ b/src/lib/audio_delay.cc @@ -21,10 +21,12 @@ #include "audio_delay.h" #include "audio_buffers.h" #include "dcpomatic_assert.h" +#include <boost/make_shared.hpp> #include <iostream> using std::cout; using boost::shared_ptr; +using boost::make_shared; AudioDelay::AudioDelay (int samples) : _samples (samples) @@ -38,7 +40,7 @@ AudioDelay::run (shared_ptr<const AudioBuffers> in) /* You can't call this with varying channel counts */ DCPOMATIC_ASSERT (!_tail || in->channels() == _tail->channels()); - shared_ptr<AudioBuffers> out (new AudioBuffers (in->channels(), in->frames())); + shared_ptr<AudioBuffers> out = make_shared<AudioBuffers> (in->channels(), in->frames()); if (in->frames() > _samples) { diff --git a/src/lib/audio_filter.cc b/src/lib/audio_filter.cc index 44345fc9d..4203d074c 100644 --- a/src/lib/audio_filter.cc +++ b/src/lib/audio_filter.cc @@ -20,10 +20,12 @@ #include "audio_filter.h" #include "audio_buffers.h" +#include <boost/make_shared.hpp> #include <cmath> using std::min; using boost::shared_ptr; +using boost::make_shared; /** @return array of floats which the caller must destroy with delete[] */ float * @@ -75,7 +77,7 @@ AudioFilter::~AudioFilter () shared_ptr<AudioBuffers> AudioFilter::run (shared_ptr<const AudioBuffers> in) { - shared_ptr<AudioBuffers> out (new AudioBuffers (in->channels(), in->frames())); + shared_ptr<AudioBuffers> out = make_shared<AudioBuffers> (in->channels(), in->frames()); if (!_tail) { _tail.reset (new AudioBuffers (in->channels(), _M + 1)); diff --git a/src/lib/audio_filter_graph.cc b/src/lib/audio_filter_graph.cc index 87a158a4e..f27befb03 100644 --- a/src/lib/audio_filter_graph.cc +++ b/src/lib/audio_filter_graph.cc @@ -25,12 +25,14 @@ extern "C" { #include <libavfilter/buffersink.h> #include <libavfilter/buffersrc.h> } +#include <boost/make_shared.hpp> #include "i18n.h" using std::string; using std::cout; using boost::shared_ptr; +using boost::make_shared; AudioFilterGraph::AudioFilterGraph (int sample_rate, int channels) : _sample_rate (sample_rate) @@ -113,7 +115,7 @@ AudioFilterGraph::process (shared_ptr<const AudioBuffers> buffers) the constructor) so we need to create new buffers with some extra silent channels. */ - shared_ptr<AudioBuffers> extended_buffers (new AudioBuffers (process_channels, buffers->frames())); + shared_ptr<AudioBuffers> extended_buffers = make_shared<AudioBuffers> (process_channels, buffers->frames()); for (int i = 0; i < buffers->channels(); ++i) { extended_buffers->copy_channel_from (buffers.get(), i, i); } diff --git a/src/lib/cinema.cc b/src/lib/cinema.cc index 469cf2e6b..3f1750621 100644 --- a/src/lib/cinema.cc +++ b/src/lib/cinema.cc @@ -25,11 +25,13 @@ #include <dcp/raw_convert.h> #include <libxml++/libxml++.h> #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <iostream> using std::list; using std::string; using boost::shared_ptr; +using boost::make_shared; Cinema::Cinema (cxml::ConstNodePtr node) : name (node->string_child ("Name")) @@ -56,7 +58,7 @@ Cinema::read_screens (cxml::ConstNodePtr node) { list<cxml::NodePtr> s = node->node_children ("Screen"); for (list<cxml::NodePtr>::iterator i = s.begin(); i != s.end(); ++i) { - add_screen (shared_ptr<Screen> (new Screen (*i))); + add_screen (make_shared<Screen> (*i)); } } diff --git a/src/lib/cinema_kdms.cc b/src/lib/cinema_kdms.cc index 84cd9c18f..b32da4d6e 100644 --- a/src/lib/cinema_kdms.cc +++ b/src/lib/cinema_kdms.cc @@ -29,6 +29,7 @@ #include "log.h" #include <zip.h> #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include "i18n.h" @@ -37,6 +38,7 @@ using std::cout; using std::string; using std::runtime_error; using boost::shared_ptr; +using boost::make_shared; void CinemaKDMs::make_zip_file (string film_name, boost::filesystem::path zip_file) const @@ -53,7 +55,7 @@ CinemaKDMs::make_zip_file (string film_name, boost::filesystem::path zip_file) c list<shared_ptr<string> > kdm_strings; BOOST_FOREACH (ScreenKDM const & i, screen_kdms) { - shared_ptr<string> kdm (new string (i.kdm.as_xml ())); + shared_ptr<string> kdm = boost::make_shared<string> (i.kdm.as_xml ()); kdm_strings.push_back (kdm); struct zip_source* source = zip_source_buffer (zip, kdm->c_str(), kdm->length(), 0); diff --git a/src/lib/config.cc b/src/lib/config.cc index 891d832a2..8e1997325 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -39,6 +39,7 @@ #include <boost/algorithm/string.hpp> #include <boost/foreach.hpp> #include <boost/thread.hpp> +#include <boost/make_shared.hpp> #include <cstdlib> #include <fstream> #include <iostream> @@ -55,6 +56,7 @@ using std::remove; using std::exception; using std::cerr; using boost::shared_ptr; +using boost::make_shared; using boost::optional; using boost::algorithm::trim; @@ -267,7 +269,7 @@ Config::read () cxml::NodePtr signer = f.optional_node_child ("Signer"); if (signer) { - shared_ptr<dcp::CertificateChain> c (new dcp::CertificateChain ()); + shared_ptr<dcp::CertificateChain> c = make_shared<dcp::CertificateChain> (); /* Read the signing certificates and private key in from the config file */ BOOST_FOREACH (cxml::NodePtr i, signer->node_children ("Certificate")) { c->add (dcp::Certificate (i->content ())); @@ -281,7 +283,7 @@ Config::read () cxml::NodePtr decryption = f.optional_node_child ("Decryption"); if (decryption) { - shared_ptr<dcp::CertificateChain> c (new dcp::CertificateChain ()); + shared_ptr<dcp::CertificateChain> c = make_shared<dcp::CertificateChain> (); BOOST_FOREACH (cxml::NodePtr i, decryption->node_children ("Certificate")) { c->add (dcp::Certificate (i->content ())); } @@ -559,7 +561,7 @@ Config::read_cinemas (cxml::Document const & f) /* Slightly grotty two-part construction of Cinema here so that we can use shared_from_this. */ - shared_ptr<Cinema> cinema (new Cinema (*i)); + shared_ptr<Cinema> cinema = make_shared<Cinema> (*i); cinema->read_screens (*i); _cinemas.push_back (cinema); } diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 295f33b3c..dbbd65077 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -35,6 +35,7 @@ #include <dcp/reel.h> #include <libxml++/libxml++.h> #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <iterator> #include <iostream> @@ -47,6 +48,7 @@ using std::pair; using std::vector; using std::list; using boost::shared_ptr; +using boost::make_shared; using boost::scoped_ptr; using boost::optional; using boost::function; @@ -132,7 +134,7 @@ DCPContent::examine (shared_ptr<Job> job) job->set_progress_unknown (); Content::examine (job); - shared_ptr<DCPExaminer> examiner (new DCPExaminer (shared_from_this ())); + shared_ptr<DCPExaminer> examiner = make_shared<DCPExaminer> (shared_from_this ()); video->take_from_examiner (examiner); set_default_colour_conversion (); diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index e7e88d319..3bf7c1464 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -43,12 +43,14 @@ #include <dcp/sound_frame.h> #include <dcp/sound_asset_reader.h> #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <iostream> using std::list; using std::cout; using boost::shared_ptr; using boost::dynamic_pointer_cast; +using boost::make_shared; DCPDecoder::DCPDecoder (shared_ptr<const DCPContent> c, shared_ptr<Log> log, bool fast) : _dcp_content (c) @@ -94,15 +96,15 @@ DCPDecoder::pass (PassReason reason, bool) shared_ptr<dcp::PictureAsset> asset = (*_reel)->main_picture()->asset (); int64_t const entry_point = (*_reel)->main_picture()->entry_point (); if (_mono_reader) { - video->give (shared_ptr<ImageProxy> (new J2KImageProxy (_mono_reader->get_frame (entry_point + frame), asset->size())), _offset + frame); + video->give (make_shared<J2KImageProxy> (_mono_reader->get_frame (entry_point + frame), asset->size()), _offset + frame); } else { video->give ( - shared_ptr<ImageProxy> (new J2KImageProxy (_stereo_reader->get_frame (entry_point + frame), asset->size(), dcp::EYE_LEFT)), + make_shared<J2KImageProxy> (_stereo_reader->get_frame (entry_point + frame), asset->size(), dcp::EYE_LEFT), _offset + frame ); video->give ( - shared_ptr<ImageProxy> (new J2KImageProxy (_stereo_reader->get_frame (entry_point + frame), asset->size(), dcp::EYE_RIGHT)), + make_shared<J2KImageProxy> (_stereo_reader->get_frame (entry_point + frame), asset->size(), dcp::EYE_RIGHT), _offset + frame ); } @@ -115,7 +117,7 @@ DCPDecoder::pass (PassReason reason, bool) int const channels = _dcp_content->audio->stream()->channels (); int const frames = sf->size() / (3 * channels); - shared_ptr<AudioBuffers> data (new AudioBuffers (channels, frames)); + shared_ptr<AudioBuffers> data = make_shared<AudioBuffers> (channels, frames); for (int i = 0; i < frames; ++i) { for (int j = 0; j < channels; ++j) { data->data()[j][i] = static_cast<int> ((from[0] << 8) | (from[1] << 16) | (from[2] << 24)) / static_cast<float> (INT_MAX - 256); diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc index e7057efc4..b361b9419 100644 --- a/src/lib/dcp_subtitle_content.cc +++ b/src/lib/dcp_subtitle_content.cc @@ -28,6 +28,7 @@ #include <dcp/interop_load_font_node.h> #include <libxml++/libxml++.h> #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include "i18n.h" @@ -35,6 +36,7 @@ using std::string; using std::list; using boost::shared_ptr; using boost::dynamic_pointer_cast; +using boost::make_shared; DCPSubtitleContent::DCPSubtitleContent (shared_ptr<const Film> film, boost::filesystem::path path) : Content (film, path) @@ -76,7 +78,7 @@ DCPSubtitleContent::examine (shared_ptr<Job> job) _length = ContentTime::from_seconds (sc->latest_subtitle_out().as_seconds ()); BOOST_FOREACH (shared_ptr<dcp::LoadFontNode> i, sc->load_font_nodes ()) { - subtitle->add_font (shared_ptr<Font> (new Font (i->id))); + subtitle->add_font (boost::make_shared<Font> (i->id)); } } diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc index be69f3eed..6d270dab2 100644 --- a/src/lib/dcp_video.cc +++ b/src/lib/dcp_video.cc @@ -47,6 +47,7 @@ #include <libxml++/libxml++.h> #include <boost/asio.hpp> #include <boost/thread.hpp> +#include <boost/make_shared.hpp> #include <stdint.h> #include <iomanip> #include <iostream> @@ -60,6 +61,7 @@ using std::string; using std::cout; using boost::shared_ptr; +using boost::make_shared; using dcp::Size; using dcp::Data; @@ -158,7 +160,7 @@ DCPVideo::encode_remotely (EncodeServerDescription serv, int timeout) boost::asio::ip::tcp::resolver::query query (serv.host_name(), raw_convert<string> (Config::instance()->server_port_base ())); boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve (query); - shared_ptr<Socket> socket (new Socket (timeout)); + shared_ptr<Socket> socket = make_shared<Socket> (timeout); socket->connect (*endpoint_iterator); diff --git a/src/lib/decoder_factory.cc b/src/lib/decoder_factory.cc index dc01a043a..ec0140b0c 100644 --- a/src/lib/decoder_factory.cc +++ b/src/lib/decoder_factory.cc @@ -31,42 +31,44 @@ #include "video_mxf_content.h" #include "video_mxf_decoder.h" #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> using std::list; using boost::shared_ptr; using boost::dynamic_pointer_cast; +using boost::make_shared; shared_ptr<Decoder> decoder_factory (shared_ptr<const Content> content, shared_ptr<Log> log, bool fast) { shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (content); if (fc) { - return shared_ptr<Decoder> (new FFmpegDecoder (fc, log, fast)); + return make_shared<FFmpegDecoder> (fc, log, fast); } shared_ptr<const DCPContent> dc = dynamic_pointer_cast<const DCPContent> (content); if (dc) { - return shared_ptr<Decoder> (new DCPDecoder (dc, log, fast)); + return make_shared<DCPDecoder> (dc, log, fast); } shared_ptr<const ImageContent> ic = dynamic_pointer_cast<const ImageContent> (content); if (ic) { - return shared_ptr<Decoder> (new ImageDecoder (ic, log)); + return make_shared<ImageDecoder> (ic, log); } shared_ptr<const TextSubtitleContent> rc = dynamic_pointer_cast<const TextSubtitleContent> (content); if (rc) { - return shared_ptr<Decoder> (new TextSubtitleDecoder (rc)); + return make_shared<TextSubtitleDecoder> (rc); } shared_ptr<const DCPSubtitleContent> dsc = dynamic_pointer_cast<const DCPSubtitleContent> (content); if (dsc) { - return shared_ptr<Decoder> (new DCPSubtitleDecoder (dsc)); + return make_shared<DCPSubtitleDecoder> (dsc); } shared_ptr<const VideoMXFContent> vmc = dynamic_pointer_cast<const VideoMXFContent> (content); if (vmc) { - return shared_ptr<Decoder> (new VideoMXFDecoder (vmc, log)); + return make_shared<VideoMXFDecoder> (vmc, log); } return shared_ptr<Decoder> (); diff --git a/src/lib/encode_server.cc b/src/lib/encode_server.cc index f318da03b..635913cc2 100644 --- a/src/lib/encode_server.cc +++ b/src/lib/encode_server.cc @@ -41,6 +41,7 @@ #include <boost/algorithm/string.hpp> #include <boost/scoped_array.hpp> #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <string> #include <vector> #include <iostream> @@ -63,6 +64,7 @@ using boost::thread; using boost::bind; using boost::scoped_array; using boost::optional; +using boost::make_shared; using dcp::Size; using dcp::Data; @@ -108,7 +110,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()); - shared_ptr<cxml::Document> xml (new cxml::Document ("EncodingRequest")); + shared_ptr<cxml::Document> 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. @@ -119,7 +121,7 @@ EncodeServer::process (shared_ptr<Socket> socket, struct timeval& after_read, st return -1; } - shared_ptr<PlayerVideo> pvf (new PlayerVideo (xml, socket)); + shared_ptr<PlayerVideo> pvf = make_shared<PlayerVideo> (xml, socket); DCPVideo dcp_video_frame (pvf, xml, _log); @@ -264,7 +266,7 @@ EncodeServer::broadcast_received () if (_verbose) { cout << "Offering services to master " << _broadcast.send_endpoint.address().to_string () << "\n"; } - shared_ptr<Socket> socket (new Socket); + shared_ptr<Socket> socket = make_shared<Socket> (); try { socket->connect (boost::asio::ip::tcp::endpoint (_broadcast.send_endpoint.address(), Config::instance()->server_port_base() + 1)); socket->write (xml.length() + 1); diff --git a/src/lib/encode_server_finder.cc b/src/lib/encode_server_finder.cc index 7491d9ef7..a017a0af1 100644 --- a/src/lib/encode_server_finder.cc +++ b/src/lib/encode_server_finder.cc @@ -28,6 +28,7 @@ #include "raw_convert.h" #include <libcxml/cxml.h> #include <boost/lambda/lambda.hpp> +#include <boost/make_shared.hpp> #include <iostream> #include "i18n.h" @@ -39,6 +40,7 @@ using std::cout; using boost::shared_ptr; using boost::scoped_array; using boost::weak_ptr; +using boost::make_shared; EncodeServerFinder* EncodeServerFinder::_instance = 0; @@ -151,7 +153,7 @@ catch (...) void EncodeServerFinder::start_accept () { - shared_ptr<Socket> socket (new Socket ()); + shared_ptr<Socket> socket = make_shared<Socket> (); _listen_acceptor->async_accept ( socket->socket(), boost::bind (&EncodeServerFinder::handle_accept, this, boost::asio::placeholders::error, socket) @@ -174,7 +176,7 @@ EncodeServerFinder::handle_accept (boost::system::error_code ec, shared_ptr<Sock socket->read (reinterpret_cast<uint8_t*> (buffer.get()), length); string s (buffer.get()); - shared_ptr<cxml::Document> xml (new cxml::Document ("ServerAvailable")); + shared_ptr<cxml::Document> xml = make_shared<cxml::Document> ("ServerAvailable"); xml->read_string (s); string const ip = socket->socket().remote_endpoint().address().to_string (); diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index b34fdf6aa..f3a4c4c4f 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -42,6 +42,7 @@ extern "C" { } #include <libxml++/libxml++.h> #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <iostream> #include "i18n.h" @@ -56,6 +57,7 @@ using std::pair; using std::make_pair; using std::max; using boost::shared_ptr; +using boost::make_shared; using boost::dynamic_pointer_cast; using boost::optional; @@ -78,7 +80,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, cxml::ConstNodePtr no list<cxml::NodePtr> c = node->node_children ("SubtitleStream"); for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) { - _subtitle_streams.push_back (shared_ptr<FFmpegSubtitleStream> (new FFmpegSubtitleStream (*i, version))); + _subtitle_streams.push_back (make_shared<FFmpegSubtitleStream> (*i, version)); if ((*i)->optional_number_child<int> ("Selected")) { _subtitle_stream = _subtitle_streams.back (); } @@ -86,7 +88,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, cxml::ConstNodePtr no c = node->node_children ("AudioStream"); for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) { - shared_ptr<FFmpegAudioStream> as (new FFmpegAudioStream (*i, version)); + shared_ptr<FFmpegAudioStream> as = make_shared<FFmpegAudioStream> (*i, version); audio->add_stream (as); if (version < 11 && !(*i)->optional_node_child ("Selected")) { /* This is an old file and this stream is not selected, so un-map it */ @@ -210,7 +212,7 @@ FFmpegContent::examine (shared_ptr<Job> job) Content::examine (job); - shared_ptr<FFmpegExaminer> examiner (new FFmpegExaminer (shared_from_this (), job)); + shared_ptr<FFmpegExaminer> examiner = make_shared<FFmpegExaminer> (shared_from_this (), job); if (examiner->has_video ()) { video.reset (new VideoContent (this)); diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index df6b7416b..69ed7ac12 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -50,6 +50,7 @@ extern "C" { } #include <boost/foreach.hpp> #include <boost/algorithm/string.hpp> +#include <boost/make_shared.hpp> #include <vector> #include <iomanip> #include <iostream> @@ -71,6 +72,7 @@ using std::pair; using std::max; using std::map; using boost::shared_ptr; +using boost::make_shared; using boost::is_any_of; using boost::split; using dcp::Size; @@ -175,7 +177,7 @@ FFmpegDecoder::deinterleave_audio (shared_ptr<FFmpegAudioStream> stream) const */ int const total_samples = size / bytes_per_audio_sample (stream); int const frames = total_samples / stream->channels(); - shared_ptr<AudioBuffers> audio (new AudioBuffers (stream->channels(), frames)); + shared_ptr<AudioBuffers> audio = make_shared<AudioBuffers> (stream->channels(), frames); switch (audio_sample_format (stream)) { case AV_SAMPLE_FMT_U8: @@ -452,7 +454,7 @@ FFmpegDecoder::decode_video_packet () if (i->second != AV_NOPTS_VALUE) { double const pts = i->second * av_q2d (_format_context->streams[_video_stream.get()]->time_base) + _pts_offset.seconds (); video->give ( - shared_ptr<ImageProxy> (new RawImageProxy (image)), + make_shared<RawImageProxy> (image), llrint (pts * _ffmpeg_content->active_video_frame_rate ()) ); } else { @@ -532,7 +534,7 @@ FFmpegDecoder::decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTimeP /* Note RGBA is expressed little-endian, so the first byte in the word is R, second G, third B, fourth A. */ - shared_ptr<Image> image (new Image (AV_PIX_FMT_RGBA, dcp::Size (rect->w, rect->h), true)); + shared_ptr<Image> image = make_shared<Image> (AV_PIX_FMT_RGBA, dcp::Size (rect->w, rect->h), true); #ifdef DCPOMATIC_HAVE_AVSUBTITLERECT_PICT /* Start of the first line in the subtitle */ diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc index 18a87f40e..2e48810b1 100644 --- a/src/lib/ffmpeg_examiner.cc +++ b/src/lib/ffmpeg_examiner.cc @@ -32,6 +32,7 @@ extern "C" { #include "util.h" #include "safe_stringstream.h" #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <iostream> #include "i18n.h" @@ -40,6 +41,7 @@ using std::string; using std::cout; using std::max; using boost::shared_ptr; +using boost::make_shared; using boost::optional; /** @param job job that the examiner is operating in, or 0 */ @@ -80,7 +82,7 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo ); } else if (s->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { - _subtitle_streams.push_back (shared_ptr<FFmpegSubtitleStream> (new FFmpegSubtitleStream (subtitle_stream_name (s), s->id))); + _subtitle_streams.push_back (boost::make_shared<FFmpegSubtitleStream> (subtitle_stream_name (s), s->id)); } } diff --git a/src/lib/film.cc b/src/lib/film.cc index 3cd3f0f21..3378b2042 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -62,6 +62,7 @@ #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <boost/regex.hpp> #include <unistd.h> #include <stdexcept> @@ -89,6 +90,7 @@ using boost::weak_ptr; using boost::dynamic_pointer_cast; using boost::optional; using boost::is_any_of; +using boost::make_shared; #define LOG_GENERAL(...) log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); #define LOG_GENERAL_NC(...) log()->log (__VA_ARGS__, LogEntry::TYPE_GENERAL); @@ -318,21 +320,21 @@ Film::make_dcp () throw MissingSettingError (_("name")); } - JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this()))); + JobManager::instance()->add (make_shared<TranscodeJob> (shared_from_this())); } /** Start a job to send our DCP to the configured TMS */ void Film::send_dcp_to_tms () { - shared_ptr<Job> j (new UploadJob (shared_from_this())); + shared_ptr<Job> j = make_shared<UploadJob> (shared_from_this()); JobManager::instance()->add (j); } shared_ptr<xmlpp::Document> Film::metadata () const { - shared_ptr<xmlpp::Document> doc (new xmlpp::Document); + shared_ptr<xmlpp::Document> doc = make_shared<xmlpp::Document> (); xmlpp::Element* root = doc->create_root_node ("Metadata"); root->add_child("Version")->add_child_text (raw_convert<string> (current_state_version)); @@ -1003,7 +1005,7 @@ Film::content () const void Film::examine_content (shared_ptr<Content> c) { - shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c)); + shared_ptr<Job> j = make_shared<ExamineContentJob> (shared_from_this(), c); JobManager::instance()->add (j); } @@ -1014,7 +1016,7 @@ Film::examine_and_add_content (shared_ptr<Content> c) run_ffprobe (c->path(0), file ("ffprobe.log"), _log); } - shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c)); + shared_ptr<Job> j = make_shared<ExamineContentJob> (shared_from_this(), c); _job_connections.push_back ( j->Finished.connect (bind (&Film::maybe_add_content, this, weak_ptr<Job> (j), weak_ptr<Content> (c))) @@ -1038,7 +1040,7 @@ Film::maybe_add_content (weak_ptr<Job> j, weak_ptr<Content> c) add_content (content); if (Config::instance()->automatic_audio_analysis() && content->audio) { - shared_ptr<Playlist> playlist (new Playlist); + shared_ptr<Playlist> playlist = make_shared<Playlist> (); playlist->add (content); boost::signals2::connection c; JobManager::instance()->analyse_audio ( @@ -1180,7 +1182,7 @@ Film::make_kdm ( dcp::Formulation formulation ) const { - shared_ptr<const dcp::CPL> cpl (new dcp::CPL (cpl_file)); + shared_ptr<const dcp::CPL> cpl = make_shared<dcp::CPL> (cpl_file); shared_ptr<const dcp::CertificateChain> signer = Config::instance()->signer_chain (); if (!signer->valid ()) { throw InvalidSignerError (); diff --git a/src/lib/image.cc b/src/lib/image.cc index 71a3a5bcc..1107f0a40 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -34,6 +34,7 @@ extern "C" { #include <libavutil/pixdesc.h> #include <libavutil/frame.h> } +#include <boost/make_shared.hpp> #include <iostream> #include "i18n.h" @@ -45,6 +46,7 @@ using std::cerr; using std::list; using std::runtime_error; using boost::shared_ptr; +using boost::make_shared; using dcp::Size; int @@ -149,7 +151,7 @@ Image::crop_scale_window ( To get around this, we ask Image to overallocate its buffers by the overrun. */ - shared_ptr<Image> out (new Image (out_format, out_size, out_aligned, (out_size.width - inter_size.width) / 2)); + shared_ptr<Image> out = make_shared<Image> (out_format, out_size, out_aligned, (out_size.width - inter_size.width) / 2); out->make_black (); /* Size of the image after any crop */ @@ -227,7 +229,7 @@ Image::scale (dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_fo */ DCPOMATIC_ASSERT (aligned ()); - shared_ptr<Image> scaled (new Image (out_format, out_size, out_aligned)); + shared_ptr<Image> scaled = make_shared<Image> (out_format, out_size, out_aligned); struct SwsContext* scale_context = sws_getContext ( size().width, size().height, pixel_format(), @@ -819,7 +821,7 @@ merge (list<PositionImage> images) all.extend (dcpomatic::Rect<int> (i->position, i->image->size().width, i->image->size().height)); } - shared_ptr<Image> merged (new Image (images.front().image->pixel_format (), dcp::Size (all.width, all.height), true)); + shared_ptr<Image> merged = make_shared<Image> (images.front().image->pixel_format (), dcp::Size (all.width, all.height), true); merged->make_transparent (); for (list<PositionImage>::const_iterator i = images.begin(); i != images.end(); ++i) { merged->alpha_blend (i->image, i->position - all.position()); diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index d4e736771..ca8bd380f 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -31,6 +31,7 @@ #include <libcxml/cxml.h> #include <libxml++/libxml++.h> #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <iostream> #include "i18n.h" @@ -39,6 +40,7 @@ using std::string; using std::cout; using std::list; using boost::shared_ptr; +using boost::make_shared; ImageContent::ImageContent (shared_ptr<const Film> film, boost::filesystem::path p) : Content (film) @@ -119,7 +121,7 @@ ImageContent::examine (shared_ptr<Job> job) shared_ptr<const Film> film = _film.lock (); DCPOMATIC_ASSERT (film); - shared_ptr<ImageExaminer> examiner (new ImageExaminer (film, shared_from_this(), job)); + shared_ptr<ImageExaminer> examiner = make_shared<ImageExaminer> (film, shared_from_this(), job); video->take_from_examiner (examiner); set_default_colour_conversion (); } diff --git a/src/lib/image_proxy.cc b/src/lib/image_proxy.cc index 3a09cb8e8..69c296605 100644 --- a/src/lib/image_proxy.cc +++ b/src/lib/image_proxy.cc @@ -27,6 +27,7 @@ #include "cross.h" #include <dcp/util.h> #include <libcxml/cxml.h> +#include <boost/make_shared.hpp> #include <iostream> #include "i18n.h" @@ -34,16 +35,17 @@ using std::cout; using std::string; using boost::shared_ptr; +using boost::make_shared; shared_ptr<ImageProxy> image_proxy_factory (shared_ptr<cxml::Node> xml, shared_ptr<Socket> socket) { if (xml->string_child("Type") == N_("Raw")) { - return shared_ptr<ImageProxy> (new RawImageProxy (xml, socket)); + return make_shared<RawImageProxy> (xml, socket); } else if (xml->string_child("Type") == N_("Magick")) { - return shared_ptr<MagickImageProxy> (new MagickImageProxy (xml, socket)); + return make_shared<MagickImageProxy> (xml, socket); } else if (xml->string_child("Type") == N_("J2K")) { - return shared_ptr<J2KImageProxy> (new J2KImageProxy (xml, socket)); + return make_shared<J2KImageProxy> (xml, socket); } throw NetworkError (_("Unexpected image type received by server")); diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc index 44b5ebea7..35d70162c 100644 --- a/src/lib/j2k_image_proxy.cc +++ b/src/lib/j2k_image_proxy.cc @@ -30,6 +30,7 @@ #include <dcp/j2k.h> #include <libcxml/cxml.h> #include <libxml++/libxml++.h> +#include <boost/make_shared.hpp> #include <iostream> #include "i18n.h" @@ -39,6 +40,7 @@ using std::cout; using boost::shared_ptr; using boost::optional; using boost::dynamic_pointer_cast; +using boost::make_shared; using dcp::Data; /** Construct a J2KImageProxy from a JPEG2000 file */ @@ -107,7 +109,7 @@ J2KImageProxy::image (optional<dcp::NoteHandler>) const } } - shared_ptr<Image> image (new Image (pixel_format(), _size, true)); + shared_ptr<Image> image = make_shared<Image> (pixel_format(), _size, true); /* Copy data in whatever format (sRGB or XYZ) into our Image; I'm assuming the data is 12-bit either way. diff --git a/src/lib/json_server.cc b/src/lib/json_server.cc index 0006201e6..6e53f9819 100644 --- a/src/lib/json_server.cc +++ b/src/lib/json_server.cc @@ -27,6 +27,7 @@ #include "util.h" #include "film.h" #include "transcode_job.h" +#include <boost/make_shared.hpp> #include <iostream> using std::string; @@ -35,6 +36,7 @@ using std::map; using std::list; using boost::thread; using boost::shared_ptr; +using boost::make_shared; using boost::dynamic_pointer_cast; using boost::asio::ip::tcp; @@ -61,7 +63,7 @@ try tcp::acceptor a (io_service, tcp::endpoint (tcp::v4 (), port)); while (true) { try { - shared_ptr<tcp::socket> s (new tcp::socket (io_service)); + shared_ptr<tcp::socket> s = make_shared<tcp::socket> (io_service); a.accept (*s); handle (s); } diff --git a/src/lib/log.cc b/src/lib/log.cc index b7edd4e29..769852044 100644 --- a/src/lib/log.cc +++ b/src/lib/log.cc @@ -27,6 +27,7 @@ #include "config.h" #include "safe_stringstream.h" #include "string_log_entry.h" +#include <boost/make_shared.hpp> #include <time.h> #include <cstdio> @@ -35,6 +36,7 @@ using std::string; using std::cout; using boost::shared_ptr; +using boost::make_shared; Log::Log () : _types (0) @@ -71,7 +73,7 @@ Log::log (string message, int type) return; } - shared_ptr<StringLogEntry> e (new StringLogEntry (type, message)); + shared_ptr<StringLogEntry> e = boost::make_shared<StringLogEntry> (type, message); do_log (e); } @@ -81,13 +83,13 @@ Log::dcp_log (dcp::NoteType type, string m) { switch (type) { case dcp::DCP_PROGRESS: - do_log (shared_ptr<const LogEntry> (new StringLogEntry (LogEntry::TYPE_GENERAL, m))); + do_log (boost::make_shared<const StringLogEntry> (LogEntry::TYPE_GENERAL, m)); break; case dcp::DCP_ERROR: - do_log (shared_ptr<const LogEntry> (new StringLogEntry (LogEntry::TYPE_ERROR, m))); + do_log (boost::make_shared<const StringLogEntry> (LogEntry::TYPE_ERROR, m)); break; case dcp::DCP_NOTE: - do_log (shared_ptr<const LogEntry> (new StringLogEntry (LogEntry::TYPE_WARNING, m))); + do_log (boost::make_shared<const StringLogEntry> (LogEntry::TYPE_WARNING, m)); break; } } diff --git a/src/lib/mid_side_decoder.cc b/src/lib/mid_side_decoder.cc index b9b8dd098..8d5dc1875 100644 --- a/src/lib/mid_side_decoder.cc +++ b/src/lib/mid_side_decoder.cc @@ -21,6 +21,7 @@ #include "mid_side_decoder.h" #include "audio_buffers.h" #include "audio_mapping.h" +#include <boost/make_shared.hpp> #include "i18n.h" @@ -28,6 +29,7 @@ using std::string; using std::min; using std::vector; using boost::shared_ptr; +using boost::make_shared; string MidSideDecoder::name () const @@ -50,14 +52,14 @@ MidSideDecoder::out_channels () const shared_ptr<AudioProcessor> MidSideDecoder::clone (int) const { - return shared_ptr<AudioProcessor> (new MidSideDecoder ()); + return make_shared<MidSideDecoder> (); } shared_ptr<AudioBuffers> MidSideDecoder::run (shared_ptr<const AudioBuffers> in, int channels) { int const N = min (channels, 3); - shared_ptr<AudioBuffers> out (new AudioBuffers (channels, in->frames ())); + shared_ptr<AudioBuffers> out = make_shared<AudioBuffers> (channels, in->frames ()); for (int i = 0; i < in->frames(); ++i) { float const left = in->data()[0][i]; float const right = in->data()[1][i]; diff --git a/src/lib/player.cc b/src/lib/player.cc index 30313d39d..1d3e22e20 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -52,6 +52,7 @@ #include <dcp/reel_subtitle_asset.h> #include <dcp/reel_picture_asset.h> #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <stdint.h> #include <algorithm> #include <iostream> @@ -71,6 +72,7 @@ using std::map; using std::make_pair; using std::copy; using boost::shared_ptr; +using boost::make_shared; using boost::weak_ptr; using boost::dynamic_pointer_cast; using boost::optional; @@ -139,7 +141,7 @@ Player::setup_pieces () decoder->audio->set_ignore (); } - _pieces.push_back (shared_ptr<Piece> (new Piece (i, decoder, frc))); + _pieces.push_back (make_shared<Piece> (i, decoder, frc)); } _have_valid_pieces = true; @@ -278,7 +280,7 @@ Player::black_player_video_frame (DCPTime time) const { return shared_ptr<PlayerVideo> ( new PlayerVideo ( - shared_ptr<const ImageProxy> (new RawImageProxy (_black_image)), + make_shared<RawImageProxy> (_black_image), time, Crop (), optional<double> (), @@ -413,7 +415,7 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) Frame const length_frames = length.frames_round (_film->audio_frame_rate ()); - shared_ptr<AudioBuffers> audio (new AudioBuffers (_film->audio_channels(), length_frames)); + shared_ptr<AudioBuffers> audio = make_shared<AudioBuffers> (_film->audio_channels(), length_frames); audio->make_silent (); list<shared_ptr<Piece> > ov = overlaps (time, time + length, has_audio); @@ -470,13 +472,13 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) /* Gain */ if (i->content->audio->gain() != 0) { - shared_ptr<AudioBuffers> gain (new AudioBuffers (all.audio)); + shared_ptr<AudioBuffers> gain = make_shared<AudioBuffers> (all.audio); gain->apply_gain (i->content->audio->gain ()); all.audio = gain; } /* Remap channels */ - shared_ptr<AudioBuffers> dcp_mapped (new AudioBuffers (_film->audio_channels(), all.audio->frames())); + shared_ptr<AudioBuffers> dcp_mapped = make_shared<AudioBuffers> (_film->audio_channels(), all.audio->frames()); dcp_mapped->make_silent (); AudioMapping map = j->mapping (); for (int i = 0; i < map.input_channels(); ++i) { diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index e6533d2cc..eff5c48ee 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -42,6 +42,7 @@ #include <dcp/interop_subtitle_asset.h> #include <dcp/smpte_subtitle_asset.h> #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include "i18n.h" @@ -54,6 +55,7 @@ using std::list; using std::string; using std::cout; using boost::shared_ptr; +using boost::make_shared; using boost::optional; using boost::dynamic_pointer_cast; using dcp::Data; @@ -303,7 +305,7 @@ ReelWriter::finish () shared_ptr<dcp::Reel> ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr<Font> > const & fonts) { - shared_ptr<dcp::Reel> reel (new dcp::Reel ()); + shared_ptr<dcp::Reel> reel = make_shared<dcp::Reel> (); shared_ptr<dcp::ReelPictureAsset> reel_picture_asset; @@ -336,7 +338,7 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr if (_sound_asset) { /* We have made a sound asset of our own. Put it into the reel */ - reel->add (shared_ptr<dcp::ReelSoundAsset> (new dcp::ReelSoundAsset (_sound_asset, 0))); + reel->add (make_shared<dcp::ReelSoundAsset> (_sound_asset, 0)); } else { /* We don't have a sound asset of our own; hopefully we have one to reference */ BOOST_FOREACH (ReferencedReelAsset j, refs) { @@ -460,13 +462,13 @@ ReelWriter::write (PlayerSubtitles subs) lang = "Unknown"; } if (_film->interop ()) { - shared_ptr<dcp::InteropSubtitleAsset> s (new dcp::InteropSubtitleAsset ()); + shared_ptr<dcp::InteropSubtitleAsset> s = make_shared<dcp::InteropSubtitleAsset> (); s->set_movie_title (_film->name ()); s->set_language (lang); s->set_reel_number ("1"); _subtitle_asset = s; } else { - shared_ptr<dcp::SMPTESubtitleAsset> s (new dcp::SMPTESubtitleAsset ()); + shared_ptr<dcp::SMPTESubtitleAsset> s = make_shared<dcp::SMPTESubtitleAsset> (); s->set_content_title_text (_film->name ()); s->set_language (lang); s->set_edit_rate (dcp::Fraction (_film->video_frame_rate (), 1)); diff --git a/src/lib/render_subtitles.cc b/src/lib/render_subtitles.cc index 76aa09229..94a6b837b 100644 --- a/src/lib/render_subtitles.cc +++ b/src/lib/render_subtitles.cc @@ -28,6 +28,7 @@ #include <cairomm/cairomm.h> #include <pangomm.h> #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <iostream> using std::list; @@ -39,6 +40,7 @@ using std::pair; using std::cerr; using std::make_pair; using boost::shared_ptr; +using boost::make_shared; using boost::optional; static FcConfig* fc_config = 0; @@ -80,7 +82,7 @@ render_line (list<dcp::SubtitleString> subtitles, list<shared_ptr<Font> > fonts, /* ...and add a bit more for luck */ height += target.height / 11; - shared_ptr<Image> image (new Image (AV_PIX_FMT_RGBA, dcp::Size (target.width, height), false)); + shared_ptr<Image> image = make_shared<Image> (AV_PIX_FMT_RGBA, dcp::Size (target.width, height), false); image->make_black (); #ifdef DCPOMATIC_HAVE_FORMAT_STRIDE_FOR_WIDTH diff --git a/src/lib/resampler.cc b/src/lib/resampler.cc index db5552d15..4476d9f1f 100644 --- a/src/lib/resampler.cc +++ b/src/lib/resampler.cc @@ -24,6 +24,7 @@ #include "compose.hpp" #include "dcpomatic_assert.h" #include <samplerate.h> +#include <boost/make_shared.hpp> #include <iostream> #include "i18n.h" @@ -33,6 +34,7 @@ using std::pair; using std::make_pair; using std::runtime_error; using boost::shared_ptr; +using boost::make_shared; /** @param in Input sampling rate (Hz) * @param out Output sampling rate (Hz) @@ -62,7 +64,7 @@ Resampler::run (shared_ptr<const AudioBuffers> in) int in_frames = in->frames (); int in_offset = 0; int out_offset = 0; - shared_ptr<AudioBuffers> resampled (new AudioBuffers (_channels, 0)); + shared_ptr<AudioBuffers> resampled = make_shared<AudioBuffers> (_channels, 0); while (in_frames > 0) { @@ -136,7 +138,7 @@ Resampler::run (shared_ptr<const AudioBuffers> in) shared_ptr<const AudioBuffers> Resampler::flush () { - shared_ptr<AudioBuffers> out (new AudioBuffers (_channels, 0)); + shared_ptr<AudioBuffers> out = make_shared<AudioBuffers> (_channels, 0); int out_offset = 0; int64_t const output_size = 65536; diff --git a/src/lib/server.cc b/src/lib/server.cc index 09e0a4bd0..d90ec9116 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -20,10 +20,12 @@ #include "server.h" #include "dcpomatic_socket.h" +#include <boost/make_shared.hpp> #include "i18n.h" using boost::shared_ptr; +using boost::make_shared; Server::Server (int port) : _terminate (false) @@ -56,7 +58,7 @@ Server::start_accept () } } - shared_ptr<Socket> socket (new Socket); + shared_ptr<Socket> socket = make_shared<Socket> (); _acceptor.async_accept (socket->socket (), boost::bind (&Server::handle_accept, this, socket, boost::asio::placeholders::error)); } diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc index 5b3b453b6..9fd49831f 100644 --- a/src/lib/subtitle_content.cc +++ b/src/lib/subtitle_content.cc @@ -28,6 +28,7 @@ #include <libcxml/cxml.h> #include <libxml++/libxml++.h> #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <iostream> #include "i18n.h" @@ -37,6 +38,7 @@ using std::vector; using std::cout; using std::list; using boost::shared_ptr; +using boost::make_shared; using boost::dynamic_pointer_cast; int const SubtitleContentProperty::X_OFFSET = 500; @@ -84,6 +86,7 @@ SubtitleContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version return shared_ptr<SubtitleContent> (); } + /* Can't use make_shared here as the constructor is private */ return shared_ptr<SubtitleContent> (new SubtitleContent (parent, node, version)); } @@ -130,7 +133,7 @@ SubtitleContent::SubtitleContent (Content* parent, cxml::ConstNodePtr node, int list<cxml::NodePtr> fonts = node->node_children ("Font"); for (list<cxml::NodePtr>::const_iterator i = fonts.begin(); i != fonts.end(); ++i) { - _fonts.push_back (shared_ptr<Font> (new Font (*i))); + _fonts.push_back (make_shared<Font> (*i)); } connect_to_fonts (); diff --git a/src/lib/text_subtitle_content.cc b/src/lib/text_subtitle_content.cc index 24a328d08..ea56ac7bb 100644 --- a/src/lib/text_subtitle_content.cc +++ b/src/lib/text_subtitle_content.cc @@ -26,6 +26,7 @@ #include "raw_convert.h" #include "subtitle_content.h" #include <libxml++/libxml++.h> +#include <boost/make_shared.hpp> #include <iostream> #include "i18n.h" @@ -33,6 +34,7 @@ using std::string; using std::cout; using boost::shared_ptr; +using boost::make_shared; TextSubtitleContent::TextSubtitleContent (shared_ptr<const Film> film, boost::filesystem::path path) : Content (film, path) @@ -58,7 +60,7 @@ TextSubtitleContent::examine (boost::shared_ptr<Job> job) boost::mutex::scoped_lock lm (_mutex); _length = s.length (); - subtitle->add_font (shared_ptr<Font> (new Font (TEXT_FONT_ID))); + subtitle->add_font (make_shared<Font> (TEXT_FONT_ID)); } string diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index 7144f70d5..5e41253b8 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -30,6 +30,7 @@ #include "log.h" #include "safe_stringstream.h" #include "compose.hpp" +#include <boost/make_shared.hpp> #include <iostream> #include <iomanip> @@ -44,6 +45,7 @@ using std::fixed; using std::setprecision; using std::cout; using boost::shared_ptr; +using boost::make_shared; /** @param s Film to use. */ @@ -90,7 +92,7 @@ TranscodeJob::run () _transcoder.reset (); if (_film->upload_after_make_dcp ()) { - shared_ptr<Job> job (new UploadJob (_film)); + shared_ptr<Job> job = make_shared<UploadJob> (_film); JobManager::instance()->add (job); } diff --git a/src/lib/upmixer_a.cc b/src/lib/upmixer_a.cc index a1221e5ac..e390487d4 100644 --- a/src/lib/upmixer_a.cc +++ b/src/lib/upmixer_a.cc @@ -21,6 +21,7 @@ #include "upmixer_a.h" #include "audio_buffers.h" #include "audio_mapping.h" +#include <boost/make_shared.hpp> #include "i18n.h" @@ -28,6 +29,7 @@ using std::string; using std::min; using std::vector; using boost::shared_ptr; +using boost::make_shared; UpmixerA::UpmixerA (int sampling_rate) : _left (0.02, 1900.0 / sampling_rate, 4800.0 / sampling_rate) @@ -61,7 +63,7 @@ UpmixerA::out_channels () const shared_ptr<AudioProcessor> UpmixerA::clone (int sampling_rate) const { - return shared_ptr<AudioProcessor> (new UpmixerA (sampling_rate)); + return make_shared<UpmixerA> (sampling_rate); } shared_ptr<AudioBuffers> @@ -85,7 +87,7 @@ UpmixerA::run (shared_ptr<const AudioBuffers> in, int channels) all_out.push_back (_ls.run (in_L)); all_out.push_back (_rs.run (in_R)); - shared_ptr<AudioBuffers> out (new AudioBuffers (channels, in->frames ())); + shared_ptr<AudioBuffers> out = make_shared<AudioBuffers> (channels, in->frames ()); int const N = min (channels, 6); for (int i = 0; i < N; ++i) { diff --git a/src/lib/upmixer_b.cc b/src/lib/upmixer_b.cc index 90e1267cd..65452424a 100644 --- a/src/lib/upmixer_b.cc +++ b/src/lib/upmixer_b.cc @@ -21,6 +21,7 @@ #include "upmixer_b.h" #include "audio_buffers.h" #include "audio_mapping.h" +#include <boost/make_shared.hpp> #include "i18n.h" @@ -28,6 +29,7 @@ using std::string; using std::min; using std::vector; using boost::shared_ptr; +using boost::make_shared; UpmixerB::UpmixerB (int sampling_rate) : _lfe (0.01, 150.0 / sampling_rate) @@ -58,13 +60,13 @@ UpmixerB::out_channels () const 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())); + shared_ptr<AudioBuffers> out = make_shared<AudioBuffers> (channels, in->frames()); /* L + R minus 6dB (in terms of amplitude) */ shared_ptr<AudioBuffers> in_LR = in->channel(0); @@ -94,7 +96,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())); + shared_ptr<AudioBuffers> 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); diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index a59e9669d..ae6cb64dd 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -83,6 +83,7 @@ VideoContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version) return shared_ptr<VideoContent> (); } + /* Can't use make_shared here as the constructor is private */ return shared_ptr<VideoContent> (new VideoContent (parent, node, version)); } diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index edc746010..fbc8de9ae 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -25,6 +25,7 @@ #include "log.h" #include "compose.hpp" #include <boost/foreach.hpp> +#include <boost/make_shared.hpp> #include <iostream> #include "i18n.h" @@ -34,6 +35,7 @@ using std::list; using std::max; using std::back_inserter; using boost::shared_ptr; +using boost::make_shared; using boost::optional; VideoDecoder::VideoDecoder (Decoder* parent, shared_ptr<const Content> c, shared_ptr<Log> log) @@ -166,7 +168,7 @@ VideoDecoder::fill_one_eye (Frame from, Frame to, Eyes eye) } /* Fill with black... */ - shared_ptr<const ImageProxy> filler_image (new RawImageProxy (_black_image)); + shared_ptr<const ImageProxy> filler_image = make_shared<RawImageProxy> (_black_image); Part filler_part = PART_WHOLE; /* ...unless there's some video we can fill with */ @@ -192,8 +194,8 @@ void VideoDecoder::fill_both_eyes (VideoFrame from, VideoFrame to) { /* Fill with black... */ - shared_ptr<const ImageProxy> filler_left_image (new RawImageProxy (_black_image)); - shared_ptr<const ImageProxy> filler_right_image (new RawImageProxy (_black_image)); + shared_ptr<const ImageProxy> filler_left_image = make_shared<RawImageProxy> (_black_image); + shared_ptr<const ImageProxy> filler_right_image = make_shared<RawImageProxy> (_black_image); Part filler_left_part = PART_WHOLE; Part filler_right_part = PART_WHOLE; diff --git a/src/lib/video_filter_graph.cc b/src/lib/video_filter_graph.cc index 201150560..b6b3c2668 100644 --- a/src/lib/video_filter_graph.cc +++ b/src/lib/video_filter_graph.cc @@ -25,6 +25,7 @@ extern "C" { #include <libavfilter/buffersrc.h> #include <libavfilter/buffersink.h> } +#include <boost/make_shared.hpp> #include "i18n.h" @@ -34,6 +35,7 @@ using std::vector; using std::string; using std::make_pair; using boost::shared_ptr; +using boost::make_shared; VideoFilterGraph::VideoFilterGraph (dcp::Size s, AVPixelFormat p) : _size (s) @@ -51,7 +53,7 @@ VideoFilterGraph::process (AVFrame* frame) list<pair<shared_ptr<Image>, int64_t> > images; if (_copy) { - images.push_back (make_pair (shared_ptr<Image> (new Image (frame)), av_frame_get_best_effort_timestamp (frame))); + images.push_back (make_pair (make_shared<Image> (frame), av_frame_get_best_effort_timestamp (frame))); } else { int r = av_buffersrc_write_frame (_buffer_src_context, frame); if (r < 0) { @@ -63,7 +65,7 @@ VideoFilterGraph::process (AVFrame* frame) break; } - images.push_back (make_pair (shared_ptr<Image> (new Image (_frame)), av_frame_get_best_effort_timestamp (_frame))); + images.push_back (make_pair (make_shared<Image> (_frame), av_frame_get_best_effort_timestamp (_frame))); av_frame_unref (_frame); } } @@ -117,4 +119,3 @@ VideoFilterGraph::sink_name () const { return "buffersink"; } - diff --git a/src/lib/video_mxf_content.cc b/src/lib/video_mxf_content.cc index d86fc4cf6..f5fab485e 100644 --- a/src/lib/video_mxf_content.cc +++ b/src/lib/video_mxf_content.cc @@ -28,12 +28,14 @@ #include <dcp/stereo_picture_asset.h> #include <dcp/exceptions.h> #include <libxml++/libxml++.h> +#include <boost/make_shared.hpp> #include "i18n.h" using std::list; using std::string; using boost::shared_ptr; +using boost::make_shared; VideoMXFContent::VideoMXFContent (shared_ptr<const Film> film, boost::filesystem::path path) : Content (film, path) @@ -51,7 +53,7 @@ bool VideoMXFContent::valid_mxf (boost::filesystem::path path) { try { - shared_ptr<dcp::MonoPictureAsset> mp (new dcp::MonoPictureAsset (path)); + shared_ptr<dcp::MonoPictureAsset> mp = make_shared<dcp::MonoPictureAsset> (path); return true; } catch (dcp::MXFFileError& e) { @@ -60,7 +62,7 @@ VideoMXFContent::valid_mxf (boost::filesystem::path path) } try { - shared_ptr<dcp::StereoPictureAsset> sp (new dcp::StereoPictureAsset (path)); + shared_ptr<dcp::StereoPictureAsset> sp = make_shared<dcp::StereoPictureAsset> (path); return true; } catch (dcp::MXFFileError& e) { @@ -79,7 +81,7 @@ VideoMXFContent::examine (shared_ptr<Job> job) Content::examine (job); video.reset (new VideoContent (this)); - shared_ptr<VideoMXFExaminer> examiner (new VideoMXFExaminer (shared_from_this ())); + shared_ptr<VideoMXFExaminer> examiner = make_shared<VideoMXFExaminer> (shared_from_this ()); video->take_from_examiner (examiner); } diff --git a/src/lib/video_mxf_decoder.cc b/src/lib/video_mxf_decoder.cc index 938d7deaf..24f5c31ea 100644 --- a/src/lib/video_mxf_decoder.cc +++ b/src/lib/video_mxf_decoder.cc @@ -27,8 +27,10 @@ #include <dcp/stereo_picture_asset.h> #include <dcp/stereo_picture_asset_reader.h> #include <dcp/exceptions.h> +#include <boost/make_shared.hpp> using boost::shared_ptr; +using boost::make_shared; VideoMXFDecoder::VideoMXFDecoder (shared_ptr<const VideoMXFContent> content, shared_ptr<Log> log) : _content (content) @@ -77,10 +79,10 @@ VideoMXFDecoder::pass (PassReason, bool) } if (_mono_reader) { - video->give (shared_ptr<ImageProxy> (new J2KImageProxy (_mono_reader->get_frame(frame), _size)), frame); + video->give (make_shared<J2KImageProxy> (_mono_reader->get_frame(frame), _size), frame); } else { - video->give (shared_ptr<ImageProxy> (new J2KImageProxy (_stereo_reader->get_frame(frame), _size, dcp::EYE_LEFT)), frame); - video->give (shared_ptr<ImageProxy> (new J2KImageProxy (_stereo_reader->get_frame(frame), _size, dcp::EYE_RIGHT)), frame); + video->give (make_shared<J2KImageProxy> (_stereo_reader->get_frame(frame), _size, dcp::EYE_LEFT), frame); + video->give (make_shared<J2KImageProxy> (_stereo_reader->get_frame(frame), _size, dcp::EYE_RIGHT), frame); } _next += ContentTime::from_frames (1, vfr); |
