hls-test/ogvjs-1.8.4/ogv-decoder-video-theora-wasm.js
2021-10-22 11:27:02 -07:00

43 lines
9.4 KiB
JavaScript

var OGVDecoderVideoTheoraW = (function() {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
return (
function(OGVDecoderVideoTheoraW) {
OGVDecoderVideoTheoraW = OGVDecoderVideoTheoraW || {};
var a;a||(a=typeof OGVDecoderVideoTheoraW !== 'undefined' ? OGVDecoderVideoTheoraW : {});var aa,l;a.ready=new Promise(function(b,c){aa=b;l=c});var fa=a,m={},r;for(r in a)a.hasOwnProperty(r)&&(m[r]=a[r]);var ha="object"===typeof window,w="function"===typeof importScripts,A="",B,C,E,F,G;
if("object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node)A=w?require("path").dirname(A)+"/":__dirname+"/",B=function(b,c){F||(F=require("fs"));G||(G=require("path"));b=G.normalize(b);return F.readFileSync(b,c?null:"utf8")},E=function(b){b=B(b,!0);b.buffer||(b=new Uint8Array(b));b.buffer||H("Assertion failed: undefined");return b},C=function(b,c,e){F||(F=require("fs"));G||(G=require("path"));b=G.normalize(b);F.readFile(b,function(d,f){d?e(d):c(f.buffer)})},
1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("unhandledRejection",H),a.inspect=function(){return"[Emscripten Module object]"};else if(ha||w)w?A=self.location.href:"undefined"!==typeof document&&document.currentScript&&(A=document.currentScript.src),_scriptDir&&(A=_scriptDir),0!==A.indexOf("blob:")?A=A.substr(0,A.lastIndexOf("/")+1):A="",B=function(b){var c=new XMLHttpRequest;c.open("GET",b,!1);c.send(null);return c.responseText},w&&(E=function(b){var c=
new XMLHttpRequest;c.open("GET",b,!1);c.responseType="arraybuffer";c.send(null);return new Uint8Array(c.response)}),C=function(b,c,e){var d=new XMLHttpRequest;d.open("GET",b,!0);d.responseType="arraybuffer";d.onload=function(){200==d.status||0==d.status&&d.response?c(d.response):e()};d.onerror=e;d.send(null)};a.print||console.log.bind(console);var I=a.printErr||console.warn.bind(console);for(r in m)m.hasOwnProperty(r)&&(a[r]=m[r]);m=null;var J;a.wasmBinary&&(J=a.wasmBinary);
var noExitRuntime=a.noExitRuntime||!0;"object"!==typeof WebAssembly&&H("no native wasm support detected");var M,ia=!1,ja,N;function ka(){var b=M.buffer;ja=b;a.HEAP8=new Int8Array(b);a.HEAP16=new Int16Array(b);a.HEAP32=new Int32Array(b);a.HEAPU8=N=new Uint8Array(b);a.HEAPU16=new Uint16Array(b);a.HEAPU32=new Uint32Array(b);a.HEAPF32=new Float32Array(b);a.HEAPF64=new Float64Array(b)}var O,la=[],ma=[],na=[];function oa(){var b=a.preRun.shift();la.unshift(b)}var S=0,T=null,U=null;a.preloadedImages={};
a.preloadedAudios={};function H(b){if(a.onAbort)a.onAbort(b);I(b);ia=!0;b=new WebAssembly.RuntimeError("abort("+b+"). Build with -s ASSERTIONS=1 for more info.");l(b);throw b;}function pa(){return V.startsWith("data:application/octet-stream;base64,")}var V;V="ogv-decoder-video-theora-wasm.wasm";if(!pa()){var qa=V;V=a.locateFile?a.locateFile(qa,A):A+qa}
function ra(){var b=V;try{if(b==V&&J)return new Uint8Array(J);if(E)return E(b);throw"both async and sync fetching of the wasm failed";}catch(c){H(c)}}
function sa(){if(!J&&(ha||w)){if("function"===typeof fetch&&!V.startsWith("file://"))return fetch(V,{credentials:"same-origin"}).then(function(b){if(!b.ok)throw"failed to load wasm binary file at '"+V+"'";return b.arrayBuffer()}).catch(function(){return ra()});if(C)return new Promise(function(b,c){C(V,function(e){b(new Uint8Array(e))},c)})}return Promise.resolve().then(function(){return ra()})}
function ta(b){for(;0<b.length;){var c=b.shift();if("function"==typeof c)c(a);else{var e=c.A;"number"===typeof e?void 0===c.o?O.get(e)():O.get(e)(c.o):e(void 0===c.o?null:c.o)}}}
var Ga={a:function(b,c,e){N.copyWithin(b,c,c+e)},b:function(b){var c=N.length;b>>>=0;if(2147483648<b)return!1;for(var e=1;4>=e;e*=2){var d=c*(1+.2/e);d=Math.min(d,b+100663296);d=Math.max(b,d);0<d%65536&&(d+=65536-d%65536);a:{try{M.grow(Math.min(2147483648,d)-ja.byteLength+65535>>>16);ka();var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},c:function(b,c,e,d,f,g,t,p,D,q,x,K,P,Q,ba,ca){function da(y,n,u,ea,ua,va,Ha,Ia,R){if(Fa){var h=new Float64Array(y.buffer);n=new Float64Array(wa,n,u*ea>>
3);h.set(n)}else y.set(new Uint8Array(wa,n,u*ea));var v;for(n=v=0;n<va;n++,v+=u)for(h=0;h<u;h++)y[v+h]=R;for(;n<va+Ia;n++,v+=u){for(h=0;h<ua;h++)y[v+h]=R;for(h=ua+Ha;h<u;h++)y[v+h]=R}for(;n<ea;n++,v+=u)for(h=0;h<u;h++)y[v+h]=R;return y}var wa=M.buffer,k=a.videoFormat,xa=(P&-2)*D/t,ya=(Q&-2)*q/p,za=x*D/t,Aa=K*q/p;x===k.cropWidth&&K===k.cropHeight&&(ba=k.displayWidth,ca=k.displayHeight);for(var Ba=a.recycledFrames,z,Ca=p*c,Da=q*d,Ea=q*g;0<Ba.length;){var L=Ba.shift();k=L.format;if(k.width===t&&k.height===
p&&k.chromaWidth===D&&k.chromaHeight===q&&k.cropLeft===P&&k.cropTop===Q&&k.cropWidth===x&&k.cropHeight===K&&k.displayWidth===ba&&k.displayHeight===ca&&L.y.bytes.length===Ca&&L.u.bytes.length===Da&&L.v.bytes.length===Ea){z=L;break}}z||(z={format:{width:t,height:p,chromaWidth:D,chromaHeight:q,cropLeft:P,cropTop:Q,cropWidth:x,cropHeight:K,displayWidth:ba,displayHeight:ca},y:{bytes:new Uint8Array(Ca),stride:c},u:{bytes:new Uint8Array(Da),stride:d},v:{bytes:new Uint8Array(Ea),stride:g}});da(z.y.bytes,
b,c,p,P,Q,x,K,0);da(z.u.bytes,e,d,q,xa,ya,za,Aa,128);da(z.v.bytes,f,g,q,xa,ya,za,Aa,128);a.frameBuffer=z},d:function(b,c,e,d,f,g,t,p,D,q,x){a.videoFormat={width:b,height:c,chromaWidth:e,chromaHeight:d,cropLeft:p,cropTop:D,cropWidth:g,cropHeight:t,displayWidth:q,displayHeight:x,fps:f};a.loadedMetadata=!0}};
(function(){function b(f){a.asm=f.exports;M=a.asm.e;ka();O=a.asm.n;ma.unshift(a.asm.f);S--;a.monitorRunDependencies&&a.monitorRunDependencies(S);0==S&&(null!==T&&(clearInterval(T),T=null),U&&(f=U,U=null,f()))}function c(f){b(f.instance)}function e(f){return sa().then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){I("failed to asynchronously prepare wasm: "+g);H(g)})}var d={a:Ga};S++;a.monitorRunDependencies&&a.monitorRunDependencies(S);if(a.instantiateWasm)try{return a.instantiateWasm(d,
b)}catch(f){return I("Module.instantiateWasm callback failed with error: "+f),!1}(function(){return J||"function"!==typeof WebAssembly.instantiateStreaming||pa()||V.startsWith("file://")||"function"!==typeof fetch?e(c):fetch(V,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,d).then(c,function(g){I("wasm streaming compile failed: "+g);I("falling back to ArrayBuffer instantiation");return e(c)})})})().catch(l);return{}})();
a.___wasm_call_ctors=function(){return(a.___wasm_call_ctors=a.asm.f).apply(null,arguments)};a._ogv_video_decoder_init=function(){return(a._ogv_video_decoder_init=a.asm.g).apply(null,arguments)};a._ogv_video_decoder_async=function(){return(a._ogv_video_decoder_async=a.asm.h).apply(null,arguments)};a._ogv_video_decoder_process_header=function(){return(a._ogv_video_decoder_process_header=a.asm.i).apply(null,arguments)};
a._ogv_video_decoder_process_frame=function(){return(a._ogv_video_decoder_process_frame=a.asm.j).apply(null,arguments)};a._ogv_video_decoder_destroy=function(){return(a._ogv_video_decoder_destroy=a.asm.k).apply(null,arguments)};a._malloc=function(){return(a._malloc=a.asm.l).apply(null,arguments)};a._free=function(){return(a._free=a.asm.m).apply(null,arguments)};var W;U=function Ja(){W||Ka();W||(U=Ja)};
function Ka(){function b(){if(!W&&(W=!0,a.calledRun=!0,!ia)){ta(ma);aa(a);if(a.onRuntimeInitialized)a.onRuntimeInitialized();if(a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;){var c=a.postRun.shift();na.unshift(c)}ta(na)}}if(!(0<S)){if(a.preRun)for("function"==typeof a.preRun&&(a.preRun=[a.preRun]);a.preRun.length;)oa();ta(la);0<S||(a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1);b()},1)):b())}}a.run=Ka;
if(a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);0<a.preInit.length;)a.preInit.pop()();Ka();var X,La,Y;"undefined"===typeof performance||"undefined"===typeof performance.now?Y=Date.now:Y=performance.now.bind(performance);function Z(b){var c=Y();b=b();a.cpuTime+=Y()-c;return b}a.loadedMetadata=!!fa.videoFormat;a.videoFormat=fa.videoFormat||null;a.frameBuffer=null;a.cpuTime=0;Object.defineProperty(a,"processing",{get:function(){return!1}});
a.init=function(b){Z(function(){a._ogv_video_decoder_init()});b()};a.processHeader=function(b,c){var e=Z(function(){var d=b.byteLength;X&&La>=d||(X&&a._free(X),La=d,X=a._malloc(La));var f=X;(new Uint8Array(M.buffer,f,d)).set(new Uint8Array(b));return a._ogv_video_decoder_process_header(f,d)});c(e)};a.s=[];
a.processFrame=function(b,c){function e(p){a._free(g);c(p)}var d=a._ogv_video_decoder_async(),f=b.byteLength,g=a._malloc(f);d&&a.s.push(e);var t=Z(function(){(new Uint8Array(M.buffer,g,f)).set(new Uint8Array(b));return a._ogv_video_decoder_process_frame(g,f)});d||e(t)};a.close=function(){};a.sync=function(){a._ogv_video_decoder_async()&&(a.s.push(function(){}),Z(function(){a._ogv_video_decoder_process_frame(0,0)}))};a.recycledFrames=[];
a.recycleFrame=function(b){var c=a.recycledFrames;c.push(b);16<c.length&&c.shift()};var Fa="object"===typeof navigator&&navigator.userAgent.match(/Trident/);
return OGVDecoderVideoTheoraW.ready
}
);
})();
if (typeof exports === 'object' && typeof module === 'object')
module.exports = OGVDecoderVideoTheoraW;
else if (typeof define === 'function' && define['amd'])
define([], function() { return OGVDecoderVideoTheoraW; });
else if (typeof exports === 'object')
exports["OGVDecoderVideoTheoraW"] = OGVDecoderVideoTheoraW;