diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-06-14 00:20:06 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-06-14 00:20:06 +0100 |
| commit | 8837fe70049bd5ed7ab583c06d6c9a620a01b351 (patch) | |
| tree | 798e86e707bfecc147a54d999fe826f4bc5dd3a8 /src/subtitle_node.cc | |
| parent | 937e4352072486832372fc8ebdb83583be9b8a2a (diff) | |
Tighten up time parsing, and also allow the previously
unsupported Interop HH:MM:SS.sss format for times.
Diffstat (limited to 'src/subtitle_node.cc')
| -rw-r--r-- | src/subtitle_node.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/subtitle_node.cc b/src/subtitle_node.cc index bd689aa2..44c32e26 100644 --- a/src/subtitle_node.cc +++ b/src/subtitle_node.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -45,7 +45,8 @@ using boost::shared_ptr; using boost::lexical_cast; using namespace dcp; -SubtitleNode::SubtitleNode (boost::shared_ptr<const cxml::Node> node, int tcr, string font_id_attribute) +/** @param tcr Timecode rate for SMPTE, or empty for Interop */ +SubtitleNode::SubtitleNode (boost::shared_ptr<const cxml::Node> node, optional<int> tcr, string font_id_attribute) { in = Time (node->string_attribute ("TimeIn"), tcr); out = Time (node->string_attribute ("TimeOut"), tcr); @@ -65,7 +66,7 @@ SubtitleNode::SubtitleNode (boost::shared_ptr<const cxml::Node> node, int tcr, s } Time -SubtitleNode::fade_time (shared_ptr<const cxml::Node> node, string name, int tcr) +SubtitleNode::fade_time (shared_ptr<const cxml::Node> node, string name, optional<int> tcr) { string const u = node->optional_string_attribute (name).get_value_or (""); Time t; @@ -75,7 +76,7 @@ SubtitleNode::fade_time (shared_ptr<const cxml::Node> node, string name, int tcr } else if (u.find (":") != string::npos) { t = Time (u, tcr); } else { - t = Time (0, 0, 0, lexical_cast<int> (u), tcr); + t = Time (0, 0, 0, lexical_cast<int> (u), tcr.get_value_or(250)); } if (t > Time (0, 0, 8, 0, 250)) { |
