antosdk-apps/libjpeg/build/debug/main.js

18 lines
52 KiB
JavaScript
Raw Normal View History

2020-12-28 18:12:36 +01:00
(function(){}).call(this);var e,t=function(){function t(){this._src=null,this._parser=new e.JpegImage,this.onload=null}return t.prototype={get src(){return this._src},set src(e){this.load(e)},get width(){return this._parser.width},get height(){return this._parser.height},load:function(e){this._src=e,
/**
* @license
* Copyright 2015 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function(e,t){if(0!==e.indexOf("data:")){var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=function(){t(r.response)},r.send(null)}else{for(var n=e.indexOf("base64,")+7,i=atob(e.substring(n)),a=new Uint8Array(i.length),s=i.length-1;s>=0;s--)a[s]=i.charCodeAt(s);t(a.buffer)}}(e,function(e){this.parse(new Uint8Array(e)),this.onload&&this.onload()}.bind(this))},parse:function(e){this._parser.parse(e)},getData:function(e,t){return this._parser.getData(e,t,!1)},copyToImageData:function(e){if(2===this._parser.numComponents||this._parser.numComponents>4)throw new Error("Unsupported amount of components");var t,r,n=e.width,i=e.height,a=n*i*4,s=e.data;if(1!==this._parser.numComponents){var o=this._parser.getData(n,i,!0);for(t=0,r=0;t<a;)s[t++]=o[r++],s[t++]=o[r++],s[t++]=o[r++],s[t++]=255}else{var c=this._parser.getData(n,i,!1);for(t=0,r=0;t<a;){var l=c[r++];s[t++]=l,s[t++]=l,s[t++]=l,s[t++]=255}}}},t}();"function"==typeof exports&&(module.exports={JpegImage:t,JpegDecoder:r,JpxDecoder:n,Jbig2Decoder:i}),function(e){"use strict";var t=function(){var e=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]);function t(){}function r(e,t){for(var r,n,i=0,a=[],s=16;s>0&&!e[s-1];)s--;a.push({children:[],index:0});var o,c=a[0];for(r=0;r<s;r++){for(n=0;n<e[r];n++){for((c=a.pop()).children[c.index]=t[i];c.index>0;)c=a.pop();for(c.index++,a.push(c);a.length<=r;)a.push(o={children:[],index:0}),c.children[c.index]=o.children,c=o;i++}r+1<s&&(a.push(o={children:[],index:0}),c.children[c.index]=o.children,c=o)}return a[0].children}function n(e,t,r){return 64*((e.blocksPerLine+1)*t+r)}function i(t,r,i,a,s,o,c,l,h){i.precision,i.samplesPerLine,i.scanLines;var f=i.mcusPerLine,u=i.progressive,p=(i.maxH,i.maxV,r),m=0,d=0;function v(){if(d>0)return d--,m>>d&1;if(255===(m=t[r++])){var e=t[r++];if(e)throw"unexpected marker: "+(m<<8|e).toString(16)}return d=7,m>>>7}function g(e){for(var t=e;;){if("number"==typeof(t=t[v()]))return t;if("object"!=typeof t)throw"invalid huffman sequence"}}function b(e){for(var t=0;e>0;)t=t<<1|v(),e--;return t}function y(e){if(1===e)return 1===v()?1:-1;var t=b(e);return t>=1<<e-1?t:t+(-1<<e)+1}var x,w=0,C=0;function P(e,t,r,i,a){var s=r%f;t(e,n(e,(r/f|0)*e.v+i,s*e.h+a))}function k(e,t,r){t(e,n(e,r/e.blocksPerLine|0,r%e.blocksPerLine))}var I,M,S,T,A,D,L=a.length;D=u?0===o?0===l?function(e,t){var r=g(e.huffmanTableDC),n=0===r?0:y(r)<<h;e.blockData[t]=e.pred+=n}:function(e,t){e.blockData[t]|=v()<<h}:0===l?function(t,r){if(w>0)w--;else for(var n=o,i=c;n<=i;){var a=g(t.huffmanTableAC),s=15&a,l=a>>4;if(0!==s){var f=e[n+=l];t.blockData[r+f]=y(s)*(1<<h),n++}else{if(l<15){w=b(l)+(1<<l)-1;break}n+=16}}}:function(t,r){for(var n,i,a=o,s=c,l=0;a<=s;){var f=e[a];switch(C){case 0:if(l=(i=g(t.huffmanTableAC))>>4,0==(n=15&i))l<15?(w=b(l)+(1<<l),C=4):(l=16,C=1);else{if(1!==n)throw"invalid ACn encoding";x=y(n),C=l?2:3}continue;case 1:case 2:t.blockData[r+f]?t.blockData[r+f]+=v()<<h:0==--l&&(C=2===C?3:0);break;case 3:t.blockData[r+f]?t.blockData[r+f]+=v()<<h:(t.blockData[r+f]=x<<h,C=0);break;case 4:t.blockData[r+f]&&(t.blockData[r+f]+=v()<<h)}a++}4===C&&0==--w&&(C=0)}:function(t,r){var n=g(t.huffmanTableDC),i=0===n?0:y(n);t.blockData[r]=t.pred+=i;for(var a=1;a<64;){var s=g(t.huffmanTableAC),o=15&s,c=s>>4;if(0!==o){var l=e[a+=c];t.blockData[r+l]=y(o),a++}else{if(c<15)break;a+=16}}};var z,O,F,B,q=0;for(O=1===L?a[0].blocksPerLine*a[0].blocksPerColumn:f*i.mcusPerColumn,s||(s=O);q<O;){for(M=0;M<L;M++)a[M].pred=0;if(w=0,1===L)for(I=a[0],A=0;A<s;A++)k(I,D,q),q++;else for(A=0;A<s;A++){for(M=0;M<L;M++)for(F=(I=a[M]).h,B=I.v,S=0;S<B;S++)for(T=0;T<F;T++)P(I,D,q,S,T);q++}if(d=0,(z=t[r]<<8|t[r+1])<=65280)throw"marker was not found";if(!(z>=65488&&z<=65495))break;r+=2}return r-p}function a(e,t,r){for(var n,i,a,s,o,c,l,h,f,u,p,m,d,v,g,b,y,x=e.quantizationTable,w=e.blockData,C=0;C<64;C+=8)f=w[t+C],u=w[t+C+1],p=w[t+C+2],m=w[t+C+3],d=w[t+C+4],v=w[t+C+5],g=w[t+C+6],b=w[t+C+7],f*=x[C],0!=(u