imagescript 3.8.1 → 3.10.0
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/README.md +16 -12
- package/THIRD_PARTY_NOTICES.md +62 -3
- package/dist/animation-encoder.d.ts +2 -0
- package/dist/animation-encoder.js +6 -12
- package/dist/animation.d.ts +7 -1
- package/dist/animation.js +21 -16
- package/dist/codecs/av1/encode.js +149 -44
- package/dist/codecs/avif-enc.js +35 -9
- package/dist/codecs/avif.js +161 -76
- package/dist/codecs/jpeg.js +7 -1
- package/dist/codecs/jxl/acs-enc.js +18 -6
- package/dist/codecs/jxl/aq-enc.js +38 -37
- package/dist/codecs/jxl/color.js +14 -3
- package/dist/codecs/jxl/filters.js +44 -34
- package/dist/codecs/jxl/frame.js +218 -37
- package/dist/codecs/jxl/modular.js +40 -29
- package/dist/codecs/jxl/patches-enc.js +349 -0
- package/dist/codecs/jxl/vardct-enc.js +197 -137
- package/dist/codecs/jxl/vardct.js +53 -19
- package/dist/codecs/jxl.js +32 -21
- package/dist/codecs/png.js +48 -12
- package/dist/codecs/tiff.js +5 -3
- package/dist/codecs/vp8-enc.js +60 -4
- package/dist/codecs/vp8l.js +94 -62
- package/dist/codecs/webp.js +51 -16
- package/dist/image.d.ts +59 -6
- package/dist/image.js +27 -18
- package/dist/render/blend.js +102 -0
- package/dist/render/filter.js +6 -90
- package/dist/render/hinting.js +118 -75
- package/dist/render/svg-text.js +854 -0
- package/dist/render/svg.js +866 -102
- package/dist/render/text.js +1 -1
- package/dist/util/icc.js +143 -0
- package/dist/util/threads.js +101 -0
- package/dist/util/worker.js +52 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* JPEG XL patches for the lossy encoder: text-like features of screenshots stored once in a reference frame and added
|
|
3
|
+
* where they repeat, ported from libjxl (lib/jxl/enc_patch_dictionary.cc: FindTextLikePatches, FindBestPatchDictionary,
|
|
4
|
+
* PatchDictionaryEncoder; enc_modular.cc: the XYB quantization of Modular frames). Copyright (c) the JPEG XL Project
|
|
5
|
+
* Authors, BSD-3-Clause License (see THIRD_PARTY_NOTICES.md)
|
|
6
|
+
*/
|
|
7
|
+
import { BitWriter } from "./bit-writer.js";
|
|
8
|
+
import { Tokens, EntropyCode, packSigned } from "./entropy-enc.js";
|
|
9
|
+
import { MATree, channelTokens, streamHeader, PRED_GRADIENT, PROP_CHANNEL } from "./modular-enc.js";
|
|
10
|
+
import { u32 } from "./headers-enc.js";
|
|
11
|
+
const DEQUANT = [0.01615, 0.08875, 0.1922], WEIGHTS = [30, 3, 1];
|
|
12
|
+
const PATCH_SIDE = 4, EXTRA_SIDE = 4, MAX_PATCH_SIZE = 32, DISTANCE_LIMIT = 50;
|
|
13
|
+
const SIMILAR = 0.8, VERY_SIMILAR = 0.03, HAS_SIMILAR = 0.03, MIN_PEAK = 2, HAS_SIMILAR_RADIUS = 2, MIN_MAX_PATCH_SIZE = 20;
|
|
14
|
+
const REFERENCE = 3;
|
|
15
|
+
function f16(v) {
|
|
16
|
+
const f = new Float32Array(1), u = new Uint32Array(f.buffer);
|
|
17
|
+
f[0] = v;
|
|
18
|
+
const x = u[0], sign = x >>> 16 & 0x8000, e = (x >>> 23 & 255) - 127 + 15;
|
|
19
|
+
let m = x & 0x7fffff;
|
|
20
|
+
if (e <= 0)
|
|
21
|
+
return sign;
|
|
22
|
+
if (e >= 31)
|
|
23
|
+
return sign | 0x7bff;
|
|
24
|
+
m += 0x1000;
|
|
25
|
+
if (m & 0x800000)
|
|
26
|
+
return e + 1 >= 31 ? sign | 0x7bff : sign | (e + 1) << 10;
|
|
27
|
+
return sign | e << 10 | m >> 13;
|
|
28
|
+
}
|
|
29
|
+
function fromF16(bits) {
|
|
30
|
+
const e = bits >> 10 & 31, m = bits & 1023, s = bits & 0x8000 ? -1 : 1;
|
|
31
|
+
return e === 0 ? s * m / 1024 / 16384 : s * (1 + m / 1024) * 2 ** (e - 15);
|
|
32
|
+
}
|
|
33
|
+
function candidates(planes, stride, width, height) {
|
|
34
|
+
const [p0, p1, p2] = planes;
|
|
35
|
+
const at = (c, x, y) => planes[c][y * stride + x];
|
|
36
|
+
const same = (x1, y1, x2, y2) => {
|
|
37
|
+
const i = y1 * stride + x1, j = y2 * stride + x2;
|
|
38
|
+
return Math.abs(p0[i] - p0[j]) <= 1e-4 && Math.abs(p1[i] - p1[j]) <= 1e-4 && Math.abs(p2[i] - p2[j]) <= 1e-4;
|
|
39
|
+
};
|
|
40
|
+
const similar = (a, i, b, j, threshold) => Math.abs(a[0][i] - b[0][j]) * WEIGHTS[0] + Math.abs(a[1][i] - b[1][j]) * WEIGHTS[1] + Math.abs(a[2][i] - b[2][j]) * WEIGHTS[2] <= threshold;
|
|
41
|
+
const sw = Math.ceil(width / PATCH_SIDE), screenshot = new Uint8Array(sw * Math.ceil(height / PATCH_SIDE));
|
|
42
|
+
let any = false;
|
|
43
|
+
for (let by = 0; by < Math.floor(height / PATCH_SIDE); by++) {
|
|
44
|
+
for (let bx = 0; bx < Math.floor(width / PATCH_SIDE); bx++) {
|
|
45
|
+
const x0 = bx * PATCH_SIDE, y0 = by * PATCH_SIDE;
|
|
46
|
+
let allSame = true;
|
|
47
|
+
for (let iy = 0; iy < PATCH_SIDE && allSame; iy++)
|
|
48
|
+
for (let ix = 0; ix < PATCH_SIDE; ix++)
|
|
49
|
+
if (!same(x0 + ix, y0 + iy, x0, y0)) {
|
|
50
|
+
allSame = false;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
if (!allSame)
|
|
54
|
+
continue;
|
|
55
|
+
let n = 0, nSame = 0;
|
|
56
|
+
for (let iy = -EXTRA_SIDE; iy < EXTRA_SIDE + PATCH_SIDE; iy++) {
|
|
57
|
+
for (let ix = -EXTRA_SIDE; ix < EXTRA_SIDE + PATCH_SIDE; ix++) {
|
|
58
|
+
const x = x0 + ix, y = y0 + iy;
|
|
59
|
+
if (x < 0 || x >= width || y < 0 || y >= height)
|
|
60
|
+
continue;
|
|
61
|
+
n++;
|
|
62
|
+
if (same(x, y, x0, y0))
|
|
63
|
+
nSame++;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (nSame * 8 < n * 7)
|
|
67
|
+
continue;
|
|
68
|
+
screenshot[by * sw + bx] = 1;
|
|
69
|
+
any = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (!any)
|
|
73
|
+
return [];
|
|
74
|
+
const isBackground = new Uint8Array(width * height), queued = new Uint8Array(width * height), background = [0, 1, 2].map(() => new Float32Array(width * height));
|
|
75
|
+
const queue = new Int32Array(width * height * 4);
|
|
76
|
+
let end = 0;
|
|
77
|
+
for (let y = 0; y < height; y++) {
|
|
78
|
+
for (let x = 0; x < width; x++) {
|
|
79
|
+
if (!screenshot[(y / PATCH_SIDE | 0) * sw + (x / PATCH_SIDE | 0)])
|
|
80
|
+
continue;
|
|
81
|
+
queue[end++] = x;
|
|
82
|
+
queue[end++] = y;
|
|
83
|
+
queue[end++] = x;
|
|
84
|
+
queue[end++] = y;
|
|
85
|
+
queued[y * width + x] = 1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
for (let q = 0; q < end; q += 4) {
|
|
89
|
+
const cx = queue[q], cy = queue[q + 1], sx = queue[q + 2], sy = queue[q + 3];
|
|
90
|
+
isBackground[cy * width + cx] = 1;
|
|
91
|
+
for (let c = 0; c < 3; c++)
|
|
92
|
+
background[c][cy * width + cx] = at(c, sx, sy);
|
|
93
|
+
const src = sy * stride + sx;
|
|
94
|
+
for (let dx = -1; dx <= 1; dx++) {
|
|
95
|
+
for (let dy = -1; dy <= 1; dy++) {
|
|
96
|
+
if (!dx && !dy)
|
|
97
|
+
continue;
|
|
98
|
+
const nx = cx + dx, ny = cy + dy;
|
|
99
|
+
if (nx < 0 || ny < 0 || nx >= width || ny >= height || Math.abs(nx - sx) + Math.abs(ny - sy) > DISTANCE_LIMIT)
|
|
100
|
+
continue;
|
|
101
|
+
const i = ny * width + nx;
|
|
102
|
+
if (!queued[i] && similar(planes, src, planes, ny * stride + nx, SIMILAR) && (!screenshot[(ny / PATCH_SIDE | 0) * sw + (nx / PATCH_SIDE | 0)] || same(sx, sy, nx, ny))) {
|
|
103
|
+
queued[i] = 1;
|
|
104
|
+
queue[end++] = nx;
|
|
105
|
+
queue[end++] = ny;
|
|
106
|
+
queue[end++] = sx;
|
|
107
|
+
queue[end++] = sy;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const visited = new Uint8Array(width * height), found = [];
|
|
113
|
+
let stack = new Int32Array(1024);
|
|
114
|
+
for (let y = 0; y < height; y++) {
|
|
115
|
+
for (let x = 0; x < width; x++) {
|
|
116
|
+
if (isBackground[y * width + x] || visited[y * width + x])
|
|
117
|
+
continue;
|
|
118
|
+
stack[0] = y * width + x;
|
|
119
|
+
let top = 1, minX = x, maxX = x, minY = y, maxY = y, reference = -1, allSimilar = true;
|
|
120
|
+
while (top) {
|
|
121
|
+
const pixel = stack[--top], cy = pixel / width | 0, cx = pixel - cy * width;
|
|
122
|
+
if (visited[pixel])
|
|
123
|
+
continue;
|
|
124
|
+
visited[pixel] = 1;
|
|
125
|
+
minX = Math.min(minX, cx);
|
|
126
|
+
maxX = Math.max(maxX, cx);
|
|
127
|
+
minY = Math.min(minY, cy);
|
|
128
|
+
maxY = Math.max(maxY, cy);
|
|
129
|
+
for (let dx = -1; dx <= 1; dx++) {
|
|
130
|
+
for (let dy = -1; dy <= 1; dy++) {
|
|
131
|
+
if (!dx && !dy)
|
|
132
|
+
continue;
|
|
133
|
+
const nx = cx + dx, ny = cy + dy;
|
|
134
|
+
if (nx < 0 || ny < 0 || nx >= width || ny >= height)
|
|
135
|
+
continue;
|
|
136
|
+
const i = ny * width + nx;
|
|
137
|
+
if (!isBackground[i]) {
|
|
138
|
+
if (visited[i])
|
|
139
|
+
continue;
|
|
140
|
+
if (top === stack.length) {
|
|
141
|
+
const grown = new Int32Array(2 * top);
|
|
142
|
+
grown.set(stack);
|
|
143
|
+
stack = grown;
|
|
144
|
+
}
|
|
145
|
+
stack[top++] = i;
|
|
146
|
+
}
|
|
147
|
+
else if (reference < 0)
|
|
148
|
+
reference = i;
|
|
149
|
+
else if (!similar(background, i, background, reference, VERY_SIMILAR))
|
|
150
|
+
allSimilar = false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (reference < 0 || !allSimilar || maxX - minX >= MAX_PATCH_SIZE || maxY - minY >= MAX_PATCH_SIZE)
|
|
155
|
+
continue;
|
|
156
|
+
const ref = [background[0][reference], background[1][reference], background[2][reference]];
|
|
157
|
+
let hasSimilar = false;
|
|
158
|
+
for (let iy = Math.max(minY - HAS_SIMILAR_RADIUS, 0); iy < Math.min(maxY + HAS_SIMILAR_RADIUS + 1, height) && !hasSimilar; iy++)
|
|
159
|
+
for (let ix = Math.max(minX - HAS_SIMILAR_RADIUS, 0); ix < Math.min(maxX + HAS_SIMILAR_RADIUS + 1, width); ix++)
|
|
160
|
+
if (similar(background, reference, planes, iy * stride + ix, HAS_SIMILAR)) {
|
|
161
|
+
hasSimilar = true;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
if (!hasSimilar)
|
|
165
|
+
continue;
|
|
166
|
+
const w = maxX - minX + 1, h = maxY - minY + 1;
|
|
167
|
+
const fpixels = [0, 1, 2].map(() => new Float32Array(w * h)), quantized = new Int8Array(3 * w * h);
|
|
168
|
+
let peak = 0;
|
|
169
|
+
for (const c of [1, 0, 2]) {
|
|
170
|
+
for (let iy = 0; iy < h; iy++) {
|
|
171
|
+
for (let ix = 0; ix < w; ix++) {
|
|
172
|
+
const v = fpixels[c][iy * w + ix] = at(c, minX + ix, minY + iy) - ref[c];
|
|
173
|
+
const q = Math.trunc(Math.fround(v) / DEQUANT[c]);
|
|
174
|
+
quantized[c * w * h + iy * w + ix] = q;
|
|
175
|
+
peak = Math.max(peak, Math.abs(q));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (peak < MIN_PEAK)
|
|
180
|
+
continue;
|
|
181
|
+
found.push({ w, h, fpixels, key: `${w}x${h}:${quantized.join(',')}`, positions: [[minX, minY]] });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const unique = new Map();
|
|
185
|
+
for (const c of found) {
|
|
186
|
+
const u = unique.get(c.key);
|
|
187
|
+
if (u)
|
|
188
|
+
u.positions.push(...c.positions);
|
|
189
|
+
else
|
|
190
|
+
unique.set(c.key, c);
|
|
191
|
+
}
|
|
192
|
+
const repeated = [...unique.values()].filter(c => c.positions.length >= 2);
|
|
193
|
+
if (!repeated.length || Math.max(...repeated.map(c => c.w * c.h)) < MIN_MAX_PATCH_SIZE)
|
|
194
|
+
return [];
|
|
195
|
+
return repeated;
|
|
196
|
+
}
|
|
197
|
+
export function findPatches(planes, stride, width, height, distance, numExtra) {
|
|
198
|
+
const info = candidates(planes, stride, width, height);
|
|
199
|
+
if (!info.length)
|
|
200
|
+
return null;
|
|
201
|
+
info.sort((a, b) => b.w * b.h - a.w * a.h);
|
|
202
|
+
let total = 0, maxW = 0, maxH = 0;
|
|
203
|
+
for (const p of info) {
|
|
204
|
+
total += p.w * p.h;
|
|
205
|
+
maxW = Math.max(maxW, p.w);
|
|
206
|
+
maxH = Math.max(maxH, p.h);
|
|
207
|
+
}
|
|
208
|
+
let refW = Math.max(maxW, Math.sqrt(total)), refH = Math.max(maxH, Math.sqrt(total));
|
|
209
|
+
let spots = [], usedH = 0;
|
|
210
|
+
for (;;) {
|
|
211
|
+
refW = Math.floor(refW * 1.05 + 1);
|
|
212
|
+
refH = Math.floor(refH * 1.05 + 1);
|
|
213
|
+
const occupied = new Uint8Array(refW * refH);
|
|
214
|
+
spots = [];
|
|
215
|
+
usedH = 0;
|
|
216
|
+
let ok = true;
|
|
217
|
+
for (const p of info) {
|
|
218
|
+
let spot = null;
|
|
219
|
+
for (let y0 = 0; y0 + p.h <= refH && !spot; y0++) {
|
|
220
|
+
for (let x0 = 0; x0 + p.w <= refW;) {
|
|
221
|
+
let blocked = -1;
|
|
222
|
+
for (let y = y0; y < y0 + p.h && blocked < 0; y++)
|
|
223
|
+
for (let x = x0; x < x0 + p.w; x++)
|
|
224
|
+
if (occupied[y * refW + x]) {
|
|
225
|
+
blocked = x;
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
if (blocked < 0) {
|
|
229
|
+
spot = [x0, y0];
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
x0 = blocked + 1;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (!spot) {
|
|
236
|
+
ok = false;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
for (let y = spot[1]; y < spot[1] + p.h; y++)
|
|
240
|
+
occupied.fill(1, y * refW + spot[0], y * refW + spot[0] + p.w);
|
|
241
|
+
spots.push(spot);
|
|
242
|
+
usedH = Math.max(usedH, spot[1] + p.h);
|
|
243
|
+
}
|
|
244
|
+
if (ok)
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
refH = usedH;
|
|
248
|
+
if (refW > 1024 || refH > 1024)
|
|
249
|
+
return null;
|
|
250
|
+
const factors = [65536 / (1 + 23 * distance), 4096 / (1 + 14 * distance), 4096 / (1 + 14 * distance)];
|
|
251
|
+
const lfBits = factors.map(f => f16(128 / f)), steps = lfBits.map(b => fromF16(b) / 128);
|
|
252
|
+
const n = refW * refH, ints = [0, 1, 2].map(() => new Int32Array(n)), decoded = [0, 1, 2].map(() => new Float32Array(n));
|
|
253
|
+
info.forEach((p, k) => {
|
|
254
|
+
const [x0, y0] = spots[k];
|
|
255
|
+
for (let y = 0; y < p.h; y++) {
|
|
256
|
+
for (let x = 0; x < p.w; x++) {
|
|
257
|
+
const i = (y0 + y) * refW + x0 + x, j = y * p.w + x;
|
|
258
|
+
for (let c = 0; c < 3; c++)
|
|
259
|
+
ints[c][i] = Math.round(p.fpixels[c][j] / steps[c]);
|
|
260
|
+
for (let c = 0; c < 3; c++)
|
|
261
|
+
decoded[c][i] = Math.fround(ints[c][i] * steps[c]);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
info.forEach((p, k) => {
|
|
266
|
+
const [x0, y0] = spots[k];
|
|
267
|
+
for (const [px, py] of p.positions)
|
|
268
|
+
for (let y = 0; y < p.h; y++)
|
|
269
|
+
for (let x = 0; x < p.w; x++)
|
|
270
|
+
for (let c = 0; c < 3; c++)
|
|
271
|
+
planes[c][(py + y) * stride + px + x] -= decoded[c][(y0 + y) * refW + x0 + x];
|
|
272
|
+
});
|
|
273
|
+
const frame = new BitWriter();
|
|
274
|
+
frame.write(1, 0);
|
|
275
|
+
frame.write(2, 2);
|
|
276
|
+
frame.write(1, 1);
|
|
277
|
+
frame.write(2, 0);
|
|
278
|
+
frame.write(2, 0);
|
|
279
|
+
for (let e = 0; e < numExtra; e++)
|
|
280
|
+
frame.write(2, 0);
|
|
281
|
+
frame.write(2, 3);
|
|
282
|
+
frame.write(1, 1);
|
|
283
|
+
const sizes = [[8, 0], [11, 256], [14, 2304], [30, 18688]];
|
|
284
|
+
u32(frame, refW, sizes);
|
|
285
|
+
u32(frame, refH, sizes);
|
|
286
|
+
frame.write(2, REFERENCE);
|
|
287
|
+
frame.write(1, 1);
|
|
288
|
+
u32(frame, 0, [[0, 0], [4, 0], [5, 16], [10, 48]]);
|
|
289
|
+
frame.write(1, 0);
|
|
290
|
+
frame.write(1, 0);
|
|
291
|
+
frame.write(2, 0);
|
|
292
|
+
frame.write(2, 0);
|
|
293
|
+
frame.write(2, 0);
|
|
294
|
+
const section = new BitWriter();
|
|
295
|
+
section.write(1, 0);
|
|
296
|
+
for (const b of [lfBits[0], lfBits[1], lfBits[2]])
|
|
297
|
+
section.write(16, b);
|
|
298
|
+
const channels = [ints[1], ints[0], ints[2].map((v, i) => v - ints[1][i])];
|
|
299
|
+
for (let e = 0; e < numExtra; e++)
|
|
300
|
+
channels.push(new Int32Array(n));
|
|
301
|
+
let root = { predictor: PRED_GRADIENT };
|
|
302
|
+
for (let c = channels.length - 2; c >= 0; c--)
|
|
303
|
+
root = { property: PROP_CHANNEL, split: c, above: root, below: { predictor: PRED_GRADIENT } };
|
|
304
|
+
const tree = new MATree(root), tokens = new Tokens();
|
|
305
|
+
channels.forEach((data, c) => channelTokens(tokens, tree, data, refW, refH, c, 0));
|
|
306
|
+
const code = new EntropyCode([tokens], tree.numLeaves);
|
|
307
|
+
section.write(1, 1);
|
|
308
|
+
tree.write(section);
|
|
309
|
+
code.writeHeader(section);
|
|
310
|
+
streamHeader(section);
|
|
311
|
+
code.writeTokens(section, tokens);
|
|
312
|
+
section.zeroPadToByte();
|
|
313
|
+
frame.write(1, 0);
|
|
314
|
+
frame.zeroPadToByte();
|
|
315
|
+
u32(frame, section.length, [[10, 0], [14, 1024], [22, 17408], [30, 4211712]]);
|
|
316
|
+
frame.zeroPadToByte();
|
|
317
|
+
frame.append(section);
|
|
318
|
+
const dictionary = new Tokens();
|
|
319
|
+
dictionary.push(0, info.length);
|
|
320
|
+
info.forEach((p, k) => {
|
|
321
|
+
dictionary.push(1, REFERENCE);
|
|
322
|
+
dictionary.push(3, spots[k][0]);
|
|
323
|
+
dictionary.push(3, spots[k][1]);
|
|
324
|
+
dictionary.push(2, p.w - 1);
|
|
325
|
+
dictionary.push(2, p.h - 1);
|
|
326
|
+
dictionary.push(7, p.positions.length - 1);
|
|
327
|
+
p.positions.forEach(([x, y], i) => {
|
|
328
|
+
if (i) {
|
|
329
|
+
dictionary.push(6, packSigned(x - p.positions[i - 1][0]));
|
|
330
|
+
dictionary.push(6, packSigned(y - p.positions[i - 1][1]));
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
dictionary.push(4, x);
|
|
334
|
+
dictionary.push(4, y);
|
|
335
|
+
}
|
|
336
|
+
dictionary.push(5, 2);
|
|
337
|
+
for (let e = 0; e < numExtra; e++)
|
|
338
|
+
dictionary.push(5, 0);
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
const dictionaryCode = new EntropyCode([dictionary], 10);
|
|
342
|
+
return {
|
|
343
|
+
frame,
|
|
344
|
+
writeDictionary: (w) => {
|
|
345
|
+
dictionaryCode.writeHeader(w);
|
|
346
|
+
dictionaryCode.writeTokens(w, dictionary);
|
|
347
|
+
},
|
|
348
|
+
};
|
|
349
|
+
}
|