diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-06-20 22:47:17 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-06-20 22:47:17 +0100 |
| commit | 23a1a0395b31c4dc36d65531d02b7df240a25dce (patch) | |
| tree | ef0d51564a51eefee596799c42c59cbebbdb507b | |
| parent | 6f1af34ae95586281f1632ceb87cc95784ccff28 (diff) | |
Accept V4+ styles as well as V4 ones in SSA.
| -rw-r--r-- | src/ssa_reader.cc | 2 | ||||
| -rw-r--r-- | test/ssa_reader_test.cc | 48 |
2 files changed, 49 insertions, 1 deletions
diff --git a/src/ssa_reader.cc b/src/ssa_reader.cc index eb85dea..93e96f2 100644 --- a/src/ssa_reader.cc +++ b/src/ssa_reader.cc @@ -312,7 +312,7 @@ SSAReader::read (function<optional<string> ()> get_line) /* Section heading */ if (line.get() == "[Script Info]") { part = INFO; - } else if (line.get() == "[V4 Styles]") { + } else if (line.get() == "[V4 Styles]" || line.get() == "[V4+ Styles]") { part = STYLES; } else if (line.get() == "[Events]") { part = EVENTS; diff --git a/test/ssa_reader_test.cc b/test/ssa_reader_test.cc index 0fa326b..d0ed8fa 100644 --- a/test/ssa_reader_test.cc +++ b/test/ssa_reader_test.cc @@ -303,3 +303,51 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test4) BLOCK ("2nd line: this is bold", "Verdana", 50, true, false, false); SUB_END (); } + +/** Test reading of a .ass file */ +BOOST_AUTO_TEST_CASE (ssa_reader_test5) +{ + boost::filesystem::path p = private_test / "dcpsubtest-en.ass"; + FILE* f = fopen (p.string().c_str(), "r"); + sub::SSAReader reader (f); + fclose (f); + list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ()); + + list<sub::Subtitle>::iterator i = subs.begin (); + list<sub::Line>::iterator j; + list<sub::Block>::iterator k; + + BOOST_REQUIRE (i != subs.end ()); + + SUB_START (sub::Time::from_hms (0, 0, 1, 0), sub::Time::from_hms (0, 0, 3, 0)); + /* The first line should be one line (26 points, 1.2 times + spaced, as a proportion of the total screen height 729 + points) up. + */ + LINE ((26.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN); + BLOCK ("1st subtitle, 1st line", "arial", 26, true, false, false); + LINE (0, sub::BOTTOM_OF_SCREEN); + BLOCK ("2nd subtitle, 2nd line", "arial", 26, true, false, false); + SUB_END (); + + SUB_START (sub::Time::from_hms (0, 0, 3, 100), sub::Time::from_hms (0, 0, 5, 100)); + LINE ((26.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN); + BLOCK ("2nd subtitle, 1st line", "arial", 26, true, false, false); + LINE (0, sub::BOTTOM_OF_SCREEN); + BLOCK ("2nd subtitle, 2nd line", "arial", 26, true, false, false); + SUB_END (); + + SUB_START (sub::Time::from_hms (0, 0, 5, 200), sub::Time::from_hms (0, 0, 7, 200)); + LINE ((26.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN); + BLOCK ("3rd subtitle, 1st line", "arial", 26, true, false, false); + LINE (0, sub::BOTTOM_OF_SCREEN); + BLOCK ("3rd subtitle, 2nd line", "arial", 26, true, false, false); + SUB_END (); + + SUB_START (sub::Time::from_hms (0, 0, 7, 300), sub::Time::from_hms (0, 0, 9, 300)); + LINE ((26.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN); + BLOCK ("4th subtitle, 1st line", "arial", 26, true, false, false); + LINE (0, sub::BOTTOM_OF_SCREEN); + BLOCK ("4th subtitle, 2nd line", "arial", 26, true, false, false); + SUB_END (); +} |
