pdf-parser.js 5.2.27 → 5.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{afm-widths-BYiX2L9D.cjs → afm-widths-BHD2HZIL.cjs} +553 -642
- package/dist/{afm-widths-blUDDjlI.js → afm-widths-B_IGbGky.js} +553 -642
- package/dist/afm-widths.cjs +1 -1
- package/dist/afm-widths.js +1 -1
- package/dist/annotations.cjs +5 -3
- package/dist/annotations.js +5 -3
- package/dist/builtin-encoding.cjs +17 -6
- package/dist/builtin-encoding.js +17 -6
- package/dist/bytes/crc32.cjs +5 -3
- package/dist/bytes/crc32.js +5 -3
- package/dist/bytes/flate.cjs +0 -1
- package/dist/bytes/flate.js +0 -1
- package/dist/cff-bounds.cjs +42 -24
- package/dist/cff-bounds.js +42 -24
- package/dist/cff.cjs +13 -6
- package/dist/cff.js +13 -6
- package/dist/cmap-table.cjs +54 -26
- package/dist/cmap-table.js +54 -26
- package/dist/cmap.cjs +5 -3
- package/dist/cmap.js +5 -3
- package/dist/content-write.cjs +3 -2
- package/dist/content-write.js +3 -2
- package/dist/crypto/aes.cjs +76 -55
- package/dist/crypto/aes.js +76 -55
- package/dist/crypto/md5.cjs +345 -149
- package/dist/crypto/md5.js +345 -149
- package/dist/crypto/rc4.cjs +5 -4
- package/dist/crypto/rc4.js +5 -4
- package/dist/crypto/sha2.cjs +92 -43
- package/dist/crypto/sha2.js +92 -43
- package/dist/embedded-font.cjs +4 -2
- package/dist/embedded-font.js +4 -2
- package/dist/encoding.cjs +1 -1
- package/dist/encoding.js +1 -1
- package/dist/encrypt-write.cjs +25 -21
- package/dist/encrypt-write.js +25 -21
- package/dist/encrypt.cjs +43 -64
- package/dist/encrypt.js +43 -64
- package/dist/filters.cjs +40 -20
- package/dist/filters.js +40 -20
- package/dist/font-face.cjs +2 -1
- package/dist/font-face.js +2 -1
- package/dist/font-read.cjs +12 -6
- package/dist/font-read.js +12 -6
- package/dist/font-tables.cjs +55 -28
- package/dist/font-tables.js +55 -28
- package/dist/gdef-table.cjs +6 -3
- package/dist/gdef-table.js +6 -3
- package/dist/glyf-contours.cjs +3 -1
- package/dist/glyf-contours.js +3 -1
- package/dist/glyf.cjs +22 -11
- package/dist/glyf.js +22 -11
- package/dist/gpos-table.cjs +37 -19
- package/dist/gpos-table.js +37 -19
- package/dist/gsub-table.cjs +28 -17
- package/dist/gsub-table.js +28 -17
- package/dist/hmtx-table.cjs +5 -3
- package/dist/hmtx-table.js +5 -3
- package/dist/image/ccitt-encode.cjs +8 -5
- package/dist/image/ccitt-encode.js +8 -5
- package/dist/image/ccitt.cjs +801 -209
- package/dist/image/ccitt.js +801 -209
- package/dist/image/jbig2-arith.cjs +340 -306
- package/dist/image/jbig2-arith.js +340 -306
- package/dist/image/jbig2-bitmap.cjs +8 -5
- package/dist/image/jbig2-bitmap.js +8 -5
- package/dist/image/jbig2-generic.cjs +240 -69
- package/dist/image/jbig2-generic.js +240 -69
- package/dist/image/jbig2-text.cjs +4 -2
- package/dist/image/jbig2-text.js +4 -2
- package/dist/image/jbig2.cjs +69 -31
- package/dist/image/jbig2.js +69 -31
- package/dist/image/jp2-boxes.cjs +52 -27
- package/dist/image/jp2-boxes.js +52 -27
- package/dist/image/jpeg-info.cjs +29 -24
- package/dist/image/jpeg-info.js +29 -24
- package/dist/image/jpeg2000-codestream.cjs +44 -24
- package/dist/image/jpeg2000-codestream.js +44 -24
- package/dist/image/jpeg2000-dwt.cjs +2 -1
- package/dist/image/jpeg2000-dwt.js +2 -1
- package/dist/image/jpeg2000-t1.cjs +21 -11
- package/dist/image/jpeg2000-t1.js +21 -11
- package/dist/image/jpeg2000-t2.cjs +12 -5
- package/dist/image/jpeg2000-t2.js +12 -5
- package/dist/image/jpeg2000-tagtree.cjs +8 -4
- package/dist/image/jpeg2000-tagtree.js +8 -4
- package/dist/image/jpeg2000.cjs +11 -6
- package/dist/image/jpeg2000.js +11 -6
- package/dist/image/png-decode.cjs +62 -39
- package/dist/image/png-decode.d.cts +3 -2
- package/dist/image/png-decode.d.ts +3 -2
- package/dist/image/png-decode.js +62 -39
- package/dist/image/png-filter.cjs +23 -15
- package/dist/image/png-filter.js +23 -15
- package/dist/images-read.cjs +41 -36
- package/dist/images-read.js +41 -36
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/interpret.cjs +39 -24
- package/dist/interpret.js +39 -24
- package/dist/lexer.cjs +86 -51
- package/dist/lexer.js +86 -51
- package/dist/math-content-write.cjs +9 -5
- package/dist/math-content-write.js +9 -5
- package/dist/math-font-write.cjs +2 -1
- package/dist/math-font-write.js +2 -1
- package/dist/math-font.cjs +16 -7
- package/dist/math-font.js +16 -7
- package/dist/math-table.cjs +25 -13
- package/dist/math-table.js +25 -13
- package/dist/matrix.cjs +3 -2
- package/dist/matrix.js +3 -2
- package/dist/measure.cjs +1 -1
- package/dist/measure.js +1 -1
- package/dist/navigation.cjs +10 -5
- package/dist/navigation.js +10 -5
- package/dist/ot-layout-common.cjs +4 -2
- package/dist/ot-layout-common.js +4 -2
- package/dist/parse.cjs +7 -5
- package/dist/parse.js +7 -5
- package/dist/pdf-text.cjs +5 -2
- package/dist/pdf-text.js +5 -2
- package/dist/predictors.cjs +14 -9
- package/dist/predictors.js +14 -9
- package/dist/raster.cjs +30 -19
- package/dist/raster.js +30 -19
- package/dist/read.cjs +17 -8
- package/dist/read.js +17 -8
- package/dist/serialize.cjs +6 -2
- package/dist/serialize.js +6 -2
- package/dist/sfnt-subset.cjs +25 -13
- package/dist/sfnt-subset.js +25 -13
- package/dist/sfnt.cjs +20 -10
- package/dist/sfnt.js +20 -10
- package/dist/text-group.cjs +0 -1
- package/dist/text-group.js +0 -1
- package/dist/tounicode.cjs +4 -2
- package/dist/tounicode.js +4 -2
- package/dist/winansi.cjs +1 -1
- package/dist/winansi.js +1 -1
- package/dist/write.cjs +20 -12
- package/dist/write.js +20 -12
- package/dist/xref.cjs +5 -2
- package/dist/xref.js +5 -2
- package/package.json +2 -2
|
@@ -1,293 +1,293 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/image/jbig2-arith.ts
|
|
3
3
|
const QE_STATES = [
|
|
4
|
-
|
|
5
|
-
22017,
|
|
6
|
-
1,
|
|
7
|
-
1,
|
|
8
|
-
1
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
13313,
|
|
12
|
-
2,
|
|
13
|
-
6,
|
|
14
|
-
0
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
6145,
|
|
18
|
-
3,
|
|
19
|
-
9,
|
|
20
|
-
0
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
2753,
|
|
24
|
-
4,
|
|
25
|
-
12,
|
|
26
|
-
0
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
1313,
|
|
30
|
-
5,
|
|
31
|
-
29,
|
|
32
|
-
0
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
545,
|
|
36
|
-
38,
|
|
37
|
-
33,
|
|
38
|
-
0
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
22017,
|
|
42
|
-
7,
|
|
43
|
-
6,
|
|
44
|
-
1
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
21505,
|
|
48
|
-
8,
|
|
49
|
-
14,
|
|
50
|
-
0
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
18433,
|
|
54
|
-
9,
|
|
55
|
-
14,
|
|
56
|
-
0
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
14337,
|
|
60
|
-
10,
|
|
61
|
-
14,
|
|
62
|
-
0
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
12289,
|
|
66
|
-
11,
|
|
67
|
-
17,
|
|
68
|
-
0
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
9217,
|
|
72
|
-
12,
|
|
73
|
-
18,
|
|
74
|
-
0
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
7169,
|
|
78
|
-
13,
|
|
79
|
-
20,
|
|
80
|
-
0
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
5633,
|
|
84
|
-
29,
|
|
85
|
-
21,
|
|
86
|
-
0
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
22017,
|
|
90
|
-
15,
|
|
91
|
-
14,
|
|
92
|
-
1
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
21505,
|
|
96
|
-
16,
|
|
97
|
-
14,
|
|
98
|
-
0
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
20737,
|
|
102
|
-
17,
|
|
103
|
-
15,
|
|
104
|
-
0
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
18433,
|
|
108
|
-
18,
|
|
109
|
-
16,
|
|
110
|
-
0
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
14337,
|
|
114
|
-
19,
|
|
115
|
-
17,
|
|
116
|
-
0
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
13313,
|
|
120
|
-
20,
|
|
121
|
-
18,
|
|
122
|
-
0
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
12289,
|
|
126
|
-
21,
|
|
127
|
-
19,
|
|
128
|
-
0
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
10241,
|
|
132
|
-
22,
|
|
133
|
-
19,
|
|
134
|
-
0
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
9217,
|
|
138
|
-
23,
|
|
139
|
-
20,
|
|
140
|
-
0
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
8705,
|
|
144
|
-
24,
|
|
145
|
-
21,
|
|
146
|
-
0
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
7169,
|
|
150
|
-
25,
|
|
151
|
-
22,
|
|
152
|
-
0
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
6145,
|
|
156
|
-
26,
|
|
157
|
-
23,
|
|
158
|
-
0
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
5633,
|
|
162
|
-
27,
|
|
163
|
-
24,
|
|
164
|
-
0
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
5121,
|
|
168
|
-
28,
|
|
169
|
-
25,
|
|
170
|
-
0
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
4609,
|
|
174
|
-
29,
|
|
175
|
-
26,
|
|
176
|
-
0
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
4353,
|
|
180
|
-
30,
|
|
181
|
-
27,
|
|
182
|
-
0
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
2753,
|
|
186
|
-
31,
|
|
187
|
-
28,
|
|
188
|
-
0
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
2497,
|
|
192
|
-
32,
|
|
193
|
-
29,
|
|
194
|
-
0
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
2209,
|
|
198
|
-
33,
|
|
199
|
-
30,
|
|
200
|
-
0
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
1313,
|
|
204
|
-
34,
|
|
205
|
-
31,
|
|
206
|
-
0
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
1089,
|
|
210
|
-
35,
|
|
211
|
-
32,
|
|
212
|
-
0
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
673,
|
|
216
|
-
36,
|
|
217
|
-
33,
|
|
218
|
-
0
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
545,
|
|
222
|
-
37,
|
|
223
|
-
34,
|
|
224
|
-
0
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
321,
|
|
228
|
-
38,
|
|
229
|
-
35,
|
|
230
|
-
0
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
273,
|
|
234
|
-
39,
|
|
235
|
-
36,
|
|
236
|
-
0
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
133,
|
|
240
|
-
40,
|
|
241
|
-
37,
|
|
242
|
-
0
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
73,
|
|
246
|
-
41,
|
|
247
|
-
38,
|
|
248
|
-
0
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
37,
|
|
252
|
-
42,
|
|
253
|
-
39,
|
|
254
|
-
0
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
21,
|
|
258
|
-
43,
|
|
259
|
-
40,
|
|
260
|
-
0
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
9,
|
|
264
|
-
44,
|
|
265
|
-
41,
|
|
266
|
-
0
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
5,
|
|
270
|
-
45,
|
|
271
|
-
42,
|
|
272
|
-
0
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
1,
|
|
276
|
-
45,
|
|
277
|
-
43,
|
|
278
|
-
0
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
22017,
|
|
282
|
-
46,
|
|
283
|
-
46,
|
|
284
|
-
0
|
|
285
|
-
|
|
4
|
+
{
|
|
5
|
+
qe: 22017,
|
|
6
|
+
nmps: 1,
|
|
7
|
+
nlps: 1,
|
|
8
|
+
switchMps: 1
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
qe: 13313,
|
|
12
|
+
nmps: 2,
|
|
13
|
+
nlps: 6,
|
|
14
|
+
switchMps: 0
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
qe: 6145,
|
|
18
|
+
nmps: 3,
|
|
19
|
+
nlps: 9,
|
|
20
|
+
switchMps: 0
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
qe: 2753,
|
|
24
|
+
nmps: 4,
|
|
25
|
+
nlps: 12,
|
|
26
|
+
switchMps: 0
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
qe: 1313,
|
|
30
|
+
nmps: 5,
|
|
31
|
+
nlps: 29,
|
|
32
|
+
switchMps: 0
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
qe: 545,
|
|
36
|
+
nmps: 38,
|
|
37
|
+
nlps: 33,
|
|
38
|
+
switchMps: 0
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
qe: 22017,
|
|
42
|
+
nmps: 7,
|
|
43
|
+
nlps: 6,
|
|
44
|
+
switchMps: 1
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
qe: 21505,
|
|
48
|
+
nmps: 8,
|
|
49
|
+
nlps: 14,
|
|
50
|
+
switchMps: 0
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
qe: 18433,
|
|
54
|
+
nmps: 9,
|
|
55
|
+
nlps: 14,
|
|
56
|
+
switchMps: 0
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
qe: 14337,
|
|
60
|
+
nmps: 10,
|
|
61
|
+
nlps: 14,
|
|
62
|
+
switchMps: 0
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
qe: 12289,
|
|
66
|
+
nmps: 11,
|
|
67
|
+
nlps: 17,
|
|
68
|
+
switchMps: 0
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
qe: 9217,
|
|
72
|
+
nmps: 12,
|
|
73
|
+
nlps: 18,
|
|
74
|
+
switchMps: 0
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
qe: 7169,
|
|
78
|
+
nmps: 13,
|
|
79
|
+
nlps: 20,
|
|
80
|
+
switchMps: 0
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
qe: 5633,
|
|
84
|
+
nmps: 29,
|
|
85
|
+
nlps: 21,
|
|
86
|
+
switchMps: 0
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
qe: 22017,
|
|
90
|
+
nmps: 15,
|
|
91
|
+
nlps: 14,
|
|
92
|
+
switchMps: 1
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
qe: 21505,
|
|
96
|
+
nmps: 16,
|
|
97
|
+
nlps: 14,
|
|
98
|
+
switchMps: 0
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
qe: 20737,
|
|
102
|
+
nmps: 17,
|
|
103
|
+
nlps: 15,
|
|
104
|
+
switchMps: 0
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
qe: 18433,
|
|
108
|
+
nmps: 18,
|
|
109
|
+
nlps: 16,
|
|
110
|
+
switchMps: 0
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
qe: 14337,
|
|
114
|
+
nmps: 19,
|
|
115
|
+
nlps: 17,
|
|
116
|
+
switchMps: 0
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
qe: 13313,
|
|
120
|
+
nmps: 20,
|
|
121
|
+
nlps: 18,
|
|
122
|
+
switchMps: 0
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
qe: 12289,
|
|
126
|
+
nmps: 21,
|
|
127
|
+
nlps: 19,
|
|
128
|
+
switchMps: 0
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
qe: 10241,
|
|
132
|
+
nmps: 22,
|
|
133
|
+
nlps: 19,
|
|
134
|
+
switchMps: 0
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
qe: 9217,
|
|
138
|
+
nmps: 23,
|
|
139
|
+
nlps: 20,
|
|
140
|
+
switchMps: 0
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
qe: 8705,
|
|
144
|
+
nmps: 24,
|
|
145
|
+
nlps: 21,
|
|
146
|
+
switchMps: 0
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
qe: 7169,
|
|
150
|
+
nmps: 25,
|
|
151
|
+
nlps: 22,
|
|
152
|
+
switchMps: 0
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
qe: 6145,
|
|
156
|
+
nmps: 26,
|
|
157
|
+
nlps: 23,
|
|
158
|
+
switchMps: 0
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
qe: 5633,
|
|
162
|
+
nmps: 27,
|
|
163
|
+
nlps: 24,
|
|
164
|
+
switchMps: 0
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
qe: 5121,
|
|
168
|
+
nmps: 28,
|
|
169
|
+
nlps: 25,
|
|
170
|
+
switchMps: 0
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
qe: 4609,
|
|
174
|
+
nmps: 29,
|
|
175
|
+
nlps: 26,
|
|
176
|
+
switchMps: 0
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
qe: 4353,
|
|
180
|
+
nmps: 30,
|
|
181
|
+
nlps: 27,
|
|
182
|
+
switchMps: 0
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
qe: 2753,
|
|
186
|
+
nmps: 31,
|
|
187
|
+
nlps: 28,
|
|
188
|
+
switchMps: 0
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
qe: 2497,
|
|
192
|
+
nmps: 32,
|
|
193
|
+
nlps: 29,
|
|
194
|
+
switchMps: 0
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
qe: 2209,
|
|
198
|
+
nmps: 33,
|
|
199
|
+
nlps: 30,
|
|
200
|
+
switchMps: 0
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
qe: 1313,
|
|
204
|
+
nmps: 34,
|
|
205
|
+
nlps: 31,
|
|
206
|
+
switchMps: 0
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
qe: 1089,
|
|
210
|
+
nmps: 35,
|
|
211
|
+
nlps: 32,
|
|
212
|
+
switchMps: 0
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
qe: 673,
|
|
216
|
+
nmps: 36,
|
|
217
|
+
nlps: 33,
|
|
218
|
+
switchMps: 0
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
qe: 545,
|
|
222
|
+
nmps: 37,
|
|
223
|
+
nlps: 34,
|
|
224
|
+
switchMps: 0
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
qe: 321,
|
|
228
|
+
nmps: 38,
|
|
229
|
+
nlps: 35,
|
|
230
|
+
switchMps: 0
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
qe: 273,
|
|
234
|
+
nmps: 39,
|
|
235
|
+
nlps: 36,
|
|
236
|
+
switchMps: 0
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
qe: 133,
|
|
240
|
+
nmps: 40,
|
|
241
|
+
nlps: 37,
|
|
242
|
+
switchMps: 0
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
qe: 73,
|
|
246
|
+
nmps: 41,
|
|
247
|
+
nlps: 38,
|
|
248
|
+
switchMps: 0
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
qe: 37,
|
|
252
|
+
nmps: 42,
|
|
253
|
+
nlps: 39,
|
|
254
|
+
switchMps: 0
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
qe: 21,
|
|
258
|
+
nmps: 43,
|
|
259
|
+
nlps: 40,
|
|
260
|
+
switchMps: 0
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
qe: 9,
|
|
264
|
+
nmps: 44,
|
|
265
|
+
nlps: 41,
|
|
266
|
+
switchMps: 0
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
qe: 5,
|
|
270
|
+
nmps: 45,
|
|
271
|
+
nlps: 42,
|
|
272
|
+
switchMps: 0
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
qe: 1,
|
|
276
|
+
nmps: 45,
|
|
277
|
+
nlps: 43,
|
|
278
|
+
switchMps: 0
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
qe: 22017,
|
|
282
|
+
nmps: 46,
|
|
283
|
+
nlps: 46,
|
|
284
|
+
switchMps: 0
|
|
285
|
+
}
|
|
286
286
|
];
|
|
287
|
-
const QE_VALUE = Uint16Array.from(QE_STATES, (row) => row
|
|
288
|
-
const QE_NMPS = Uint8Array.from(QE_STATES, (row) => row
|
|
289
|
-
const QE_NLPS = Uint8Array.from(QE_STATES, (row) => row
|
|
290
|
-
const QE_SWITCH = Uint8Array.from(QE_STATES, (row) => row
|
|
287
|
+
const QE_VALUE = Uint16Array.from(QE_STATES, (row) => row.qe);
|
|
288
|
+
const QE_NMPS = Uint8Array.from(QE_STATES, (row) => row.nmps);
|
|
289
|
+
const QE_NLPS = Uint8Array.from(QE_STATES, (row) => row.nlps);
|
|
290
|
+
const QE_SWITCH = Uint8Array.from(QE_STATES, (row) => row.switchMps);
|
|
291
291
|
function createArithContexts(contextBits) {
|
|
292
292
|
return new Uint8Array(1 << contextBits);
|
|
293
293
|
}
|
|
@@ -295,6 +295,13 @@ const A_INITIAL = 32768;
|
|
|
295
295
|
const C_INITIAL_SHIFT = 16;
|
|
296
296
|
const INITDEC_C_SHIFT = 7;
|
|
297
297
|
const PAST_END_BYTE = 255;
|
|
298
|
+
const MARKER_FOLLOWER_THRESHOLD = 143;
|
|
299
|
+
const MARKER_C_INCREMENT = 65280;
|
|
300
|
+
const STUFFED_BYTE_SHIFT = 9;
|
|
301
|
+
const NORMAL_BYTE_SHIFT = 8;
|
|
302
|
+
const STUFFED_BYTE_CT_RELOAD = 7;
|
|
303
|
+
const A_REGISTER_MASK = 65535;
|
|
304
|
+
const C_HIGH_HALF_SHIFT = 16;
|
|
298
305
|
var MqDecoder = class {
|
|
299
306
|
data;
|
|
300
307
|
start;
|
|
@@ -318,25 +325,25 @@ var MqDecoder = class {
|
|
|
318
325
|
return index >= this.start && index < this.end ? this.data[index] ?? PAST_END_BYTE : PAST_END_BYTE;
|
|
319
326
|
}
|
|
320
327
|
byteIn() {
|
|
321
|
-
if (this.byteAt(this.bp) ===
|
|
322
|
-
if (this.byteAt(this.bp + 1) >
|
|
323
|
-
this.c = this.c +
|
|
324
|
-
this.ct =
|
|
328
|
+
if (this.byteAt(this.bp) === PAST_END_BYTE) {
|
|
329
|
+
if (this.byteAt(this.bp + 1) > MARKER_FOLLOWER_THRESHOLD) {
|
|
330
|
+
this.c = this.c + MARKER_C_INCREMENT >>> 0;
|
|
331
|
+
this.ct = NORMAL_BYTE_SHIFT;
|
|
325
332
|
return;
|
|
326
333
|
}
|
|
327
334
|
this.bp++;
|
|
328
|
-
this.c = this.c + (this.byteAt(this.bp) <<
|
|
329
|
-
this.ct =
|
|
335
|
+
this.c = this.c + (this.byteAt(this.bp) << STUFFED_BYTE_SHIFT) >>> 0;
|
|
336
|
+
this.ct = STUFFED_BYTE_CT_RELOAD;
|
|
330
337
|
return;
|
|
331
338
|
}
|
|
332
339
|
this.bp++;
|
|
333
|
-
this.c = this.c + (this.byteAt(this.bp) <<
|
|
334
|
-
this.ct =
|
|
340
|
+
this.c = this.c + (this.byteAt(this.bp) << NORMAL_BYTE_SHIFT) >>> 0;
|
|
341
|
+
this.ct = NORMAL_BYTE_SHIFT;
|
|
335
342
|
}
|
|
336
343
|
renormalise() {
|
|
337
344
|
do {
|
|
338
345
|
if (this.ct === 0) this.byteIn();
|
|
339
|
-
this.a = this.a << 1 &
|
|
346
|
+
this.a = this.a << 1 & A_REGISTER_MASK;
|
|
340
347
|
this.c = this.c << 1 >>> 0;
|
|
341
348
|
this.ct--;
|
|
342
349
|
} while ((this.a & A_INITIAL) === 0);
|
|
@@ -348,7 +355,7 @@ var MqDecoder = class {
|
|
|
348
355
|
const qe = QE_VALUE[index] ?? 0;
|
|
349
356
|
this.a -= qe;
|
|
350
357
|
let decision;
|
|
351
|
-
if (this.c >>>
|
|
358
|
+
if (this.c >>> C_HIGH_HALF_SHIFT < qe) {
|
|
352
359
|
if (this.a < qe) {
|
|
353
360
|
decision = mps;
|
|
354
361
|
index = QE_NMPS[index] ?? 0;
|
|
@@ -359,7 +366,7 @@ var MqDecoder = class {
|
|
|
359
366
|
}
|
|
360
367
|
this.a = qe;
|
|
361
368
|
} else {
|
|
362
|
-
this.c = this.c - (qe <<
|
|
369
|
+
this.c = this.c - (qe << C_HIGH_HALF_SHIFT) >>> 0;
|
|
363
370
|
if ((this.a & A_INITIAL) !== 0) return mps;
|
|
364
371
|
if (this.a < qe) {
|
|
365
372
|
decision = 1 - mps;
|
|
@@ -380,18 +387,39 @@ function createIntegerContexts() {
|
|
|
380
387
|
return createArithContexts(INTEGER_CONTEXT_BITS);
|
|
381
388
|
}
|
|
382
389
|
const INTEGER_RANGES = [
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
390
|
+
{
|
|
391
|
+
bits: 2,
|
|
392
|
+
offset: 0
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
bits: 4,
|
|
396
|
+
offset: 4
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
bits: 6,
|
|
400
|
+
offset: 20
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
bits: 8,
|
|
404
|
+
offset: 84
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
bits: 12,
|
|
408
|
+
offset: 340
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
bits: 32,
|
|
412
|
+
offset: 4436
|
|
413
|
+
}
|
|
389
414
|
];
|
|
390
415
|
function decodeInteger(mq, contexts) {
|
|
416
|
+
const PREV_SATURATION_THRESHOLD = 256;
|
|
417
|
+
const PREV_REGISTER_MASK = 511;
|
|
418
|
+
const PREV_SATURATION_HIGH_BIT = 256;
|
|
391
419
|
let prev = 1;
|
|
392
420
|
const nextBit = () => {
|
|
393
421
|
const bit = mq.decode(contexts, prev);
|
|
394
|
-
prev = prev <
|
|
422
|
+
prev = prev < PREV_SATURATION_THRESHOLD ? prev << 1 | bit : (prev << 1 | bit) & PREV_REGISTER_MASK | PREV_SATURATION_HIGH_BIT;
|
|
395
423
|
return bit;
|
|
396
424
|
};
|
|
397
425
|
const readBits = (count) => {
|
|
@@ -403,13 +431,19 @@ function decodeInteger(mq, contexts) {
|
|
|
403
431
|
let magnitude = 0;
|
|
404
432
|
let matched = false;
|
|
405
433
|
for (let i = 0; i < INTEGER_RANGES.length - 1; i++) if (nextBit() === 0) {
|
|
406
|
-
const
|
|
434
|
+
const { bits, offset } = INTEGER_RANGES[i] ?? {
|
|
435
|
+
bits: 0,
|
|
436
|
+
offset: 0
|
|
437
|
+
};
|
|
407
438
|
magnitude = readBits(bits) + offset;
|
|
408
439
|
matched = true;
|
|
409
440
|
break;
|
|
410
441
|
}
|
|
411
442
|
if (!matched) {
|
|
412
|
-
const
|
|
443
|
+
const { bits, offset } = INTEGER_RANGES[INTEGER_RANGES.length - 1] ?? {
|
|
444
|
+
bits: 0,
|
|
445
|
+
offset: 0
|
|
446
|
+
};
|
|
413
447
|
magnitude = readBits(bits) + offset;
|
|
414
448
|
}
|
|
415
449
|
if (sign === 1) return magnitude === 0 ? void 0 : -magnitude;
|