X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fsubtitle_encoder.cc;h=3721ee02b5835c9d8021fbb5aa500dc48ddf821a;hb=8fedaaa75c4586a4cc7ffb393bd71d1fdb091dc8;hp=61c4dc3ae660774adc8badf312c47cd2c6beae73;hpb=4347d97b703cfddcd322051092ccfcd5b5a6b941;p=dcpomatic.git diff --git a/src/lib/subtitle_encoder.cc b/src/lib/subtitle_encoder.cc index 61c4dc3ae..3721ee02b 100644 --- a/src/lib/subtitle_encoder.cc +++ b/src/lib/subtitle_encoder.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019 Carl Hetherington + Copyright (C) 2019-2020 Carl Hetherington This file is part of DCP-o-matic. @@ -18,7 +18,7 @@ */ -#include "font.h" +#include "font_data.h" #include "subtitle_encoder.h" #include "player.h" #include "compose.hpp" @@ -26,18 +26,21 @@ #include #include #include -#include #include -#include +#include #include "i18n.h" -using std::string; using std::make_pair; +using std::make_shared; using std::pair; +using std::shared_ptr; +using std::string; using std::vector; -using boost::shared_ptr; using boost::optional; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif using dcp::raw_convert; /** @param output Directory, if there will be multiple output files, or a filename. @@ -75,9 +78,11 @@ SubtitleEncoder::SubtitleEncoder (shared_ptr film, shared_ptr j _assets.push_back (make_pair(shared_ptr(), boost::filesystem::change_extension(filename, extension))); } - BOOST_FOREACH (dcpomatic::DCPTimePeriod i, film->reels()) { + for (auto i: film->reels()) { _reels.push_back (i); } + + _default_font = dcp::ArrayData (default_font_file()); } void @@ -111,8 +116,8 @@ SubtitleEncoder::go () } if (!_film->interop() || _include_font) { - BOOST_FOREACH (shared_ptr j, _player->get_subtitle_fonts()) { - i->first->add_font (j->id(), default_font_file()); + for (auto j: _player->get_subtitle_fonts()) { + i->first->add_font (j.id, _default_font); } } @@ -124,7 +129,7 @@ SubtitleEncoder::go () void SubtitleEncoder::text (PlayerText subs, TextType type, optional track, dcpomatic::DCPTimePeriod period) { - if (type != TEXT_OPEN_SUBTITLE) { + if (type != TextType::OPEN_SUBTITLE) { return; } @@ -132,17 +137,19 @@ SubtitleEncoder::text (PlayerText subs, TextType type, optional tr shared_ptr asset; vector lang = _film->subtitle_languages (); if (_film->interop ()) { - shared_ptr s (new dcp::InteropSubtitleAsset()); + auto s = make_shared(); s->set_movie_title (_film->name()); - s->set_language (lang.empty() ? "Unknown" : lang.front().to_string()); + if (!lang.empty()) { + s->set_language (lang.front().to_string()); + } s->set_reel_number (raw_convert(_reel_index + 1)); _assets[_reel_index].first = s; } else { - shared_ptr s (new dcp::SMPTESubtitleAsset()); + auto s = make_shared(); s->set_content_title_text (_film->name()); if (!lang.empty()) { s->set_language (lang.front()); - } else { + } else if (!track->language.empty()) { s->set_language (dcp::LanguageTag(track->language)); } s->set_edit_rate (dcp::Fraction (_film->video_frame_rate(), 1)); @@ -156,7 +163,7 @@ SubtitleEncoder::text (PlayerText subs, TextType type, optional tr } } - BOOST_FOREACH (StringText i, subs.string) { + for (auto i: subs.string) { /* XXX: couldn't / shouldn't we use period here rather than getting time from the subtitle? */ i.set_in (i.in()); i.set_out (i.out());