X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fssa_reader.cc;h=4a9be0e28b0d4300aaa01b191cdfbb141103bc93;hb=4518eac6c41c51e781d2f17e0f26fe7713ac93c1;hp=e2b845e5babede06b61dd9cf377210987accbffe;hpb=4320728168bea602527eb101a8094cd95dcfce37;p=libsub.git diff --git a/src/ssa_reader.cc b/src/ssa_reader.cc index e2b845e..4a9be0e 100644 --- a/src/ssa_reader.cc +++ b/src/ssa_reader.cc @@ -25,7 +25,6 @@ #include "compose.hpp" #include #include -#include #include #include @@ -33,7 +32,6 @@ using std::string; using std::vector; using std::map; using std::cout; -using std::list; using boost::optional; using boost::function; using namespace boost::algorithm; @@ -214,11 +212,32 @@ SSAReader::parse_style (RawSubtitle& sub, string style, int play_res_x, int play sub.underline = true; } else if (style == "\\u0") { sub.underline = false; - } else if (style == "\\an1" || style == "\\an2" || style == "\\an3") { + } else if (style == "\\an1") { + sub.horizontal_position.reference = sub::LEFT_OF_SCREEN; + sub.vertical_position.reference = sub::BOTTOM_OF_SCREEN; + } else if (style == "\\an2") { + sub.horizontal_position.reference = sub::HORIZONTAL_CENTRE_OF_SCREEN; + sub.vertical_position.reference = sub::BOTTOM_OF_SCREEN; + } else if (style == "\\an3") { + sub.horizontal_position.reference = sub::RIGHT_OF_SCREEN; sub.vertical_position.reference = sub::BOTTOM_OF_SCREEN; - } else if (style == "\\an4" || style == "\\an5" || style == "\\an6") { + } else if (style == "\\an4") { + sub.horizontal_position.reference = sub::LEFT_OF_SCREEN; + sub.vertical_position.reference = sub::VERTICAL_CENTRE_OF_SCREEN; + } else if (style == "\\an5") { + sub.horizontal_position.reference = sub::HORIZONTAL_CENTRE_OF_SCREEN; sub.vertical_position.reference = sub::VERTICAL_CENTRE_OF_SCREEN; - } else if (style == "\\an7" || style == "\\an8" || style == "\\an9") { + } else if (style == "\\an6") { + sub.horizontal_position.reference = sub::RIGHT_OF_SCREEN; + sub.vertical_position.reference = sub::VERTICAL_CENTRE_OF_SCREEN; + } else if (style == "\\an7") { + sub.horizontal_position.reference = sub::LEFT_OF_SCREEN; + sub.vertical_position.reference = sub::TOP_OF_SCREEN; + } else if (style == "\\an8") { + sub.horizontal_position.reference = sub::HORIZONTAL_CENTRE_OF_SCREEN; + sub.vertical_position.reference = sub::TOP_OF_SCREEN; + } else if (style == "\\an9") { + sub.horizontal_position.reference = sub::RIGHT_OF_SCREEN; sub.vertical_position.reference = sub::TOP_OF_SCREEN; } else if (boost::starts_with(style, "\\pos")) { vector bits; @@ -244,7 +263,7 @@ SSAReader::parse_style (RawSubtitle& sub, string style, int play_res_x, int play * @param line SSA line string (i.e. just the subtitle, possibly with embedded stuff) * @return List of RawSubtitles to represent line with vertical reference TOP_OF_SUBTITLE. */ -list +vector SSAReader::parse_line (RawSubtitle base, string line, int play_res_x, int play_res_y) { enum { @@ -253,7 +272,7 @@ SSAReader::parse_line (RawSubtitle base, string line, int play_res_x, int play_r BACKSLASH } state = TEXT; - list subs; + vector subs; RawSubtitle current = base; string style; @@ -419,7 +438,7 @@ SSAReader::read (function ()> get_line) case EVENTS: if (type == "Format") { split (event_format, body, is_any_of (",")); - BOOST_FOREACH (string& i, event_format) { + for (auto& i: event_format) { trim (i); } } else if (type == "Dialogue") { @@ -468,7 +487,7 @@ SSAReader::read (function ()> get_line) } else if (event_format[i] == "MarginV") { sub.vertical_position.proportional = raw_convert(event[i]) / play_res_y; } else if (event_format[i] == "Text") { - BOOST_FOREACH (sub::RawSubtitle j, parse_line (sub, event[i], play_res_x, play_res_y)) { + for (auto j: parse_line (sub, event[i], play_res_x, play_res_y)) { _subs.push_back (j); } }