/[tivodecode]/t2sami/trunk/CC.h
ViewVC logotype

Contents of /t2sami/trunk/CC.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 185 - (show annotations) (download)
Fri Mar 23 03:57:21 2007 UTC (15 years, 4 months ago) by jmemmott
File MIME type: text/plain
File size: 3297 byte(s)
Merged in captioning improvements made between between versions 2.0.0025 and 2.0.0033 of Windows source.

1 // CC.h
2 //
3 //********************************************************************
4 //
5 // Copyright (c) 2005-2007 James Memmott <jmemmott@braeman.com>
6 //
7 // This software is provided 'as-is', without any express or implied warranty.
8 // In no event will the author be held liable for any damages arising from the
9 // use of this software.
10 //
11 // Permission is granted to anyone to use this software for any purpose, including
12 // commercial applications, and to alter it and redistribute it freely, subject to
13 // the following restrictions:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the disclaimer.
17 //
18 // 2. The origin of this software must not be misrepresented; you must not claim
19 // that you wrote the original software. If you use this software in a product,
20 // an acknowledgment in the product documentation would be appreciated but is
21 // not required.
22 //
23 // 3. Altered source versions must be plainly marked as such, and must not be
24 // misrepresented as being the original software.
25 //
26 //********************************************************************
27 //
28
29 #ifndef CC_H
30 #define CC_H
31
32 #if _MSC_VER > 1000
33 #pragma once
34 #endif // _MSC_VER > 1000
35 #include <string>
36
37 // forward declare class
38 class CTivoScan;
39
40 //********************************************************************
41 // CCNode
42
43 class CCNode {
44
45 friend class CClosedCaption;
46
47 public:
48
49 CCNode( double PTS, byte b1, byte b2 );
50 CCNode();
51
52 double m_PTS;
53 byte m_b1;
54 byte m_b2;
55 CCNode *m_link;
56
57 };
58
59 /////////////////////////////////////////////////////////////////////////////
60 // Captioning Modes
61 #define CAP_ROLL 0x10
62 #define CAP_ROLL2 0x12
63 #define CAP_ROLL3 0x13
64 #define CAP_ROLL4 0x14
65 #define CAP_POPON 0x24
66 #define CAP_UNKNOWN 0x40
67
68 //********************************************************************
69 // CClosedCaption
70
71 class CClosedCaption{
72
73 friend class CTivoScan;
74
75 // Attributes
76 public:
77
78 FILE * m_nFile;
79 unsigned int CC_last;
80 int m_nNowChannel;
81 CCNode *m_head[4];
82 CCNode *m_lastNodeAdded;
83 CCNode *m_ChannelExtra;
84 bool m_bEocValid;
85 double m_EocPTS;
86 int m_popLast;
87 double m_popPTS;
88 std::string m_szOutputFile;
89
90 private:
91
92 CTivoScan *m_pParent;
93 int m_captionMode;
94
95 // Implementation
96 public:
97 CClosedCaption();
98 virtual ~CClosedCaption();
99
100 bool Initialize( std::string szOutputName );
101 bool Close(void);
102
103 protected:
104 int CcDecode( byte b1, byte b2 );
105 void WriteLine( const char * lpMessage );
106 std::string CompressString( std::string &cs );
107 void SplitSubtitles();
108 void WriteSubtitles();
109 bool WriteSubtitleLine( bool &bDoBR, int line );
110 void InsertNode( CCNode *node );
111 void ClearNodes();
112 void ClearNodes( int line );
113 void ClearNodes( double dTimeStamp );
114 std::string HtmlEncode( unsigned char c );
115 std::string NodesToString( int line );
116 double FirstNodePTS( int line );
117 double LastNodePTS( int line );
118 bool IsEoc();
119 int getSyncTime( int line = -1 );
120 bool isRollup() { return ( ((m_captionMode & CAP_ROLL) != 0) &&
121 ((m_captionMode & 0x0f) > 1) ) ? true : false; }
122 void doRollup( double dPTS );
123 int getSubtitleLineCount();
124 bool validPreamble( byte b, byte *set );
125 int getPreambleRow( byte b1, byte b2 );
126 std::string getOutputFileName() { return m_szOutputFile; }
127
128
129 };
130
131 #endif

cvs@jdrake.com
ViewVC Help
Powered by ViewVC 1.1.13