1
+ #pragma description SUP Bluray Subtitle
2
+
3
+ #pragma magic [50 47] @ 0x00
4
+ #pragma endian big
5
+
6
+ import std.mem;
7
+
8
+ enum SegmentType : u8{
9
+ PaletteDefinitionSegment=0x14,
10
+ ObjectDefinitionSegment=0x15,
11
+ PresentationCompositionSegment=0x16,
12
+ WindowDefinitionSegment=0x17,
13
+ END=0x80
14
+ };
15
+
16
+
17
+
18
+ enum CompositionState : u8 {
19
+ Normal=0x00,
20
+ AcquisitionPoint=0x40,
21
+ EpochStart=0x80
22
+ };
23
+ enum PaletteUpdateFlag : u8 {
24
+ False=0x00,
25
+ True=0x80
26
+ };
27
+ enum ObjectCroppedFlag : u8{
28
+ True=0x40,
29
+ False=0x00
30
+ };
31
+ struct CompositionObject{
32
+ u16 objectID;
33
+ u8 windowID;
34
+ ObjectCroppedFlag objectCroppedFlag;
35
+ u16 objectHorizontalPosition;
36
+ u16 objectVerticalPosition;
37
+ if (objectCroppedFlag == ObjectCroppedFlag::True){
38
+ u16 objectCroppingHorizontalPosition;
39
+ u16 objectCroppingVerticalPosition;
40
+ u16 objectCroppingWidth;
41
+ u16 objectCroppingHeight;
42
+ }
43
+ };
44
+ struct PresentationCompositionSegment{
45
+ u16 width;
46
+ u16 height;
47
+ u8 framerate;
48
+ u16 compositionNumber;
49
+ CompositionState compositionState;
50
+ PaletteUpdateFlag paletteUpdateFlag;
51
+ u8 paletteID;
52
+ u8 numberOfCompositionObjects;
53
+ CompositionObject compositionObject[numberOfCompositionObjects];
54
+ };
55
+
56
+
57
+ struct WindowDefinitionSegment{
58
+ u8 numberOfWindows;
59
+ u8 windowID;
60
+ u16 windowHorizontalPosition;
61
+ u16 windowVerticalPosition;
62
+ u16 windowWidth;
63
+ u16 windowHeight;
64
+ };
65
+
66
+ fn paletteCount(){
67
+ u64 len = (parent.parent.header.segmentSize-7)/5+1;
68
+ return len;
69
+ };
70
+ struct PaletteEntry{
71
+ u8 paletteEntryID;
72
+ u8 luminance;
73
+ u8 colorDifferenceRed [[color("FF0000")]];
74
+ u8 colorDifferenceBlue [[color("0000FF")]];
75
+ u8 Transparency;
76
+ };
77
+ struct PaletteDefinitionSegment{
78
+ u8 paletteID;
79
+ u8 paletteVersionNumber;
80
+ PaletteEntry paletteEntry[paletteCount()];
81
+ };
82
+
83
+
84
+ enum LastInSequenceFlag : u8{
85
+ LastInSequence=0x40,
86
+ FirstInSequence=0x80,
87
+ FirstAndLastsInSequence=0xC0
88
+ };
89
+ struct ObjectDefinitionSegment{
90
+ u16 objectID;
91
+ u8 objectVersionNumber;
92
+ LastInSequenceFlag lastInSequenceFlag;
93
+ u24 objectDataLength;
94
+ //u16 width;
95
+ //u16 height;
96
+ u8 objectData[objectDataLength];
97
+ };
98
+
99
+
100
+ struct PGSHeader{
101
+ char magicNumber[2];
102
+ u32 presentationTimeStamp;
103
+ u32 decodingTimeStamp;
104
+ SegmentType segmentType;
105
+ u16 segmentSize;
106
+ };
107
+
108
+ struct PGSSegment{
109
+ PGSHeader header;
110
+ match(header.segmentType){
111
+ (0x14): PaletteDefinitionSegment paletteDefinitionSegment;
112
+ (0x15): ObjectDefinitionSegment objectDefinitionSegment;
113
+ (0x16): PresentationCompositionSegment presentationCompositionSegment;
114
+ (0x17): WindowDefinitionSegment windowDefinitionSegment;
115
+ }
116
+ };
117
+
118
+
119
+ PGSSegment pgsSegment[while(!std::mem::eof())] @ 0;
0 commit comments