
* Add sRGB -> RGB conversion before resize * Add clamping for color space conversions * Clip for demultiplication as well * Fixing linear <-> srgb conversion * Update benchmark * Decouple srgb calculations * Generate lookup tables * Update src/codecs/resize/options.tsx * Defaulting on, renaming, removing redundant state
115 lines
3.7 KiB
JavaScript
115 lines
3.7 KiB
JavaScript
(function() {
|
|
var wasm;
|
|
const __exports = {};
|
|
|
|
|
|
let cachegetUint8Memory = null;
|
|
function getUint8Memory() {
|
|
if (cachegetUint8Memory === null || cachegetUint8Memory.buffer !== wasm.memory.buffer) {
|
|
cachegetUint8Memory = new Uint8Array(wasm.memory.buffer);
|
|
}
|
|
return cachegetUint8Memory;
|
|
}
|
|
|
|
let WASM_VECTOR_LEN = 0;
|
|
|
|
function passArray8ToWasm(arg) {
|
|
const ptr = wasm.__wbindgen_malloc(arg.length * 1);
|
|
getUint8Memory().set(arg, ptr / 1);
|
|
WASM_VECTOR_LEN = arg.length;
|
|
return ptr;
|
|
}
|
|
|
|
function getArrayU8FromWasm(ptr, len) {
|
|
return getUint8Memory().subarray(ptr / 1, ptr / 1 + len);
|
|
}
|
|
|
|
let cachedGlobalArgumentPtr = null;
|
|
function globalArgumentPtr() {
|
|
if (cachedGlobalArgumentPtr === null) {
|
|
cachedGlobalArgumentPtr = wasm.__wbindgen_global_argument_ptr();
|
|
}
|
|
return cachedGlobalArgumentPtr;
|
|
}
|
|
|
|
let cachegetUint32Memory = null;
|
|
function getUint32Memory() {
|
|
if (cachegetUint32Memory === null || cachegetUint32Memory.buffer !== wasm.memory.buffer) {
|
|
cachegetUint32Memory = new Uint32Array(wasm.memory.buffer);
|
|
}
|
|
return cachegetUint32Memory;
|
|
}
|
|
/**
|
|
* @param {Uint8Array} arg0
|
|
* @param {number} arg1
|
|
* @param {number} arg2
|
|
* @param {number} arg3
|
|
* @param {number} arg4
|
|
* @param {number} arg5
|
|
* @param {boolean} arg6
|
|
* @param {boolean} arg7
|
|
* @returns {Uint8Array}
|
|
*/
|
|
__exports.resize = function(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
|
|
const ptr0 = passArray8ToWasm(arg0);
|
|
const len0 = WASM_VECTOR_LEN;
|
|
const retptr = globalArgumentPtr();
|
|
wasm.resize(retptr, ptr0, len0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
|
|
const mem = getUint32Memory();
|
|
const rustptr = mem[retptr / 4];
|
|
const rustlen = mem[retptr / 4 + 1];
|
|
|
|
const realRet = getArrayU8FromWasm(rustptr, rustlen).slice();
|
|
wasm.__wbindgen_free(rustptr, rustlen * 1);
|
|
return realRet;
|
|
|
|
};
|
|
|
|
const heap = new Array(32);
|
|
|
|
heap.fill(undefined);
|
|
|
|
heap.push(undefined, null, true, false);
|
|
|
|
let heap_next = heap.length;
|
|
|
|
function dropObject(idx) {
|
|
if (idx < 36) return;
|
|
heap[idx] = heap_next;
|
|
heap_next = idx;
|
|
}
|
|
|
|
__exports.__wbindgen_object_drop_ref = function(i) { dropObject(i); };
|
|
|
|
function init(path_or_module) {
|
|
let instantiation;
|
|
const imports = { './resize': __exports };
|
|
if (path_or_module instanceof WebAssembly.Module) {
|
|
instantiation = WebAssembly.instantiate(path_or_module, imports)
|
|
.then(instance => {
|
|
return { instance, module: path_or_module }
|
|
});
|
|
} else {
|
|
const data = fetch(path_or_module);
|
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
instantiation = WebAssembly.instantiateStreaming(data, imports)
|
|
.catch(e => {
|
|
console.warn("`WebAssembly.instantiateStreaming` failed. Assuming this is because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
return data
|
|
.then(r => r.arrayBuffer())
|
|
.then(bytes => WebAssembly.instantiate(bytes, imports));
|
|
});
|
|
} else {
|
|
instantiation = data
|
|
.then(response => response.arrayBuffer())
|
|
.then(buffer => WebAssembly.instantiate(buffer, imports));
|
|
}
|
|
}
|
|
return instantiation.then(({instance}) => {
|
|
wasm = init.wasm = instance.exports;
|
|
|
|
});
|
|
};
|
|
self.wasm_bindgen = Object.assign(init, __exports);
|
|
})();
|