Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclsid2 <clsid2@users.sourceforge.net>2008-07-25 16:07:13 +0400
committerclsid2 <clsid2@users.sourceforge.net>2008-07-25 16:07:13 +0400
commit857e71a007ffd6ea0bcc4e85e89e6f8267439c93 (patch)
tree8c09a8e08155c76e633a5946d294a7432624548b /src/subtitles/RealTextParser.h
parent89c192cc8dcc275b1fe3716d360df5232bfa880c (diff)
Some VSFilter changes:
- Added RealText support - PAR correction option (for anamorphic video) - Fix rare seeking issue with VobSubs git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@686 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/subtitles/RealTextParser.h')
-rw-r--r--src/subtitles/RealTextParser.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/subtitles/RealTextParser.h b/src/subtitles/RealTextParser.h
new file mode 100644
index 000000000..06247e430
--- /dev/null
+++ b/src/subtitles/RealTextParser.h
@@ -0,0 +1,102 @@
+#pragma once
+
+#include <sstream>
+using std::wostream;
+using std::wostringstream;
+using std::endl;
+
+#include <string>
+using std::wstring;
+
+#include <map>
+using std::map;
+using std::pair;
+
+#include <vector>
+using std::vector;
+
+#include <list>
+using std::list;
+
+#include <cwctype>
+using std::towlower;
+
+class CRealTextParser
+{
+public:
+ CRealTextParser();
+ virtual ~CRealTextParser(void);
+
+ struct Tag
+ {
+ Tag(): m_bOpen(false), m_bClose(false), m_bComment(false), m_bText(false) {}
+
+ wstring m_szName;
+
+ bool m_bOpen;
+ bool m_bClose;
+
+ bool m_bComment;
+ bool m_bText;
+
+ map<wstring, wstring> m_mapAttributes;
+ };
+
+ struct Subtitles
+ {
+ Subtitles(): m_WindowTag(), m_FontTag(), m_bCenter(false) {}
+
+ Tag m_WindowTag;
+ Tag m_FontTag;
+
+ bool m_bCenter;
+
+ map<pair<int, int>, wstring> m_mapLines;
+ };
+
+ bool ParseRealText(wstring p_szFile);
+
+ const Subtitles& GetParsedSubtitles();
+
+ bool OutputSRT(wostream& p_rOutput);
+
+private:
+ bool ExtractTag(wstring& p_rszLine, Tag& p_rTag);
+ bool ExtractTextTag(wstring& p_rszLine, Tag& p_rTag);
+ bool ExtractString(wstring& p_rszLine, wstring& p_rszString);
+ bool SkipSpaces(wstring& p_rszLine, unsigned int& p_riPos);
+ bool GetString(wstring& p_rszLine, unsigned int& p_riPos, wstring& p_rszString, const wstring& p_crszEndChars);
+ bool GetAttributes(wstring& p_rszLine, unsigned int& p_riPos, map<wstring, wstring>& p_rmapAttributes);
+
+ int GetTimecode(const wstring& p_crszTimecode);
+ wstring FormatTimecode(int iTimecode,
+ int iMillisecondPrecision = 3,
+ bool p_bPadZeroes = true,
+ const wstring& p_crszSeparator = L":",
+ const wstring& p_crszMillisecondSeparator = L".");
+
+ wstring StringToLower(const wstring& p_crszString);
+
+ wstring RenderTags(const list<Tag>& p_crlTags);
+
+ void PopTag(list<Tag>& p_rlistTags, const wstring& p_crszTagName);
+
+ // Filter out for example multiple font tags opened previously (font tags are not always terminated properly in realtext and can build up)
+ void FilterReduntantTags(list<Tag>& p_rlistTags);
+
+
+ Subtitles m_RealText;
+
+ bool m_bIgnoreFont;
+ bool m_bIgnoreFontSize;
+ bool m_bIgnoreFontColor;
+ bool m_bIgnoreFontWeight;
+ bool m_bIgnoreFontFace;
+
+ int m_iMinFontSize;
+ int m_iMaxFontSize;
+
+ int m_iDefaultSubtitleDurationInMillisecs;
+
+ bool m_bTryToIgnoreErrors;
+};