/** * Off-main-thread camera-to-proxy conversion. * * `cameraToProxy` is a pixel loop over the whole frame: 2.4 s on a 24 MP decode * here, and four parallel imports serialised on it. The buffers arrive as * SharedArrayBuffer views, so the worker mutates the frame in place and nothing * is copied across the thread boundary. */ import { parentPort, workerData } from 'node:worker_threads'; import { cameraToProxy } from './color.mjs'; try { const gain = cameraToProxy(workerData.rgb16, workerData.rgb8, workerData.matrix); parentPort.postMessage({ gain }); } catch (error) { parentPort.postMessage({ error: error instanceof Error ? error.message : String(error) }); }