c++11 tidying.
authorCarl Hetherington <cth@carlh.net>
Fri, 22 Jan 2021 22:50:58 +0000 (23:50 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 22 Jan 2021 22:51:40 +0000 (23:51 +0100)
src/lib/image_decoder.cc
src/lib/job.cc
src/lib/video_content.cc
test/4k_test.cc
test/burnt_subtitle_test.cc
test/silence_padding_test.cc

index d35a0625f01a171c106f1fb89d33108ef2a4dd2e..2f7416c62630eaf740e4039532d71fb87e9d6ea4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -34,6 +34,7 @@
 #include "i18n.h"
 
 using std::cout;
+using std::make_shared;
 using std::shared_ptr;
 using dcp::Size;
 using namespace dcpomatic;
@@ -43,7 +44,7 @@ ImageDecoder::ImageDecoder (shared_ptr<const Film> film, shared_ptr<const ImageC
        , _image_content (c)
        , _frame_video_position (0)
 {
-       video.reset (new VideoDecoder (this, c));
+       video = make_shared<VideoDecoder>(this, c);
 }
 
 bool
@@ -55,7 +56,7 @@ ImageDecoder::pass ()
 
        if (!_image_content->still() || !_image) {
                /* Either we need an image or we are using moving images, so load one */
-               boost::filesystem::path path = _image_content->path (_image_content->still() ? 0 : _frame_video_position);
+               auto path = _image_content->path (_image_content->still() ? 0 : _frame_video_position);
                if (valid_j2k_file (path)) {
                        AVPixelFormat pf;
                        if (_image_content->video->colour_conversion()) {
@@ -68,9 +69,9 @@ ImageDecoder::pass ()
                        /* We can't extract image size from a JPEG2000 codestream without decoding it,
                           so pass in the image content's size here.
                        */
-                       _image.reset (new J2KImageProxy (path, _image_content->video->size(), pf));
+                       _image = make_shared<J2KImageProxy>(path, _image_content->video->size(), pf);
                } else {
-                       _image.reset (new FFmpegImageProxy(path, _image_content->video->range()));
+                       _image = make_shared<FFmpegImageProxy>(path, _image_content->video->range());
                }
        }
 
index f0d8fcbbc1d4554dc920924cfdae43bdb0f4c01a..b1ff0fb32f23f82134fb3b461e4a821cfa5d50ba 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -104,7 +104,7 @@ Job::run_wrapper ()
                string m = String::compose (_("An error occurred whilst handling the file %1."), boost::filesystem::path (e.filename()).leaf());
 
                try {
-                       boost::filesystem::space_info const s = boost::filesystem::space (e.filename());
+                       auto const s = boost::filesystem::space (e.filename());
                        if (s.available < pow (1024, 3)) {
                                m += N_("\n\n");
                                m += _("The drive that the film is stored on is low in disc space.  Free some more space and try again.");
@@ -478,8 +478,8 @@ Job::status () const
                s += buffer;
 
                if (t > 10 && r > 0) {
-                       boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
-                       boost::posix_time::ptime finish = now + boost::posix_time::seconds(r);
+                       auto now = boost::posix_time::second_clock::local_time();
+                       auto finish = now + boost::posix_time::seconds(r);
                        char finish_string[16];
                        snprintf (finish_string, sizeof(finish_string), "%02d:%02d", int(finish.time_of_day().hours()), int(finish.time_of_day().minutes()));
                        string day;
index 4933de71bb0a85fd13acfb670b37fc086f664d62..14e4824679cfaff42a42fa70b0211d25053d384e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -97,7 +97,7 @@ VideoContent::VideoContent (Content* parent, cxml::ConstNodePtr node, int versio
        _size.height = node->number_child<int> ("VideoHeight");
 
        /* Backwards compatibility */
-       optional<double> r = node->optional_number_child<double>("VideoFrameRate");
+       auto r = node->optional_number_child<double>("VideoFrameRate");
        if (r) {
                _parent->set_video_frame_rate (r.get ());
        }
@@ -143,11 +143,11 @@ VideoContent::VideoContent (Content* parent, cxml::ConstNodePtr node, int versio
                        _legacy_ratio = Ratio::from_id(r.get())->ratio();
                }
        } else if (version <= 37) {
-               optional<string> ratio = node->node_child("Scale")->optional_string_child("Ratio");
+               auto ratio = node->node_child("Scale")->optional_string_child("Ratio");
                if (ratio) {
                        _legacy_ratio = Ratio::from_id(ratio.get())->ratio();
                }
-               optional<bool> scale = node->node_child("Scale")->optional_bool_child("Scale");
+               auto scale = node->node_child("Scale")->optional_bool_child("Scale");
                if (scale) {
                        if (*scale) {
                                /* This is what we used to call "no stretch" */
@@ -189,7 +189,7 @@ VideoContent::VideoContent (Content* parent, vector<shared_ptr<Content> > c)
        , _length (0)
        , _yuv (false)
 {
-       shared_ptr<VideoContent> ref = c[0]->video;
+       auto ref = c[0]->video;
        DCPOMATIC_ASSERT (ref);
 
        for (size_t i = 1; i < c.size(); ++i) {
@@ -277,11 +277,11 @@ void
 VideoContent::take_from_examiner (shared_ptr<VideoExaminer> d)
 {
        /* These examiner calls could call other content methods which take a lock on the mutex */
-       dcp::Size const vs = d->video_size ();
-       Frame vl = d->video_length ();
-       optional<double> const ar = d->sample_aspect_ratio ();
-       bool const yuv = d->yuv ();
-       VideoRange const range = d->range ();
+       auto const vs = d->video_size ();
+       auto vl = d->video_length ();
+       auto const ar = d->sample_aspect_ratio ();
+       auto const yuv = d->yuv ();
+       auto const range = d->range ();
 
        ChangeSignaller<Content> cc1 (_parent, VideoContentProperty::SIZE);
        ChangeSignaller<Content> cc2 (_parent, VideoContentProperty::SCALE);
@@ -353,7 +353,7 @@ VideoContent::technical_summary () const
 dcp::Size
 VideoContent::size_after_3d_split () const
 {
-       dcp::Size const s = size ();
+       auto const s = size ();
        switch (frame_type ()) {
        case VIDEO_FRAME_TYPE_2D:
        case VIDEO_FRAME_TYPE_3D:
@@ -388,12 +388,12 @@ VideoContent::fade (shared_ptr<const Film> film, Frame f) const
 
        double const vfr = _parent->active_video_frame_rate(film);
 
-       Frame const ts = _parent->trim_start().frames_round(vfr);
+       auto const ts = _parent->trim_start().frames_round(vfr);
        if ((f - ts) < fade_in()) {
                return double (f - ts) / fade_in();
        }
 
-       Frame fade_out_start = length() - _parent->trim_end().frames_round(vfr) - fade_out();
+       auto fade_out_start = length() - _parent->trim_end().frames_round(vfr) - fade_out();
        if (f >= fade_out_start) {
                return 1 - double (f - fade_out_start) / fade_out();
        }
@@ -438,8 +438,8 @@ VideoContent::processing_description (shared_ptr<const Film> film)
                d += buffer;
        }
 
-       dcp::Size const container_size = film->frame_size ();
-       dcp::Size const scaled = scaled_size (container_size);
+       auto const container_size = film->frame_size ();
+       auto const scaled = scaled_size (container_size);
 
        if (scaled != size_after_crop ()) {
                d += String::compose (
@@ -602,11 +602,11 @@ VideoContent::scaled_size (dcp::Size film_container)
                return *_custom_size;
        }
 
-       dcp::Size size = size_after_crop ();
+       auto size = size_after_crop ();
        size.width *= _sample_aspect_ratio.get_value_or(1);
 
        /* This is what we will return unless there is any legacy stuff to take into account */
-       dcp::Size auto_size = fit_ratio_within (size.ratio(), film_container);
+       auto auto_size = fit_ratio_within (size.ratio(), film_container);
 
        if (_legacy_ratio) {
                if (fit_ratio_within(*_legacy_ratio, film_container) != auto_size) {
index e09aeeb5c4882912f7c0c8feb813537e02ba8542..6c6dea82781cb7bf746d9d6ca308bd3c6e1c06a2 100644 (file)
 #include "test.h"
 
 using std::shared_ptr;
+using std::make_shared;
 
 BOOST_AUTO_TEST_CASE (fourk_test)
 {
-       shared_ptr<Film> film = new_test_film ("4k_test");
+       auto film = new_test_film ("4k_test");
        LogSwitcher ls (film->log());
        film->set_name ("4k_test");
-       shared_ptr<FFmpegContent> c (new FFmpegContent("test/data/test.mp4"));
+       auto c = make_shared<FFmpegContent>("test/data/test.mp4");
        film->set_resolution (RESOLUTION_4K);
        film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
        film->set_container (Ratio::from_id ("185"));
index 4a056dbf70e949af532eb6cbe43eeb9d54bc1e34..edad2c674ea8ae39ff07f6f29f5a2c06d31a692f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -51,16 +51,17 @@ using std::cout;
 using std::map;
 using std::shared_ptr;
 using std::dynamic_pointer_cast;
+using std::make_shared;
 using namespace dcpomatic;
 
 /** Build a small DCP with no picture and a single subtitle overlaid onto it from a SubRip file */
 BOOST_AUTO_TEST_CASE (burnt_subtitle_test_subrip)
 {
-       shared_ptr<Film> film = new_test_film ("burnt_subtitle_test_subrip");
+       auto film = new_test_film ("burnt_subtitle_test_subrip");
        film->set_container (Ratio::from_id ("185"));
        film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
        film->set_name ("frobozz");
-       shared_ptr<StringText> content (new StringText (film, "test/data/subrip2.srt"));
+       auto content = make_shared<StringText>(film, "test/data/subrip2.srt");
        content->subtitle->set_use (true);
        content->subtitle->set_burn (true);
        film->examine_and_add_content (content);
@@ -74,11 +75,11 @@ BOOST_AUTO_TEST_CASE (burnt_subtitle_test_subrip)
 /** Build a small DCP with no picture and a single subtitle overlaid onto it from a DCP XML file */
 BOOST_AUTO_TEST_CASE (burnt_subtitle_test_dcp)
 {
-       shared_ptr<Film> film = new_test_film ("burnt_subtitle_test_dcp");
+       auto film = new_test_film ("burnt_subtitle_test_dcp");
        film->set_container (Ratio::from_id ("185"));
        film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
        film->set_name ("frobozz");
-       shared_ptr<DCPTextContent> content (new DCPTextContent (film, "test/data/dcp_sub.xml"));
+       auto content = make_shared<DCPTextContent>(film, "test/data/dcp_sub.xml");
        content->subtitle->set_use (true);
        film->examine_and_add_content (content);
        BOOST_REQUIRE (!wait_for_jobs());
@@ -91,7 +92,7 @@ BOOST_AUTO_TEST_CASE (burnt_subtitle_test_dcp)
 /** Burn some subtitles into an existing DCP to check the colour conversion */
 BOOST_AUTO_TEST_CASE (burnt_subtitle_test_onto_dcp)
 {
-       shared_ptr<Film> film = new_test_film ("burnt_subtitle_test_onto_dcp");
+       auto film = new_test_film ("burnt_subtitle_test_onto_dcp");
        film->set_container (Ratio::from_id ("185"));
        film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
        film->set_name ("frobozz");
@@ -101,13 +102,13 @@ BOOST_AUTO_TEST_CASE (burnt_subtitle_test_onto_dcp)
        BOOST_REQUIRE (!wait_for_jobs());
 
        Config::instance()->set_log_types (Config::instance()->log_types() | LogEntry::TYPE_DEBUG_ENCODE);
-       shared_ptr<Film> film2 = new_test_film ("burnt_subtitle_test_onto_dcp2");
+       auto film2 = new_test_film ("burnt_subtitle_test_onto_dcp2");
        film2->set_container (Ratio::from_id ("185"));
        film2->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
        film2->set_name ("frobozz");
-       shared_ptr<DCPContent> background_dcp (new DCPContent(film2, film->dir(film->dcp_name())));
+       auto background_dcp = make_shared<DCPContent>(film2, film->dir(film->dcp_name()));
        film2->examine_and_add_content (background_dcp);
-       shared_ptr<StringText> sub = dynamic_pointer_cast<StringText> (
+       auto sub = dynamic_pointer_cast<StringText> (
                content_factory(film2, "test/data/subrip2.srt").front()
                );
        sub->subtitle->set_burn (true);
@@ -126,12 +127,12 @@ BOOST_AUTO_TEST_CASE (burnt_subtitle_test_onto_dcp)
        BOOST_REQUIRE_EQUAL (dcp.cpls().front()->reels().size(), 1);
        BOOST_REQUIRE (dcp.cpls().front()->reels().front()->main_picture());
        BOOST_REQUIRE (dcp.cpls().front()->reels().front()->main_picture()->asset());
-       shared_ptr<const dcp::MonoPictureAsset> pic = dynamic_pointer_cast<dcp::ReelMonoPictureAsset> (
+       auto pic = dynamic_pointer_cast<dcp::ReelMonoPictureAsset> (
                dcp.cpls().front()->reels().front()->main_picture()
                )->mono_asset();
        BOOST_REQUIRE (pic);
-       shared_ptr<const dcp::MonoPictureFrame> frame = pic->start_read()->get_frame (12);
-       shared_ptr<dcp::OpenJPEGImage> xyz = frame->xyz_image ();
+       auto frame = pic->start_read()->get_frame(12);
+       auto xyz = frame->xyz_image ();
        BOOST_CHECK_EQUAL (xyz->size().width, 1998);
        BOOST_CHECK_EQUAL (xyz->size().height, 1080);
 
index e1d893ccba4772c90871137f99286524bfb60aee..11c5bd0d1a17c7ca63cb365ed2e58717426b753b 100644 (file)
 #include <dcp/sound_asset_reader.h>
 #include <boost/test/unit_test.hpp>
 
+using std::make_shared;
 using std::string;
-using boost::lexical_cast;
 using std::shared_ptr;
+using boost::lexical_cast;
 
 static void
 test_silence_padding (int channels)
 {
        string const film_name = "silence_padding_test_" + lexical_cast<string> (channels);
-       shared_ptr<Film> film = new_test_film (film_name);
+       auto film = new_test_film (film_name);
        film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
        film->set_container (Ratio::from_id ("185"));
        film->set_name (film_name);
 
-       shared_ptr<FFmpegContent> content (new FFmpegContent("test/data/staircase.wav"));
+       auto content = make_shared<FFmpegContent>("test/data/staircase.wav");
        film->examine_and_add_content (content);
        BOOST_REQUIRE (!wait_for_jobs());
 
@@ -64,7 +65,7 @@ test_silence_padding (int channels)
        dcp::DCP check (path.string ());
        check.read ();
 
-       shared_ptr<const dcp::ReelSoundAsset> sound_asset = check.cpls().front()->reels().front()->main_sound ();
+       auto sound_asset = check.cpls()[0]->reels()[0]->main_sound();
        BOOST_CHECK (sound_asset);
        BOOST_CHECK_EQUAL (sound_asset->asset()->channels (), channels);
 
@@ -74,7 +75,7 @@ test_silence_padding (int channels)
        int frame = 0;
 
        while (n < sound_asset->asset()->intrinsic_duration()) {
-               shared_ptr<const dcp::SoundFrame> sound_frame = sound_asset->asset()->start_read()->get_frame (frame++);
+               auto sound_frame = sound_asset->asset()->start_read()->get_frame(frame++);
                uint8_t const * d = sound_frame->data ();
 
                for (int i = 0; i < sound_frame->size(); i += (3 * sound_asset->asset()->channels())) {
@@ -135,8 +136,8 @@ BOOST_AUTO_TEST_CASE (silence_padding_test)
 
 BOOST_AUTO_TEST_CASE (silence_padding_test2)
 {
-       shared_ptr<Film> film = new_test_film2 ("silence_padding_test2");
-       shared_ptr<FFmpegContent> content (new FFmpegContent(TestPaths::private_data() / "cars.mov"));
+       auto film = new_test_film2 ("silence_padding_test2");
+       auto content = make_shared<FFmpegContent>(TestPaths::private_data() / "cars.mov");
        film->examine_and_add_content (content);
        BOOST_REQUIRE (!wait_for_jobs());