mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-16 18:49:50 +00:00
Fix AVIF multithreading (#981)
This commit is contained in:
@@ -13,11 +13,22 @@
|
||||
import type { AVIFModule } from 'codecs/avif/enc/avif_enc';
|
||||
import type { EncodeOptions } from '../shared/meta';
|
||||
import wasmUrlWithoutMT from 'url:codecs/avif/enc/avif_enc.wasm';
|
||||
import wasmUrlWithMT from 'url:codecs/avif/enc/avif_enc_mt.wasm';
|
||||
import workerUrl from 'omt:codecs/avif/enc/avif_enc_mt.worker.js';
|
||||
import { initEmscriptenModule } from 'features/worker-utils';
|
||||
import { threads } from 'wasm-feature-detect';
|
||||
|
||||
let emscriptenModule: Promise<AVIFModule>;
|
||||
|
||||
async function init() {
|
||||
if (await threads()) {
|
||||
const avifEncoder = await import('codecs/avif/enc/avif_enc_mt');
|
||||
return initEmscriptenModule<AVIFModule>(
|
||||
avifEncoder.default,
|
||||
wasmUrlWithMT,
|
||||
workerUrl,
|
||||
);
|
||||
}
|
||||
const avifEncoder = await import('codecs/avif/enc/avif_enc.js');
|
||||
return initEmscriptenModule(avifEncoder.default, wasmUrlWithoutMT);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user