void MicroDVDSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, std::string const& encoding) const { agi::vfr::Framerate fps = AskForFPS(true, false); if (!fps.IsLoaded()) return; AssFile copy(*src); copy.Sort(); StripComments(copy); RecombineOverlaps(copy); MergeIdentical(copy); StripTags(copy); ConvertNewlines(copy, "|"); TextFileWriter file(filename, encoding); // Write FPS line if (!fps.IsVFR()) file.WriteLineToFile(str(boost::format("{1}{1}%.6f") % fps.FPS())); // Write lines for (auto current : copy.Line | agi::of_type<AssDialogue>()) { int start = fps.FrameAtTime(current->Start, agi::vfr::START); int end = fps.FrameAtTime(current->End, agi::vfr::END); file.WriteLineToFile(str(boost::format("{%i}{%i}%s") % start % end % boost::replace_all_copy(current->Text.get(), "\\N", "|"))); } }
void MicroDVDSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename, wxString const& encoding) const { agi::vfr::Framerate fps = AskForFPS(true, false); if (!fps.IsLoaded()) return; AssFile copy(*src); copy.Sort(); StripComments(copy.Line); RecombineOverlaps(copy.Line); MergeIdentical(copy.Line); StripTags(copy.Line); ConvertNewlines(copy.Line, "|"); TextFileWriter file(filename, encoding); // Write FPS line if (!fps.IsVFR()) { file.WriteLineToFile(wxString::Format("{1}{1}%.6f", fps.FPS())); } // Write lines for (LineList::const_iterator cur = copy.Line.begin(); cur != copy.Line.end(); ++cur) { if (AssDialogue *current = dynamic_cast<AssDialogue*>(*cur)) { int start = fps.FrameAtTime(current->Start, agi::vfr::START); int end = fps.FrameAtTime(current->End, agi::vfr::END); file.WriteLineToFile(wxString::Format("{%i}{%i}%s", start, end, current->Text)); } } }
void EncoreSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename, wxString const&) const { agi::vfr::Framerate fps = AskForFPS(false, true); if (!fps.IsLoaded()) return; // Convert to encore AssFile copy(*src); copy.Sort(); StripComments(copy.Line); RecombineOverlaps(copy.Line); MergeIdentical(copy.Line); StripTags(copy.Line); ConvertNewlines(copy.Line, "\r\n"); // Encode wants ; for NTSC and : for PAL // The manual suggests no other frame rates are supported char sep = fps.NeedsDropFrames() ? ';' : ':'; SmpteFormatter ft(fps, sep); // Write lines int i = 0; TextFileWriter file(filename, "UTF-8"); for (LineList::const_iterator cur = copy.Line.begin(); cur != copy.Line.end(); ++cur) { if (AssDialogue *current = dynamic_cast<AssDialogue*>(*cur)) { ++i; file.WriteLineToFile(wxString::Format("%i %s %s %s", i, ft.ToSMPTE(current->Start), ft.ToSMPTE(current->End), current->Text)); } } }
// // AddTrace() // // - adds text to the status dialog text buffer. The window is // updated with the new text only if there's a newline character // in the text. // void CPlayerStatusDialog::AddTrace(const CString& strText) { // no analysis if in express autoplay or output is suppressed #ifdef _TESTING if (m_bSuppressOutput) return; #else if (theApp.InExpressAutoPlay() || m_bSuppressOutput) return; #endif // need to be either printing analysis or providing a hint if (!theApp.GetValue(tbEnableAnalysisTracing) && !m_bCopyHintBlock) return; // CString strNewText; BOOL bOutputText = ConvertNewlines(strNewText, strText); if (m_bSuppressStream) { if (bOutputText) m_bSuppressStream = FALSE; // reset } else { // show analysis notes if enabled if (theApp.GetValue(tbEnableAnalysisTracing)) { m_strAnalysis += strNewText; if (bOutputText) OutputText(); } // and update hint window // if (m_bAutoHintMode && m_bCopyHintBlock && (m_nSuspendHints == 0) && if (m_bCopyHintBlock && (m_nSuspendHints == 0) && (m_nCurrentOutputLevel <= m_nRequiredHintTraceLevel)) { // route to the autohint window m_strHintBlock += strNewText; CAutoHintDialog* pHintDlg = (CAutoHintDialog*) pMAINFRAME->GetDialog(twAutoHintDialog); pHintDlg->SetHintText(m_strHintBlock); } } }
void TTXTSubtitleFormat::ConvertToTTXT(AssFile &file) const { file.Sort(); StripComments(file); RecombineOverlaps(file); MergeIdentical(file); StripTags(file); ConvertNewlines(file, "\r\n"); // Find last line agi::Time lastTime; if (!file.Events.empty()) lastTime = file.Events.back().End; // Insert blank line at the end auto diag = new AssDialogue; diag->Start = lastTime; diag->End = lastTime+OPT_GET("Timing/Default Duration")->GetInt(); file.Events.push_back(*diag); }
void TTXTSubtitleFormat::ConvertToTTXT(AssFile &file) const { file.Sort(); StripComments(file); RecombineOverlaps(file); MergeIdentical(file); StripTags(file); ConvertNewlines(file, "\r\n"); // Find last line AssTime lastTime; for (auto line : file.Line | boost::adaptors::reversed | agi::of_type<AssDialogue>()) { lastTime = line->End; break; } // Insert blank line at the end auto diag = new AssDialogue; diag->Start = lastTime; diag->End = lastTime+OPT_GET("Timing/Default Duration")->GetInt(); file.Line.push_back(*diag); }
void EncoreSubtitleFormat::WriteFile(const AssFile *src, agi::fs::path const& filename, agi::vfr::Framerate const& video_fps, std::string const&) const { agi::vfr::Framerate fps = AskForFPS(false, true, video_fps); if (!fps.IsLoaded()) return; // Convert to encore AssFile copy(*src); copy.Sort(); StripComments(copy); RecombineOverlaps(copy); MergeIdentical(copy); StripTags(copy); ConvertNewlines(copy, "\r\n"); // Encore wants ; for NTSC and : for PAL // The manual suggests no other frame rates are supported SmpteFormatter ft(fps, fps.NeedsDropFrames() ? ";" : ":"); // Write lines int i = 0; TextFileWriter file(filename, "UTF-8"); for (auto const& current : copy.Events) file.WriteLineToFile(str(boost::format("%i %s %s %s") % ++i % ft.ToSMPTE(current.Start) % ft.ToSMPTE(current.End) % current.Text)); }
void TTXTSubtitleFormat::ConvertToTTXT(AssFile &file) const { file.Sort(); StripComments(file.Line); RecombineOverlaps(file.Line); MergeIdentical(file.Line); StripTags(file.Line); ConvertNewlines(file.Line, "\r\n"); // Find last line AssTime lastTime; for (LineList::reverse_iterator cur = file.Line.rbegin(); cur != file.Line.rend(); ++cur) { if (AssDialogue *prev = dynamic_cast<AssDialogue*>(*cur)) { lastTime = prev->End; break; } } // Insert blank line at the end AssDialogue *diag = new AssDialogue; diag->Start = lastTime; diag->End = lastTime+OPT_GET("Timing/Default Duration")->GetInt(); file.Line.push_back(diag); }
void CPlayerStatusDialog::Trace(const CString& strText) { // sanity check CString strOutput = strText; if (strOutput.IsEmpty() || m_bSuppressStream) return; // AfxMessageBox(strText); // NCR TESTING SHows many types of messages!!!!!!!!!!!! // no analysis if in express autoplay or output is suppressed #ifdef _TESTING if (m_bSuppressOutput) return; #else if (theApp.InExpressAutoPlay() || m_bSuppressOutput) return; #endif // need to be either printing analysis or providing a hint if (!theApp.GetValue(tbEnableAnalysisTracing) && !m_bCopyHintBlock) return; // get and test the trace level int nTraceLevelLimit = theApp.GetValue(tnAnalysisTraceLevel); m_nCurrentOutputLevel = 0; // see if a verbosity escape code is present if (strOutput[0] == '!') { m_bIgnoreStreamLevel = TRUE; strOutput = strOutput.Mid(1); } else { m_bIgnoreStreamLevel = FALSE; } // see if a verbosity level code is present if (isdigit(strOutput[0])) m_nCurrentOutputLevel = strOutput[0] - '0'; else m_nCurrentOutputLevel = tnDefaultTraceLevel; // look for an autohint bypass (not so informative information) BOOL bSkipAutoHint = FALSE; if (strOutput[0] == _T('$')) { bSkipAutoHint = TRUE; strOutput = strOutput.Mid(1); } // check for temporary stream level override if ((m_nOverrideOutputLevel > 0) && (!m_bIgnoreStreamLevel)) m_nCurrentOutputLevel = m_nOverrideOutputLevel; // skip if the verbosity in the stream is too high if (m_nCurrentOutputLevel > nTraceLevelLimit) { // if this string doesn't contain a CR, suppress remainder of output stream if (strOutput.Find('\n') < 0) m_bSuppressStream = TRUE; return; } // strip the verbosity level digit if (isdigit(strOutput[0])) strOutput = strOutput.Mid(1); // convert newlines CString strNewText; BOOL bOutputText = ConvertNewlines(strNewText, strOutput); // show analysis notes if (theApp.GetValue(tbEnableAnalysisTracing)) { m_strAnalysis += strNewText; if (bOutputText) OutputText(); } // and show hints // if (m_bAutoHintMode && m_bCopyHintBlock && !bSkipAutoHint && (m_nSuspendHints == 0) && if (m_bCopyHintBlock && !bSkipAutoHint && (m_nSuspendHints == 0) && (m_nCurrentOutputLevel <= m_nRequiredHintTraceLevel)) { // route to the autohint window m_strHintBlock += strNewText; CAutoHintDialog* pHintDlg = (CAutoHintDialog*) pMAINFRAME->GetDialog(twAutoHintDialog); pHintDlg->SetHintText(m_strHintBlock); } }