-
-
Notifications
You must be signed in to change notification settings - Fork 195
/
Copy pathsup.hexpat
119 lines (103 loc) · 2.66 KB
/
sup.hexpat
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
#pragma description SUP Bluray Subtitle
#pragma magic [ 50 47 ] @ 0x00
#pragma endian big
import std.mem;
enum SegmentType : u8{
PaletteDefinitionSegment=0x14,
ObjectDefinitionSegment=0x15,
PresentationCompositionSegment=0x16,
WindowDefinitionSegment=0x17,
END=0x80
};
enum CompositionState : u8 {
Normal=0x00,
AcquisitionPoint=0x40,
EpochStart=0x80
};
enum PaletteUpdateFlag : u8 {
False=0x00,
True=0x80
};
enum ObjectCroppedFlag : u8{
True=0x40,
False=0x00
};
struct CompositionObject{
u16 objectID;
u8 windowID;
ObjectCroppedFlag objectCroppedFlag;
u16 objectHorizontalPosition;
u16 objectVerticalPosition;
if (objectCroppedFlag == ObjectCroppedFlag::True){
u16 objectCroppingHorizontalPosition;
u16 objectCroppingVerticalPosition;
u16 objectCroppingWidth;
u16 objectCroppingHeight;
}
};
struct PresentationCompositionSegment{
u16 width;
u16 height;
u8 framerate;
u16 compositionNumber;
CompositionState compositionState;
PaletteUpdateFlag paletteUpdateFlag;
u8 paletteID;
u8 numberOfCompositionObjects;
CompositionObject compositionObject[numberOfCompositionObjects];
};
struct WindowDefinitionSegment{
u8 numberOfWindows;
u8 windowID;
u16 windowHorizontalPosition;
u16 windowVerticalPosition;
u16 windowWidth;
u16 windowHeight;
};
fn paletteCount(){
u64 len = (parent.parent.header.segmentSize-7)/5+1;
return len;
};
struct PaletteEntry{
u8 paletteEntryID;
u8 luminance;
u8 colorDifferenceRed [[color("FF0000")]];
u8 colorDifferenceBlue [[color("0000FF")]];
u8 Transparency;
};
struct PaletteDefinitionSegment{
u8 paletteID;
u8 paletteVersionNumber;
PaletteEntry paletteEntry[paletteCount()];
};
enum LastInSequenceFlag : u8{
LastInSequence=0x40,
FirstInSequence=0x80,
FirstAndLastsInSequence=0xC0
};
struct ObjectDefinitionSegment{
u16 objectID;
u8 objectVersionNumber;
LastInSequenceFlag lastInSequenceFlag;
u24 objectDataLength;
//u16 width;
//u16 height;
u8 objectData[objectDataLength];
};
struct PGSHeader{
char magicNumber[2];
u32 presentationTimeStamp;
u32 decodingTimeStamp;
SegmentType segmentType;
u16 segmentSize;
};
struct PGSSegment{
PGSHeader header;
match(header.segmentType){
(0x14): PaletteDefinitionSegment paletteDefinitionSegment;
(0x15): ObjectDefinitionSegment objectDefinitionSegment;
(0x16): PresentationCompositionSegment presentationCompositionSegment;
(0x17): WindowDefinitionSegment windowDefinitionSegment;
}
};
PGSSegment pgsSegment[while(!std::mem::eof())] @ 0;