-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSegment.cs
More file actions
298 lines (242 loc) · 7.21 KB
/
Segment.cs
File metadata and controls
298 lines (242 loc) · 7.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
/***
* http://blog.thescorpius.com/index.php/2017/07/15/presentation-graphic-stream-sup-files-bluray-subtitle-format/
*/
using System;
using System.Collections.Generic;
using System.Drawing;
namespace SupSubtitleParser
{
public class Segment
{
/// <summary>
/// Presentation Timestamp
/// </summary>
public UInt32 PTS { get; set; }
/// <summary>
/// Decoding Timestamp
/// </summary>
public UInt32 DTS { get; set; }
/// <summary>
/// 0x14: PDS
/// 0x15: ODS
/// 0x16: PCS
/// 0x17: WDS
/// 0x80: END
/// </summary>
public SegType Type { get; set; }
/// <summary>
/// Size of the segment
/// </summary>
public UInt16 DataSize { get; set; }
public Segment()
{
}
public Segment(Segment seg)
{
this.DTS = seg.DTS;
this.PTS = seg.PTS;
this.DataSize = seg.DataSize;
this.Type = seg.Type;
}
}
/// <summary>
/// Presentation Composition Segment
/// </summary>
public class PCSData : Segment
{
/// <summary>
/// Video width in pixels
/// </summary>
public Size Size { get; set; }
/// <summary>
/// Video height in pixels
/// </summary>
public UInt16 Height { get; set; }
/// <summary>
/// Always 0x10. Can be ignored.
/// </summary>
public UInt16 FrameRate { get; set; }
/// <summary>
/// Composition Number
/// </summary>
public UInt16 CompNum { get; set; }
/// <summary>
/// Composition State
/// </summary>
public CompState CompState { get; set; }
/// <summary>
/// Palette Update Flag
/// </summary>
public UInt16 PaletteUpdFlag { get; set; }
/// <summary>
/// ID of the palette to be used in the Palette only Display Update
/// </summary>
public UInt16 PaletteID { get; set; }
/// <summary>
/// Number of Composition Objects
/// </summary>
public UInt16 CompObjCount { get; set; }
public List<PCSObject> PCSObjects { get; set; }
public PCSData()
{
this.Type = SegType.PCS;
}
public PCSData(Segment seg) : base(seg)
{
}
}
public class PCSObject
{
/// <summary>
/// ID of the ODS segment that defines the image to be shown
/// </summary>
public UInt16 ObjectID { get; set; }
/// <summary>
/// Id of the WDS segment to which the image is allocated in the PCS. Up to two images may be assigned to one window
/// </summary>
public UInt16 WindowID { get; set; }
/// <summary>
/// Object Cropped Flag
/// 0x40: Force display of the cropped image object
/// 0x00: Off
/// </summary>
public bool ObjCroppedFlag { get; set; }
/// <summary>
/// Point from the top left pixel of the image on the screen
/// </summary>
public Point Origin { get; set; }
/// <summary>
/// Point from the top left pixel of the cropped object in the screen.
/// Only used when the Object Cropped Flag is set to 0x40.
/// </summary>
public Point? CropOrigin { get; set; }
/// <summary>
/// Size of the cropped object in the screen.
/// Only used when the Object Cropped Flag is set to 0x40.
/// </summary>
public Size? CropSize { get; set; }
}
/// <summary>
/// Window Definition Segment
/// </summary>
public class WDSData : Segment
{
public UInt16 ObjectCount { get; set; }
public List<WDSObject> WDSObjects { get; set; }
public WDSData()
{
Type = SegType.WDS;
}
public WDSData(Segment seg) : base(seg)
{
}
}
public class WDSObject
{
/// <summary>
/// ID of this window
/// </summary>
public UInt16 WindowsID { get; set; }
/// <summary>
/// Origin from the top left pixel of the window in the screen.
/// </summary>
public Point Origin { get; set; }
/// <summary>
/// Size of the window
/// </summary>
public Size Size { get; set; }
}
/// <summary>
/// Palette Definition Segment
/// </summary>
public class PDSData : Segment
{
/// <summary>
/// ID of the palette
/// </summary>
public UInt16 PaletteID { get; set; }
/// <summary>
/// Version of this palette within the Epoch
/// </summary>
public UInt16 PaletteVer { get; set; }
public List<PDSEntryObject> EntryObjects { get; set; }
public PDSData()
{
Type = SegType.PDS;
}
public PDSData(Segment seg) : base(seg)
{
}
}
public class PDSEntryObject
{
/// <summary>
/// Entry number of the palette
/// </summary>
public UInt16 PaletteEntryID { get; set; }
/// <summary>
/// Luminance (Y value)
/// </summary>
public UInt16 Luminance { get; set; }
/// <summary>
/// Color Difference Red (Cr value)
/// </summary>
public UInt16 ColorDifferenceRed { get; set; }
/// <summary>
/// Color Difference Blue (Cb value)
/// </summary>
public UInt16 ColorDifferenceBlue { get; set; }
/// <summary>
/// Transparency (Alpha value)
/// </summary>
public UInt16 Transparency { get; set; }
}
public class ODSData : Segment
{
/// <summary>
/// ID of this object
/// </summary>
public UInt16 ObjectID { get; set; }
/// <summary>
/// Version of this object
/// </summary>
public UInt16 ObjectVer { get; set; }
/// <summary>
/// If the image is split into a series of consecutive fragments, the last fragment has this flag set. Possible values:
/// 0x40: Last in sequence
/// 0x80: First in sequence
/// 0xC0: First and last in sequence(0x40 | 0x80)
/// </summary>
public UInt16 SeqFlag { get; set; }
/// <summary>
/// The length of the Run-length Encoding (RLE) data buffer with the compressed image data.
/// </summary>
public UInt32 ObjDataLength { get; set; }
/// <summary>
/// Size of the image
/// </summary>
public Size ImageSize { get; set; }
/// <summary>
/// This is the image data compressed using Run-length Encoding (RLE).
/// The size of the data is defined in the Object Data Length field.
/// </summary>
public byte[] ObjectData { get; set; }
public ODSData()
{
Type = SegType.ODS;
}
public ODSData(Segment seg) : base(seg)
{
}
}
public class ENDData : Segment
{
public ENDData()
{
Type = SegType.END;
}
public ENDData(Segment seg) : base(seg)
{
}
}
}