-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEBML_Core.ahk
149 lines (139 loc) · 4.35 KB
/
EBML_Core.ahk
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
_Core(ByRef Array, Quick="") {
Static elem := Elem(), file
; array_list(elem)
; msgbox,% Array.___Name
; HL := 1
If HL
TV_Modify(Array.___TV_ItemID, "Select")
;=====================================
; Get Data if node is not Master and has not yet get Data
;===============================================================================
If (Array.___Kind != "m") AND (Array.___Kind != "") AND (Array.___Data = "") ; ArrayType.HasKey(array.___Kind)
{
EBML_TypeElement(File, Array)
return
}
If (Array.___Kind = "m")
{
;=====================================
; Check each current nodes
;===============================================================================
If (Quick = ".*")
{
For i, Node in Array.___ItemOrder
{
If (Array[Node].___Kind = "m")
_Core(Array[Node], ".*")
Else If (Array[Node].___Kind != "m") AND (Array[Node].___Data = "") ; Prevent from get data multiple times
EBML_TypeElement(File, Array[Node])
Else If (Array[Node].___Kind = "")
msgbox, ERROR `n unknow .___Kind
}
}
;=====================================
; Set Offset after last item
;===============================================================================
If Array.___ItemsCount
{
LastItem := Array.___ItemOrder[Array.___ItemsCount] ; data offset to first nonprocessed segment instad of last+size (to do)
Offset := Array[LastItem, "___EndOffset"]
}
Else
{
Offset := Array.___DataOffset
}
loop
{
If (Offset >= Array.___EndOffset)
{
return FALSE
Break
}
pos := Offset
File.Seek(OffSet, 0)
File.RawRead(Buffer, 12) ; 4+8 = ID+Size = MaxHeaderSize
;=====================================
Header := EBML_ReadHeader(Buffer)
Offset += Header.Next
Header_Size := Header.HSize
ID_Num := Header.ID
ID_Name := elem[ID_Num, "Name"]
ID_Kind := elem[ID_Num, "Kind"]
mode := ID_Name
; mode := ID_Num
ID := ID_Name=""?ID_Num:mode ; String or Hex if missing name
;=====================================
If ID_Name in Cluster,Cues
{
; =========== -=TV=- ===========
Array["_ForceReturn", "___TV_ItemID"] := TV_Add("--==FORCE RETURN CAUSE: " ID_Name "==--", Array.___TV_ItemID, ex)
return
; continue
}
;=====================================
{
Array.___ItemsCounter.HasKey(ID)
?(Array.___ItemsCounter[ID] ++)
:(Array.___ItemsCounter[ID] := 1)
}
{
Array.___ItemsCount
?(Array.___ItemsCount ++)
:(Array.___ItemsCount := 1)
}
Array_ID := ID "[" Array.___ItemsCounter[ID] "]" ; Name_String
Array.___ItemOrder[Array.___ItemsCount] := Array_ID
Array[Array_ID] := {}
;=====================================
; TreeView
;===============================================================================
; TV_ID := ID_Name=""?ID_NumH(ID_Num):ID_Name "[" Array.___ItemsCounter[ID] "]" ; Name[1] - Unknow ID = Hex
TV_ID := ID_Name=""?ID_NumH(ID_Num):ID_Name ; Name - Unknow ID = Hex
; TV_ID := ID_NumH(ID_Num) "[" Array.___ItemsCounter[ID] "]"
; ex := "Expand"
; =========== -=TV=- ===========
Array[Array_ID].___TV_String := TV_ID
Array[Array_ID].___TV_ItemID := TV_Add(TV_ID, Array.___TV_ItemID, ex)
;=====================================
; Array build
;===============================================================================
Array[Array_ID].___DataOffset := pos + Header_Size
Array[Array_ID].___DataSize := Header.DSize
Array[Array_ID].___ID := ID_Num
Array[Array_ID].___HeadOffset := pos
Array[Array_ID].___HeadSize := Header_Size
Array[Array_ID].___Name := ID
Array[Array_ID].___Kind := ID_Kind
Array[Array_ID].___EndOffset := pos + Header_Size + Header.DSize
If (ID_Kind = "m")
{
Array[Array_ID].___ItemsCounter := []
Array[Array_ID].___ItemOrder := []
Array[Array_ID].___ItemsCount := 0
}
; =========== -=TV=- ===========
If HL
TV_Modify(Array[Array_ID].___TV_ItemID, "Select")
;=====================================
; Interpretate
;===============================================================================
If (Quick = Array_ID)
return TRUE
If (Quick = ".*")
{
If (ID_Kind = "m")
{
_Core(Array[Array_ID], ".*")
}
Else
{
EBML_TypeElement(File, Array[Array_ID])
}
}
}
}
If (Array = "SetFile")
{
file := Quick
}
}