projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make DCP text track language properly optional and ignore bad values on imported...
[dcpomatic.git]
/
src
/
lib
/
subtitle_encoder.cc
diff --git
a/src/lib/subtitle_encoder.cc
b/src/lib/subtitle_encoder.cc
index b018dcfb429a47073a946cff59298bfbc1a48730..66957270fe91d0d6d2cbef7e11dd4223842931b8 100644
(file)
--- a/
src/lib/subtitle_encoder.cc
+++ b/
src/lib/subtitle_encoder.cc
@@
-1,5
+1,5
@@
/*
/*
- Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2019
-2020
Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
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"
#include "subtitle_encoder.h"
#include "player.h"
#include "compose.hpp"
@@
-26,17
+26,17
@@
#include <dcp/interop_subtitle_asset.h>
#include <dcp/raw_convert.h>
#include <dcp/smpte_subtitle_asset.h>
#include <dcp/interop_subtitle_asset.h>
#include <dcp/raw_convert.h>
#include <dcp/smpte_subtitle_asset.h>
-#include <boost/shared_ptr.hpp>
#include <boost/filesystem.hpp>
#include <boost/bind/bind.hpp>
#include "i18n.h"
#include <boost/filesystem.hpp>
#include <boost/bind/bind.hpp>
#include "i18n.h"
-using std::string;
using std::make_pair;
using std::make_pair;
+using std::make_shared;
using std::pair;
using std::pair;
+using std::shared_ptr;
+using std::string;
using std::vector;
using std::vector;
-using boost::shared_ptr;
using boost::optional;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
using boost::optional;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
@@
-78,9
+78,11
@@
SubtitleEncoder::SubtitleEncoder (shared_ptr<const Film> film, shared_ptr<Job> j
_assets.push_back (make_pair(shared_ptr<dcp::SubtitleAsset>(), boost::filesystem::change_extension(filename, extension)));
}
_assets.push_back (make_pair(shared_ptr<dcp::SubtitleAsset>(), boost::filesystem::change_extension(filename, extension)));
}
-
BOOST_FOREACH (dcpomatic::DCPTimePeriod i,
film->reels()) {
+
for (auto i:
film->reels()) {
_reels.push_back (i);
}
_reels.push_back (i);
}
+
+ _default_font = dcp::ArrayData (default_font_file());
}
void
}
void
@@
-114,8
+116,8
@@
SubtitleEncoder::go ()
}
if (!_film->interop() || _include_font) {
}
if (!_film->interop() || _include_font) {
-
BOOST_FOREACH (shared_ptr<dcpomatic::Font> 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
);
}
}
}
}
@@
-127,28
+129,28
@@
SubtitleEncoder::go ()
void
SubtitleEncoder::text (PlayerText subs, TextType type, optional<DCPTextTrack> track, dcpomatic::DCPTimePeriod period)
{
void
SubtitleEncoder::text (PlayerText subs, TextType type, optional<DCPTextTrack> track, dcpomatic::DCPTimePeriod period)
{
- if (type != T
EXT_
OPEN_SUBTITLE) {
+ if (type != T
extType::
OPEN_SUBTITLE) {
return;
}
if (!_assets[_reel_index].first) {
shared_ptr<dcp::SubtitleAsset> asset;
return;
}
if (!_assets[_reel_index].first) {
shared_ptr<dcp::SubtitleAsset> asset;
-
vector<dcp::LanguageTag>
lang = _film->subtitle_languages ();
+
auto
lang = _film->subtitle_languages ();
if (_film->interop ()) {
if (_film->interop ()) {
-
shared_ptr<dcp::InteropSubtitleAsset> s (new dcp::InteropSubtitleAsset()
);
+
auto s = make_shared<dcp::InteropSubtitleAsset>(
);
s->set_movie_title (_film->name());
s->set_movie_title (_film->name());
- if (
!lang.empty()
) {
- s->set_language (lang.f
ront().
to_string());
+ if (
lang.first
) {
+ s->set_language (lang.f
irst->
to_string());
}
s->set_reel_number (raw_convert<string>(_reel_index + 1));
_assets[_reel_index].first = s;
} else {
}
s->set_reel_number (raw_convert<string>(_reel_index + 1));
_assets[_reel_index].first = s;
} else {
-
shared_ptr<dcp::SMPTESubtitleAsset> s (new dcp::SMPTESubtitleAsset()
);
+
auto s = make_shared<dcp::SMPTESubtitleAsset>(
);
s->set_content_title_text (_film->name());
s->set_content_title_text (_film->name());
- if (
!lang.empty()
) {
- s->set_language (
lang.front()
);
- } else if (
!track->language.empty()
) {
- s->set_language (
dcp::LanguageTag(track->language
));
+ if (
lang.first
) {
+ s->set_language (
*lang.first
);
+ } else if (
track->language
) {
+ s->set_language (
track->language.get(
));
}
s->set_edit_rate (dcp::Fraction (_film->video_frame_rate(), 1));
s->set_reel_number (_reel_index + 1);
}
s->set_edit_rate (dcp::Fraction (_film->video_frame_rate(), 1));
s->set_reel_number (_reel_index + 1);
@@
-161,7
+163,7
@@
SubtitleEncoder::text (PlayerText subs, TextType type, optional<DCPTextTrack> 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());
/* 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());