hls-test/ogvjs-1.8.4/ogv-decoder-video-av1-wasm.js

45 lines
9.9 KiB
JavaScript
Raw Normal View History

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