@wasm-audio-decoders/flac
Version:
Web Assembly streaming FLAC decoder
365 lines (323 loc) • 41.6 kB
JavaScript
/* **************************************************
* This file is auto-generated during the build process.
* Any edits to this file will be overwritten.
****************************************************/
export default function EmscriptenWASM(WASMAudioDecoderCommon) {
// include: shell_minimal.js
var Module = Module;
// Redefine these in a --pre-js to override behavior. If you would like to
// remove out() or err() altogether, you can no-op it out to function() {},
// and build with --closure 1 to get Closure optimize out all the uses
// altogether.
var out = text => console.log(text);
var err = text => console.error(text);
// Override this function in a --pre-js file to get a signal for when
// compilation is ready. In that callback, call the function run() to start
// the program.
function ready() {}
// --pre-jses are emitted after the Module integration code, so that they can
// refer to Module (if they choose; they can also define Module)
// include: src/flac/src/emscripten-pre.js
Module = {};
// end include: src/flac/src/emscripten-pre.js
// end include: shell_minimal.js
// include: preamble_minimal.js
/** @param {string|number=} what */ function abort(what) {
throw what;
}
var HEAP8, HEAP16, HEAP32, HEAPU8, HEAPU16, HEAPU32, HEAPF32, HEAPF64, HEAP64, HEAPU64, wasmMemory;
// include: runtime_shared.js
// include: runtime_stack_check.js
// end include: runtime_stack_check.js
// include: runtime_exceptions.js
// end include: runtime_exceptions.js
// include: runtime_debug.js
// end include: runtime_debug.js
// include: memoryprofiler.js
// end include: memoryprofiler.js
function updateMemoryViews() {
var b = wasmMemory.buffer;
HEAP8 = new Int8Array(b);
HEAP16 = new Int16Array(b);
HEAPU8 = new Uint8Array(b);
HEAPU16 = new Uint16Array(b);
HEAP32 = new Int32Array(b);
HEAPU32 = new Uint32Array(b);
HEAPF32 = new Float32Array(b);
HEAPF64 = new Float64Array(b);
HEAP64 = new BigInt64Array(b);
HEAPU64 = new BigUint64Array(b);
}
// end include: runtime_shared.js
// end include: preamble_minimal.js
// Begin JS library code
/** @noinline */ var base64Decode = b64 => {
var b1, b2, i = 0, j = 0, bLength = b64.length;
var output = new Uint8Array((bLength * 3 >> 2) - (b64[bLength - 2] == "=") - (b64[bLength - 1] == "="));
for (;i < bLength; i += 4, j += 3) {
b1 = base64ReverseLookup[b64.charCodeAt(i + 1)];
b2 = base64ReverseLookup[b64.charCodeAt(i + 2)];
output[j] = base64ReverseLookup[b64.charCodeAt(i)] << 2 | b1 >> 4;
output[j + 1] = b1 << 4 | b2 >> 2;
output[j + 2] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i + 3)];
}
return output;
};
var __abort_js = () => abort("");
var __emscripten_runtime_keepalive_clear = () => {};
var timers = {};
var callUserCallback = func => func();
var _emscripten_get_now = () => performance.now();
var __setitimer_js = (which, timeout_ms) => {
// First, clear any existing timer.
if (timers[which]) {
clearTimeout(timers[which].id);
delete timers[which];
}
// A timeout of zero simply cancels the current timeout so we have nothing
// more to do.
if (!timeout_ms) return 0;
var id = setTimeout(() => {
delete timers[which];
callUserCallback(() => __emscripten_timeout(which, _emscripten_get_now()));
}, timeout_ms);
timers[which] = {
id,
timeout_ms
};
return 0;
};
var _emscripten_resize_heap = requestedSize => {
var oldSize = HEAPU8.length;
// With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
requestedSize >>>= 0;
return false;
};
var _fd_close = fd => 52;
var _fd_read = (fd, iov, iovcnt, pnum) => 52;
var INT53_MAX = 9007199254740992;
var INT53_MIN = -9007199254740992;
var bigintToI53Checked = num => (num < INT53_MIN || num > INT53_MAX) ? NaN : Number(num);
function _fd_seek(fd, offset, whence, newOffset) {
offset = bigintToI53Checked(offset);
return 70;
}
var printCharBuffers = [ null, [], [] ];
var UTF8Decoder = new TextDecoder;
/**
* Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
* array that contains uint8 values, returns a copy of that string as a
* Javascript String object.
* heapOrArray is either a regular array, or a JavaScript typed array view.
* @param {number=} idx
* @param {number=} maxBytesToRead
* @return {string}
*/ var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead = NaN) => {
var endIdx = idx + maxBytesToRead;
var endPtr = idx;
// TextDecoder needs to know the byte length in advance, it doesn't stop on
// null terminator by itself. Also, use the length info to avoid running tiny
// strings through TextDecoder, since .subarray() allocates garbage.
// (As a tiny code save trick, compare endPtr against endIdx using a negation,
// so that undefined/NaN means Infinity)
while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
return UTF8Decoder.decode(heapOrArray.buffer ? heapOrArray.subarray(idx, endPtr) : new Uint8Array(heapOrArray.slice(idx, endPtr)));
};
var printChar = (stream, curr) => {
var buffer = printCharBuffers[stream];
if (curr === 0 || curr === 10) {
(stream === 1 ? out : err)(UTF8ArrayToString(buffer));
buffer.length = 0;
} else {
buffer.push(curr);
}
};
var _fd_write = (fd, iov, iovcnt, pnum) => {
// hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
var num = 0;
for (var i = 0; i < iovcnt; i++) {
var ptr = HEAPU32[((iov) >> 2)];
var len = HEAPU32[(((iov) + (4)) >> 2)];
iov += 8;
for (var j = 0; j < len; j++) {
printChar(fd, HEAPU8[ptr + j]);
}
num += len;
}
HEAPU32[((pnum) >> 2)] = num;
return 0;
};
var _proc_exit = code => {
throw `exit(${code})`;
};
// Precreate a reverse lookup table from chars
// "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" back to
// bytes to make decoding fast.
for (var base64ReverseLookup = new Uint8Array(123), i = 25; i >= 0; --i) {
base64ReverseLookup[48 + i] = 52 + i;
// '0-9'
base64ReverseLookup[65 + i] = i;
// 'A-Z'
base64ReverseLookup[97 + i] = 26 + i;
}
base64ReverseLookup[43] = 62;
// '+'
base64ReverseLookup[47] = 63;
var wasmImports = {
/** @export */ "c": __abort_js,
/** @export */ "b": __emscripten_runtime_keepalive_clear,
/** @export */ "d": __setitimer_js,
/** @export */ "e": _emscripten_resize_heap,
/** @export */ "g": _fd_close,
/** @export */ "i": _fd_read,
/** @export */ "f": _fd_seek,
/** @export */ "h": _fd_write,
/** @export */ "a": _proc_exit
};
function assignWasmExports(wasmExports) {
_free = wasmExports["l"];
_malloc = wasmExports["m"];
_create_decoder = wasmExports["n"];
_destroy_decoder = wasmExports["o"];
_decode_frame = wasmExports["p"];
__emscripten_timeout = wasmExports["r"];
}
var _free, _malloc, _create_decoder, _destroy_decoder, _decode_frame, __emscripten_timeout;
// include: postamble_minimal.js
// === Auto-generated postamble setup entry stuff ===
function initRuntime(wasmExports) {
// No ATINITS hooks
wasmExports["k"]();
}
// Initialize wasm (asynchronous)
if (!EmscriptenWASM.wasm) Object.defineProperty(EmscriptenWASM, "wasm", {get: () => String.raw`dynEncode0179c5946f1dÄ>º}ÊÄ%®z¦IGUn5Or/ñ)÷6yú=}{ üÎ
wûø@¸îqÐdµ»ôæ¾Xf+gúÕe2ëþÞ5=}\Î>ä=Muj ðÎX¼¬·¹nuí¸3_«ßLÏýU¯= C?hXi°$²OƬ´KeSäÔkf
®RJþÊo<̤@8@uw÷©«ýºGßßµm¨7¬¬¬¬¬¬qNЮ´S.^GïPíðNpήæîTVþ§¨Qísüee+.ÜèFfÖZç_¿og_soß06 RÞÑÜfÌÔ%Â/eVéw= ¨Éî6ê@U/'fÈ8vpçPûl¤g:çUf;RÝbS¤Eû8ÖHÕ·&UÞÀ÷ØY-+aRÑÈçAØ%[¾"÷
<=MÿQÆwéÚs28aÒ«vF¶Ìþ¹RQÄD¤]È&§,Bm¿ì 2£ 5Ñ©ªM= ôÌîAêrÚmI*=MÌ= !©oMc¾B Îïû$VÅPÆ= ¸À5JvÝ2¼V7= A3=}»KGvûÚuZaÆ ÇgdRlÃÏÛü"+ÝÃÄ^[ªÒ}
O»LÖíb{þB\ÑÀ¡|æ -ʪÇo£fñ®ªµ£/APãç«/åJ'2Å/õ(,rb9
z!¥rCêÆª=}ðõCg¨¬ç:þ
<
AÖº²Þ§)êÔÐb¢M%¤ñMåÒ{|3ºàú§4ÖÿÖÀ<¶iyÒ)C&y%ÂàE÷fhe-E8À´5ð ÑBh1dGv¶ì×3ù>ýï ïDfh©E$¨q2«s,Z§OY|pø2!ç¡ÆÅjËÁ8uìw<|+åòÇT\ÆÒ·1(*ÍÍ:¦B£Xz%üí¸uÒYh7Q$ûÓþÔÂ~õ"RàýöxUx óaÇ&?"ÞlPzEácw*Ñ&UüBÊêp¼yµ5?!Ôk¾=MÚ0lvaô²ÒÀJ7PEq~𹾿~s¼£ÿ&¤ÀÌDïvÒ±nIº¨þo
â&¤gðJ)CUø"¥{'¥DÀq8i0¶7Ûá]»G@7P,Ü}iÏǶ*=MXúªÄ;Ë4Òç¿23¸Y£+Q&² _O¥.Ùó7Ø·O´@ÀGnÅcܰçb%6¨c89 e+éôì+àRÄ= 'Ù®³tú#sJ¡)¬kF?ßÊ ÈV¢Û/5p}ÞDÀ÷h§¨±jAè´ÀÕÁvë\J^[=}ª$Æ~DüÎf sþÎÊ ¯.óeQ*¶?©»û3+´M-Í$3dV%}rö\£q_Z[U&ÌJûDaÃ=}=M
¸¯KÌaQy¯BnãgSMÃÏbPlÿõräv<ù%ôo !ÂoêÛµeÒ\???|
3?V'@J*ÆíåHíü¿?Õe°<áZ6¨ eÑæ²sîàV¯]4¿P¨N²Òëî幸Ök𮳦¥oæßB.´æÀHn&ãcæs|J<5JJóM²J¹.ÐbÍáÝïºÀT= /ÓEáJP8Ô.Ï-K/¿?KYÙm¼»Û ºUF¸I(¾~9"'Ù0|ÏÝD(è-ü¥ø~÷»Ú[= Oó[^ó[îÉíÜòay c-s6|T2^ë+ágOMJ¦ÐÌ"gÿ0ðÑ,<·oÄ([±ðhüÚmá[ÿ·l µPNâLöQ$òçéUi1¨(wÀÚdöé±ì®~çiUi¨·sÙ£|
|çä=MüQ KÅU=}¢ zjePÿ«
®ÑXtBdØþýÛ\ÿ¬tS%é馲ZiB¤§õè×ü¼Ùù4ÒU¥)°Ô¡[MF@Rê£Çµ_4¨e
Ô£º:j|híÚA¸qî¿JA?j5= 6j,C,ÂquâUÓÌù-°Ì í$±y,®)h¶\ÒÔýý3PvqÈô¨[áïoìl:pþ¥L¹/jéÔ_¼ZyÒgp%uyÊ÷YéÐ+èõch÷@ܳNyÓSËêkÆÍ×s$¤Ö¯¡gëÃl\¸õ:ïßOÉàîLcl8ip4n!2qªdªI&à'u^$ÒĺösCNLèËÉV2@!À}Ü/¾lØøsBÀ4!ÏÉ62m Hxs(É¢q3®nÐØ6eÌß½9ÿ_è×c?àq³mn° ÷ñ³Ôhdc¤XṤ¹æÏÅÄ wMjP7(Ô Ü!¸xs@MÒìSÜù{¶±ßAdòG©~ ·gèÞ6Ë= &m?UõlH7DöùÍ5GE¿©z·s´5Lgzã(6eQ ¬ÑÐU|ÆN+w=}rÄvH éï
g²XóU4F)þ,@Í*1@õA<;³50xgôèîn×ñLÜñ Çx_Ë´µh°HóD V±W¥isÜñ@Øvrså1ðõZk¤Uôöì1Æd_ªI 8p*hãºVm8óah¥Û#LÃÜ:OÌ\¢{f5xL×ÕNÏ=MÿP7_¬= ¡^Rù:ôkDCºçQÓaÕò^H\*Ê0Oe9NÛ»ý?1