| 1 | /***************************************************************************** |
| 2 | ** QNapi |
| 3 | ** Copyright (C) 2008-2017 Piotr KrzemiĆski <[email protected]> |
| 4 | ** |
| 5 | ** This program is free software; you can redistribute it and/or modify |
| 6 | ** it under the terms of the GNU General Public License as published by |
| 7 | ** the Free Software Foundation; either version 2 of the License, or |
| 8 | ** (at your option) any later version. |
| 9 | ** |
| 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
| 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 12 | ** |
| 13 | *****************************************************************************/ |
| 14 | |
| 15 | #include "tmplayer.h"cxx . . $ `<file>/libqnapi/src/subconvert/formats/tmplayer.h`/ |
| 16 | |
| 17 | bool TMPlayerSubtitleFormatcxx . . $ TMPlayerSubtitleFormat#::detectcxx . . $ TMPlayerSubtitleFormat#detect(5f1b03c390062051).(const QStringListcxx . . $ QStringList# &lines) const { |
| 18 | foreachcxx . . $ `<external>/15045578679651060896/qglobal.h:1145:13`! (QString line, lines) { |
| 19 | if (!line.trimmedcxx . . $ QString#trimmed(dca2c5857e9adf82).().isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 20 | QRegExpcxx . . $ QRegExp# rcxx . . $ QRegExp#QRegExp(31e086911ff70bd0).("^(0\\d|\\d\\d):(0\\d|\\d\\d):(0\\d|\\d\\d):(.*)"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 21 | r.setPatternSyntaxcxx . . $ QRegExp#setPatternSyntax(e2983a6a777435d7).(QRegExpcxx . . $ QRegExp#::RegExp2cxx . . $ QRegExp#RegExp2.); |
| 22 | return r.exactMatchcxx . . $ QRegExp#exactMatch(f3b39adf77d9c36c).(line); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | return false; |
| 27 | } |
| 28 | |
| 29 | SubFilecxx . . $ SubFile# TMPlayerSubtitleFormatcxx . . $ TMPlayerSubtitleFormat#::decodecxx . . $ TMPlayerSubtitleFormat#decode(a10217bac3d52496).(const QStringListcxx . . $ QStringList# &lines) const { |
| 30 | SubFilecxx . . $ SubFile# sf; |
| 31 | |
| 32 | foreachcxx . . $ `<external>/15045578679651060896/qglobal.h:1145:13`! (QString line, lines) { |
| 33 | if (!line.trimmedcxx . . $ QString#trimmed(dca2c5857e9adf82).().isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).()) { |
| 34 | QRegExpcxx . . $ QRegExp# rcxx . . $ QRegExp#QRegExp(31e086911ff70bd0).("^(0\\d|\\d\\d):(0\\d|\\d\\d):(0\\d|\\d\\d):(.*)"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 35 | r.setPatternSyntaxcxx . . $ QRegExp#setPatternSyntax(e2983a6a777435d7).(QRegExpcxx . . $ QRegExp#::RegExp2cxx . . $ QRegExp#RegExp2.); |
| 36 | if (r.exactMatchcxx . . $ QRegExp#exactMatch(f3b39adf77d9c36c).(line)) { |
| 37 | int h = r.capcxx . . $ QRegExp#cap(ce915ed341d4a7f0).(1).toIntcxx . . $ QString#toInt(d7972accae11ee1f).(); |
| 38 | int m = r.capcxx . . $ QRegExp#cap(ce915ed341d4a7f0).(2).toIntcxx . . $ QString#toInt(d7972accae11ee1f).(); |
| 39 | int s = r.capcxx . . $ QRegExp#cap(ce915ed341d4a7f0).(3).toIntcxx . . $ QString#toInt(d7972accae11ee1f).(); |
| 40 | QStringcxx . . $ QString# tokenStream = rcxx . . $ QString#QString(e1217c004a86c950)..capcxx . . $ QRegExp#cap(ce915ed341d4a7f0).(4); |
| 41 | |
| 42 | SubEntrycxx . . $ SubEntry# se; |
| 43 | se.frameStartcxx . . $ SubEntry#frameStart. = 1000L * (3600L * h + 60L * m + s); |
| 44 | se.tokenscxx . . $ SubEntry#tokens. =cxx . . $ QVector#`operator=`(a1d068f9d22786ee). decodeTokenStreamcxx . . $ SubtitleFormat#decodeTokenStream(8709a708f98d071b).(tokenStreamcxx . . $ QString#QString(3520e46b33348bf6).); |
| 45 | |
| 46 | sf.entriescxx . . $ SubFile#entries..push_backcxx . . $ QVector#push_back(77d9f17553126ecb).(se); |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | for (int i = 0; i < sf.entriescxx . . $ SubFile#entries..sizecxx . . $ QVector#size(455f465bc33b4cdf).(); ++i) { |
| 52 | long plus5s = sf.entriescxx . . $ SubFile#entries.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).i].frameStartcxx . . $ SubEntry#frameStart. + 5000L; |
| 53 | sf.entriescxx . . $ SubFile#entries.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).i].frameStopcxx . . $ SubEntry#frameStop. = plus5s; |
| 54 | if (i < sf.entriescxx . . $ SubFile#entries..sizecxx . . $ QVector#size(455f465bc33b4cdf).() - 1) { |
| 55 | sf.entriescxx . . $ SubFile#entries.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).i].frameStopcxx . . $ SubEntry#frameStop. = |
| 56 | stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(plus5s, sf.entriescxx . . $ SubFile#entries.[cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).i + 1].frameStartcxx . . $ SubEntry#frameStart. - 1); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | return sf; |
| 61 | } |
| 62 | |
| 63 | QStringListcxx . . $ QStringList# TMPlayerSubtitleFormatcxx . . $ TMPlayerSubtitleFormat#::encodecxx . . $ TMPlayerSubtitleFormat#encode(547b88c4cc907c03).(const SubFilecxx . . $ SubFile# &subFile) const { |
| 64 | QStringListcxx . . $ QStringList# linescxx . . $ QStringList#QStringList(49f6e7a06ebc5aa8).; |
| 65 | foreachcxx . . $ `<external>/15045578679651060896/qglobal.h:1145:13`! (const SubEntry &entry, subFile.entries) { |
| 66 | lines.appendcxx . . $ QList#append(77d9f17553126ecb).(encodeEntrycxx . . $ TMPlayerSubtitleFormat#encodeEntry(ca3a0ff6d305d01e).(entry)); |
| 67 | } |
| 68 | return lines; |
| 69 | } |
| 70 | |
| 71 | QStringcxx . . $ QString# TMPlayerSubtitleFormatcxx . . $ TMPlayerSubtitleFormat#::encodeEntrycxx . . $ TMPlayerSubtitleFormat#encodeEntry(ca3a0ff6d305d01e).(const SubEntrycxx . . $ SubEntry# &entry) const { |
| 72 | QStringcxx . . $ QString# tokensBuffcxx . . $ QString#QString(49f6e7a06ebc5aa8).; |
| 73 | foreachcxx . . $ `<external>/15045578679651060896/qglobal.h:1145:13`! (const SubToken &token, entry.tokens) { |
| 74 | tokensBuff +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). encodeTokencxx . . $ TMPlayerSubtitleFormat#encodeToken(a468b8cbbcf05ae6).(token); |
| 75 | } |
| 76 | long ss = entry.frameStartcxx . . $ SubEntry#frameStart. / 1000; |
| 77 | int h = ss / 3600; |
| 78 | int m = (ss - h * 3600) / 60; |
| 79 | int s = ss - h * 3600 - m * 60; |
| 80 | return QStringcxx . . $ QString#QString(e1217c004a86c950).("%1:%2:%3: %4") |
| 81 | .argcxx . . $ QString#arg(64ab2ed17cc11715).(h, 2, 10, QCharcxx . . $ QChar#('0')) |
| 82 | .argcxx . . $ QString#arg(64ab2ed17cc11715).(m, 2, 10, QCharcxx . . $ QChar#('0')) |
| 83 | .argcxx . . $ QString#arg(64ab2ed17cc11715).(s, 2, 10, QCharcxx . . $ QChar#('0')) |
| 84 | .argcxx . . $ QString#arg(bc823072288cbbb5).(tokensBuff); |
| 85 | } |
| 86 | |
| 87 | QStringcxx . . $ QString# TMPlayerSubtitleFormatcxx . . $ TMPlayerSubtitleFormat#::encodeTokencxx . . $ TMPlayerSubtitleFormat#encodeToken(a468b8cbbcf05ae6).(const SubTokencxx . . $ SubToken# &entry) const { |
| 88 | switch (entry.typecxx . . $ SubToken#type.) { |
| 89 | case STT_WScxx . . $ STT_WS.: |
| 90 | returncxx . . $ QString#QString(e1217c004a86c950). " "cxx . . $ QString#QString(85c52e162fed56f9).; |
| 91 | case STT_WORDcxx . . $ STT_WORD.: |
| 92 | return entrycxx . . $ QString#QString(3520e46b33348bf6)..payloadcxx . . $ SubToken#payload.; |
| 93 | case STT_NEWLINEcxx . . $ STT_NEWLINE.: |
| 94 | returncxx . . $ QString#QString(e1217c004a86c950). "|"cxx . . $ QString#QString(85c52e162fed56f9).; |
| 95 | case STT_BOLDcxx . . $ STT_BOLD.: |
| 96 | returncxx . . $ QString#QString(e1217c004a86c950). "{y:b}"cxx . . $ QString#QString(85c52e162fed56f9).; |
| 97 | case STT_ITALICcxx . . $ STT_ITALIC.: |
| 98 | returncxx . . $ QString#QString(e1217c004a86c950). "{y:i}"cxx . . $ QString#QString(85c52e162fed56f9).; |
| 99 | case STT_UNDERLINEcxx . . $ STT_UNDERLINE.: |
| 100 | returncxx . . $ QString#QString(e1217c004a86c950). "{y:u}"cxx . . $ QString#QString(85c52e162fed56f9).; |
| 101 | case STT_FONTCOLORcxx . . $ STT_FONTCOLOR.: |
| 102 | return QStringcxx . . $ QString#QString(e1217c004a86c950).("{c:$%1}").argcxx . . $ QString#arg(bc823072288cbbb5).(entry.payloadcxx . . $ SubToken#payload.); |
| 103 | default: |
| 104 | returncxx . . $ QString#QString(e1217c004a86c950). ""cxx . . $ QString#QString(85c52e162fed56f9).; |
| 105 | } |
| 106 | } |