jassub 1.8.8 → 2.0.1
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 +66 -205
- package/dist/jassub.d.ts +71 -0
- package/dist/jassub.js +278 -0
- package/dist/jassub.js.map +1 -0
- package/dist/{jassub-worker-modern.wasm → wasm/jassub-worker-modern.wasm} +0 -0
- package/dist/wasm/jassub-worker.d.ts +2 -0
- package/dist/wasm/jassub-worker.js +1017 -0
- package/dist/wasm/jassub-worker.js.map +1 -0
- package/dist/{jassub-worker.wasm → wasm/jassub-worker.wasm} +0 -0
- package/dist/wasm/types.d.ts +118 -0
- package/dist/worker/util.d.ts +5 -0
- package/dist/worker/util.js +30 -0
- package/dist/worker/util.js.map +1 -0
- package/dist/worker/webgpu-renderer.d.ts +54 -0
- package/dist/worker/webgpu-renderer.js +434 -0
- package/dist/worker/webgpu-renderer.js.map +1 -0
- package/dist/worker/worker.d.ts +59 -0
- package/dist/worker/worker.js +215 -0
- package/dist/worker/worker.js.map +1 -0
- package/package.json +21 -16
- package/dist/COPYRIGHT +0 -951
- package/dist/default.woff2 +0 -0
- package/dist/jassub-worker.js +0 -11
- package/dist/jassub-worker.wasm.js +0 -2
- package/dist/jassub.es.js +0 -552
- package/dist/jassub.umd.js +0 -1
- package/index.d.ts +0 -122
- package/src/jassub.js +0 -860
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
const IDENTITY_MATRIX = new Float32Array([
|
|
2
|
+
1, 0, 0, 0,
|
|
3
|
+
0, 1, 0, 0,
|
|
4
|
+
0, 0, 1, 0
|
|
5
|
+
]);
|
|
6
|
+
// Color matrix conversion map - mat3x3 pre-padded for WGSL (each column padded to vec4f)
|
|
7
|
+
// Each matrix converts FROM the key color space TO the nested key color space
|
|
8
|
+
export const colorMatrixConversionMap = {
|
|
9
|
+
BT601: {
|
|
10
|
+
BT709: new Float32Array([
|
|
11
|
+
1.0863, 0.0965, -0.0141, 0,
|
|
12
|
+
-0.0723, 0.8451, -0.0277, 0,
|
|
13
|
+
-0.014, 0.0584, 1.0418, 0
|
|
14
|
+
]),
|
|
15
|
+
BT601: IDENTITY_MATRIX
|
|
16
|
+
},
|
|
17
|
+
BT709: {
|
|
18
|
+
BT601: new Float32Array([
|
|
19
|
+
0.9137, -0.1049, 0.0096, 0,
|
|
20
|
+
0.0784, 1.1722, 0.0322, 0,
|
|
21
|
+
0.0079, -0.0671, 0.9582, 0
|
|
22
|
+
]),
|
|
23
|
+
BT709: IDENTITY_MATRIX
|
|
24
|
+
},
|
|
25
|
+
FCC: {
|
|
26
|
+
BT709: new Float32Array([
|
|
27
|
+
1.0873, 0.0974, -0.0127, 0,
|
|
28
|
+
-0.0736, 0.8494, -0.0251, 0,
|
|
29
|
+
-0.0137, 0.0531, 1.0378, 0
|
|
30
|
+
]),
|
|
31
|
+
BT601: new Float32Array([
|
|
32
|
+
1.001, 0.0009, 0.0013, 0,
|
|
33
|
+
-0.0008, 1.005, 0.0027, 0,
|
|
34
|
+
-0.0002, -0.006, 0.996, 0
|
|
35
|
+
])
|
|
36
|
+
},
|
|
37
|
+
SMPTE240M: {
|
|
38
|
+
BT709: new Float32Array([
|
|
39
|
+
0.9993, -0.0004, -0.0034, 0,
|
|
40
|
+
0.0006, 0.9812, -0.0114, 0,
|
|
41
|
+
0.0001, 0.0192, 1.0148, 0
|
|
42
|
+
]),
|
|
43
|
+
BT601: new Float32Array([
|
|
44
|
+
0.913, -0.1051, 0.0063, 0,
|
|
45
|
+
0.0774, 1.1508, 0.0207, 0,
|
|
46
|
+
0.0096, -0.0456, 0.973, 0
|
|
47
|
+
])
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
// WGSL Vertex Shader
|
|
51
|
+
const VERTEX_SHADER = /* wgsl */ `
|
|
52
|
+
struct VertexOutput {
|
|
53
|
+
@builtin(position) position: vec4f,
|
|
54
|
+
@location(0) local: vec2f, // local pixel coord in [0..w-1, 0..h-1]
|
|
55
|
+
@location(1) color: vec4f,
|
|
56
|
+
@location(2) texSize: vec2f, // texture size for UV calculation
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
struct Uniforms {
|
|
60
|
+
resolution: vec2f,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
struct ImageData {
|
|
64
|
+
destRect: vec4f, // x, y, w, h
|
|
65
|
+
srcInfo: vec4f, // texW, texH, stride, 0
|
|
66
|
+
color: vec4f, // RGBA
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@group(0) @binding(0) var<uniform> uniforms: Uniforms;
|
|
70
|
+
@group(0) @binding(1) var<storage, read> imageData: ImageData;
|
|
71
|
+
|
|
72
|
+
// Quad vertices (two triangles)
|
|
73
|
+
const QUAD_POSITIONS = array<vec2f, 6>(
|
|
74
|
+
vec2f(0.0, 0.0),
|
|
75
|
+
vec2f(1.0, 0.0),
|
|
76
|
+
vec2f(0.0, 1.0),
|
|
77
|
+
vec2f(1.0, 0.0),
|
|
78
|
+
vec2f(1.0, 1.0),
|
|
79
|
+
vec2f(0.0, 1.0)
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
@vertex
|
|
83
|
+
fn vertexMain(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
84
|
+
var output: VertexOutput;
|
|
85
|
+
|
|
86
|
+
let quadPos = QUAD_POSITIONS[vertexIndex];
|
|
87
|
+
let wh = imageData.destRect.zw;
|
|
88
|
+
|
|
89
|
+
// Calculate pixel position
|
|
90
|
+
let pixelPos = imageData.destRect.xy + quadPos * wh;
|
|
91
|
+
|
|
92
|
+
// Convert to clip space (-1 to 1)
|
|
93
|
+
var clipPos = (pixelPos / uniforms.resolution) * 2.0 - 1.0;
|
|
94
|
+
clipPos.y = -clipPos.y; // Flip Y for canvas coordinates
|
|
95
|
+
|
|
96
|
+
output.position = vec4f(clipPos, 0.0, 1.0);
|
|
97
|
+
// Local pixel coordinates in [0..w-1, 0..h-1] to avoid sampling past edge
|
|
98
|
+
output.local = quadPos * max(wh - vec2f(1.0), vec2f(0.0));
|
|
99
|
+
output.color = imageData.color;
|
|
100
|
+
output.texSize = imageData.srcInfo.xy;
|
|
101
|
+
|
|
102
|
+
return output;
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
// WGSL Fragment Shader - sample texel centers to avoid edge artifacts
|
|
106
|
+
const FRAGMENT_SHADER = /* wgsl */ `
|
|
107
|
+
@group(0) @binding(2) var texSampler: sampler;
|
|
108
|
+
@group(0) @binding(3) var tex: texture_2d<f32>;
|
|
109
|
+
@group(0) @binding(4) var<uniform> colorMatrix: mat3x3f;
|
|
110
|
+
|
|
111
|
+
struct FragmentInput {
|
|
112
|
+
@location(0) local: vec2f,
|
|
113
|
+
@location(1) color: vec4f,
|
|
114
|
+
@location(2) texSize: vec2f,
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@fragment
|
|
118
|
+
fn fragmentMain(input: FragmentInput) -> @location(0) vec4f {
|
|
119
|
+
// Sample texel centers to avoid edge artifacts (add 0.5)
|
|
120
|
+
let uv = (input.local + vec2f(0.5)) / input.texSize;
|
|
121
|
+
|
|
122
|
+
// Sample mask from texture (stored in R channel)
|
|
123
|
+
// libass bitmap: 0 = transparent, 255 = opaque (NOT inverted)
|
|
124
|
+
let mask = textureSample(tex, texSampler, uv).r;
|
|
125
|
+
|
|
126
|
+
// Apply color matrix conversion (identity if no conversion needed)
|
|
127
|
+
let correctedColor = colorMatrix * input.color.rgb;
|
|
128
|
+
|
|
129
|
+
// libass color alpha: 0 = opaque, 255 = transparent (inverted)
|
|
130
|
+
let colorAlpha = 1.0 - input.color.a;
|
|
131
|
+
|
|
132
|
+
// Final alpha = colorAlpha * mask (like libass: alpha * mask)
|
|
133
|
+
let a = colorAlpha * mask;
|
|
134
|
+
|
|
135
|
+
// Premultiplied alpha output
|
|
136
|
+
return vec4f(correctedColor * a, a);
|
|
137
|
+
}
|
|
138
|
+
`;
|
|
139
|
+
export class WebGPURenderer {
|
|
140
|
+
device = null;
|
|
141
|
+
context = null;
|
|
142
|
+
pipeline = null;
|
|
143
|
+
sampler = null;
|
|
144
|
+
bindGroupLayout = null;
|
|
145
|
+
// Uniform buffer
|
|
146
|
+
uniformBuffer = null;
|
|
147
|
+
// Color matrix buffer (mat3x3f = 48 bytes with padding)
|
|
148
|
+
colorMatrixBuffer = null;
|
|
149
|
+
// Image data buffers (created on-demand, one per image)
|
|
150
|
+
imageDataBuffers = [];
|
|
151
|
+
// Textures created on-demand (no fixed limit)
|
|
152
|
+
textures = [];
|
|
153
|
+
pendingDestroyTextures = [];
|
|
154
|
+
// eslint-disable-next-line no-undef
|
|
155
|
+
format = 'bgra8unorm';
|
|
156
|
+
initPromise = null;
|
|
157
|
+
constructor() {
|
|
158
|
+
// Start async initialization immediately
|
|
159
|
+
this.initPromise = this._initDevice();
|
|
160
|
+
}
|
|
161
|
+
async _initDevice() {
|
|
162
|
+
// Check WebGPU support
|
|
163
|
+
if (!navigator.gpu) {
|
|
164
|
+
throw new Error('WebGPU not supported');
|
|
165
|
+
}
|
|
166
|
+
const adapter = await navigator.gpu.requestAdapter({
|
|
167
|
+
powerPreference: 'high-performance'
|
|
168
|
+
});
|
|
169
|
+
if (!adapter) {
|
|
170
|
+
throw new Error('No WebGPU adapter found');
|
|
171
|
+
}
|
|
172
|
+
this.device = await adapter.requestDevice();
|
|
173
|
+
this.format = navigator.gpu.getPreferredCanvasFormat();
|
|
174
|
+
// Create shader modules
|
|
175
|
+
const vertexModule = this.device.createShaderModule({
|
|
176
|
+
code: VERTEX_SHADER
|
|
177
|
+
});
|
|
178
|
+
const fragmentModule = this.device.createShaderModule({
|
|
179
|
+
code: FRAGMENT_SHADER
|
|
180
|
+
});
|
|
181
|
+
// Create sampler - use NEAREST filtering to avoid edge artifacts
|
|
182
|
+
this.sampler = this.device.createSampler({
|
|
183
|
+
magFilter: 'nearest',
|
|
184
|
+
minFilter: 'nearest',
|
|
185
|
+
addressModeU: 'clamp-to-edge',
|
|
186
|
+
addressModeV: 'clamp-to-edge'
|
|
187
|
+
});
|
|
188
|
+
// Create uniform buffer
|
|
189
|
+
this.uniformBuffer = this.device.createBuffer({
|
|
190
|
+
size: 16, // vec2f resolution + padding
|
|
191
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
192
|
+
});
|
|
193
|
+
// Create color matrix buffer (mat3x3f requires 48 bytes: 3 vec3f padded to vec4f each)
|
|
194
|
+
this.colorMatrixBuffer = this.device.createBuffer({
|
|
195
|
+
size: 48, // 3 x vec4f (each column is vec3f padded to 16 bytes)
|
|
196
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
197
|
+
});
|
|
198
|
+
// Initialize with identity matrix
|
|
199
|
+
this.setColorMatrix();
|
|
200
|
+
// Create bind group layout
|
|
201
|
+
this.bindGroupLayout = this.device.createBindGroupLayout({
|
|
202
|
+
entries: [
|
|
203
|
+
{
|
|
204
|
+
binding: 0,
|
|
205
|
+
visibility: GPUShaderStage.VERTEX,
|
|
206
|
+
buffer: { type: 'uniform' }
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
binding: 1,
|
|
210
|
+
visibility: GPUShaderStage.VERTEX,
|
|
211
|
+
buffer: { type: 'read-only-storage' }
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
binding: 2,
|
|
215
|
+
visibility: GPUShaderStage.FRAGMENT,
|
|
216
|
+
sampler: { type: 'non-filtering' } // Must match 'nearest' filter sampler
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
binding: 3,
|
|
220
|
+
visibility: GPUShaderStage.FRAGMENT,
|
|
221
|
+
texture: { sampleType: 'float' }
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
binding: 4,
|
|
225
|
+
visibility: GPUShaderStage.FRAGMENT,
|
|
226
|
+
buffer: { type: 'uniform' }
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
});
|
|
230
|
+
// Create pipeline layout
|
|
231
|
+
const pipelineLayout = this.device.createPipelineLayout({
|
|
232
|
+
bindGroupLayouts: [this.bindGroupLayout]
|
|
233
|
+
});
|
|
234
|
+
// Create render pipeline
|
|
235
|
+
this.pipeline = this.device.createRenderPipeline({
|
|
236
|
+
layout: pipelineLayout,
|
|
237
|
+
vertex: {
|
|
238
|
+
module: vertexModule,
|
|
239
|
+
entryPoint: 'vertexMain'
|
|
240
|
+
},
|
|
241
|
+
fragment: {
|
|
242
|
+
module: fragmentModule,
|
|
243
|
+
entryPoint: 'fragmentMain',
|
|
244
|
+
targets: [
|
|
245
|
+
{
|
|
246
|
+
format: this.format,
|
|
247
|
+
blend: {
|
|
248
|
+
color: {
|
|
249
|
+
srcFactor: 'one',
|
|
250
|
+
dstFactor: 'one-minus-src-alpha',
|
|
251
|
+
operation: 'add'
|
|
252
|
+
},
|
|
253
|
+
alpha: {
|
|
254
|
+
srcFactor: 'one',
|
|
255
|
+
dstFactor: 'one-minus-src-alpha',
|
|
256
|
+
operation: 'add'
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
]
|
|
261
|
+
},
|
|
262
|
+
primitive: {
|
|
263
|
+
topology: 'triangle-list'
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
async setCanvas(canvas, width, height) {
|
|
268
|
+
await this.initPromise;
|
|
269
|
+
if (!this.device) {
|
|
270
|
+
throw new Error('WebGPU device not initialized. Did you await the constructor promise?');
|
|
271
|
+
}
|
|
272
|
+
canvas.width = width;
|
|
273
|
+
canvas.height = height;
|
|
274
|
+
if (!this.context) {
|
|
275
|
+
// Get canvas context
|
|
276
|
+
this.context = canvas.getContext('webgpu');
|
|
277
|
+
if (!this.context) {
|
|
278
|
+
throw new Error('Could not get WebGPU context');
|
|
279
|
+
}
|
|
280
|
+
this.context.configure({
|
|
281
|
+
device: this.device,
|
|
282
|
+
format: this.format,
|
|
283
|
+
alphaMode: 'premultiplied'
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
// Update uniform buffer with resolution
|
|
287
|
+
this.device.queue.writeBuffer(this.uniformBuffer, 0, new Float32Array([width, height]));
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Set the color matrix for color space conversion.
|
|
291
|
+
* Pass null or undefined to use identity (no conversion).
|
|
292
|
+
* Matrix should be a pre-padded Float32Array with 12 values (3 columns × 4 floats each).
|
|
293
|
+
*/
|
|
294
|
+
setColorMatrix(matrix) {
|
|
295
|
+
if (!this.device || !this.colorMatrixBuffer)
|
|
296
|
+
return;
|
|
297
|
+
this.device.queue.writeBuffer(this.colorMatrixBuffer, 0, matrix ?? IDENTITY_MATRIX);
|
|
298
|
+
}
|
|
299
|
+
createTextureInfo(width, height) {
|
|
300
|
+
const texture = this.device.createTexture({
|
|
301
|
+
size: [width, height],
|
|
302
|
+
format: 'r8unorm',
|
|
303
|
+
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST
|
|
304
|
+
});
|
|
305
|
+
return {
|
|
306
|
+
texture,
|
|
307
|
+
view: texture.createView(),
|
|
308
|
+
width,
|
|
309
|
+
height
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
render(images, heap) {
|
|
313
|
+
if (!this.device || !this.context || !this.pipeline || images.length === 0)
|
|
314
|
+
return;
|
|
315
|
+
const commandEncoder = this.device.createCommandEncoder();
|
|
316
|
+
const textureView = this.context.getCurrentTexture().createView();
|
|
317
|
+
// Begin render pass
|
|
318
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
319
|
+
colorAttachments: [
|
|
320
|
+
{
|
|
321
|
+
view: textureView,
|
|
322
|
+
clearValue: { r: 0, g: 0, b: 0, a: 0 },
|
|
323
|
+
loadOp: 'clear',
|
|
324
|
+
storeOp: 'store'
|
|
325
|
+
}
|
|
326
|
+
]
|
|
327
|
+
});
|
|
328
|
+
renderPass.setPipeline(this.pipeline);
|
|
329
|
+
// Grow arrays if needed
|
|
330
|
+
while (this.textures.length < images.length) {
|
|
331
|
+
this.textures.push(this.createTextureInfo(64, 64));
|
|
332
|
+
}
|
|
333
|
+
while (this.imageDataBuffers.length < images.length) {
|
|
334
|
+
this.imageDataBuffers.push(this.device.createBuffer({
|
|
335
|
+
size: 48, // 3 x vec4f
|
|
336
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST
|
|
337
|
+
}));
|
|
338
|
+
}
|
|
339
|
+
// Render each image
|
|
340
|
+
for (let i = 0; i < images.length; i++) {
|
|
341
|
+
const img = images[i];
|
|
342
|
+
let texInfo = this.textures[i];
|
|
343
|
+
// Recreate texture if size changed (use actual w, not stride)
|
|
344
|
+
if (texInfo.width !== img.w || texInfo.height !== img.h) {
|
|
345
|
+
// Defer destruction until after submit to avoid destroying textures still in use
|
|
346
|
+
this.pendingDestroyTextures.push(texInfo.texture);
|
|
347
|
+
texInfo = this.createTextureInfo(img.w, img.h);
|
|
348
|
+
this.textures[i] = texInfo;
|
|
349
|
+
}
|
|
350
|
+
// Upload bitmap data using bytesPerRow to handle stride
|
|
351
|
+
// Only need stride * (h-1) + w bytes per ASS spec
|
|
352
|
+
// this... didnt work, is the used alternative bad?
|
|
353
|
+
// const dataSize = img.stride * (img.h - 1) + img.w
|
|
354
|
+
// const bitmapData = heap.subarray(img.bitmap, img.bitmap + dataSize)
|
|
355
|
+
// this.device.queue.writeTexture(
|
|
356
|
+
// { texture: texInfo.texture },
|
|
357
|
+
// bitmapData as unknown as ArrayBuffer,
|
|
358
|
+
// { bytesPerRow: img.stride }, // Source rows are stride bytes apart
|
|
359
|
+
// { width: img.w, height: img.h } // But we only copy w pixels per row
|
|
360
|
+
// )
|
|
361
|
+
this.device.queue.writeTexture({ texture: texInfo.texture }, heap.buffer, { bytesPerRow: img.stride, offset: img.bitmap }, // Source rows are stride bytes apart
|
|
362
|
+
{ width: img.w, height: img.h } // But we only copy w pixels per row
|
|
363
|
+
);
|
|
364
|
+
// Update image data buffer
|
|
365
|
+
const imageData = new Float32Array([
|
|
366
|
+
// destRect
|
|
367
|
+
img.dst_x, img.dst_y, img.w, img.h,
|
|
368
|
+
// srcInfo
|
|
369
|
+
img.w, img.h, img.stride, 0,
|
|
370
|
+
// color (RGBA from 0xRRGGBBAA)
|
|
371
|
+
((img.color >>> 24) & 0xFF) / 255,
|
|
372
|
+
((img.color >>> 16) & 0xFF) / 255,
|
|
373
|
+
((img.color >>> 8) & 0xFF) / 255,
|
|
374
|
+
(img.color & 0xFF) / 255
|
|
375
|
+
]);
|
|
376
|
+
const imageBuffer = this.imageDataBuffers[i];
|
|
377
|
+
this.device.queue.writeBuffer(imageBuffer, 0, imageData);
|
|
378
|
+
// Create bind group for this image
|
|
379
|
+
const bindGroup = this.device.createBindGroup({
|
|
380
|
+
layout: this.bindGroupLayout,
|
|
381
|
+
entries: [
|
|
382
|
+
{ binding: 0, resource: { buffer: this.uniformBuffer } },
|
|
383
|
+
{ binding: 1, resource: { buffer: imageBuffer } },
|
|
384
|
+
{ binding: 2, resource: this.sampler },
|
|
385
|
+
{ binding: 3, resource: texInfo.view },
|
|
386
|
+
{ binding: 4, resource: { buffer: this.colorMatrixBuffer } }
|
|
387
|
+
]
|
|
388
|
+
});
|
|
389
|
+
renderPass.setBindGroup(0, bindGroup);
|
|
390
|
+
renderPass.draw(6); // 6 vertices for quad
|
|
391
|
+
}
|
|
392
|
+
renderPass.end();
|
|
393
|
+
this.device.queue.submit([commandEncoder.finish()]);
|
|
394
|
+
// Now safe to destroy old textures
|
|
395
|
+
for (const tex of this.pendingDestroyTextures) {
|
|
396
|
+
tex.destroy();
|
|
397
|
+
}
|
|
398
|
+
this.pendingDestroyTextures = [];
|
|
399
|
+
}
|
|
400
|
+
clear() {
|
|
401
|
+
if (!this.device || !this.context)
|
|
402
|
+
return;
|
|
403
|
+
const commandEncoder = this.device.createCommandEncoder();
|
|
404
|
+
const textureView = this.context.getCurrentTexture().createView();
|
|
405
|
+
const renderPass = commandEncoder.beginRenderPass({
|
|
406
|
+
colorAttachments: [
|
|
407
|
+
{
|
|
408
|
+
view: textureView,
|
|
409
|
+
clearValue: { r: 0, g: 0, b: 0, a: 0 },
|
|
410
|
+
loadOp: 'clear',
|
|
411
|
+
storeOp: 'store'
|
|
412
|
+
}
|
|
413
|
+
]
|
|
414
|
+
});
|
|
415
|
+
renderPass.end();
|
|
416
|
+
this.device.queue.submit([commandEncoder.finish()]);
|
|
417
|
+
}
|
|
418
|
+
destroy() {
|
|
419
|
+
for (const tex of this.textures) {
|
|
420
|
+
tex.texture.destroy();
|
|
421
|
+
}
|
|
422
|
+
this.textures = [];
|
|
423
|
+
this.uniformBuffer?.destroy();
|
|
424
|
+
this.colorMatrixBuffer?.destroy();
|
|
425
|
+
for (const buf of this.imageDataBuffers) {
|
|
426
|
+
buf.destroy();
|
|
427
|
+
}
|
|
428
|
+
this.imageDataBuffers = [];
|
|
429
|
+
this.device?.destroy();
|
|
430
|
+
this.device = null;
|
|
431
|
+
this.context = null;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
//# sourceMappingURL=webgpu-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-renderer.js","sourceRoot":"","sources":["../../src/worker/webgpu-renderer.ts"],"names":[],"mappings":"AAGA,MAAM,eAAe,GAAG,IAAI,YAAY,CAAC;IACvC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACV,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACV,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;CACX,CAAC,CAAA;AAEF,yFAAyF;AACzF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,KAAK,EAAE;QACL,KAAK,EAAE,IAAI,YAAY,CAAC;YACtB,MAAM,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC;YAC1B,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC;YAC3B,CAAC,KAAK,EAAE,MAA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AAE,CAAC,EAAE;oBACtC,MAAM,EAAE,OAAO;oBACf,OAAO,EAAE,OAAO;iBACjB;aACF;SACF,CAAC,CAAA;QAEF,UAAU,CAAC,GAAG,EAAE,CAAA;QAChB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IACrD,CAAC;IAED,OAAO;QACL,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,CAAA;QACvB,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;QAElB,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,CAAA;QAC7B,IAAI,CAAC,iBAAiB,EAAE,OAAO,EAAE,CAAA;QACjC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxC,GAAG,CAAC,OAAO,EAAE,CAAA;QACf,CAAC;QACD,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAA;QAE1B,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QAClB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { finalizer } from 'abslink';
|
|
2
|
+
import { WebGPURenderer } from './webgpu-renderer';
|
|
3
|
+
import type { ASS_Event, ASS_Style, JASSUB } from '../wasm/types.js';
|
|
4
|
+
interface opts {
|
|
5
|
+
wasmUrl: string;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
subUrl: string | undefined;
|
|
9
|
+
subContent: string | null;
|
|
10
|
+
fonts: Array<string | Uint8Array>;
|
|
11
|
+
availableFonts: Record<string, Uint8Array | string>;
|
|
12
|
+
fallbackFont: string;
|
|
13
|
+
debug: boolean;
|
|
14
|
+
libassMemoryLimit: number;
|
|
15
|
+
libassGlyphLimit: number;
|
|
16
|
+
useLocalFonts: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare class ASSRenderer {
|
|
19
|
+
_offCanvas?: OffscreenCanvas;
|
|
20
|
+
_wasm: JASSUB;
|
|
21
|
+
_subtitleColorSpace?: 'BT601' | 'BT709' | 'SMPTE240M' | 'FCC' | null;
|
|
22
|
+
_videoColorSpace?: 'BT709' | 'BT601';
|
|
23
|
+
_malloc: (size: number) => number;
|
|
24
|
+
_gpurender: WebGPURenderer;
|
|
25
|
+
debug: boolean;
|
|
26
|
+
useLocalFonts: boolean;
|
|
27
|
+
_availableFonts: Record<string, Uint8Array | string>;
|
|
28
|
+
_fontMap: Record<string, boolean>;
|
|
29
|
+
_fontId: number;
|
|
30
|
+
_ready: Promise<void>;
|
|
31
|
+
_getFont: (font: string) => Promise<void>;
|
|
32
|
+
constructor(data: opts, getFont: (font: string) => Promise<void>);
|
|
33
|
+
ready(): Promise<void>;
|
|
34
|
+
addFont(fontOrURL: Uint8Array | string): void;
|
|
35
|
+
createEvent(event: ASS_Event): void;
|
|
36
|
+
getEvents(): Partial<ASS_Event>[];
|
|
37
|
+
setEvent(event: ASS_Event, index: number): void;
|
|
38
|
+
removeEvent(index: number): void;
|
|
39
|
+
createStyle(style: ASS_Style): ASS_Style;
|
|
40
|
+
getStyles(): Partial<ASS_Style>[];
|
|
41
|
+
setStyle(style: ASS_Style, index: number): void;
|
|
42
|
+
removeStyle(index: number): void;
|
|
43
|
+
styleOverride(style: ASS_Style): void;
|
|
44
|
+
disableStyleOverride(): void;
|
|
45
|
+
setDefaultFont(fontName: string): void;
|
|
46
|
+
setTrack(content: string): void;
|
|
47
|
+
freeTrack(): void;
|
|
48
|
+
setTrackByUrl(url: string): void;
|
|
49
|
+
_checkColorSpace(): void;
|
|
50
|
+
_findAvailableFonts(font: string): void;
|
|
51
|
+
_asyncWrite(font: Uint8Array | string): void;
|
|
52
|
+
_allocFont(uint8: Uint8Array): void;
|
|
53
|
+
_processAvailableFonts(content: string): void;
|
|
54
|
+
_canvas(width: number, height: number, videoWidth: number, videoHeight: number): void;
|
|
55
|
+
[finalizer](): void;
|
|
56
|
+
_draw(time: number, force?: boolean): void;
|
|
57
|
+
_setColorSpace(videoColorSpace: 'RGB' | 'BT709' | 'BT601'): void;
|
|
58
|
+
}
|
|
59
|
+
export {};
|