long scanInit(void) { int i; startStopEvent = epicsEventMustCreate(epicsEventEmpty); scanCtl = ctlPause; initPeriodic(); initOnce(); buildScanLists(); for (i = 0; i < nPeriodic; i++) spawnPeriodic(i); return 0; }
/** * SPQR benchmarking implementation */ int main() { Run run; c = configSPQR(stdin); if (c->errors) { freeSPQR(c); die("Sorry! Problem(s) with your configuration file.", 1); } /* printConfig(c); printf("\n"); */ run = runAll(initOnce(c)); printRun(run); freeRun(run); freeSPQR(c); return 0; }
bool Classic::toASS(const QByteArray &txt, LibASS *ass, double fps) { if (!ass) return false; bool ok = false, use_mDVD_FPS = Use_mDVD_FPS; QRegExp TMPRegExp("\\d{1,2}:\\d{1,2}:\\d{1,2}\\D"); QRegExp MPL2RegExp("\\[\\d+\\]\\[\\d*\\]"); QRegExp MicroDVDRegExp("\\{\\d+\\}\\{\\d*\\}"); QList< Sub_Without_End > subs_without_end; foreach (const QString &line, QString(txt).remove('\r').split('\n', QString::SkipEmptyParts)) { double start = 0.0, duration = 0.0; QByteArray sub; int idx; if ((idx = line.indexOf(TMPRegExp)) > -1) { int h = -1, m = -1, s = -1; sscanf(line.toUtf8().data()+idx, "%d:%d:%d", &h, &m, &s); if (h > -1 && m > -1 && s > -1) { start = h*3600 + m*60 + s; sub = line.section(TMPRegExp, 1, 1, QString::SectionIncludeTrailingSep).toUtf8(); } } else if ((idx = line.indexOf(MPL2RegExp)) > -1) { int s = -1, e = -1; sscanf(line.toUtf8().data()+idx, "[%d][%d]", &s, &e); if (s > -1) { start = s / 10.; duration = e / 10. - start; sub = line.section(MPL2RegExp, 1, 1, QString::SectionIncludeTrailingSep).toUtf8(); } } else if ((idx = line.indexOf(MicroDVDRegExp)) > -1) { int s = -1, e = -1; sscanf(line.toUtf8().data()+idx, "{%d}{%d}", &s, &e); if (s > -1) { sub = line.section(MicroDVDRegExp, 1, 1, QString::SectionIncludeTrailingSep).toUtf8(); if (use_mDVD_FPS && s == e && (s == 0 || s == 1)) { use_mDVD_FPS = false; double new_fps = atof(QByteArray(sub).replace('.', ',').data()); if (new_fps > 0.0 && new_fps < 1000.0) { fps = new_fps; continue; } } start = s / fps; duration = e / fps - start; } } if (start >= 0.0 && !sub.isEmpty()) { if (duration > 0.0) { initOnce(); ass->addASSEvent(sub.replace('|', "\\n"), start, duration); } else subs_without_end.push_back(Sub_Without_End(start, Sub_max_s, sub.replace('|', "\\n"))); } } if (subs_without_end.size()) { qSort(subs_without_end); for (int i = 0; i < subs_without_end.size()-1; ++i) { unsigned diff = subs_without_end[i+1] - subs_without_end[i]; if (!diff) { subs_without_end[i+1] += subs_without_end[i]; subs_without_end.removeAt(i); --i; } else subs_without_end[i].setDuration(diff); } initOnce(); foreach (const Sub_Without_End &sub, subs_without_end) ass->addASSEvent(sub.sub, sub.start, sub.duration); }
bool StFreeImage::init() { static const bool isFreeImageInitiailed = initOnce(); return isFreeImageInitiailed; }
bool Classic::toASS(const QByteArray &txt, LibASS *ass, double fps) { if (!ass) return false; bool ok = false, use_mDVD_FPS = Use_mDVD_FPS; const QRegExp TMPRegExp("\\d{1,2}:\\d{1,2}:\\d{1,2}\\D\\s?"); const QRegExp MPL2RegExp("\\[\\d+\\]\\[\\d*\\]\\s?"); const QRegExp MicroDVDRegExp("\\{\\d+\\}\\{\\d*\\}\\s?"); QRegExp MicroDVDStylesRegExp("\\{(\\w):(.*)\\}"); MicroDVDStylesRegExp.setMinimal(true); QList<SubWithoutEnd> subsWithoutEnd; for (const QString &line : QString(txt).remove('\r').split('\n', QString::SkipEmptyParts)) { double start = 0.0, duration = 0.0; QString sub; int idx; if ((idx = line.indexOf(TMPRegExp)) > -1) { int h = -1, m = -1, s = -1; sscanf(line.toLatin1().constData() + idx, "%d:%d:%d", &h, &m, &s); if (h > -1 && m > -1 && s > -1) { start = h*3600 + m*60 + s; sub = convertLine(TMPRegExp, line); } } else if ((idx = line.indexOf(MPL2RegExp)) > -1) { int s = -1, e = -1; sscanf(line.toLatin1().constData() + idx, "[%d][%d]", &s, &e); if (s > -1) { for (const QString &l : convertLine(MPL2RegExp, line).split('\n')) { if (!sub.isEmpty()) sub.append('\n'); if (!l.isEmpty()) { switch (l.at(0).toLatin1()) { case '/': sub.append("{\\i1}" + l.mid(1) + "{\\i0}"); break; case '\\': sub.append("{\\b1}" + l.mid(1) + "{\\b0}"); break; case '_': sub.append("{\\u1}" + l.mid(1) + "{\\u0}"); break; default: sub.append(l); break; } } } start = s / 10.0; duration = e / 10.0 - start; } } else if ((idx = line.indexOf(MicroDVDRegExp)) > -1) { int s = -1, e = -1; sscanf(line.toLatin1().constData() + idx, "{%d}{%d}", &s, &e); if (s > -1) { sub = convertLine(MicroDVDRegExp, line); if (use_mDVD_FPS && (s == 0 || s == 1)) { use_mDVD_FPS = false; const double newFPS = sub.midRef(0, 6).toDouble(); if (newFPS > 0.0 && newFPS < 100.0) { fps = newFPS; continue; } } int pos = 0; while ((pos = MicroDVDStylesRegExp.indexIn(sub, pos)) != -1) { const int matchedLength = MicroDVDStylesRegExp.matchedLength(); const QString styleText = MicroDVDStylesRegExp.cap(2); const QChar s = MicroDVDStylesRegExp.cap(1).at(0); const bool singleLine = s.isLower(); switch (s.toLower().toLatin1()) { case 'c': if (styleText.startsWith('$') && styleText.length() == 7) { replaceText(sub, pos, matchedLength, singleLine, "{\\1c&" + styleText.mid(1) + "&}", "{\\1c}"); continue; } break; case 'f': replaceText(sub, pos, matchedLength, singleLine, "{\\fn" + styleText + "}", "{\\fn}"); continue; case 's': replaceText(sub, pos, matchedLength, singleLine, "{\\fs" + styleText + "}", "{\\fs}"); continue; case 'p': if (!singleLine) { replaceText(sub, pos, matchedLength, false, "{\\pos(" + styleText + ")}", QString()); continue; } break; case 'y': replaceText(sub, pos, matchedLength, singleLine, "{\\" + styleText + "1}", "{\\" + styleText + "0}"); continue; } pos += MicroDVDStylesRegExp.matchedLength(); } start = s / fps; duration = e / fps - start; } } if (start >= 0.0 && !sub.isEmpty()) { if (duration > 0.0) { initOnce(ok, ass); ass->addASSEvent(Functions::convertToASS(sub), start, duration); } else subsWithoutEnd.append(SubWithoutEnd(start, Sub_max_s, sub)); } } if (!subsWithoutEnd.isEmpty()) { qSort(subsWithoutEnd); for (int i = 0; i < subsWithoutEnd.size()-1; ++i) { const unsigned diff = subsWithoutEnd.at(i+1) - subsWithoutEnd.at(i); if (!diff) { subsWithoutEnd[i+1] += subsWithoutEnd.at(i); subsWithoutEnd.removeAt(i); --i; } else subsWithoutEnd[i].setDuration(diff); } initOnce(ok, ass); for (const SubWithoutEnd &sub : asConst(subsWithoutEnd)) ass->addASSEvent(Functions::convertToASS(sub.sub), sub.start, sub.duration); } return ok; }