X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fffmpeg_content.cc;h=2c42cf579cbbb1a11b2a8916531d050010f9e5ca;hb=444809fb888ed99803f2d19c94d3faef067cf348;hp=ac62ac7f44870e6b979ced49e8bfa6f82e69cc16;hpb=a332bd6be323f03dad5b180fb237afe54f1bf81e;p=dcpomatic.git diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index ac62ac7f4..2c42cf579 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2019 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -41,7 +41,6 @@ extern "C" { #include } #include -#include #include #include "i18n.h" @@ -53,8 +52,9 @@ using std::cout; using std::pair; using std::make_pair; using std::max; -using boost::shared_ptr; -using boost::dynamic_pointer_cast; +using std::make_shared; +using std::shared_ptr; +using std::dynamic_pointer_cast; using boost::optional; using dcp::raw_convert; using namespace dcpomatic; @@ -74,7 +74,7 @@ template optional get_optional_enum (cxml::ConstNodePtr node, string name) { - optional const v = node->optional_number_child(name); + auto const v = node->optional_number_child(name); if (!v) { return optional(); } @@ -88,35 +88,32 @@ FFmpegContent::FFmpegContent (cxml::ConstNodePtr node, int version, list audio = AudioContent::from_xml (this, node, version); text = TextContent::from_xml (this, node, version); - list c = node->node_children ("SubtitleStream"); - for (list::const_iterator i = c.begin(); i != c.end(); ++i) { - _subtitle_streams.push_back (shared_ptr (new FFmpegSubtitleStream (*i, version))); - if ((*i)->optional_number_child ("Selected")) { + for (auto i: node->node_children("SubtitleStream")) { + _subtitle_streams.push_back (make_shared(i, version)); + if (i->optional_number_child("Selected")) { _subtitle_stream = _subtitle_streams.back (); } } - c = node->node_children ("AudioStream"); - for (list::const_iterator i = c.begin(); i != c.end(); ++i) { - shared_ptr as (new FFmpegAudioStream (*i, version)); + for (auto i: node->node_children("AudioStream")) { + auto as = make_shared(i, version); audio->add_stream (as); - if (version < 11 && !(*i)->optional_node_child ("Selected")) { + if (version < 11 && !i->optional_node_child ("Selected")) { /* This is an old file and this stream is not selected, so un-map it */ as->set_mapping (AudioMapping (as->channels (), MAX_DCP_AUDIO_CHANNELS)); } } - c = node->node_children ("Filter"); - for (list::iterator i = c.begin(); i != c.end(); ++i) { - Filter const * f = Filter::from_id ((*i)->content ()); + for (auto i: node->node_children("Filter")) { + Filter const * f = Filter::from_id(i->content()); if (f) { _filters.push_back (f); } else { - notes.push_back (String::compose (_("DCP-o-matic no longer supports the `%1' filter, so it has been turned off."), (*i)->content())); + notes.push_back (String::compose (_("DCP-o-matic no longer supports the `%1' filter, so it has been turned off."), i->content())); } } - optional const f = node->optional_number_child ("FirstVideo"); + auto const f = node->optional_number_child ("FirstVideo"); if (f) { _first_video = ContentTime (f.get ()); } @@ -131,7 +128,7 @@ FFmpegContent::FFmpegContent (cxml::ConstNodePtr node, int version, list FFmpegContent::FFmpegContent (vector > c) : Content (c) { - vector >::const_iterator i = c.begin (); + auto i = c.begin (); bool need_video = false; bool need_audio = false; @@ -157,20 +154,20 @@ FFmpegContent::FFmpegContent (vector > c) } if (need_video) { - video.reset (new VideoContent (this, c)); + video = make_shared(this, c); } if (need_audio) { - audio.reset (new AudioContent (this, c)); + audio = make_shared(this, c); } if (need_text) { - text.push_back (shared_ptr (new TextContent (this, c))); + text.push_back (make_shared(this, c)); } - shared_ptr ref = dynamic_pointer_cast (c[0]); + auto ref = dynamic_pointer_cast (c[0]); DCPOMATIC_ASSERT (ref); for (size_t i = 0; i < c.size(); ++i) { - shared_ptr fc = dynamic_pointer_cast (c[i]); + auto fc = dynamic_pointer_cast(c[i]); if (fc->only_text() && fc->only_text()->use() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) { throw JoinError (_("Content to be joined must use the same subtitle stream.")); } @@ -202,8 +199,8 @@ FFmpegContent::as_xml (xmlpp::Node* node, bool with_paths) const if (audio) { audio->as_xml (node); - BOOST_FOREACH (AudioStreamPtr i, audio->streams ()) { - shared_ptr f = dynamic_pointer_cast (i); + for (auto i: audio->streams ()) { + auto f = dynamic_pointer_cast (i); DCPOMATIC_ASSERT (f); f->as_xml (node->add_child("AudioStream")); } @@ -215,16 +212,16 @@ FFmpegContent::as_xml (xmlpp::Node* node, bool with_paths) const boost::mutex::scoped_lock lm (_mutex); - for (vector >::const_iterator i = _subtitle_streams.begin(); i != _subtitle_streams.end(); ++i) { - xmlpp::Node* t = node->add_child("SubtitleStream"); - if (_subtitle_stream && *i == _subtitle_stream) { + for (auto i: _subtitle_streams) { + auto t = node->add_child("SubtitleStream"); + if (_subtitle_stream && i == _subtitle_stream) { t->add_child("Selected")->add_child_text("1"); } - (*i)->as_xml (t); + i->as_xml (t); } - for (vector::const_iterator i = _filters.begin(); i != _filters.end(); ++i) { - node->add_child("Filter")->add_child_text ((*i)->id ()); + for (auto i: _filters) { + node->add_child("Filter")->add_child_text(i->id()); } if (_first_video) { @@ -260,14 +257,14 @@ FFmpegContent::examine (shared_ptr film, shared_ptr job) Content::examine (film, job); - shared_ptr examiner (new FFmpegExaminer (shared_from_this (), job)); + auto examiner = make_shared(shared_from_this (), job); if (examiner->has_video ()) { video.reset (new VideoContent (this)); video->take_from_examiner (examiner); } - boost::filesystem::path first_path = path (0); + auto first_path = path (0); { boost::mutex::scoped_lock lm (_mutex); @@ -281,7 +278,7 @@ FFmpegContent::examine (shared_ptr film, shared_ptr job) _bits_per_pixel = examiner->bits_per_pixel (); if (examiner->rotation()) { - double rot = *examiner->rotation (); + auto rot = *examiner->rotation (); if (fabs (rot - 180) < 1.0) { _filters.push_back (Filter::from_id ("vflip")); _filters.push_back (Filter::from_id ("hflip")); @@ -294,14 +291,14 @@ FFmpegContent::examine (shared_ptr film, shared_ptr job) } if (!examiner->audio_streams().empty ()) { - audio.reset (new AudioContent (this)); + audio = make_shared(this); - BOOST_FOREACH (shared_ptr i, examiner->audio_streams ()) { + for (auto i: examiner->audio_streams()) { audio->add_stream (i); } - AudioStreamPtr as = audio->streams().front(); - AudioMapping m = as->mapping (); + auto as = audio->streams().front(); + auto m = as->mapping (); m.make_default (film ? film->audio_processor() : 0, first_path); as->set_mapping (m); } @@ -309,7 +306,7 @@ FFmpegContent::examine (shared_ptr film, shared_ptr job) _subtitle_streams = examiner->subtitle_streams (); if (!_subtitle_streams.empty ()) { text.clear (); - text.push_back (shared_ptr (new TextContent (this, TEXT_OPEN_SUBTITLE, TEXT_UNKNOWN))); + text.push_back (make_shared(this, TEXT_OPEN_SUBTITLE, TEXT_UNKNOWN)); _subtitle_stream = _subtitle_streams.front (); } } @@ -345,7 +342,7 @@ string FFmpegContent::technical_summary () const { string as = ""; - BOOST_FOREACH (shared_ptr i, ffmpeg_audio_streams ()) { + for (auto i: ffmpeg_audio_streams ()) { as += i->technical_summary () + " " ; } @@ -358,9 +355,9 @@ FFmpegContent::technical_summary () const ss = _subtitle_stream->technical_summary (); } - string filt = Filter::ffmpeg_string (_filters); + auto filt = Filter::ffmpeg_string (_filters); - string s = Content::technical_summary (); + auto s = Content::technical_summary (); if (video) { s += " - " + video->technical_summary (); @@ -408,7 +405,7 @@ FFmpegContent::full_length (shared_ptr film) const if (audio) { DCPTime longest; - BOOST_FOREACH (AudioStreamPtr i, audio->streams()) { + for (auto i: audio->streams()) { longest = max (longest, DCPTime::from_frames(llrint(i->length() / frc.speed_up), i->frame_rate())); } return longest; @@ -429,7 +426,7 @@ FFmpegContent::approximate_length () const DCPOMATIC_ASSERT (audio); Frame longest = 0; - BOOST_FOREACH (AudioStreamPtr i, audio->streams ()) { + for (auto i: audio->streams()) { longest = max (longest, Frame(llrint(i->length()))); } @@ -466,8 +463,8 @@ FFmpegContent::identifier () const s += "_" + _subtitle_stream->identifier (); } - for (vector::const_iterator i = _filters.begin(); i != _filters.end(); ++i) { - s += "_" + (*i)->id (); + for (auto i: _filters) { + s += "_" + i->id(); } return s; @@ -478,7 +475,7 @@ FFmpegContent::set_default_colour_conversion () { DCPOMATIC_ASSERT (video); - dcp::Size const s = video->size (); + auto const s = video->size (); boost::mutex::scoped_lock lm (_mutex); @@ -670,7 +667,7 @@ FFmpegContent::ffmpeg_audio_streams () const vector > fa; if (audio) { - BOOST_FOREACH (AudioStreamPtr i, audio->streams()) { + for (auto i: audio->streams()) { fa.push_back (dynamic_pointer_cast (i)); } } @@ -681,7 +678,7 @@ FFmpegContent::ffmpeg_audio_streams () const void FFmpegContent::take_settings_from (shared_ptr c) { - shared_ptr fc = dynamic_pointer_cast (c); + auto fc = dynamic_pointer_cast (c); if (!fc) { return; }