diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-01-10 00:07:47 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-01-10 00:07:47 +0000 |
| commit | 67a414dc3826761c8933640e85560644f5f02310 (patch) | |
| tree | 6fc3ab11423d5fdd15847890be56bb98ed241852 /src/subtitle.cc | |
| parent | 9fc6bcde891567ca04fe2d9835ab48a17c9b69a7 (diff) | |
Fix handling of timing in SMPTE subtitles.
Diffstat (limited to 'src/subtitle.cc')
| -rw-r--r-- | src/subtitle.cc | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/subtitle.cc b/src/subtitle.cc index 12714961..6c2ccd7e 100644 --- a/src/subtitle.cc +++ b/src/subtitle.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,36 +25,47 @@ #include <boost/lexical_cast.hpp> using std::string; +using std::list; +using boost::optional; using boost::shared_ptr; using boost::lexical_cast; using namespace dcp; -Subtitle::Subtitle (boost::shared_ptr<const cxml::Node> node) +Subtitle::Subtitle (boost::shared_ptr<const cxml::Node> node, int tcr) { - in = Time (node->string_attribute ("TimeIn")); - out = Time (node->string_attribute ("TimeOut")); - font_nodes = type_children<Font> (node, "Font"); - text_nodes = type_children<Text> (node, "Text"); - fade_up_time = fade_time (node, "FadeUpTime"); - fade_down_time = fade_time (node, "FadeDownTime"); + in = Time (node->string_attribute ("TimeIn"), tcr); + out = Time (node->string_attribute ("TimeOut"), tcr); + + list<cxml::NodePtr> f = node->node_children ("Font"); + for (list<cxml::NodePtr>::iterator i = f.begin(); i != f.end(); ++i) { + font_nodes.push_back (shared_ptr<Font> (new Font (*i, tcr))); + } + + list<cxml::NodePtr> t = node->node_children ("Text"); + for (list<cxml::NodePtr>::iterator i = t.begin(); i != t.end(); ++i) { + text_nodes.push_back (shared_ptr<Text> (new Text (*i, tcr))); + } + + fade_up_time = fade_time (node, "FadeUpTime", tcr); + fade_down_time = fade_time (node, "FadeDownTime", tcr); } Time -Subtitle::fade_time (shared_ptr<const cxml::Node> node, string name) +Subtitle::fade_time (shared_ptr<const cxml::Node> node, string name, int tcr) { string const u = node->optional_string_attribute (name).get_value_or (""); Time t; if (u.empty ()) { - t = Time (0, 0, 0, 20); + t = Time (0, 0, 0, 20, 250); } else if (u.find (":") != string::npos) { - t = Time (u); + t = Time (u, tcr); } else { - t = Time (0, 0, 0, lexical_cast<int> (u)); + t = Time (0, 0, 0, lexical_cast<int> (u), tcr); } - if (t > Time (0, 0, 8, 0)) { - t = Time (0, 0, 8, 0); + if (t > Time (0, 0, 8, 0, 250)) { + t = Time (0, 0, 8, 0, 250); } return t; |
