forked from difcareer/010templates
-
Notifications
You must be signed in to change notification settings - Fork 3
/
ISOBMFTemplate.bt
executable file
·157 lines (140 loc) · 4.92 KB
/
ISOBMFTemplate.bt
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
//--------------------------------------
//--- 010 Editor v4.0.3 Binary Template
//
// File: ISOBMFTemplate.bt
// Author: @RReverser
// Revision: 201302261710
// Purpose: Parse ISO Base Media File Format files (QuickTime, JPEG2000, MPEG-4, etc.)
//--------------------------------------
BigEndian();
typedef struct
{
uint32 size <hidden = true>;
char type[4] <hidden = true>;
switch (type)
{
case "ftyp":
char fileType[4] <name = "File type", comment = "http://ftyps.com/">;
break;
case "co64":
ubyte version <name = "Version">;
ubyte flags[3] <name = "Flags", format = binary>;
uint32 n <hidden = true>;
uint64 entries[n] <name = "Chunk offsets">;
break;
case "ctts":
ubyte version <name = "Version">;
ubyte flags[3] <name = "Flags", format = binary>;
uint32 n <hidden = true>;
struct {
uint32 sampleCount <name = "Sample count">;
uint32 offset <name = "Offset">;
} entries[n] <name = "Chunk offsets">;
break;
case "elst":
ubyte version <name = "Version">;
ubyte flags[3] <name = "Flags", format = binary>;
uint32 n <hidden = true>;
struct {
uint32 duration <name = "Duration", comment = "In global timescale units">;
uint32 mediaTime <name = "Media time", comment = "In trak timescale units">;
uint32 playbackSpeed <name = "Playback speed">;
} entries[n] <name = "Edit list entries">;
break;
case "fiel":
ubyte fields <name = "Scan mode", comment = "1 for progressive scan, 2 for 2:1 interlaced">;
ubyte detail <name = "Detail", comment = "https://developer.apple.com/quicktime/icefloe/dispatch019.html#fiel">;
break;
case "hdlr":
ubyte version <name = "Version">;
ubyte flags[3] <name = "Flags", format = binary>;
char component_type[4] <name = "Component type">;
char subtype[4] <name = "Component subtype">;
uint32 manufacturer <name = "Component manufacturer">;
uint32 flags <name = "Component flags">;
uint32 flags_mask <name = "Component flags mask">;
string name <name = "Component name">;
break;
case "mdhd":
ubyte version <name = "Version">;
ubyte flags[3] <name = "Flags", format = binary>;
if (version < 1)
{
uint32 creation_time <name = "Creation time">;
uint32 modification_time <name = "Modification time">;
}
else
{
uint64 creation_time <name = "Creation time">;
uint64 modification_time <name = "Modification time">;
}
uint32 time_scale <name = "Time scale">;
if (version < 1)
{
uint32 duration <name = "Duration">;
}
else
{
uint64 duration <name = "Duration">;
}
uint16 lang <name = "Language", format = binary, comment = "ISO-639 language code represented with three 5-bit values (each of which is the ASCII value of the letter minus 0x60)">;
uint16 quality <name = "Quality">;
break;
case "stco":
ubyte version <name = "Version">;
ubyte flags[3] <name = "Flags", format = binary>;
uint32 n <hidden = true>;
uint32 entries[n] <name = "Chunk offsets">;
break;
case "stss":
ubyte version <name = "Version">;
ubyte flags[3] <name = "Flags", format = binary>;
uint32 n <hidden = true>;
uint32 entries[n] <name = "Sync samples">;
break;
case "stsz":
ubyte version <name = "Version">;
ubyte flags[3] <name = "Flags", format = binary>;
uint32 uniform_size <name = "Uniform size">;
uint32 n <hidden = true>;
uint32 entries[n] <name = "Sample sizes">;
break;
case "cmov":
case "edts":
case "mdia":
case "minf":
case "moov":
case "rmda":
case "rmra":
case "stbl":
case "trak":
while (FTell() - startof(this) < size)
{
struct Atom child;
}
break;
default:
FSeek(FTell() - 8);
break;
}
local int left = size - (FTell() - startof(this));
if (left > 0)
{
ubyte data[left] <format = hex>;
}
}
Atom <name = GetAtomName, size = GetAtomSize>;
int GetAtomSize(Atom &atom)
{
return ReadUInt(startof(atom));
}
string GetAtomName(Atom &atom)
{
char type[4];
ReadBytes(type, startof(atom) + 4, 4);
return type;
}
while (!FEof())
{
Atom atom;
}