|
1
|
|
|
|
|
2
|
|
|
/* |
|
3
|
|
|
* Copyright (c) 2017-2018 Rafael da Silva Rocha. |
|
4
|
|
|
* https://github.com/rochars/byte-data |
|
5
|
|
|
* |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* A char. |
|
10
|
|
|
* @type {!Object} |
|
11
|
|
|
*/ |
|
12
|
|
|
module.exports.chr = {"bits": 8, "char": true}; |
|
13
|
|
|
/** |
|
14
|
|
|
* A 4-char string |
|
15
|
|
|
* @type {!Object} |
|
16
|
|
|
*/ |
|
17
|
|
|
module.exports.fourCC = {"bits": 32, "char": true}; |
|
18
|
|
|
/** |
|
19
|
|
|
* Booleans |
|
20
|
|
|
* @type {!Object} |
|
21
|
|
|
*/ |
|
22
|
|
|
module.exports.bool = {"bits": 1}; |
|
23
|
|
|
/** |
|
24
|
|
|
* Signed 2-bit integers |
|
25
|
|
|
* @type {!Object} |
|
26
|
|
|
*/ |
|
27
|
|
|
module.exports.int2 = {"bits": 2, "signed": true}; |
|
28
|
|
|
/** |
|
29
|
|
|
* Unsigned 2-bit integers |
|
30
|
|
|
* @type {!Object} |
|
31
|
|
|
*/ |
|
32
|
|
|
module.exports.uInt2 = {"bits": 2}; |
|
33
|
|
|
/** |
|
34
|
|
|
* Signed 4-bit integers |
|
35
|
|
|
* @type {!Object} |
|
36
|
|
|
*/ |
|
37
|
|
|
module.exports.int4 = {"bits": 4, "signed": true}; |
|
38
|
|
|
/** |
|
39
|
|
|
* Unsigned 4-bit integers |
|
40
|
|
|
* @type {!Object} |
|
41
|
|
|
*/ |
|
42
|
|
|
module.exports.uInt4 = {"bits": 4}; |
|
43
|
|
|
/** |
|
44
|
|
|
* Signed 8-bit integers |
|
45
|
|
|
* @type {!Object} |
|
46
|
|
|
*/ |
|
47
|
|
|
module.exports.int8 = {"bits": 8, "signed": true}; |
|
48
|
|
|
/** |
|
49
|
|
|
* Unsigned 4-bit integers |
|
50
|
|
|
* @type {!Object} |
|
51
|
|
|
*/ |
|
52
|
|
|
module.exports.uInt8 = {"bits": 8}; |
|
53
|
|
|
// LE |
|
54
|
|
|
/** |
|
55
|
|
|
* Signed 16-bit integers little-endian |
|
56
|
|
|
* @type {!Object} |
|
57
|
|
|
*/ |
|
58
|
|
|
module.exports.int16 = {"bits": 16, "signed": true}; |
|
59
|
|
|
/** |
|
60
|
|
|
* Unsigned 16-bit integers little-endian |
|
61
|
|
|
* @type {!Object} |
|
62
|
|
|
*/ |
|
63
|
|
|
module.exports.uInt16 = {"bits": 16}; |
|
64
|
|
|
/** |
|
65
|
|
|
* Half-precision floating-point numbers little-endian |
|
66
|
|
|
* @type {!Object} |
|
67
|
|
|
*/ |
|
68
|
|
|
module.exports.float16 = {"bits": 16, "float": true}; |
|
69
|
|
|
/** |
|
70
|
|
|
* Signed 24-bit integers little-endian |
|
71
|
|
|
* @type {!Object} |
|
72
|
|
|
*/ |
|
73
|
|
|
module.exports.int24 = {"bits": 24, "signed": true}; |
|
74
|
|
|
/** |
|
75
|
|
|
* Unsigned 24-bit integers little-endian |
|
76
|
|
|
* @type {!Object} |
|
77
|
|
|
*/ |
|
78
|
|
|
module.exports.uInt24 = {"bits": 24}; |
|
79
|
|
|
/** |
|
80
|
|
|
* Signed 32-bit integers little-endian |
|
81
|
|
|
* @type {!Object} |
|
82
|
|
|
*/ |
|
83
|
|
|
module.exports.int32 = {"bits": 32, "signed": true}; |
|
84
|
|
|
/** |
|
85
|
|
|
* Unsigned 32-bit integers little-endian |
|
86
|
|
|
* @type {!Object} |
|
87
|
|
|
*/ |
|
88
|
|
|
module.exports.uInt32 = {"bits": 32}; |
|
89
|
|
|
/** |
|
90
|
|
|
* Single-precision floating-point numbers little-endian |
|
91
|
|
|
* @type {!Object} |
|
92
|
|
|
*/ |
|
93
|
|
|
module.exports.float32 = {"bits": 32, "float": true}; |
|
94
|
|
|
/** |
|
95
|
|
|
* Signed 40-bit integers little-endian |
|
96
|
|
|
* @type {!Object} |
|
97
|
|
|
*/ |
|
98
|
|
|
module.exports.int40 = {"bits": 40, "signed": true}; |
|
99
|
|
|
/** |
|
100
|
|
|
* Unsigned 40-bit integers little-endian |
|
101
|
|
|
* @type {!Object} |
|
102
|
|
|
*/ |
|
103
|
|
|
module.exports.uInt40 = {"bits": 40}; |
|
104
|
|
|
/** |
|
105
|
|
|
* Signed 48-bit integers little-endian |
|
106
|
|
|
* @type {!Object} |
|
107
|
|
|
*/ |
|
108
|
|
|
module.exports.int48 = {"bits": 48, "signed": true}; |
|
109
|
|
|
/** |
|
110
|
|
|
* Unsigned 48-bit integers little-endian |
|
111
|
|
|
* @type {!Object} |
|
112
|
|
|
*/ |
|
113
|
|
|
module.exports.uInt48 = {"bits": 48}; |
|
114
|
|
|
/** |
|
115
|
|
|
* Double-precision floating-point numbers little-endian |
|
116
|
|
|
* @type {!Object} |
|
117
|
|
|
*/ |
|
118
|
|
|
module.exports.float64 = {"bits": 64, "float": true}; |
|
119
|
|
|
// BE |
|
120
|
|
|
/** |
|
121
|
|
|
* Signed 16-bit integers big-endian |
|
122
|
|
|
* @type {!Object} |
|
123
|
|
|
*/ |
|
124
|
|
|
module.exports.int16BE = {"bits": 16, "signed": true, "be": true}; |
|
125
|
|
|
/** |
|
126
|
|
|
* Unsigned 16-bit integers big-endian |
|
127
|
|
|
* @type {!Object} |
|
128
|
|
|
*/ |
|
129
|
|
|
module.exports.uInt16BE = {"bits": 16, "be": true}; |
|
130
|
|
|
/** |
|
131
|
|
|
* Half-precision floating-point numbers big-endian |
|
132
|
|
|
* @type {!Object} |
|
133
|
|
|
*/ |
|
134
|
|
|
module.exports.float16BE = {"bits": 16, "float": true, "be": true}; |
|
135
|
|
|
/** |
|
136
|
|
|
* Signed 24-bit integers big-endian |
|
137
|
|
|
* @type {!Object} |
|
138
|
|
|
*/ |
|
139
|
|
|
module.exports.int24BE = {"bits": 24, "signed": true, "be": true}; |
|
140
|
|
|
/** |
|
141
|
|
|
* Unsigned 24-bit integers big-endian |
|
142
|
|
|
* @type {!Object} |
|
143
|
|
|
*/ |
|
144
|
|
|
module.exports.uInt24BE = {"bits": 24, "be": true}; |
|
145
|
|
|
/** |
|
146
|
|
|
* Signed 32-bit integers big-endian |
|
147
|
|
|
* @type {!Object} |
|
148
|
|
|
*/ |
|
149
|
|
|
module.exports.int32BE = {"bits": 32, "signed": true, "be": true}; |
|
150
|
|
|
/** |
|
151
|
|
|
* Unsigned 32-bit integers big-endian |
|
152
|
|
|
* @type {!Object} |
|
153
|
|
|
*/ |
|
154
|
|
|
module.exports.uInt32BE = {"bits": 32, "be": true}; |
|
155
|
|
|
/** |
|
156
|
|
|
* Single-precision floating-point numbers big-endian |
|
157
|
|
|
* @type {!Object} |
|
158
|
|
|
*/ |
|
159
|
|
|
module.exports.float32BE = {"bits": 32, "float": true, "be": true}; |
|
160
|
|
|
/** |
|
161
|
|
|
* Signed 40-bit integers big-endian |
|
162
|
|
|
* @type {!Object} |
|
163
|
|
|
*/ |
|
164
|
|
|
module.exports.int40BE = {"bits": 40, "signed": true, "be": true}; |
|
165
|
|
|
/** |
|
166
|
|
|
* Unsigned 40-bit integers big-endian |
|
167
|
|
|
* @type {!Object} |
|
168
|
|
|
*/ |
|
169
|
|
|
module.exports.uInt40BE = {"bits": 40, "be": true}; |
|
170
|
|
|
/** |
|
171
|
|
|
* Signed 48-bit integers big-endian |
|
172
|
|
|
* @type {!Object} |
|
173
|
|
|
*/ |
|
174
|
|
|
module.exports.int48BE = {"bits": 48, "signed": true, "be": true}; |
|
175
|
|
|
/** |
|
176
|
|
|
* Unsigned 48-bit integers big-endian |
|
177
|
|
|
* @type {!Object} |
|
178
|
|
|
*/ |
|
179
|
|
|
module.exports.uInt48BE = {"bits": 48, "be": true}; |
|
180
|
|
|
/** |
|
181
|
|
|
* Double-precision floating-point numbers big-endian |
|
182
|
|
|
* @type {!Object} |
|
183
|
|
|
*/ |
|
184
|
|
|
module.exports.float64BE = {"bits": 64, "float": true, "be": true}; |