diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-05-04 22:43:58 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-05-04 22:43:58 +0100 |
| commit | 1d5f1487bdb81308e41c36443964e3cdcab58857 (patch) | |
| tree | 91dd46339f75ef4538b25d09076c7f22990c31ef /src/stl_binary_reader.cc | |
| parent | 94d2127b2f9227b31e5947318a4d8f974a43cb57 (diff) | |
Fix incorrect reading of STL when italic/underline codes span line breaks.
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 9a2fc11..42c9143 100644 --- a/src/stl_binary_reader.cc +++ b/src/stl_binary_reader.cc @@ -93,6 +93,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.set_frame (get_timecode (5)); @@ -100,6 +106,8 @@ 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; /* XXX: not sure what to do with JC = 0, "unchanged presentation" */ int const h = get_int (14, 1); @@ -116,6 +124,7 @@ STLBinaryReader::STLBinaryReader (istream& in) break; } + /* Loop over characters */ string text; for (size_t j = 0; j < lines[i].size(); ++j) { @@ -135,21 +144,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 ()) { |
