diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-09-13 11:47:45 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-09-13 11:47:45 +0100 |
| commit | 8ca1ad346138f5a02020cb900f43a69e154a23c7 (patch) | |
| tree | aa5cc72cc07219a65c9647e3d485c09e71f7e710 /src/stl_binary_reader.cc | |
| parent | 4937d28fc680b03920cee837343ab23d316ebb42 (diff) | |
Fix incorrect reading of STL when italic/underline codes span line breaks (from master).
Diffstat (limited to 'src/stl_binary_reader.cc')
| -rw-r--r-- | src/stl_binary_reader.cc | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/stl_binary_reader.cc b/src/stl_binary_reader.cc index d477684..8d7befb 100644 --- a/src/stl_binary_reader.cc +++ b/src/stl_binary_reader.cc @@ -94,6 +94,12 @@ STLBinaryReader::STLBinaryReader (istream& in) vector<string> lines; split (lines, whole, is_any_of ("\x8a")); + /* Italic / underline specifications can span lines, so we need to track them + outside the lines loop. + */ + bool italic = false; + bool underline = false; + for (size_t i = 0; i < lines.size(); ++i) { RawSubtitle sub; sub.from = get_timecode (5); @@ -101,7 +107,10 @@ STLBinaryReader::STLBinaryReader (istream& in) sub.vertical_position.line = get_int (13, 1) + i; sub.vertical_position.lines = maximum_rows; sub.vertical_position.reference = TOP_OF_SCREEN; + sub.italic = italic; + sub.underline = underline; + /* Loop over characters */ string text; for (size_t j = 0; j < lines[i].size(); ++j) { @@ -121,21 +130,24 @@ STLBinaryReader::STLBinaryReader (istream& in) switch (c) { case 0x80: - sub.italic = true; + italic = true; break; case 0x81: - sub.italic = false; + italic = false; break; case 0x82: - sub.underline = true; + underline = true; break; case 0x83: - sub.underline = false; + underline = false; break; default: text += lines[i][j]; break; } + + sub.italic = italic; + sub.underline = underline; } if (!text.empty ()) { |
