diff options
Diffstat (limited to 'src/lib')
37 files changed, 653 insertions, 598 deletions
diff --git a/src/lib/active_text.cc b/src/lib/active_text.cc index 2a5c4d836..19c17d6a8 100644 --- a/src/lib/active_text.cc +++ b/src/lib/active_text.cc @@ -54,15 +54,15 @@ ActiveText::operator=(ActiveText&& other) * @param always_burn_captions Always burn captions even if their content is not set to burn. */ list<PlayerText> -ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const +ActiveText::get_burnt(DCPTimePeriod period, bool always_burn_captions) const { - boost::mutex::scoped_lock lm (_mutex); + boost::mutex::scoped_lock lm(_mutex); list<PlayerText> ps; for (auto const& i: _data) { - auto caption = i.first.lock (); + auto caption = i.first.lock(); if (!caption) { continue; } @@ -73,10 +73,10 @@ ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const } for (auto j: i.second) { - DCPTimePeriod test (j.from, j.to.get_value_or(DCPTime::max())); - auto overlap = period.overlap (test); + DCPTimePeriod test(j.from, j.to.get_value_or(DCPTime::max())); + auto overlap = period.overlap(test); if (overlap && overlap->duration() > DCPTime(period.duration().get() / 2)) { - ps.push_back (j.subs); + ps.push_back(j.subs); } } } @@ -89,19 +89,19 @@ ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const * @param time Time to remove before. */ void -ActiveText::clear_before (DCPTime time) +ActiveText::clear_before(DCPTime time) { - boost::mutex::scoped_lock lm (_mutex); + boost::mutex::scoped_lock lm(_mutex); Map updated; for (auto const& i: _data) { list<Period> as; for (auto j: i.second) { if (!j.to || j.to.get() >= time) { - as.push_back (j); + as.push_back(j); } } - if (!as.empty ()) { + if (!as.empty()) { updated[i.first] = as; } } @@ -115,14 +115,14 @@ ActiveText::clear_before (DCPTime time) * @param from From time for these subtitles. */ void -ActiveText::add_from (weak_ptr<const TextContent> content, PlayerText ps, DCPTime from) +ActiveText::add_from(weak_ptr<const TextContent> content, PlayerText ps, DCPTime from) { - boost::mutex::scoped_lock lm (_mutex); + boost::mutex::scoped_lock lm(_mutex); if (_data.find(content) == _data.end()) { _data[content] = list<Period>(); } - _data[content].push_back (Period (ps, from)); + _data[content].push_back(Period(ps, from)); } @@ -132,19 +132,19 @@ ActiveText::add_from (weak_ptr<const TextContent> content, PlayerText ps, DCPTim * @return Return the corresponding subtitles and their from time. */ pair<PlayerText, DCPTime> -ActiveText::add_to (weak_ptr<const TextContent> content, DCPTime to) +ActiveText::add_to(weak_ptr<const TextContent> content, DCPTime to) { - boost::mutex::scoped_lock lm (_mutex); + boost::mutex::scoped_lock lm(_mutex); - DCPOMATIC_ASSERT (_data.find(content) != _data.end()); + DCPOMATIC_ASSERT(_data.find(content) != _data.end()); _data[content].back().to = to; for (auto& i: _data[content].back().subs.string) { - i.set_out (dcp::Time(to.seconds(), 1000)); + i.set_out(dcp::Time(to.seconds(), 1000)); } - return make_pair (_data[content].back().subs, _data[content].back().from); + return make_pair(_data[content].back().subs, _data[content].back().from); } @@ -152,9 +152,9 @@ ActiveText::add_to (weak_ptr<const TextContent> content, DCPTime to) * @return true if we have any active subtitles from this content. */ bool -ActiveText::have (weak_ptr<const TextContent> content) const +ActiveText::have(weak_ptr<const TextContent> content) const { - boost::mutex::scoped_lock lm (_mutex); + boost::mutex::scoped_lock lm(_mutex); auto i = _data.find(content); if (i == _data.end()) { @@ -166,8 +166,8 @@ ActiveText::have (weak_ptr<const TextContent> content) const void -ActiveText::clear () +ActiveText::clear() { - boost::mutex::scoped_lock lm (_mutex); - _data.clear (); + boost::mutex::scoped_lock lm(_mutex); + _data.clear(); } diff --git a/src/lib/active_text.h b/src/lib/active_text.h index 5430f9681..edbe23242 100644 --- a/src/lib/active_text.h +++ b/src/lib/active_text.h @@ -40,30 +40,30 @@ class TextContent; class ActiveText { public: - ActiveText () {} + ActiveText() {} - ActiveText (ActiveText const&) = delete; - ActiveText& operator= (ActiveText const&) = delete; + ActiveText(ActiveText const&) = delete; + ActiveText& operator=(ActiveText const&) = delete; ActiveText(ActiveText&& other); ActiveText& operator=(ActiveText&& other); - std::list<PlayerText> get_burnt (dcpomatic::DCPTimePeriod period, bool always_burn_captions) const; - void clear_before (dcpomatic::DCPTime time); - void clear (); - void add_from (std::weak_ptr<const TextContent> content, PlayerText ps, dcpomatic::DCPTime from); - std::pair<PlayerText, dcpomatic::DCPTime> add_to (std::weak_ptr<const TextContent> content, dcpomatic::DCPTime to); - bool have (std::weak_ptr<const TextContent> content) const; + std::list<PlayerText> get_burnt(dcpomatic::DCPTimePeriod period, bool always_burn_captions) const; + void clear_before(dcpomatic::DCPTime time); + void clear(); + void add_from(std::weak_ptr<const TextContent> content, PlayerText ps, dcpomatic::DCPTime from); + std::pair<PlayerText, dcpomatic::DCPTime> add_to(std::weak_ptr<const TextContent> content, dcpomatic::DCPTime to); + bool have(std::weak_ptr<const TextContent> content) const; private: class Period { public: - Period () {} + Period() {} - Period (PlayerText s, dcpomatic::DCPTime f) - : subs (s) - , from (f) + Period(PlayerText s, dcpomatic::DCPTime f) + : subs(s) + , from(f) {} PlayerText subs; diff --git a/src/lib/analyse_subtitles_job.cc b/src/lib/analyse_subtitles_job.cc index 66db25f04..c30ff0c30 100644 --- a/src/lib/analyse_subtitles_job.cc +++ b/src/lib/analyse_subtitles_job.cc @@ -42,10 +42,10 @@ using namespace boost::placeholders; #endif -AnalyseSubtitlesJob::AnalyseSubtitlesJob (shared_ptr<const Film> film, shared_ptr<Content> content) - : Job (film) - , _content (content) - , _path (_film->subtitle_analysis_path(content)) +AnalyseSubtitlesJob::AnalyseSubtitlesJob(shared_ptr<const Film> film, shared_ptr<Content> content) + : Job(film) + , _content(content) + , _path(_film->subtitle_analysis_path(content)) { } @@ -57,46 +57,46 @@ AnalyseSubtitlesJob::~AnalyseSubtitlesJob() string -AnalyseSubtitlesJob::name () const +AnalyseSubtitlesJob::name() const { return _("Analysing subtitles"); } string -AnalyseSubtitlesJob::json_name () const +AnalyseSubtitlesJob::json_name() const { return N_("analyse_subtitles"); } void -AnalyseSubtitlesJob::run () +AnalyseSubtitlesJob::run() { auto playlist = make_shared<Playlist>(); - auto content = _content.lock (); - DCPOMATIC_ASSERT (content); - playlist->add (_film, content); + auto content = _content.lock(); + DCPOMATIC_ASSERT(content); + playlist->add(_film, content); auto player = make_shared<Player>(_film, playlist, false); - player->set_ignore_audio (); - player->set_fast (); - player->set_play_referenced (); - player->Text.connect (bind(&AnalyseSubtitlesJob::analyse, this, _1, _2)); + player->set_ignore_audio(); + player->set_fast(); + player->set_play_referenced(); + player->Text.connect(bind(&AnalyseSubtitlesJob::analyse, this, _1, _2)); - set_progress_unknown (); + set_progress_unknown(); if (!content->text.empty()) { - while (!player->pass ()) { + while (!player->pass()) { boost::this_thread::interruption_point(); } } - SubtitleAnalysis analysis (_bounding_box, content->text.front()->x_offset(), content->text.front()->y_offset()); - analysis.write (_path); + SubtitleAnalysis analysis(_bounding_box, content->text.front()->x_offset(), content->text.front()->y_offset()); + analysis.write(_path); - set_progress (1); - set_state (FINISHED_OK); + set_progress(1); + set_state(FINISHED_OK); } @@ -111,7 +111,7 @@ AnalyseSubtitlesJob::analyse(PlayerText const& text, TextType type) if (!_bounding_box) { _bounding_box = i.rectangle; } else { - _bounding_box->extend (i.rectangle); + _bounding_box->extend(i.rectangle); } } @@ -139,14 +139,14 @@ AnalyseSubtitlesJob::analyse(PlayerText const& text, TextType type) for (auto standard: override_standard) { for (auto i: bounding_box(text.string, frame, standard)) { - dcpomatic::Rect<double> rect ( + dcpomatic::Rect<double> rect( double(i.x) / frame.width, double(i.y) / frame.height, double(i.width) / frame.width, double(i.height) / frame.height ); if (!_bounding_box) { _bounding_box = rect; } else { - _bounding_box->extend (rect); + _bounding_box->extend(rect); } } } diff --git a/src/lib/analyse_subtitles_job.h b/src/lib/analyse_subtitles_job.h index ea425763f..bb6aa3f31 100644 --- a/src/lib/analyse_subtitles_job.h +++ b/src/lib/analyse_subtitles_job.h @@ -31,14 +31,14 @@ class Content; class AnalyseSubtitlesJob : public Job { public: - AnalyseSubtitlesJob (std::shared_ptr<const Film> film, std::shared_ptr<Content> content); + AnalyseSubtitlesJob(std::shared_ptr<const Film> film, std::shared_ptr<Content> content); ~AnalyseSubtitlesJob(); - std::string name () const override; - std::string json_name () const override; - void run () override; + std::string name() const override; + std::string json_name() const override; + void run() override; - boost::filesystem::path path () const { + boost::filesystem::path path() const { return _path; } diff --git a/src/lib/audio_mapping.cc b/src/lib/audio_mapping.cc index 939a03414..4e13d1adb 100644 --- a/src/lib/audio_mapping.cc +++ b/src/lib/audio_mapping.cc @@ -54,26 +54,26 @@ using dcp::raw_convert; * @param input_channels Number of input channels. * @param output_channels Number of output channels. */ -AudioMapping::AudioMapping (int input_channels, int output_channels) +AudioMapping::AudioMapping(int input_channels, int output_channels) { - setup (input_channels, output_channels); + setup(input_channels, output_channels); } void -AudioMapping::setup (int input_channels, int output_channels) +AudioMapping::setup(int input_channels, int output_channels) { _gain.resize(input_channels); for (int i = 0; i < input_channels; ++i) { _gain[i].resize(output_channels); } - make_zero (); + make_zero(); } void -AudioMapping::make_zero () +AudioMapping::make_zero() { for (auto& input: _gain) { for (auto& output: input) { @@ -85,9 +85,9 @@ AudioMapping::make_zero () struct ChannelRegex { - ChannelRegex (string regex_, int channel_) - : regex (regex_) - , channel (channel_) + ChannelRegex(string regex_, int channel_) + : regex(regex_) + , channel(channel_) {} string regex; @@ -96,7 +96,7 @@ struct ChannelRegex void -AudioMapping::make_default (AudioProcessor const * processor, optional<boost::filesystem::path> filename) +AudioMapping::make_default(AudioProcessor const * processor, optional<boost::filesystem::path> filename) { static ChannelRegex const regex[] = { ChannelRegex(".*[\\._-]L[\\._-].*", 0), @@ -117,18 +117,18 @@ AudioMapping::make_default (AudioProcessor const * processor, optional<boost::fi static int const regexes = sizeof(regex) / sizeof(*regex); if (processor) { - processor->make_audio_mapping_default (*this); + processor->make_audio_mapping_default(*this); } else { - make_zero (); + make_zero(); if (input_channels() == 1) { bool guessed = false; /* See if we can guess where this stream should go */ if (filename) { for (int i = 0; i < regexes; ++i) { - boost::regex e (regex[i].regex, boost::regex::icase); + boost::regex e(regex[i].regex, boost::regex::icase); if (boost::regex_match(filename->filename().string(), e) && regex[i].channel < output_channels()) { - set (0, regex[i].channel, 1); + set(0, regex[i].channel, 1); guessed = true; } } @@ -136,41 +136,41 @@ AudioMapping::make_default (AudioProcessor const * processor, optional<boost::fi if (!guessed) { /* If we have no idea, just put it on centre */ - set (0, static_cast<int>(dcp::Channel::CENTRE), 1); + set(0, static_cast<int>(dcp::Channel::CENTRE), 1); } } else { /* 1:1 mapping */ - for (int i = 0; i < min (input_channels(), output_channels()); ++i) { - set (i, i, 1); + for (int i = 0; i < min(input_channels(), output_channels()); ++i) { + set(i, i, 1); } } } } -AudioMapping::AudioMapping (cxml::ConstNodePtr node, int state_version) +AudioMapping::AudioMapping(cxml::ConstNodePtr node, int state_version) { if (state_version < 32) { - setup (node->number_child<int>("ContentChannels"), MAX_DCP_AUDIO_CHANNELS); + setup(node->number_child<int>("ContentChannels"), MAX_DCP_AUDIO_CHANNELS); } else { - setup (node->number_child<int>("InputChannels"), node->number_child<int>("OutputChannels")); + setup(node->number_child<int>("InputChannels"), node->number_child<int>("OutputChannels")); } if (state_version <= 5) { /* Old-style: on/off mapping */ - for (auto i: node->node_children ("Map")) { - set (i->number_child<int>("ContentIndex"), i->number_child<int>("DCP"), 1); + for (auto i: node->node_children("Map")) { + set(i->number_child<int>("ContentIndex"), i->number_child<int>("DCP"), 1); } } else { for (auto i: node->node_children("Gain")) { if (state_version < 32) { - set ( + set( i->number_attribute<int>("Content"), i->number_attribute<int>("DCP"), raw_convert<float>(i->content()) ); } else { - set ( + set( number_attribute<int>(i, "Input", "input"), number_attribute<int>(i, "Output", "output"), raw_convert<float>(i->content()) @@ -182,40 +182,40 @@ AudioMapping::AudioMapping (cxml::ConstNodePtr node, int state_version) void -AudioMapping::set (dcp::Channel input_channel, int output_channel, float g) +AudioMapping::set(dcp::Channel input_channel, int output_channel, float g) { - set (static_cast<int>(input_channel), output_channel, g); + set(static_cast<int>(input_channel), output_channel, g); } void -AudioMapping::set (int input_channel, dcp::Channel output_channel, float g) +AudioMapping::set(int input_channel, dcp::Channel output_channel, float g) { - set (input_channel, static_cast<int>(output_channel), g); + set(input_channel, static_cast<int>(output_channel), g); } void -AudioMapping::set (int input_channel, int output_channel, float g) +AudioMapping::set(int input_channel, int output_channel, float g) { - DCPOMATIC_ASSERT (input_channel < int(_gain.size())); - DCPOMATIC_ASSERT (output_channel < int(_gain[0].size())); + DCPOMATIC_ASSERT(input_channel < int(_gain.size())); + DCPOMATIC_ASSERT(output_channel < int(_gain[0].size())); _gain[input_channel][output_channel] = g; } float -AudioMapping::get (int input_channel, dcp::Channel output_channel) const +AudioMapping::get(int input_channel, dcp::Channel output_channel) const { - return get (input_channel, static_cast<int>(output_channel)); + return get(input_channel, static_cast<int>(output_channel)); } float -AudioMapping::get (int input_channel, int output_channel) const +AudioMapping::get(int input_channel, int output_channel) const { - DCPOMATIC_ASSERT (input_channel < int (_gain.size())); - DCPOMATIC_ASSERT (output_channel < int (_gain[0].size())); + DCPOMATIC_ASSERT(input_channel < int(_gain.size())); + DCPOMATIC_ASSERT(output_channel < int(_gain[0].size())); return _gain[input_channel][output_channel]; } @@ -244,7 +244,7 @@ AudioMapping::as_xml(xmlpp::Element* element) const * differentiation between different AudioMappings. */ string -AudioMapping::digest () const +AudioMapping::digest() const { Digester digester; digester.add(input_channels()); @@ -255,12 +255,12 @@ AudioMapping::digest () const } } - return digester.get (); + return digester.get(); } list<int> -AudioMapping::mapped_output_channels () const +AudioMapping::mapped_output_channels() const { static float const minus_96_db = 0.000015849; @@ -269,20 +269,20 @@ AudioMapping::mapped_output_channels () const for (auto const& i: _gain) { for (auto j: dcp::used_audio_channels()) { if (abs(i[static_cast<int>(j)]) > minus_96_db) { - mapped.push_back (static_cast<int>(j)); + mapped.push_back(static_cast<int>(j)); } } } - mapped.sort (); - mapped.unique (); + mapped.sort(); + mapped.unique(); return mapped; } void -AudioMapping::unmap_all () +AudioMapping::unmap_all() { for (auto& i: _gain) { for (auto& j: i) { diff --git a/src/lib/audio_mapping.h b/src/lib/audio_mapping.h index 68487d908..0dc80193b 100644 --- a/src/lib/audio_mapping.h +++ b/src/lib/audio_mapping.h @@ -46,40 +46,40 @@ class AudioProcessor; class AudioMapping { public: - AudioMapping () {} - AudioMapping (int input_channels, int output_channels); - AudioMapping (cxml::ConstNodePtr, int); + AudioMapping() {} + AudioMapping(int input_channels, int output_channels); + AudioMapping(cxml::ConstNodePtr, int); /* Default copy constructor is fine */ void as_xml(xmlpp::Element*) const; - void make_zero (); - void make_default (AudioProcessor const * processor, boost::optional<boost::filesystem::path> filename = boost::optional<boost::filesystem::path>()); + void make_zero(); + void make_default(AudioProcessor const * processor, boost::optional<boost::filesystem::path> filename = boost::optional<boost::filesystem::path>()); - void set (dcp::Channel input_channel, int output_channel, float); - void set (int input_channel, int output_channel, float); - void set (int input_channel, dcp::Channel output_channel, float); - float get (int input_channel, int output_channel) const; - float get (int input_channel, dcp::Channel output_channel) const; + void set(dcp::Channel input_channel, int output_channel, float); + void set(int input_channel, int output_channel, float); + void set(int input_channel, dcp::Channel output_channel, float); + float get(int input_channel, int output_channel) const; + float get(int input_channel, dcp::Channel output_channel) const; - int input_channels () const { + int input_channels() const { return _gain.size(); } - int output_channels () const { + int output_channels() const { return _gain.empty() ? 0 : _gain[0].size(); } - std::string digest () const; + std::string digest() const; - std::list<int> mapped_output_channels () const; - void unmap_all (); + std::list<int> mapped_output_channels() const; + void unmap_all(); void take_from(AudioMapping const& other); private: - void setup (int input_channels, int output_channels); + void setup(int input_channels, int output_channels); /** Linear gains */ std::vector<std::vector<float>> _gain; diff --git a/src/lib/cinema_sound_processor.cc b/src/lib/cinema_sound_processor.cc index 434fdd1cf..2ddbb9086 100644 --- a/src/lib/cinema_sound_processor.cc +++ b/src/lib/cinema_sound_processor.cc @@ -42,12 +42,12 @@ vector<unique_ptr<const CinemaSoundProcessor>> CinemaSoundProcessor::_cinema_sou /** @param i Our id. * @param n User-visible name. */ -CinemaSoundProcessor::CinemaSoundProcessor (string i, string n, float knee, float below, float above) - : _id (i) - , _name (n) - , _knee (knee) - , _below (below) - , _above (above) +CinemaSoundProcessor::CinemaSoundProcessor(string i, string n, float knee, float below, float above) + : _id(i) + , _name(n) + , _knee(knee) + , _below(below) + , _above(above) { } @@ -55,11 +55,11 @@ CinemaSoundProcessor::CinemaSoundProcessor (string i, string n, float knee, floa /** @return All available sound processors */ vector<CinemaSoundProcessor const *> -CinemaSoundProcessor::all () +CinemaSoundProcessor::all() { vector<CinemaSoundProcessor const *> raw; for (auto& processor: _cinema_sound_processors) { - raw.push_back (processor.get()); + raw.push_back(processor.get()); } return raw; } @@ -69,11 +69,11 @@ CinemaSoundProcessor::all () * methods are used. */ void -CinemaSoundProcessor::setup_cinema_sound_processors () +CinemaSoundProcessor::setup_cinema_sound_processors() { - _cinema_sound_processors.push_back (unique_ptr<CinemaSoundProcessor>(new DolbyCP750)); - _cinema_sound_processors.push_back (unique_ptr<CinemaSoundProcessor>(new USL)); - _cinema_sound_processors.push_back (unique_ptr<CinemaSoundProcessor>(new DatasatAP2x)); + _cinema_sound_processors.push_back(unique_ptr<CinemaSoundProcessor>(new DolbyCP750)); + _cinema_sound_processors.push_back(unique_ptr<CinemaSoundProcessor>(new USL)); + _cinema_sound_processors.push_back(unique_ptr<CinemaSoundProcessor>(new DatasatAP2x)); } @@ -81,14 +81,14 @@ CinemaSoundProcessor::setup_cinema_sound_processors () * @return Corresponding sound processor, or 0. */ CinemaSoundProcessor const * -CinemaSoundProcessor::from_id (string id) +CinemaSoundProcessor::from_id(string id) { - auto i = _cinema_sound_processors.begin (); + auto i = _cinema_sound_processors.begin(); while (i != _cinema_sound_processors.end() && (*i)->id() != id) { ++i; } - if (i == _cinema_sound_processors.end ()) { + if (i == _cinema_sound_processors.end()) { return nullptr; } @@ -100,36 +100,36 @@ CinemaSoundProcessor::from_id (string id) * @return Corresponding sound processor. */ CinemaSoundProcessor const * -CinemaSoundProcessor::from_index (int i) +CinemaSoundProcessor::from_index(int i) { - DCPOMATIC_ASSERT (i >= 0 && i < int(_cinema_sound_processors.size())); + DCPOMATIC_ASSERT(i >= 0 && i < int(_cinema_sound_processors.size())); return _cinema_sound_processors[i].get(); } float -CinemaSoundProcessor::db_for_fader_change (float from, float to) const +CinemaSoundProcessor::db_for_fader_change(float from, float to) const { float db = 0; if (from < to) { if (from <= _knee) { - float const t = min (to, _knee); + float const t = min(to, _knee); db += (t - from) * _below; } if (to > 4) { - float const t = max (from, _knee); + float const t = max(from, _knee); db += (to - t) * _above; } } else { if (from >= _knee) { - float const t = max (to, _knee); + float const t = max(to, _knee); db -= (from - t) * _above; } if (to < _knee) { - float const t = min (from, _knee); + float const t = min(from, _knee); db -= (t - to) * _below; } } diff --git a/src/lib/cinema_sound_processor.h b/src/lib/cinema_sound_processor.h index 3ccaa5c9b..411a70366 100644 --- a/src/lib/cinema_sound_processor.h +++ b/src/lib/cinema_sound_processor.h @@ -43,28 +43,28 @@ class CinemaSoundProcessor { public: - CinemaSoundProcessor (std::string i, std::string n, float knee, float below, float above); - virtual ~CinemaSoundProcessor () {} + CinemaSoundProcessor(std::string i, std::string n, float knee, float below, float above); + virtual ~CinemaSoundProcessor() {} - CinemaSoundProcessor (CinemaSoundProcessor const&) = delete; + CinemaSoundProcessor(CinemaSoundProcessor const&) = delete; CinemaSoundProcessor& operator=(CinemaSoundProcessor const&) = delete; - float db_for_fader_change (float from, float to) const; + float db_for_fader_change(float from, float to) const; /** @return id for our use */ - std::string id () const { + std::string id() const { return _id; } /** @return user-visible name for this sound processor */ - std::string name () const { + std::string name() const { return _name; } - static std::vector<CinemaSoundProcessor const *> all (); - static void setup_cinema_sound_processors (); - static CinemaSoundProcessor const * from_id (std::string id); - static CinemaSoundProcessor const * from_index (int); + static std::vector<CinemaSoundProcessor const *> all(); + static void setup_cinema_sound_processors(); + static CinemaSoundProcessor const * from_id(std::string id); + static CinemaSoundProcessor const * from_index(int); private: /** id for our use */ diff --git a/src/lib/create_cli.cc b/src/lib/create_cli.cc index 32834be23..3ef61fe11 100644 --- a/src/lib/create_cli.cc +++ b/src/lib/create_cli.cc @@ -85,6 +85,8 @@ help() " --left-eye next piece of content is for the left eye\n" " --right-eye next piece of content is for the right eye\n" " --auto-crop next piece of content should be auto-cropped\n" + " --fill-crop next piece of content should be cropped to fit the container\n" + " (e.g. to crop the letterboxing from a scope-in-flat image)\n" " --colourspace next piece of content is in the given colourspace: " + colour_conversions + "\n" " --colorspace same as --colourspace\n" " --channel <channel> next piece of content should be mapped to audio channel L, R, C, Lfe, Ls, Rs, BsL, BsR, HI, VI\n" @@ -184,6 +186,7 @@ CreateCLI::CreateCLI(int argc, char* argv[]) optional<string> next_colour_conversion; auto next_frame_type = VideoFrameType::TWO_D; auto next_auto_crop = false; + auto next_fill_crop = false; optional<dcp::Channel> channel; optional<float> gain; optional<float> fade_in; @@ -225,6 +228,9 @@ CreateCLI::CreateCLI(int argc, char* argv[]) } else if (a == "--auto-crop") { next_auto_crop = true; claimed = true; + } else if (a == "--fill-crop") { + next_fill_crop = true; + claimed = true; } else if (a == "--twok") { _twok = true; claimed = true; @@ -331,6 +337,7 @@ CreateCLI::CreateCLI(int argc, char* argv[]) c.path = a; c.frame_type = next_frame_type; c.auto_crop = next_auto_crop; + c.fill_crop = next_fill_crop; c.colour_conversion = next_colour_conversion; c.channel = channel; c.gain = gain; @@ -341,6 +348,7 @@ CreateCLI::CreateCLI(int argc, char* argv[]) content.push_back(c); next_frame_type = VideoFrameType::TWO_D; next_auto_crop = false; + next_fill_crop = false; next_colour_conversion = {}; channel = {}; gain = {}; @@ -555,6 +563,30 @@ CreateCLI::make_film(function<void (string)> error) const video->set_crop(crop); } + if (cli_content.fill_crop && video->size()) { + auto const source_ratio = video->size()->ratio(); + Crop crop; + if (source_ratio < film->container().ratio()) { + /* Part to extract is wider than the source */ + auto const height = video->size()->width / film->container().ratio(); + crop.top = crop.bottom = (video->size()->height - height) / 2; + } else { + /* Container is wider than the source */ + auto const width = video->size()->height * film->container().ratio(); + crop.left = crop.right = (video->size()->width - width) / 2; + } + + error(fmt::format( + "Cropped {} to {} left, {} right, {} top and {} bottom", + film_content->path(0).string(), + crop.left, + crop.right, + crop.top, + crop.bottom + )); + + video->set_crop(crop); + } if (cli_content.colour_conversion) { video->set_colour_conversion(PresetColourConversion::from_id(*cli_content.colour_conversion).conversion); } diff --git a/src/lib/create_cli.h b/src/lib/create_cli.h index 00abf85e5..cde8598cd 100644 --- a/src/lib/create_cli.h +++ b/src/lib/create_cli.h @@ -42,6 +42,7 @@ public: boost::filesystem::path path; VideoFrameType frame_type = VideoFrameType::TWO_D; bool auto_crop = false; + bool fill_crop = false; boost::optional<std::string> colour_conversion; boost::optional<dcp::Channel> channel; boost::optional<float> gain; diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc index 21159fcac..ac8c4245b 100644 --- a/src/lib/dcp_subtitle_content.cc +++ b/src/lib/dcp_subtitle_content.cc @@ -38,22 +38,25 @@ using std::list; using std::make_shared; using std::shared_ptr; using std::string; +using std::vector; using boost::optional; using namespace dcpomatic; -DCPSubtitleContent::DCPSubtitleContent (boost::filesystem::path path) - : Content (path) +DCPSubtitleContent::DCPSubtitleContent(boost::filesystem::path path) + : Content(path) { - text.push_back (make_shared<TextContent>(this, TextType::OPEN_SUBTITLE, TextType::OPEN_SUBTITLE)); + text = vector<shared_ptr<TextContent>>{make_shared<TextContent>(this, TextType::OPEN_SUBTITLE, TextType::OPEN_SUBTITLE)}; + /* Default to turning these subtitles on */ + only_text()->set_use(true); } DCPSubtitleContent::DCPSubtitleContent(cxml::ConstNodePtr node, boost::optional<boost::filesystem::path> film_directory, int version) - : Content (node, film_directory) - , _length (node->number_child<ContentTime::Type> ("Length")) + : Content(node, film_directory) + , _length(node->number_child<ContentTime::Type>("Length")) { list<string> notes; - text = TextContent::from_xml (this, node, version, notes); + text = TextContent::from_xml(this, node, version, notes); } void @@ -63,20 +66,16 @@ DCPSubtitleContent::examine(shared_ptr<const Film> film, shared_ptr<Job> job, bo auto subtitle_asset = load(path(0)); - auto iop = dynamic_pointer_cast<dcp::InteropTextAsset>(subtitle_asset); - auto smpte = dynamic_pointer_cast<dcp::SMPTETextAsset>(subtitle_asset); - if (smpte) { + if (auto smpte = dynamic_pointer_cast<dcp::SMPTETextAsset>(subtitle_asset)) { set_video_frame_rate(film, smpte->edit_rate().numerator); } - boost::mutex::scoped_lock lm (_mutex); - - /* Default to turning these subtitles on */ - only_text()->set_use (true); + boost::mutex::scoped_lock lm(_mutex); _length = ContentTime::from_seconds(subtitle_asset->latest_text_out().as_seconds()); subtitle_asset->fix_empty_font_ids(); + only_text()->clear_fonts(); add_fonts(only_text(), subtitle_asset); } @@ -115,26 +114,26 @@ DCPSubtitleContent::add_fonts(shared_ptr<TextContent> content, shared_ptr<dcp::T DCPTime -DCPSubtitleContent::full_length (shared_ptr<const Film> film) const +DCPSubtitleContent::full_length(shared_ptr<const Film> film) const { - FrameRateChange const frc (film, shared_from_this()); - return DCPTime (_length, frc); + FrameRateChange const frc(film, shared_from_this()); + return DCPTime(_length, frc); } DCPTime -DCPSubtitleContent::approximate_length () const +DCPSubtitleContent::approximate_length() const { - return DCPTime (_length, FrameRateChange()); + return DCPTime(_length, FrameRateChange()); } string -DCPSubtitleContent::summary () const +DCPSubtitleContent::summary() const { return path_summary() + " " + _("[subtitles]"); } string -DCPSubtitleContent::technical_summary () const +DCPSubtitleContent::technical_summary() const { return Content::technical_summary() + " - " + _("DCP XML subtitles"); } diff --git a/src/lib/dcp_subtitle_content.h b/src/lib/dcp_subtitle_content.h index dde3139a8..5b1c8426d 100644 --- a/src/lib/dcp_subtitle_content.h +++ b/src/lib/dcp_subtitle_content.h @@ -24,12 +24,12 @@ class DCPSubtitleContent : public DCPSubtitle, public Content { public: - DCPSubtitleContent (boost::filesystem::path); - DCPSubtitleContent (cxml::ConstNodePtr, boost::optional<boost::filesystem::path> film_directory, int); + DCPSubtitleContent(boost::filesystem::path); + DCPSubtitleContent(cxml::ConstNodePtr, boost::optional<boost::filesystem::path> film_directory, int); - void examine (std::shared_ptr<const Film> film, std::shared_ptr<Job>, bool tolerant) override; - std::string summary () const override; - std::string technical_summary () const override; + void examine(std::shared_ptr<const Film> film, std::shared_ptr<Job>, bool tolerant) override; + std::string summary() const override; + std::string technical_summary() const override; void as_xml( xmlpp::Element* element, @@ -38,8 +38,8 @@ public: boost::optional<boost::filesystem::path> film_directory ) const override; - dcpomatic::DCPTime full_length (std::shared_ptr<const Film> film) const override; - dcpomatic::DCPTime approximate_length () const override; + dcpomatic::DCPTime full_length(std::shared_ptr<const Film> film) const override; + dcpomatic::DCPTime approximate_length() const override; private: void add_fonts(std::shared_ptr<TextContent> content, std::shared_ptr<dcp::TextAsset> subtitle_asset); diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc index 775298091..66f4a3c4c 100644 --- a/src/lib/dcp_video.cc +++ b/src/lib/dcp_video.cc @@ -135,16 +135,32 @@ DCPVideo::get_size() const void DCPVideo::convert_to_xyz(uint16_t* dst) const { - DCPOMATIC_ASSERT(_frame->colour_conversion()); + auto conversion = [](AVPixelFormat fmt) { + return fmt == AV_PIX_FMT_XYZ12LE ? AV_PIX_FMT_XYZ12LE : AV_PIX_FMT_RGB48LE; + }; - auto image = _frame->image(force(AV_PIX_FMT_RGB48LE), VideoRange::FULL, false); - dcp::rgb_to_xyz( - image->data()[0], - dst, - image->size(), - image->stride()[0], - _frame->colour_conversion().get() - ); + auto image = _frame->image(conversion, VideoRange::FULL, false); + + if (_frame->colour_conversion()) { + dcp::rgb_to_xyz( + image->data()[0], + dst, + image->size(), + image->stride()[0], + _frame->colour_conversion().get() + ); + } else { + auto const size = image->size(); + auto const row_bytes = static_cast<size_t>(size.width) * 3 * sizeof(uint16_t); + auto src = image->data()[0]; + auto const src_stride = image->stride()[0]; + auto out = reinterpret_cast<uint8_t*>(dst); + for (int y = 0; y < size.height; ++y) { + memcpy(out, src, row_bytes); + src += src_stride; + out += row_bytes; + } + } } diff --git a/src/lib/dcpomatic_socket.cc b/src/lib/dcpomatic_socket.cc index d3bfbc309..876fa47d3 100644 --- a/src/lib/dcpomatic_socket.cc +++ b/src/lib/dcpomatic_socket.cc @@ -50,7 +50,11 @@ Socket::Socket (int timeout) void Socket::check () { +#if BOOST_VERSION >= 108700 if (_deadline.expiry() <= std::chrono::system_clock::now()) { +#else + if (_deadline.expires_at() <= std::chrono::system_clock::now()) { +#endif _socket.close(); _deadline.expires_at(std::chrono::time_point<std::chrono::system_clock>::max()); } @@ -321,7 +325,11 @@ Socket::set_send_buffer_size (int size) void Socket::set_deadline_from_now(int seconds) { +#if BOOST_VERSION >= 108700 _deadline.expires_after(std::chrono::seconds(seconds)); +#else + _deadline.expires_from_now(std::chrono::seconds(seconds)); +#endif } void diff --git a/src/lib/encode_server_finder.cc b/src/lib/encode_server_finder.cc index d2ecd03b7..a873b258a 100644 --- a/src/lib/encode_server_finder.cc +++ b/src/lib/encode_server_finder.cc @@ -54,69 +54,69 @@ using namespace boost::placeholders; EncodeServerFinder* EncodeServerFinder::_instance = 0; -EncodeServerFinder::EncodeServerFinder () - : _stop (false) +EncodeServerFinder::EncodeServerFinder() + : _stop(false) { - Config::instance()->Changed.connect (boost::bind (&EncodeServerFinder::config_changed, this, _1)); + Config::instance()->Changed.connect(boost::bind(&EncodeServerFinder::config_changed, this, _1)); } void -EncodeServerFinder::start () +EncodeServerFinder::start() { - _search_thread = boost::thread (boost::bind(&EncodeServerFinder::search_thread, this)); - _listen_thread = boost::thread (boost::bind(&EncodeServerFinder::listen_thread, this)); + _search_thread = boost::thread(boost::bind(&EncodeServerFinder::search_thread, this)); + _listen_thread = boost::thread(boost::bind(&EncodeServerFinder::listen_thread, this)); #ifdef DCPOMATIC_LINUX - pthread_setname_np (_search_thread.native_handle(), "encode-server-search"); - pthread_setname_np (_listen_thread.native_handle(), "encode-server-listen"); + pthread_setname_np(_search_thread.native_handle(), "encode-server-search"); + pthread_setname_np(_listen_thread.native_handle(), "encode-server-listen"); #endif } -EncodeServerFinder::~EncodeServerFinder () +EncodeServerFinder::~EncodeServerFinder() { - stop (); + stop(); } void -EncodeServerFinder::stop () +EncodeServerFinder::stop() { boost::this_thread::disable_interruption dis; _stop = true; - _search_condition.notify_all (); + _search_condition.notify_all(); try { _search_thread.join(); } catch (...) {} _listen_io_context.stop(); try { - _listen_thread.join (); + _listen_thread.join(); } catch (...) {} - boost::mutex::scoped_lock lm (_servers_mutex); - _servers.clear (); + boost::mutex::scoped_lock lm(_servers_mutex); + _servers.clear(); } void -EncodeServerFinder::search_thread () +EncodeServerFinder::search_thread() try { - start_of_thread ("EncodeServerFinder-search"); + start_of_thread("EncodeServerFinder-search"); boost::system::error_code error; dcpomatic::io_context io_context; boost::asio::ip::udp::socket socket(io_context); - socket.open (boost::asio::ip::udp::v4(), error); + socket.open(boost::asio::ip::udp::v4(), error); if (error) { - throw NetworkError ("failed to set up broadcast socket"); + throw NetworkError("failed to set up broadcast socket"); } - socket.set_option (boost::asio::ip::udp::socket::reuse_address(true)); - socket.set_option (boost::asio::socket_base::broadcast(true)); + socket.set_option(boost::asio::ip::udp::socket::reuse_address(true)); + socket.set_option(boost::asio::socket_base::broadcast(true)); string const data = DCPOMATIC_HELLO; int const interval = 10; @@ -125,8 +125,8 @@ try if (Config::instance()->use_any_servers()) { /* Broadcast to look for servers */ try { - boost::asio::ip::udp::endpoint end_point (boost::asio::ip::address_v4::broadcast(), HELLO_PORT); - socket.send_to (boost::asio::buffer(data.c_str(), data.size() + 1), end_point); + boost::asio::ip::udp::endpoint end_point(boost::asio::ip::address_v4::broadcast(), HELLO_PORT); + socket.send_to(boost::asio::buffer(data.c_str(), data.size() + 1), end_point); } catch (...) { } @@ -152,14 +152,14 @@ try /* Discard servers that we haven't seen for a while */ bool removed = false; { - boost::mutex::scoped_lock lm (_servers_mutex); + boost::mutex::scoped_lock lm(_servers_mutex); auto i = _servers.begin(); while (i != _servers.end()) { if (i->last_seen_seconds() > 2 * interval) { auto j = i; ++j; - _servers.erase (i); + _servers.erase(i); i = j; removed = true; } else { @@ -169,49 +169,49 @@ try } if (removed) { - emit (boost::bind(boost::ref(ServersListChanged))); + emit(boost::bind(boost::ref(ServersListChanged))); } - boost::mutex::scoped_lock lm (_search_condition_mutex); - _search_condition.timed_wait (lm, boost::get_system_time() + boost::posix_time::seconds(interval)); + boost::mutex::scoped_lock lm(_search_condition_mutex); + _search_condition.timed_wait(lm, boost::get_system_time() + boost::posix_time::seconds(interval)); } } catch (...) { - store_current (); + store_current(); } void -EncodeServerFinder::listen_thread () +EncodeServerFinder::listen_thread() try { - start_of_thread ("EncodeServerFinder-listen"); + start_of_thread("EncodeServerFinder-listen"); using namespace boost::asio::ip; try { - _listen_acceptor.reset ( + _listen_acceptor.reset( new tcp::acceptor(_listen_io_context, tcp::endpoint(tcp::v4(), is_batch_converter ? BATCH_SERVER_PRESENCE_PORT : MAIN_SERVER_PRESENCE_PORT)) ); } catch (...) { boost::throw_exception(NetworkError(variant::insert_dcpomatic(_("Could not listen for remote encode servers. Perhaps another instance of {} is running.")))); } - start_accept (); + start_accept(); _listen_io_context.run(); } catch (...) { - store_current (); + store_current(); } void -EncodeServerFinder::start_accept () +EncodeServerFinder::start_accept() { _accept_socket = make_shared<Socket>(); - _listen_acceptor->async_accept ( + _listen_acceptor->async_accept( _accept_socket->socket(), boost::bind(&EncodeServerFinder::handle_accept, this, boost::asio::placeholders::error) ); @@ -219,10 +219,10 @@ EncodeServerFinder::start_accept () void -EncodeServerFinder::handle_accept (boost::system::error_code ec) +EncodeServerFinder::handle_accept(boost::system::error_code ec) { if (ec) { - start_accept (); + start_accept(); return; } @@ -230,8 +230,8 @@ EncodeServerFinder::handle_accept (boost::system::error_code ec) try { uint32_t length; - _accept_socket->read (reinterpret_cast<uint8_t*>(&length), sizeof(uint32_t)); - length = ntohl (length); + _accept_socket->read(reinterpret_cast<uint8_t*>(&length), sizeof(uint32_t)); + length = ntohl(length); if (length > 65536) { start_accept(); @@ -239,7 +239,7 @@ EncodeServerFinder::handle_accept (boost::system::error_code ec) } scoped_array<char> buffer(new char[length]); - _accept_socket->read (reinterpret_cast<uint8_t*>(buffer.get()), length); + _accept_socket->read(reinterpret_cast<uint8_t*>(buffer.get()), length); server_available = buffer.get(); } catch (NetworkError&) { /* Maybe the server went away; let's just try again */ @@ -253,7 +253,7 @@ EncodeServerFinder::handle_accept (boost::system::error_code ec) auto const ip = _accept_socket->socket().remote_endpoint().address().to_string(); bool changed = false; { - boost::mutex::scoped_lock lm (_servers_mutex); + boost::mutex::scoped_lock lm(_servers_mutex); auto i = _servers.begin(); while (i != _servers.end() && i->host_name() != ip) { ++i; @@ -262,26 +262,26 @@ EncodeServerFinder::handle_accept (boost::system::error_code ec) if (i != _servers.end()) { i->set_seen(); } else { - EncodeServerDescription sd (ip, xml->number_child<int>("Threads"), xml->optional_number_child<int>("Version").get_value_or(0)); - _servers.push_back (sd); + EncodeServerDescription sd(ip, xml->number_child<int>("Threads"), xml->optional_number_child<int>("Version").get_value_or(0)); + _servers.push_back(sd); changed = true; } } if (changed) { - emit (boost::bind(boost::ref (ServersListChanged))); + emit(boost::bind(boost::ref(ServersListChanged))); } - start_accept (); + start_accept(); } EncodeServerFinder* -EncodeServerFinder::instance () +EncodeServerFinder::instance() { if (!_instance) { - _instance = new EncodeServerFinder (); - _instance->start (); + _instance = new EncodeServerFinder(); + _instance->start(); } return _instance; @@ -289,7 +289,7 @@ EncodeServerFinder::instance () void -EncodeServerFinder::drop () +EncodeServerFinder::drop() { delete _instance; _instance = nullptr; @@ -297,22 +297,22 @@ EncodeServerFinder::drop () list<EncodeServerDescription> -EncodeServerFinder::servers () const +EncodeServerFinder::servers() const { - boost::mutex::scoped_lock lm (_servers_mutex); + boost::mutex::scoped_lock lm(_servers_mutex); return _servers; } void -EncodeServerFinder::config_changed (Config::Property what) +EncodeServerFinder::config_changed(Config::Property what) { if (what == Config::USE_ANY_SERVERS || what == Config::SERVERS) { { - boost::mutex::scoped_lock lm (_servers_mutex); - _servers.clear (); + boost::mutex::scoped_lock lm(_servers_mutex); + _servers.clear(); } - ServersListChanged (); - _search_condition.notify_all (); + ServersListChanged(); + _search_condition.notify_all(); } } diff --git a/src/lib/encode_server_finder.h b/src/lib/encode_server_finder.h index 722786b77..ae83b9609 100644 --- a/src/lib/encode_server_finder.h +++ b/src/lib/encode_server_finder.h @@ -47,28 +47,28 @@ class Socket; class EncodeServerFinder : public Signaller, public ExceptionStore { public: - static EncodeServerFinder* instance (); - static void drop (); + static EncodeServerFinder* instance(); + static void drop(); - std::list<EncodeServerDescription> servers () const; + std::list<EncodeServerDescription> servers() const; /** Emitted whenever the list of servers changes */ boost::signals2::signal<void ()> ServersListChanged; private: - EncodeServerFinder (); - ~EncodeServerFinder (); + EncodeServerFinder(); + ~EncodeServerFinder(); - void start (); - void stop (); + void start(); + void stop(); - void search_thread (); - void listen_thread (); + void search_thread(); + void listen_thread(); - void start_accept (); - void handle_accept (boost::system::error_code ec); + void start_accept(); + void handle_accept(boost::system::error_code ec); - void config_changed (Config::Property what); + void config_changed(Config::Property what); /** Thread to periodically issue broadcasts and requests to find encoding servers */ boost::thread _search_thread; diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index d7c741d09..50e4cf41d 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -54,68 +54,68 @@ using namespace dcpomatic; boost::mutex FFmpeg::_mutex; -FFmpeg::FFmpeg (std::shared_ptr<const FFmpegContent> c) - : _ffmpeg_content (c) +FFmpeg::FFmpeg(std::shared_ptr<const FFmpegContent> c) + : _ffmpeg_content(c) { - setup_general (); - setup_decoders (); + setup_general(); + setup_decoders(); } -FFmpeg::~FFmpeg () +FFmpeg::~FFmpeg() { - boost::mutex::scoped_lock lm (_mutex); + boost::mutex::scoped_lock lm(_mutex); for (auto& i: _codec_context) { - avcodec_free_context (&i); + avcodec_free_context(&i); } - av_frame_free (&_video_frame); + av_frame_free(&_video_frame); for (auto& audio_frame: _audio_frame) { - av_frame_free (&audio_frame.second); + av_frame_free(&audio_frame.second); } - avformat_close_input (&_format_context); + avformat_close_input(&_format_context); } static int -avio_read_wrapper (void* data, uint8_t* buffer, int amount) +avio_read_wrapper(void* data, uint8_t* buffer, int amount) { - return reinterpret_cast<FFmpeg*>(data)->avio_read (buffer, amount); + return reinterpret_cast<FFmpeg*>(data)->avio_read(buffer, amount); } static int64_t -avio_seek_wrapper (void* data, int64_t offset, int whence) +avio_seek_wrapper(void* data, int64_t offset, int whence) { - return reinterpret_cast<FFmpeg*>(data)->avio_seek (offset, whence); + return reinterpret_cast<FFmpeg*>(data)->avio_seek(offset, whence); } void -FFmpeg::setup_general () +FFmpeg::setup_general() { - _file_group.set_paths (_ffmpeg_content->paths ()); - _avio_buffer = static_cast<uint8_t*> (wrapped_av_malloc(_avio_buffer_size)); - _avio_context = avio_alloc_context (_avio_buffer, _avio_buffer_size, 0, this, avio_read_wrapper, 0, avio_seek_wrapper); + _file_group.set_paths(_ffmpeg_content->paths()); + _avio_buffer = static_cast<uint8_t*>(wrapped_av_malloc(_avio_buffer_size)); + _avio_context = avio_alloc_context(_avio_buffer, _avio_buffer_size, 0, this, avio_read_wrapper, 0, avio_seek_wrapper); if (!_avio_context) { - throw std::bad_alloc (); + throw std::bad_alloc(); } - _format_context = avformat_alloc_context (); + _format_context = avformat_alloc_context(); if (!_format_context) { - throw std::bad_alloc (); + throw std::bad_alloc(); } _format_context->pb = _avio_context; AVDictionary* options = nullptr; - int e = avformat_open_input (&_format_context, 0, 0, &options); + int e = avformat_open_input(&_format_context, 0, 0, &options); if (e < 0) { - throw OpenFileError (_ffmpeg_content->path(0).string(), e, OpenFileError::READ); + throw OpenFileError(_ffmpeg_content->path(0).string(), e, OpenFileError::READ); } - if (avformat_find_stream_info (_format_context, 0) < 0) { - throw DecodeError (_("could not find stream information")); + if (avformat_find_stream_info(_format_context, 0) < 0) { + throw DecodeError(_("could not find stream information")); } /* Find video stream */ @@ -147,15 +147,15 @@ FFmpeg::setup_general () _video_stream = video_stream_undefined_frame_rate.get(); } - _video_frame = av_frame_alloc (); + _video_frame = av_frame_alloc(); if (_video_frame == nullptr) { - throw std::bad_alloc (); + throw std::bad_alloc(); } } void -FFmpeg::setup_decoders () +FFmpeg::setup_decoders() { for (uint32_t i = 0; i < _format_context->nb_streams; ++i) { setup_decoder(i); @@ -166,7 +166,7 @@ FFmpeg::setup_decoders () void FFmpeg::setup_decoder(int stream_index) { - boost::mutex::scoped_lock lm (_mutex); + boost::mutex::scoped_lock lm(_mutex); if (stream_index >= static_cast<int>(_codec_context.size())) { _codec_context.resize(stream_index + 1); @@ -211,7 +211,7 @@ FFmpeg::setup_decoder(int stream_index) AVCodecContext * -FFmpeg::video_codec_context () const +FFmpeg::video_codec_context() const { if (!_video_stream) { return nullptr; @@ -222,7 +222,7 @@ FFmpeg::video_codec_context () const AVCodecContext * -FFmpeg::subtitle_codec_context () const +FFmpeg::subtitle_codec_context() const { auto str = _ffmpeg_content->subtitle_stream(); if (!str) { @@ -234,7 +234,7 @@ FFmpeg::subtitle_codec_context () const int -FFmpeg::avio_read (uint8_t* buffer, int const amount) +FFmpeg::avio_read(uint8_t* buffer, int const amount) { auto result = _file_group.read(buffer, amount); if (result.eof && result.bytes_read == 0) { @@ -245,20 +245,20 @@ FFmpeg::avio_read (uint8_t* buffer, int const amount) int64_t -FFmpeg::avio_seek (int64_t const pos, int whence) +FFmpeg::avio_seek(int64_t const pos, int whence) { if (whence == AVSEEK_SIZE) { - return _file_group.length (); + return _file_group.length(); } - return _file_group.seek (pos, whence); + return _file_group.seek(pos, whence); } FFmpegSubtitlePeriod -FFmpeg::subtitle_period (AVPacket const* packet, AVStream const* stream, AVSubtitle const & sub) +FFmpeg::subtitle_period(AVPacket const* packet, AVStream const* stream, AVSubtitle const & sub) { - auto const packet_time = ContentTime::from_seconds (packet->pts * av_q2d(stream->time_base)); + auto const packet_time = ContentTime::from_seconds(packet->pts * av_q2d(stream->time_base)); auto const start = packet_time + ContentTime::from_seconds(sub.start_display_time / 1e3); if (sub.end_display_time == 0 || sub.end_display_time == static_cast<uint32_t>(-1)) { @@ -270,7 +270,7 @@ FFmpeg::subtitle_period (AVPacket const* packet, AVStream const* stream, AVSubti } } - return FFmpegSubtitlePeriod (start, packet_time + ContentTime::from_seconds(sub.end_display_time / 1e3)); + return FFmpegSubtitlePeriod(start, packet_time + ContentTime::from_seconds(sub.end_display_time / 1e3)); } @@ -280,7 +280,7 @@ FFmpeg::subtitle_period (AVPacket const* packet, AVStream const* stream, AVSubti * in FFmpeg. */ ContentTime -FFmpeg::pts_offset (vector<shared_ptr<FFmpegAudioStream>> audio_streams, optional<ContentTime> first_video, double video_frame_rate) const +FFmpeg::pts_offset(vector<shared_ptr<FFmpegAudioStream>> audio_streams, optional<ContentTime> first_video, double video_frame_rate) const { /* Audio and video frame PTS values may not start with 0. We want to fiddle them so that: @@ -298,15 +298,15 @@ FFmpeg::pts_offset (vector<shared_ptr<FFmpegAudioStream>> audio_streams, optiona /* First, make one of them start at 0 */ - auto po = ContentTime::min (); + auto po = ContentTime::min(); if (first_video) { - po = - first_video.get (); + po = - first_video.get(); } for (auto i: audio_streams) { if (i->first_audio) { - po = max (po, - i->first_audio.get ()); + po = max(po, - i->first_audio.get()); } } @@ -316,14 +316,14 @@ FFmpeg::pts_offset (vector<shared_ptr<FFmpegAudioStream>> audio_streams, optiona I don't think we ever want to do that, as it seems things at -ve PTS are not meant to be seen (use for alignment bars etc.); see mantis #418. */ - if (po > ContentTime ()) { - po = ContentTime (); + if (po > ContentTime()) { + po = ContentTime(); } /* Now adjust so that the video pts starts on a frame */ if (first_video) { auto const fvc = first_video.get() + po; - po += fvc.ceil (video_frame_rate) - fvc; + po += fvc.ceil(video_frame_rate) - fvc; } return po; @@ -331,14 +331,14 @@ FFmpeg::pts_offset (vector<shared_ptr<FFmpegAudioStream>> audio_streams, optiona AVFrame * -FFmpeg::audio_frame (shared_ptr<const FFmpegAudioStream> stream) +FFmpeg::audio_frame(shared_ptr<const FFmpegAudioStream> stream) { auto iter = _audio_frame.find(stream); if (iter != _audio_frame.end()) { return iter->second; } - auto frame = av_frame_alloc (); + auto frame = av_frame_alloc(); if (frame == nullptr) { throw std::bad_alloc(); } diff --git a/src/lib/ffmpeg.h b/src/lib/ffmpeg.h index 63446e5cd..f64f7c7bc 100644 --- a/src/lib/ffmpeg.h +++ b/src/lib/ffmpeg.h @@ -47,25 +47,25 @@ class Log; class FFmpeg { public: - explicit FFmpeg (std::shared_ptr<const FFmpegContent>); - virtual ~FFmpeg (); + explicit FFmpeg(std::shared_ptr<const FFmpegContent>); + virtual ~FFmpeg(); - std::shared_ptr<const FFmpegContent> ffmpeg_content () const { + std::shared_ptr<const FFmpegContent> ffmpeg_content() const { return _ffmpeg_content; } - int avio_read (uint8_t *, int); - int64_t avio_seek (int64_t, int); + int avio_read(uint8_t *, int); + int64_t avio_seek(int64_t, int); protected: - AVCodecContext* video_codec_context () const; - AVCodecContext* subtitle_codec_context () const; - dcpomatic::ContentTime pts_offset ( + AVCodecContext* video_codec_context() const; + AVCodecContext* subtitle_codec_context() const; + dcpomatic::ContentTime pts_offset( std::vector<std::shared_ptr<FFmpegAudioStream>> audio_streams, boost::optional<dcpomatic::ContentTime> first_video, double video_frame_rate ) const; void setup_decoder(int stream_index); - static FFmpegSubtitlePeriod subtitle_period (AVPacket const* packet, AVStream const* stream, AVSubtitle const & sub); + static FFmpegSubtitlePeriod subtitle_period(AVPacket const* packet, AVStream const* stream, AVSubtitle const & sub); std::shared_ptr<const FFmpegContent> _ffmpeg_content; @@ -82,7 +82,7 @@ protected: /** Index of video stream within AVFormatContext */ boost::optional<int> _video_stream; - AVFrame* audio_frame (std::shared_ptr<const FFmpegAudioStream> stream); + AVFrame* audio_frame(std::shared_ptr<const FFmpegAudioStream> stream); /* It would appear (though not completely verified) that one must have a mutex around calls to avcodec_open* and avcodec_close... and here @@ -91,8 +91,8 @@ protected: static boost::mutex _mutex; private: - void setup_general (); - void setup_decoders (); + void setup_general(); + void setup_decoders(); /** AVFrames used for decoding audio streams; accessed with audio_frame() */ std::map<std::shared_ptr<const FFmpegAudioStream>, AVFrame*> _audio_frame; diff --git a/src/lib/file_group.cc b/src/lib/file_group.cc index 8ff684ed3..44ebe5075 100644 --- a/src/lib/file_group.cc +++ b/src/lib/file_group.cc @@ -37,42 +37,42 @@ using std::vector; /** Construct a FileGroup with no files */ -FileGroup::FileGroup () +FileGroup::FileGroup() { } /** Construct a FileGroup with a single file */ -FileGroup::FileGroup (boost::filesystem::path p) +FileGroup::FileGroup(boost::filesystem::path p) { - _paths.push_back (p); - ensure_open_path (0); - seek (0, SEEK_SET); + _paths.push_back(p); + ensure_open_path(0); + seek(0, SEEK_SET); } /** Construct a FileGroup with multiple files */ -FileGroup::FileGroup (vector<boost::filesystem::path> const & p) - : _paths (p) +FileGroup::FileGroup(vector<boost::filesystem::path> const & p) + : _paths(p) { - ensure_open_path (0); - seek (0, SEEK_SET); + ensure_open_path(0); + seek(0, SEEK_SET); } void -FileGroup::set_paths (vector<boost::filesystem::path> const & p) +FileGroup::set_paths(vector<boost::filesystem::path> const & p) { _paths = p; - ensure_open_path (0); - seek (0, SEEK_SET); + ensure_open_path(0); + seek(0, SEEK_SET); } /** Ensure that the given path index in the content is the _current_file */ void -FileGroup::ensure_open_path (size_t p) const +FileGroup::ensure_open_path(size_t p) const { if (_current_file && _current_path == p) { /* Already open */ @@ -95,7 +95,7 @@ FileGroup::ensure_open_path (size_t p) const int64_t -FileGroup::seek (int64_t pos, int whence) const +FileGroup::seek(int64_t pos, int whence) const { switch (whence) { case SEEK_SET: @@ -122,10 +122,10 @@ FileGroup::seek (int64_t pos, int whence) const } if (i < _paths.size()) { - ensure_open_path (i); + ensure_open_path(i); _current_file->seek(sub_pos, SEEK_SET); } else { - ensure_open_path (_paths.size() - 1); + ensure_open_path(_paths.size() - 1); _current_file->seek(_current_size, SEEK_SET); } @@ -138,9 +138,9 @@ FileGroup::seek (int64_t pos, int whence) const * @param amount Number of bytes to read. */ FileGroup::Result -FileGroup::read (uint8_t* buffer, int amount) const +FileGroup::read(uint8_t* buffer, int amount) const { - DCPOMATIC_ASSERT (_current_file); + DCPOMATIC_ASSERT(_current_file); int read = 0; while (true) { @@ -148,7 +148,7 @@ FileGroup::read (uint8_t* buffer, int amount) const bool eof = false; size_t to_read = amount - read; - DCPOMATIC_ASSERT (_current_file); + DCPOMATIC_ASSERT(_current_file); auto const current_position = _current_file->tell(); if (current_position == -1) { @@ -168,7 +168,7 @@ FileGroup::read (uint8_t* buffer, int amount) const } if (_current_file->error()) { - throw FileError (fmt::format("fread error {}", errno), _paths[_current_path]); + throw FileError(fmt::format("fread error {}", errno), _paths[_current_path]); } if (eof) { @@ -176,7 +176,7 @@ FileGroup::read (uint8_t* buffer, int amount) const if ((_current_path + 1) >= _paths.size()) { return { read, true }; } - ensure_open_path (_current_path + 1); + ensure_open_path(_current_path + 1); } } @@ -186,7 +186,7 @@ FileGroup::read (uint8_t* buffer, int amount) const /** @return Combined length of all the files */ int64_t -FileGroup::length () const +FileGroup::length() const { int64_t len = 0; for (size_t i = 0; i < _paths.size(); ++i) { diff --git a/src/lib/file_group.h b/src/lib/file_group.h index aac72c228..c16b50f89 100644 --- a/src/lib/file_group.h +++ b/src/lib/file_group.h @@ -40,14 +40,14 @@ class FileGroup { public: - FileGroup (); - explicit FileGroup (boost::filesystem::path); - explicit FileGroup (std::vector<boost::filesystem::path> const &); + FileGroup(); + explicit FileGroup(boost::filesystem::path); + explicit FileGroup(std::vector<boost::filesystem::path> const &); - FileGroup (FileGroup const&) = delete; - FileGroup& operator= (FileGroup const&) = delete; + FileGroup(FileGroup const&) = delete; + FileGroup& operator=(FileGroup const&) = delete; - void set_paths (std::vector<boost::filesystem::path> const &); + void set_paths(std::vector<boost::filesystem::path> const &); struct Result { Result(int bytes_read_, bool eof_) @@ -59,12 +59,12 @@ public: bool eof = false; }; - int64_t seek (int64_t, int) const; - Result read (uint8_t*, int) const; - int64_t length () const; + int64_t seek(int64_t, int) const; + Result read(uint8_t*, int) const; + int64_t length() const; private: - void ensure_open_path (size_t) const; + void ensure_open_path(size_t) const; std::vector<boost::filesystem::path> _paths; /** Index of path that we are currently reading from */ diff --git a/src/lib/hints.cc b/src/lib/hints.cc index 35eb640d4..90b88a6ef 100644 --- a/src/lib/hints.cc +++ b/src/lib/hints.cc @@ -44,16 +44,19 @@ #include <fmt/format.h> #include <boost/algorithm/string.hpp> #include <iostream> +#include <numeric> #include "i18n.h" using std::cout; using std::make_shared; +using std::map; using std::max; using std::shared_ptr; using std::string; using std::weak_ptr; +using std::vector; using boost::optional; using namespace dcpomatic; #if BOOST_VERSION >= 106100 @@ -584,24 +587,42 @@ Hints::text(PlayerText text, TextType type, optional<DCPTextTrack> track, DCPTim void Hints::closed_caption(PlayerText text, DCPTimePeriod period) { - int lines = text.string.size(); - for (auto i: text.string) { - if (utf8_strlen(i.text()) > MAX_CLOSED_CAPTION_LENGTH) { - ++lines; - if (!_long_ccap) { - _long_ccap = true; - hint( - fmt::format( - "At least one of your closed caption lines has more than {} characters. " - "It is advisable to make each line {} characters at most in length.", - MAX_CLOSED_CAPTION_LENGTH, - MAX_CLOSED_CAPTION_LENGTH) - ); + map<float, vector<StringText>> lines; + for (auto const& line: text.string) { + bool added = false; + for (auto& existing: lines) { + if (std::abs(existing.first - line.v_position()) < dcp::ALIGN_EPSILON) { + existing.second.push_back(line); + added = true; } } + if (!added) { + lines[line.v_position()] = { line }; + } + } + + for (auto const& line: lines) { + int const length = std::accumulate( + line.second.begin(), + line.second.end(), + 0, + [](int acc, StringText const& text) { + return acc + dcp::utf8_strlen(text.text()); + }); + + if (length > MAX_CLOSED_CAPTION_LENGTH && !_long_ccap) { + _long_ccap = true; + hint( + fmt::format( + "At least one of your closed caption lines has more than {} characters. " + "It is advisable to make each line {} characters at most in length.", + MAX_CLOSED_CAPTION_LENGTH, + MAX_CLOSED_CAPTION_LENGTH) + ); + } } - if (!_too_many_ccap_lines && lines > MAX_CLOSED_CAPTION_LINES) { + if (!_too_many_ccap_lines && lines.size() > MAX_CLOSED_CAPTION_LINES) { hint(fmt::format(_("Some of your closed captions span more than {} lines, so they will be truncated."), MAX_CLOSED_CAPTION_LINES)); _too_many_ccap_lines = true; } diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index 8d3092196..4e9eff237 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -46,33 +46,33 @@ using boost::optional; using namespace dcpomatic; -ImageContent::ImageContent (boost::filesystem::path p) +ImageContent::ImageContent(boost::filesystem::path p) { video = make_shared<VideoContent>(this); if (dcp::filesystem::is_regular_file(p) && valid_image_file(p)) { - add_path (p); + add_path(p); } else { _path_to_scan = p; } - set_default_colour_conversion (); + set_default_colour_conversion(); } ImageContent::ImageContent(cxml::ConstNodePtr node, boost::optional<boost::filesystem::path> film_directory, int version) : Content(node, film_directory) { - video = VideoContent::from_xml (this, node, version, VideoRange::FULL); + video = VideoContent::from_xml(this, node, version, VideoRange::FULL); } string -ImageContent::summary () const +ImageContent::summary() const { - string s = path_summary () + " "; + string s = path_summary() + " "; /* Get the string() here so that the name does not have quotes around it */ - if (still ()) { + if (still()) { s += _("[still]"); } else { s += _("[moving images]"); @@ -83,12 +83,12 @@ ImageContent::summary () const string -ImageContent::technical_summary () const +ImageContent::technical_summary() const { string s = Content::technical_summary() + " - " + video->technical_summary() + " - "; - if (still ()) { + if (still()) { s += _("still"); } else { s += _("moving"); @@ -114,92 +114,92 @@ void ImageContent::examine(shared_ptr<const Film> film, shared_ptr<Job> job, bool tolerant) { if (_path_to_scan) { - job->sub (_("Scanning image files")); + job->sub(_("Scanning image files")); vector<boost::filesystem::path> paths; int n = 0; for (auto i: dcp::filesystem::directory_iterator(*_path_to_scan)) { if (dcp::filesystem::is_regular_file(i.path()) && valid_image_file(i.path())) { - paths.push_back (i.path()); + paths.push_back(i.path()); } ++n; if ((n % 1000) == 0) { - job->set_progress_unknown (); + job->set_progress_unknown(); } } if (paths.empty()) { - throw FileError (_("No valid image files were found in the folder."), *_path_to_scan); + throw FileError(_("No valid image files were found in the folder."), *_path_to_scan); } - sort (paths.begin(), paths.end(), ImageFilenameSorter()); - set_paths (paths); + sort(paths.begin(), paths.end(), ImageFilenameSorter()); + set_paths(paths); } Content::examine(film, job, tolerant); auto examiner = make_shared<ImageExaminer>(film, shared_from_this(), job); video->take_from_examiner(film, examiner); - set_default_colour_conversion (); + set_default_colour_conversion(); } DCPTime -ImageContent::full_length (shared_ptr<const Film> film) const +ImageContent::full_length(shared_ptr<const Film> film) const { - FrameRateChange const frc (film, shared_from_this()); - return DCPTime::from_frames (llrint(video->length_after_3d_combine() * frc.factor()), film->video_frame_rate()); + FrameRateChange const frc(film, shared_from_this()); + return DCPTime::from_frames(llrint(video->length_after_3d_combine() * frc.factor()), film->video_frame_rate()); } DCPTime -ImageContent::approximate_length () const +ImageContent::approximate_length() const { - return DCPTime::from_frames (video->length_after_3d_combine(), 24); + return DCPTime::from_frames(video->length_after_3d_combine(), 24); } string -ImageContent::identifier () const +ImageContent::identifier() const { char buffer[256]; - snprintf (buffer, sizeof(buffer), "%s_%s_%" PRId64, Content::identifier().c_str(), video->identifier().c_str(), video->length()); + snprintf(buffer, sizeof(buffer), "%s_%s_%" PRId64, Content::identifier().c_str(), video->identifier().c_str(), video->length()); return buffer; } bool -ImageContent::still () const +ImageContent::still() const { return number_of_paths() == 1; } void -ImageContent::set_default_colour_conversion () +ImageContent::set_default_colour_conversion() { for (auto i: paths()) { if (valid_j2k_file (i)) { /* We default to no colour conversion if we have JPEG2000 files */ - video->unset_colour_conversion (); + video->unset_colour_conversion(); return; } } - bool const s = still (); + bool const s = still(); - boost::mutex::scoped_lock lm (_mutex); + boost::mutex::scoped_lock lm(_mutex); if (s) { - video->set_colour_conversion (PresetColourConversion::from_id ("srgb").conversion); + video->set_colour_conversion(PresetColourConversion::from_id("srgb").conversion); } else { - video->set_colour_conversion (PresetColourConversion::from_id ("rec709").conversion); + video->set_colour_conversion(PresetColourConversion::from_id("rec709").conversion); } } void -ImageContent::add_properties (shared_ptr<const Film> film, list<UserProperty>& p) const +ImageContent::add_properties(shared_ptr<const Film> film, list<UserProperty>& p) const { - Content::add_properties (film, p); - video->add_properties (p); + Content::add_properties(film, p); + video->add_properties(p); } diff --git a/src/lib/image_content.h b/src/lib/image_content.h index 4b3b13380..04318ae0d 100644 --- a/src/lib/image_content.h +++ b/src/lib/image_content.h @@ -26,20 +26,20 @@ class ImageContent : public Content { public: - ImageContent (boost::filesystem::path); - ImageContent (cxml::ConstNodePtr, boost::optional<boost::filesystem::path> film_directory, int); + ImageContent(boost::filesystem::path); + ImageContent(cxml::ConstNodePtr, boost::optional<boost::filesystem::path> film_directory, int); - std::shared_ptr<ImageContent> shared_from_this () { - return std::dynamic_pointer_cast<ImageContent> (Content::shared_from_this ()); + std::shared_ptr<ImageContent> shared_from_this() { + return std::dynamic_pointer_cast<ImageContent>(Content::shared_from_this()); }; - std::shared_ptr<const ImageContent> shared_from_this () const { - return std::dynamic_pointer_cast<const ImageContent> (Content::shared_from_this ()); + std::shared_ptr<const ImageContent> shared_from_this() const { + return std::dynamic_pointer_cast<const ImageContent>(Content::shared_from_this()); }; void examine(std::shared_ptr<const Film> film, std::shared_ptr<Job>, bool tolerant) override; - std::string summary () const override; - std::string technical_summary () const override; + std::string summary() const override; + std::string technical_summary() const override; void as_xml( xmlpp::Element* element, @@ -48,17 +48,17 @@ public: boost::optional<boost::filesystem::path> film_directory ) const override; - dcpomatic::DCPTime full_length (std::shared_ptr<const Film> film) const override; - dcpomatic::DCPTime approximate_length () const override; + dcpomatic::DCPTime full_length(std::shared_ptr<const Film> film) const override; + dcpomatic::DCPTime approximate_length() const override; - std::string identifier () const override; + std::string identifier() const override; - void set_default_colour_conversion (); + void set_default_colour_conversion(); - bool still () const; + bool still() const; private: - void add_properties (std::shared_ptr<const Film> film, std::list<UserProperty>& p) const override; + void add_properties(std::shared_ptr<const Film> film, std::list<UserProperty>& p) const override; boost::optional<boost::filesystem::path> _path_to_scan; }; diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index 527a98c7d..29e4a2f07 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -43,16 +43,16 @@ using dcp::Size; using namespace dcpomatic; -ImageDecoder::ImageDecoder (shared_ptr<const Film> film, shared_ptr<const ImageContent> c) - : Decoder (film) - , _image_content (c) +ImageDecoder::ImageDecoder(shared_ptr<const Film> film, shared_ptr<const ImageContent> c) + : Decoder(film) + , _image_content(c) { video = make_shared<VideoDecoder>(this, c); } bool -ImageDecoder::pass () +ImageDecoder::pass() { if (_frame_video_position >= _image_content->video->length()) { return true; @@ -60,8 +60,8 @@ ImageDecoder::pass () if (!_image_content->still() || !_image) { /* Either we need an image or we are using moving images, so load one */ - auto path = _image_content->path (_image_content->still() ? 0 : _frame_video_position); - if (valid_j2k_file (path)) { + 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()) { /* We have a specified colour conversion: assume the image is RGB */ @@ -88,8 +88,8 @@ ImageDecoder::pass () void -ImageDecoder::seek (ContentTime time, bool accurate) +ImageDecoder::seek(ContentTime time, bool accurate) { - Decoder::seek (time, accurate); - _frame_video_position = time.frames_round (_image_content->active_video_frame_rate(film())); + Decoder::seek(time, accurate); + _frame_video_position = time.frames_round(_image_content->active_video_frame_rate(film())); } diff --git a/src/lib/image_decoder.h b/src/lib/image_decoder.h index 41924735c..2b07e6b28 100644 --- a/src/lib/image_decoder.h +++ b/src/lib/image_decoder.h @@ -31,14 +31,14 @@ class ImageProxy; class ImageDecoder : public Decoder { public: - ImageDecoder (std::shared_ptr<const Film> film, std::shared_ptr<const ImageContent> c); + ImageDecoder(std::shared_ptr<const Film> film, std::shared_ptr<const ImageContent> c); - std::shared_ptr<const ImageContent> content () { + std::shared_ptr<const ImageContent> content() { return _image_content; } - bool pass () override; - void seek (dcpomatic::ContentTime, bool) override; + bool pass() override; + void seek(dcpomatic::ContentTime, bool) override; private: diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc index 4a91a103f..f39500781 100644 --- a/src/lib/image_examiner.cc +++ b/src/lib/image_examiner.cc @@ -44,16 +44,16 @@ using std::sort; using boost::optional; -ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const ImageContent> content, shared_ptr<Job>) - : _film (film) - , _image_content (content) +ImageExaminer::ImageExaminer(shared_ptr<const Film> film, shared_ptr<const ImageContent> content, shared_ptr<Job>) + : _film(film) + , _image_content(content) { auto path = content->path(0); - if (valid_j2k_file (path)) { + if (valid_j2k_file(path)) { auto size = dcp::filesystem::file_size(path); dcp::File f(path, "rb"); if (!f) { - throw FileError ("Could not open file for reading", path); + throw FileError("Could not open file for reading", path); } std::vector<uint8_t> buffer(size); f.checked_read(buffer.data(), size); @@ -70,23 +70,23 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag _has_alpha = image.image->has_alpha(); } - if (content->still ()) { - _video_length = Config::instance()->default_still_length() * video_frame_rate().get_value_or (film->video_frame_rate ()); + if (content->still()) { + _video_length = Config::instance()->default_still_length() * video_frame_rate().get_value_or(film->video_frame_rate()); } else { - _video_length = _image_content->number_of_paths (); + _video_length = _image_content->number_of_paths(); } } optional<dcp::Size> -ImageExaminer::video_size () const +ImageExaminer::video_size() const { return _video_size; } optional<double> -ImageExaminer::video_frame_rate () const +ImageExaminer::video_frame_rate() const { if (_image_content->video_frame_rate()) { /* The content already knows what frame rate it should be */ @@ -99,7 +99,7 @@ ImageExaminer::video_frame_rate () const bool -ImageExaminer::yuv () const +ImageExaminer::yuv() const { /* We never convert ImageSource from YUV to RGB (though maybe sometimes we should) so it makes sense to just say they are never YUV so the option of a conversion diff --git a/src/lib/image_examiner.h b/src/lib/image_examiner.h index d6cdfac53..dddb6544f 100644 --- a/src/lib/image_examiner.h +++ b/src/lib/image_examiner.h @@ -25,21 +25,21 @@ class ImageContent; class ImageExaminer : public VideoExaminer { public: - ImageExaminer (std::shared_ptr<const Film>, std::shared_ptr<const ImageContent>, std::shared_ptr<Job>); + ImageExaminer(std::shared_ptr<const Film>, std::shared_ptr<const ImageContent>, std::shared_ptr<Job>); - bool has_video () const override { + bool has_video() const override { return true; } - boost::optional<double> video_frame_rate () const override; + boost::optional<double> video_frame_rate() const override; boost::optional<dcp::Size> video_size() const override; - Frame video_length () const override { + Frame video_length() const override { return _video_length; } - bool yuv () const override; - VideoRange range () const override { + bool yuv() const override; + VideoRange range() const override { return VideoRange::FULL; } - PixelQuanta pixel_quanta () const override { + PixelQuanta pixel_quanta() const override { /* See ::yuv - we're assuming the image is not YUV and so not subsampled */ return {}; } diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc index 8fb387158..c2058794e 100644 --- a/src/lib/j2k_image_proxy.cc +++ b/src/lib/j2k_image_proxy.cc @@ -51,57 +51,57 @@ using dcp::ArrayData; /** Construct a J2KImageProxy from a JPEG2000 file */ -J2KImageProxy::J2KImageProxy (boost::filesystem::path path, dcp::Size size, AVPixelFormat pixel_format) - : _data (new dcp::ArrayData(path)) - , _size (size) - , _pixel_format (pixel_format) - , _error (false) +J2KImageProxy::J2KImageProxy(boost::filesystem::path path, dcp::Size size, AVPixelFormat pixel_format) + : _data(new dcp::ArrayData(path)) + , _size(size) + , _pixel_format(pixel_format) + , _error(false) { /* ::image assumes 16bpp */ - DCPOMATIC_ASSERT (_pixel_format == AV_PIX_FMT_RGB48 || _pixel_format == AV_PIX_FMT_XYZ12LE); + DCPOMATIC_ASSERT(_pixel_format == AV_PIX_FMT_RGB48 || _pixel_format == AV_PIX_FMT_XYZ12LE); } -J2KImageProxy::J2KImageProxy ( +J2KImageProxy::J2KImageProxy( shared_ptr<const dcp::MonoJ2KPictureFrame> frame, dcp::Size size, AVPixelFormat pixel_format, optional<int> forced_reduction ) - : _data (frame) - , _size (size) - , _pixel_format (pixel_format) - , _forced_reduction (forced_reduction) - , _error (false) + : _data(frame) + , _size(size) + , _pixel_format(pixel_format) + , _forced_reduction(forced_reduction) + , _error(false) { /* ::image assumes 16bpp */ - DCPOMATIC_ASSERT (_pixel_format == AV_PIX_FMT_RGB48 || _pixel_format == AV_PIX_FMT_XYZ12LE); + DCPOMATIC_ASSERT(_pixel_format == AV_PIX_FMT_RGB48 || _pixel_format == AV_PIX_FMT_XYZ12LE); } -J2KImageProxy::J2KImageProxy ( +J2KImageProxy::J2KImageProxy( shared_ptr<const dcp::StereoJ2KPictureFrame> frame, dcp::Size size, dcp::Eye eye, AVPixelFormat pixel_format, optional<int> forced_reduction ) - : _data (eye == dcp::Eye::LEFT ? frame->left() : frame->right()) - , _size (size) - , _eye (eye) - , _pixel_format (pixel_format) - , _forced_reduction (forced_reduction) - , _error (false) + : _data(eye == dcp::Eye::LEFT ? frame->left() : frame->right()) + , _size(size) + , _eye(eye) + , _pixel_format(pixel_format) + , _forced_reduction(forced_reduction) + , _error(false) { /* ::image assumes 16bpp */ - DCPOMATIC_ASSERT (_pixel_format == AV_PIX_FMT_RGB48 || _pixel_format == AV_PIX_FMT_XYZ12LE); + DCPOMATIC_ASSERT(_pixel_format == AV_PIX_FMT_RGB48 || _pixel_format == AV_PIX_FMT_XYZ12LE); } -J2KImageProxy::J2KImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> socket) - : _error (false) +J2KImageProxy::J2KImageProxy(shared_ptr<cxml::Node> xml, shared_ptr<Socket> socket) + : _error(false) { - _size = dcp::Size (xml->number_child<int>("Width"), xml->number_child<int>("Height")); + _size = dcp::Size(xml->number_child<int>("Width"), xml->number_child<int>("Height")); if (xml->optional_number_child<int>("Eye")) { _eye = static_cast<dcp::Eye>(xml->number_child<int>("Eye")); } @@ -111,18 +111,18 @@ J2KImageProxy::J2KImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> soc encode servers). So we can put anything in here. It's a bit of a hack. */ _pixel_format = AV_PIX_FMT_XYZ12LE; - socket->read (data->data(), data->size()); + socket->read(data->data(), data->size()); _data = data; } int -J2KImageProxy::prepare (Image::Alignment alignment, optional<dcp::Size> target_size) const +J2KImageProxy::prepare(Image::Alignment alignment, optional<dcp::Size> target_size) const { - boost::mutex::scoped_lock lm (_mutex); + boost::mutex::scoped_lock lm(_mutex); if (_image && target_size == _target_size) { - DCPOMATIC_ASSERT (_reduce); + DCPOMATIC_ASSERT(_reduce); return *_reduce; } @@ -136,15 +136,15 @@ J2KImageProxy::prepare (Image::Alignment alignment, optional<dcp::Size> target_s } --reduce; - reduce = max (0, reduce); + reduce = max(0, reduce); } try { /* XXX: should check that potentially trashing _data here doesn't matter */ - auto decompressed = dcp::decompress_j2k (const_cast<uint8_t*>(_data->data()), _data->size(), reduce); + auto decompressed = dcp::decompress_j2k(const_cast<uint8_t*>(_data->data()), _data->size(), reduce); _image = make_shared<Image>(_pixel_format, decompressed->size(), alignment); - int const shift = 16 - decompressed->precision (0); + int const shift = 16 - decompressed->precision(0); /* Copy data in whatever format (sRGB or XYZ) into our Image; I'm assuming the data is 12-bit either way. @@ -153,9 +153,9 @@ J2KImageProxy::prepare (Image::Alignment alignment, optional<dcp::Size> target_s int const width = decompressed->size().width; int p = 0; - int* decomp_0 = decompressed->data (0); - int* decomp_1 = decompressed->data (1); - int* decomp_2 = decompressed->data (2); + int* decomp_0 = decompressed->data(0); + int* decomp_1 = decompressed->data(1); + int* decomp_2 = decompressed->data(2); for (int y = 0; y < decompressed->size().height; ++y) { auto q = reinterpret_cast<uint16_t *>(_image->data()[0] + y * _image->stride()[0]); for (int x = 0; x < width; ++x) { @@ -167,7 +167,7 @@ J2KImageProxy::prepare (Image::Alignment alignment, optional<dcp::Size> target_s } } catch (dcp::J2KDecompressionError& e) { _image = make_shared<Image>(_pixel_format, _size, alignment); - _image->make_black (); + _image->make_black(); _error = true; } @@ -179,14 +179,14 @@ J2KImageProxy::prepare (Image::Alignment alignment, optional<dcp::Size> target_s ImageProxy::Result -J2KImageProxy::image (Image::Alignment alignment, optional<dcp::Size> target_size) const +J2KImageProxy::image(Image::Alignment alignment, optional<dcp::Size> target_size) const { - int const r = prepare (alignment, target_size); + int const r = prepare(alignment, target_size); /* I think this is safe without a lock on mutex. _image is guaranteed to be set up when prepare() has happened. */ - return Result (_image, r, _error); + return Result(_image, r, _error); } @@ -204,14 +204,14 @@ J2KImageProxy::add_metadata(xmlpp::Element* element) const void -J2KImageProxy::write_to_socket (shared_ptr<Socket> socket) const +J2KImageProxy::write_to_socket(shared_ptr<Socket> socket) const { - socket->write (_data->data(), _data->size()); + socket->write(_data->data(), _data->size()); } bool -J2KImageProxy::same (shared_ptr<const ImageProxy> other) const +J2KImageProxy::same(shared_ptr<const ImageProxy> other) const { auto jp = dynamic_pointer_cast<const J2KImageProxy>(other); if (!jp) { @@ -222,19 +222,19 @@ J2KImageProxy::same (shared_ptr<const ImageProxy> other) const } -J2KImageProxy::J2KImageProxy (ArrayData data, dcp::Size size, AVPixelFormat pixel_format) - : _data (new ArrayData(data)) - , _size (size) - , _pixel_format (pixel_format) - , _error (false) +J2KImageProxy::J2KImageProxy(ArrayData data, dcp::Size size, AVPixelFormat pixel_format) + : _data(new ArrayData(data)) + , _size(size) + , _pixel_format(pixel_format) + , _error(false) { /* ::image assumes 16bpp */ - DCPOMATIC_ASSERT (_pixel_format == AV_PIX_FMT_RGB48 || _pixel_format == AV_PIX_FMT_XYZ12LE); + DCPOMATIC_ASSERT(_pixel_format == AV_PIX_FMT_RGB48 || _pixel_format == AV_PIX_FMT_XYZ12LE); } size_t -J2KImageProxy::memory_used () const +J2KImageProxy::memory_used() const { size_t m = _data->size(); if (_image) { diff --git a/src/lib/j2k_image_proxy.h b/src/lib/j2k_image_proxy.h index 1d2d5cc21..40504ddd5 100644 --- a/src/lib/j2k_image_proxy.h +++ b/src/lib/j2k_image_proxy.h @@ -34,16 +34,16 @@ namespace dcp { class J2KImageProxy : public ImageProxy { public: - J2KImageProxy (boost::filesystem::path path, dcp::Size, AVPixelFormat pixel_format); + J2KImageProxy(boost::filesystem::path path, dcp::Size, AVPixelFormat pixel_format); - J2KImageProxy ( + J2KImageProxy( std::shared_ptr<const dcp::MonoJ2KPictureFrame> frame, dcp::Size, AVPixelFormat pixel_format, boost::optional<int> forced_reduction ); - J2KImageProxy ( + J2KImageProxy( std::shared_ptr<const dcp::StereoJ2KPictureFrame> frame, dcp::Size, dcp::Eye, @@ -51,35 +51,35 @@ public: boost::optional<int> forced_reduction ); - J2KImageProxy (std::shared_ptr<cxml::Node> xml, std::shared_ptr<Socket> socket); + J2KImageProxy(std::shared_ptr<cxml::Node> xml, std::shared_ptr<Socket> socket); /* For tests */ - J2KImageProxy (dcp::ArrayData data, dcp::Size size, AVPixelFormat pixel_format); + J2KImageProxy(dcp::ArrayData data, dcp::Size size, AVPixelFormat pixel_format); - Result image ( + Result image( Image::Alignment alignment, - boost::optional<dcp::Size> size = boost::optional<dcp::Size> () + boost::optional<dcp::Size> size = boost::optional<dcp::Size>() ) const override; void add_metadata(xmlpp::Element*) const override; - void write_to_socket (std::shared_ptr<Socket> override) const override; + void write_to_socket(std::shared_ptr<Socket> override) const override; /** @return true if our image is definitely the same as another, false if it is probably not */ - bool same (std::shared_ptr<const ImageProxy>) const override; - int prepare (Image::Alignment alignment, boost::optional<dcp::Size> = boost::optional<dcp::Size>()) const override; + bool same(std::shared_ptr<const ImageProxy>) const override; + int prepare(Image::Alignment alignment, boost::optional<dcp::Size> = boost::optional<dcp::Size>()) const override; - std::shared_ptr<const dcp::Data> j2k () const { + std::shared_ptr<const dcp::Data> j2k() const { return _data; } - dcp::Size size () const { + dcp::Size size() const { return _size; } - boost::optional<dcp::Eye> eye () const { + boost::optional<dcp::Eye> eye() const { return _eye; } - size_t memory_used () const override; + size_t memory_used() const override; private: std::shared_ptr<const dcp::Data> _data; diff --git a/src/lib/nanomsg.cc b/src/lib/nanomsg.cc index fe3827247..4ec37635e 100644 --- a/src/lib/nanomsg.cc +++ b/src/lib/nanomsg.cc @@ -36,9 +36,9 @@ using boost::optional; #define NANOMSG_URL "ipc:///tmp/dcpomatic.ipc" -Nanomsg::Nanomsg (bool server) +Nanomsg::Nanomsg(bool server) { - _socket = nn_socket (AF_SP, NN_PAIR); + _socket = nn_socket(AF_SP, NN_PAIR); if (_socket < 0) { throw runtime_error("Could not set up nanomsg socket"); } @@ -54,21 +54,21 @@ Nanomsg::Nanomsg (bool server) } -Nanomsg::~Nanomsg () +Nanomsg::~Nanomsg() { - nn_shutdown (_socket, _endpoint); - nn_close (_socket); + nn_shutdown(_socket, _endpoint); + nn_close(_socket); } bool -Nanomsg::send (string s, int timeout) +Nanomsg::send(string s, int timeout) { if (timeout != 0) { - nn_setsockopt (_socket, NN_SOL_SOCKET, NN_SNDTIMEO, &timeout, sizeof(int)); + nn_setsockopt(_socket, NN_SOL_SOCKET, NN_SNDTIMEO, &timeout, sizeof(int)); } - int const r = nn_send (_socket, s.c_str(), s.length(), timeout ? 0 : NN_DONTWAIT); + int const r = nn_send(_socket, s.c_str(), s.length(), timeout ? 0 : NN_DONTWAIT); if (r < 0) { if (errno == ETIMEDOUT || errno == EAGAIN) { return false; @@ -83,7 +83,7 @@ Nanomsg::send (string s, int timeout) optional<string> -Nanomsg::get_from_pending () +Nanomsg::get_from_pending() { if (_pending.empty()) { return {}; @@ -96,10 +96,10 @@ Nanomsg::get_from_pending () void -Nanomsg::recv_and_parse (int flags) +Nanomsg::recv_and_parse(int flags) { char* buf = 0; - int const received = nn_recv (_socket, &buf, NN_MSG, flags); + int const received = nn_recv(_socket, &buf, NN_MSG, flags); if (received < 0) { if (errno == ETIMEDOUT || errno == EAGAIN) { @@ -107,36 +107,35 @@ Nanomsg::recv_and_parse (int flags) } LOG_DISK("nn_recv failed"); - throw CommunicationFailedError (); + throw CommunicationFailedError(); } char* p = buf; for (int i = 0; i < received; ++i) { if (*p == '\n') { - _pending.push_front (_current); + _pending.push_front(_current); _current = ""; } else { _current += *p; } ++p; } - nn_freemsg (buf); + nn_freemsg(buf); } optional<string> -Nanomsg::receive (int timeout) +Nanomsg::receive(int timeout) { if (timeout != 0) { - nn_setsockopt (_socket, NN_SOL_SOCKET, NN_RCVTIMEO, &timeout, sizeof(int)); + nn_setsockopt(_socket, NN_SOL_SOCKET, NN_RCVTIMEO, &timeout, sizeof(int)); } - auto l = get_from_pending (); - if (l) { + if (auto l = get_from_pending()) { return *l; } - recv_and_parse (timeout ? 0 : NN_DONTWAIT); + recv_and_parse(timeout ? 0 : NN_DONTWAIT); - return get_from_pending (); + return get_from_pending(); } diff --git a/src/lib/nanomsg.h b/src/lib/nanomsg.h index 8d89d6d99..bd15a670f 100644 --- a/src/lib/nanomsg.h +++ b/src/lib/nanomsg.h @@ -27,27 +27,27 @@ class Nanomsg { public: - explicit Nanomsg (bool server); - ~Nanomsg (); + explicit Nanomsg(bool server); + ~Nanomsg(); - Nanomsg (Nanomsg const&) = delete; - Nanomsg& operator= (Nanomsg const&) = delete; + Nanomsg(Nanomsg const&) = delete; + Nanomsg& operator=(Nanomsg const&) = delete; /** Try to send a message, waiting for some timeout before giving up. * @param timeout Timeout in milliseconds, or -1 for infinite timeout. * @return true if the send happened, false if there was a timeout. */ - bool send (std::string s, int timeout); + bool send(std::string s, int timeout); /** Try to receive a message, waiting for some timeout before giving up. * @param timeout Timeout in milliseconds, or -1 for infinite timeout. * @return Empty if the timeout was reached, otherwise the received string. */ - boost::optional<std::string> receive (int timeout); + boost::optional<std::string> receive(int timeout); private: - boost::optional<std::string> get_from_pending (); - void recv_and_parse (int flags); + boost::optional<std::string> get_from_pending(); + void recv_and_parse(int flags); int _socket; int _endpoint; diff --git a/src/lib/text_ring_buffers.cc b/src/lib/text_ring_buffers.cc index e2be7bf41..3650bf6a0 100644 --- a/src/lib/text_ring_buffers.cc +++ b/src/lib/text_ring_buffers.cc @@ -28,17 +28,17 @@ using namespace dcpomatic; void -TextRingBuffers::put (PlayerText text, DCPTextTrack track, DCPTimePeriod period) +TextRingBuffers::put(PlayerText text, DCPTextTrack track, DCPTimePeriod period) { - boost::mutex::scoped_lock lm (_mutex); - _data.push_back (Data(text, track, period)); + boost::mutex::scoped_lock lm(_mutex); + _data.push_back(Data(text, track, period)); } optional<TextRingBuffers::Data> -TextRingBuffers::get () +TextRingBuffers::get() { - boost::mutex::scoped_lock lm (_mutex); + boost::mutex::scoped_lock lm(_mutex); if (_data.empty()) { return {}; } @@ -50,7 +50,7 @@ TextRingBuffers::get () void -TextRingBuffers::clear () +TextRingBuffers::clear() { - _data.clear (); + _data.clear(); } diff --git a/src/lib/text_ring_buffers.h b/src/lib/text_ring_buffers.h index 1f366fc0b..b924a9634 100644 --- a/src/lib/text_ring_buffers.h +++ b/src/lib/text_ring_buffers.h @@ -33,13 +33,13 @@ class TextRingBuffers { public: - void put (PlayerText text, DCPTextTrack track, dcpomatic::DCPTimePeriod period); + void put(PlayerText text, DCPTextTrack track, dcpomatic::DCPTimePeriod period); struct Data { - Data (PlayerText text_, DCPTextTrack track_, dcpomatic::DCPTimePeriod period_) - : text (text_) - , track (track_) - , period (period_) + Data(PlayerText text_, DCPTextTrack track_, dcpomatic::DCPTimePeriod period_) + : text(text_) + , track(track_) + , period(period_) {} PlayerText text; @@ -47,8 +47,8 @@ public: dcpomatic::DCPTimePeriod period; }; - boost::optional<Data> get (); - void clear (); + boost::optional<Data> get(); + void clear(); private: boost::mutex _mutex; diff --git a/src/lib/util.cc b/src/lib/util.cc index adc347ab1..60b93a0c4 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -171,7 +171,7 @@ time_to_hmsf(DCPTime time, Frame rate) m -= h * 60; char buffer[64]; - snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d.%02d", h, m, s, static_cast<int>(f)); + snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d:%02d", h, m, s, static_cast<int>(f)); return buffer; } @@ -842,26 +842,6 @@ remap(shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping ma } -size_t -utf8_strlen(string s) -{ - size_t const len = s.length(); - int N = 0; - for (size_t i = 0; i < len; ++i) { - unsigned char c = s[i]; - if ((c & 0xe0) == 0xc0) { - ++i; - } else if ((c & 0xf0) == 0xe0) { - i += 2; - } else if ((c & 0xf8) == 0xf0) { - i += 3; - } - ++N; - } - return N; -} - - /** @param size Size of picture that the subtitle will be overlaid onto */ void emit_subtitle_image(ContentTimePeriod period, dcp::TextImage sub, dcp::Size size, shared_ptr<TextDecoder> decoder) diff --git a/src/lib/util.h b/src/lib/util.h index aa003ff00..9863e5d94 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -84,7 +84,6 @@ extern std::string atmos_asset_filename(std::shared_ptr<dcp::AtmosAsset> asset, extern std::string careful_string_filter(std::string s, std::wstring allowed = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.+"); extern std::pair<int, int> audio_channel_types(std::list<int> mapped, int channels); extern std::shared_ptr<AudioBuffers> remap(std::shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping map); -extern size_t utf8_strlen(std::string s); extern void emit_subtitle_image(dcpomatic::ContentTimePeriod period, dcp::TextImage sub, dcp::Size size, std::shared_ptr<TextDecoder> decoder); extern void copy_in_bits(boost::filesystem::path from, boost::filesystem::path to, std::function<void (float)>); extern dcp::Size scale_for_display(dcp::Size s, dcp::Size display_container, dcp::Size film_container, PixelQuanta quanta); diff --git a/src/lib/video_mxf_content.cc b/src/lib/video_mxf_content.cc index a26c54473..1accd7a5c 100644 --- a/src/lib/video_mxf_content.cc +++ b/src/lib/video_mxf_content.cc @@ -41,8 +41,8 @@ using boost::optional; using namespace dcpomatic; -VideoMXFContent::VideoMXFContent (boost::filesystem::path path) - : Content (path) +VideoMXFContent::VideoMXFContent(boost::filesystem::path path) + : Content(path) { } @@ -51,12 +51,12 @@ VideoMXFContent::VideoMXFContent (boost::filesystem::path path) VideoMXFContent::VideoMXFContent(cxml::ConstNodePtr node, boost::optional<boost::filesystem::path> film_directory, int version) : Content(node, film_directory) { - video = VideoContent::from_xml (this, node, version, VideoRange::FULL); + video = VideoContent::from_xml(this, node, version, VideoRange::FULL); } bool -VideoMXFContent::valid_mxf (boost::filesystem::path path) +VideoMXFContent::valid_mxf(boost::filesystem::path path) { Kumu::DefaultLogSink().UnsetFilterFlag(Kumu::LOG_ALLOW_ALL); @@ -71,7 +71,7 @@ VideoMXFContent::valid_mxf (boost::filesystem::path path) try { Kumu::DefaultLogSink().SetFilterFlag(0); - dcp::StereoJ2KPictureAsset sp (path); + dcp::StereoJ2KPictureAsset sp(path); return true; } catch (dcp::MXFFileError& e) { @@ -88,33 +88,33 @@ VideoMXFContent::valid_mxf (boost::filesystem::path path) void VideoMXFContent::examine(shared_ptr<const Film> film, shared_ptr<Job> job, bool tolerant) { - job->set_progress_unknown (); + job->set_progress_unknown(); Content::examine(film, job, tolerant); - video.reset (new VideoContent (this)); + video.reset(new VideoContent(this)); auto examiner = make_shared<VideoMXFExaminer>(shared_from_this()); video->take_from_examiner(film, examiner); - video->unset_colour_conversion (); + video->unset_colour_conversion(); } string -VideoMXFContent::summary () const +VideoMXFContent::summary() const { return fmt::format(_("{} [video]"), path_summary()); } string -VideoMXFContent::technical_summary () const +VideoMXFContent::technical_summary() const { return Content::technical_summary() + " - " + video->technical_summary(); } string -VideoMXFContent::identifier () const +VideoMXFContent::identifier() const { return Content::identifier() + "_" + video->identifier(); } @@ -130,23 +130,23 @@ VideoMXFContent::as_xml(xmlpp::Element* element, bool with_paths, PathBehaviour DCPTime -VideoMXFContent::full_length (shared_ptr<const Film> film) const +VideoMXFContent::full_length(shared_ptr<const Film> film) const { - FrameRateChange const frc (film, shared_from_this()); - return DCPTime::from_frames (llrint(video->length_after_3d_combine() * frc.factor()), film->video_frame_rate()); + FrameRateChange const frc(film, shared_from_this()); + return DCPTime::from_frames(llrint(video->length_after_3d_combine() * frc.factor()), film->video_frame_rate()); } DCPTime -VideoMXFContent::approximate_length () const +VideoMXFContent::approximate_length() const { - return DCPTime::from_frames (video->length_after_3d_combine(), 24); + return DCPTime::from_frames(video->length_after_3d_combine(), 24); } void -VideoMXFContent::add_properties (shared_ptr<const Film> film, list<UserProperty>& p) const +VideoMXFContent::add_properties(shared_ptr<const Film> film, list<UserProperty>& p) const { - Content::add_properties (film, p); - video->add_properties (p); + Content::add_properties(film, p); + video->add_properties(p); } diff --git a/src/lib/video_mxf_content.h b/src/lib/video_mxf_content.h index 4c2d051b0..0383242d5 100644 --- a/src/lib/video_mxf_content.h +++ b/src/lib/video_mxf_content.h @@ -25,21 +25,21 @@ class VideoMXFContent : public Content { public: - VideoMXFContent (boost::filesystem::path path); - VideoMXFContent (cxml::ConstNodePtr node, boost::optional<boost::filesystem::path> film_directory, int version); + VideoMXFContent(boost::filesystem::path path); + VideoMXFContent(cxml::ConstNodePtr node, boost::optional<boost::filesystem::path> film_directory, int version); - std::shared_ptr<VideoMXFContent> shared_from_this () { + std::shared_ptr<VideoMXFContent> shared_from_this() { return std::dynamic_pointer_cast<VideoMXFContent>(Content::shared_from_this()); } - std::shared_ptr<const VideoMXFContent> shared_from_this () const { + std::shared_ptr<const VideoMXFContent> shared_from_this() const { return std::dynamic_pointer_cast<const VideoMXFContent>(Content::shared_from_this()); } void examine(std::shared_ptr<const Film> film, std::shared_ptr<Job> job, bool tolerant) override; - std::string summary () const override; - std::string technical_summary () const override; - std::string identifier () const override; + std::string summary() const override; + std::string technical_summary() const override; + std::string identifier() const override; void as_xml( xmlpp::Element* element, @@ -48,9 +48,9 @@ public: boost::optional<boost::filesystem::path> film_directory ) const override; - dcpomatic::DCPTime full_length (std::shared_ptr<const Film> film) const override; - dcpomatic::DCPTime approximate_length () const override; - void add_properties (std::shared_ptr<const Film> film, std::list<UserProperty>& p) const override; + dcpomatic::DCPTime full_length(std::shared_ptr<const Film> film) const override; + dcpomatic::DCPTime approximate_length() const override; + void add_properties(std::shared_ptr<const Film> film, std::list<UserProperty>& p) const override; - static bool valid_mxf (boost::filesystem::path path); + static bool valid_mxf(boost::filesystem::path path); }; |
