X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fsubrip.cc;h=11ad3302d3659abf107eed8b8fa69d33d8109c69;hb=3b48d5494c3cae7743d283203f5c8021860ab81f;hp=9d207d528d0f04f7060ebc18c5e8d2fbe4228a16;hpb=39bc73fe192f932ed6695eb87b19de446e8b4f55;p=dcpomatic.git diff --git a/src/lib/subrip.cc b/src/lib/subrip.cc index 9d207d528..11ad3302d 100644 --- a/src/lib/subrip.cc +++ b/src/lib/subrip.cc @@ -66,13 +66,18 @@ SubRip::SubRip (shared_ptr content) switch (state) { case COUNTER: { + if (line.empty ()) { + /* a blank line at the start is ok */ + break; + } + int x = 0; try { x = lexical_cast (line); } catch (...) { } - + if (x == next_count) { state = METADATA; ++next_count; @@ -90,8 +95,7 @@ SubRip::SubRip (shared_ptr content) throw SubRipError (line, _("a time/position line"), content->path (0)); } - current->from = convert_time (p[0]); - current->to = convert_time (p[2]); + current->period = ContentTimePeriod (convert_time (p[0]), convert_time (p[2])); if (p.size() > 3) { current->x1 = convert_coordinate (p[3]); @@ -233,5 +237,5 @@ SubRip::length () const return ContentTime (); } - return _subtitles.back().to; + return _subtitles.back().period.to; }