| 27 | } |
| 28 | |
| 29 | SubFile TMPlayerSubtitleFormat::decode(const QStringList &lines) const { |
| 30 | SubFile sf; |
| 31 | |
| 32 | foreach (QString line, lines) { |
| 33 | if (!line.trimmed().isEmpty()) { |
| 34 | QRegExp r("^(0\\d|\\d\\d):(0\\d|\\d\\d):(0\\d|\\d\\d):(.*)"); |
| 35 | r.setPatternSyntax(QRegExp::RegExp2); |
| 36 | if (r.exactMatch(line)) { |
| 37 | int h = r.cap(1).toInt(); |
| 38 | int m = r.cap(2).toInt(); |
| 39 | int s = r.cap(3).toInt(); |
| 40 | QString tokenStream = r.cap(4); |
| 41 | |
| 42 | SubEntry se; |
| 43 | se.frameStart = 1000L * (3600L * h + 60L * m + s); |
| 44 | se.tokens = decodeTokenStream(tokenStream); |
| 45 | |
| 46 | sf.entries.push_back(se); |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | for (int i = 0; i < sf.entries.size(); ++i) { |
| 52 | long plus5s = sf.entries[i].frameStart + 5000L; |
| 53 | sf.entries[i].frameStop = plus5s; |
| 54 | if (i < sf.entries.size() - 1) { |
| 55 | sf.entries[i].frameStop = |
| 56 | std::min(plus5s, sf.entries[i + 1].frameStart - 1); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | return sf; |
| 61 | } |
| 62 | |
| 63 | QStringList TMPlayerSubtitleFormat::encode(const SubFile &subFile) const { |
| 64 | QStringList lines; |
nothing calls this directly
no outgoing calls
no test coverage detected