PageSourceSearch

https://tools.fthux.com/_nuxt/VlyeuQc4.js

js fthux.com collected 2026-10-02 00:50:40 UTC 12,797 bytes, 1 lines download raw bytes

1class v extends Error{constructor(t="End of scan marker detected"){super(t),this.name="EndOfScanError"}}const E=65497,q=65498,H=65499,L=65476,z=65472,S=65474,G=65501,x=[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];class V{constructor(t,s={}){Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pos",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"width",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"height",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"components",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"qTables",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"dcTables",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"acTables",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"restartInterval",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"bitBuffer",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"bitCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isProgressive",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"spectralStart",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"spectralEnd",{enumerable:!0,configurable:!0,writable:!0,value:63}),Object.defineProperty(this,"successiveHigh",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"successiveLow",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"scanComponentIds",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"eobRun",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"quantizedCoefficients",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.data=t,this.options={tolerantDecoding:s.tolerantDecoding??!0,onWarning:s.onWarning,extractCoefficients:s.extractCoefficients??!1}}decode(){if(this.data.length<2||this.data[0]!==255||this.data[1]!==216)throw new Error("Invalid JPEG signature");for(this.pos=2;this.pos<this.data.length;){const t=this.readMarker();if(t===E)break;if(t===q){if(this.parseSOS(),this.decodeScan(),!this.isProgressive)break}else if(t===H)this.parseDQT();else if(t===L)this.parseDHT();else if(t===z||t===S)this.parseSOF(),this.isProgressive=t===S;else if(t===G)this.parseDRI();else if(t>=65504&&t<=65519)this.skipSegment();else if(t>=65472&&t<=65487){if(t!==65476&&t!==65480&&t!==65484)throw new Error(`Unsupported JPEG type: marker 0x${t.toString(16)}`)}else this.pos<this.data.length&&this.skipSegment()}if(this.width===0||this.height===0)throw new Error("Failed to decode JPEG: invalid dimensions");if(this.isProgressive&&!this.options.extractCoefficients){for(const t of this.components)if(t.blocks)for(const s of t.blocks)for(const i of s)this.idct(i)}return this.options.extractCoefficients&&this.storeQuantizedCoefficients(),this.convertToRGB()}getQuantizedCoefficients(){return this.quantizedCoefficients??void 0}storeQuantizedCoefficients(){const t=Math.max(...this.components.map(e=>e.h)),s=Math.max(...this.components.map(e=>e.v)),i=Math.ceil(this.width/(8*t)),o=Math.ceil(this.height/(8*s)),n=this.components.map(e=>({id:e.id,h:e.h,v:e.v,qTable:e.qTable,blocks:e.blocks.map(c=>c.map(a=>a instanceof Int32Array?a:new Int32Array(a)))})),r=this.qTables.map(e=>e instanceof Uint8Array?new Uint8Array(e):new Uint8Array(e));this.quantizedCoefficients={format:"jpeg",width:this.width,height:this.height,isProgressive:this.isProgressive,components:n,quantizationTables:r,mcuWidth:i,mcuHeight:o}}readMarker(){for(;this.pos<this.data.length&&this.data[this.pos]!==255;)this.pos++;if(this.pos>=this.data.length-1)return E;const t=this.data[this.pos++];let s=this.data[this.pos++];for(;s===255&&this.pos<this.data.length;)s=this.data[this.pos++];return t<<8|s}readUint16(){const t=this.data[this.pos]<<8|this.data[this.pos+1];return this.pos+=2,t}skipSegment(){const t=this.readUint16();this.pos+=t-2}parseDQT(){let t=this.readUint16()-2;for(;t>0;){const s=this.data[this.pos++],i=s&15;if((s>>4&15)!==0)throw new Error("16-bit quantization tables not supported");const n=new Uint8Array(64);for(let r=0;r<64;r++)n[x[r]]=this.data[this.pos++];this.qTables[i]=n,t-=65}}parseDHT(){let t=this.readUint16()-2;for(;t>0;){const s=this.data[this.pos++],i=s&15,o=s>>4&15,n=new Uint8Array(16);let r=0;for(let a=0;a<16;a++)n[a]=this.data[this.pos++],r+=n[a];const e=new Uint8Array(r);for(let a=0;a<r;a++)e[a]=this.data[this.pos++];const c=this.buildHuffmanTable(n,e);o===0?this.dcTables[i]=c:this.acTables[i]=c,t-=17+r}}buildHuffmanTable(t,s){const i=new Int32Array(16).fill(-1),o=new Int32Array(16).fill(-1),n=new Int32Array(16).fill(-1),r=new Map;let e=0,c=0;for(let a=0;a<16;a++)if(t[a]>0){o[a]=e,n[a]=c;for(let h=0;h<t[a];h++)r.set(a<<16|e,s[c]),e++,c++;i[a]=e-1,e<<=1}else e<<=1;return{codes:r,maxCode:i,minCode:o,valPtr:n,huffVal:s}}parseSOF(){this.readUint16();const t=this.data[this.pos++];if(t!==8)throw new Error(`Unsupported precision: ${t}`);this.height=this.readUint16(),this.width=this.readUint16();const s=this.data[this.pos++];if(s!==1&&s!==3)throw new Error(`Unsupported number of components: ${s}`);this.components=[];for(let i=0;i<s;i++){const o=this.data[this.pos++],n=this.data[this.pos++],r=this.data[this.pos++];this.components.push({id:o,h:n>>4&15,v:n&15,qTable:r,dcTable:0,acTable:0,pred:0,blocks:[]})}}parseSOS(){this.readUint16();const t=this.data[this.pos++];this.scanComponentIds=[];for(let i=0;i<t;i++){const o=this.data[this.pos++],n=this.data[this.pos++];this.scanComponentIds.push(o);const r=this.components.find(e=>e.id===o);r&&(r.dcTable=n>>4&15,r.acTable=n&15)}this.spectralStart=this.data[this.pos++],this.spectralEnd=this.data[this.pos++];const s=this.data[this.pos++];this.successiveHigh=s>>4&15,this.successiveLow=s&15}parseDRI(){this.readUint16(),this.restartInterval=this.readUint16()}decodeScan(){const t=Math.max(...this.components.map(n=>n.h)),s=Math.max(...this.components.map(n=>n.v)),i=Math.ceil(this.width/(8*t)),o=Math.ceil(this.height/(8*s));this.bitBuffer=0,this.bitCount=0,this.eobRun=0;for(const n of this.components)n.pred=0;for(const n of this.components){const r=i*n.h,e=o*n.v;(!n.blocks||n.blocks.length===0)&&(n.blocks=Array(e).fill(null).map(()=>Array(r).fill(null).map(()=>new Int32Array(64))))}if(this.scanComponentIds.length===1){const n=this.scanComponentIds[0],r=this.components.find(a=>a.id===n);if(!r)return;const e=i*r.h,c=o*r.v;for(let a=0;a<c;a++)for(let h=0;h<e;h++)if(!(a>=r.blocks.length||h>=r.blocks[0].length))if(this.options.tolerantDecoding)try{this.decodeBlock(r,a,h)}catch(l){if(l instanceof v)return}else try{this.decodeBlock(r,a,h)}catch(l){if(l instanceof v)return;throw l}return}t:for(let n=0;n<o;n++)for(let r=0;r<i;r++)for(const e of this.components)if(!(this.scanComponentIds.length>0&&!this.scanComponentIds.includes(e.id)))for(let c=0;c<e.v;c++)for(let a=0;a<e.h;a++){const h=n*e.v+c,l=r*e.h+a;if(h<e.blocks.length&&l<e.blocks[0].length)if(this.options.tolerantDecoding)try{this.decodeBlock(e,h,l)}catch(f){if(f instanceof v)break t}else try{this.decodeBlock(e,h,l)}catch(f){if(f instanceof v)break t;throw f}}}decodeBlock(t,s,i){const o=t.blocks[s][i],n=this.spectralEnd>0&&this.spectralStart>0,r=n&&this.successiveHigh>0;if(n&&!r&&this.eobRun>0){this.eobRun--;return}if(this.spectralStart===0){const e=this.dcTables[t.dcTable];if(!e)throw new Error(`Missing DC table ${t.dcTable}`);if(this.successiveHigh===0){const c=this.decodeHuffman(e),a=c>0?this.receiveBits(c):0;t.pred+=a;const h=t.pred<<this.successiveLow;this.options.extractCoefficients?o[0]=h:o[0]=h*this.qTables[t.qTable][0]}else if(this.readBit()){const a=1<<this.successiveLow;this.options.extractCoefficients?o[0]+=a:o[0]+=a*this.qTables[t.qTable][0]}}if(this.spectralEnd>0){const e=this.acTables[t.acTable];if(!e)throw new Error(`Missing AC table ${t.acTable}`);if(this.successiveHigh===0){let c=this.spectralStart===0?1:this.spectralStart;for(;c<=this.spectralEnd&&c<64;){const a=this.decodeHuffman(e),h=a>>4&15,l=a&15;if(l===0)if(h===15)c+=16;else{if(this.isProgressive&&h>0){const f=this.receiveUnsignedBits(h);this.eobRun=(1<<h)-1+f}break}else{if(c+=h,c>this.spectralEnd)break;const f=this.receiveBits(l)<<this.successiveLow;this.options.extractCoefficients?o[x[c]]=f:o[x[c]]=f*this.qTables[t.qTable][x[c]],c++}}}else{const c=this.qTables[t.qTable],a=this.eobRun>0;let h=a?4:0,l=0,f=0,m=this.spectralStart===0?1:this.spectralStart;for(;m<=this.spectralEnd&&m<64;){const d=x[m],p=o[d],w=p<0?-1:1;switch(h){case 0:{const b=this.decodeHuffman(e),u=b>>4&15,g=b&15;if(g===0)if(u<15){const C=this.receiveUnsignedBits(u);this.eobRun=(1<<u)-1+C,h=4}else f=16,h=1;else{if(g!==1)throw new Error("Invalid AC refinement size");l=this.receiveBits(g),f=u,h=u?2:3}continue}case 1:case 2:if(p!==0){if(this.readBit()){const u=this.options.extractCoefficients?1<<this.successiveLow:(1<<this.successiveLow)*c[d];o[d]+=w*u}}else f--,f===0&&(h=h===2?3:0);break;case 3:if(p!==0){if(this.readBit()){const u=this.options.extractCoefficients?1<<this.successiveLow:(1<<this.successiveLow)*c[d];o[d]+=w*u}}else{const b=l<<this.successiveLow;o[d]=this.options.extractCoefficients?b:b*c[d],h=0}break;case 4:if(p!==0&&this.readBit()){const u=this.options.extractCoefficients?1<<this.successiveLow:(1<<this.successiveLow)*c[d];o[d]+=w*u}break}m++}h===4&&a&&this.eobRun>0&&this.eobRun--}}!this.isProgressive&&!this.options.extractCoefficients&&this.idct(o)}decodeHuffman(t){let s=0;for(let i=0;i<16;i++)if(s=s<<1|this.readBit(),t.minCode[i]!==-1&&s<=t.maxCode[i]){const o=t.valPtr[i]+(s-t.minCode[i]);if(o>=0&&o<t.huffVal.length)return t.huffVal[o];throw new Error(`Huffman table index out of bounds: ${o} (table size: ${t.huffVal.length})`)}throw new Error("Invalid Huffman code")}readBit(){if(this.bitCount===0){if(this.pos>=this.data.length)throw new Error("Unexpected end of JPEG data");const t=this.data[this.pos++];if(t===255){if(this.pos>=this.data.length)throw new Error("Unexpected end of JPEG data after 0xFF");const s=this.data[this.pos];if(s===0)this.pos++;else if(s>=208&&s<=215){this.pos++;for(const i of this.components)i.pred=0;return this.eobRun=0,this.bitBuffer=0,this.bitCount=0,this.readBit()}else throw this.pos--,new v}this.bitBuffer=t,this.bitCount=8}return this.bitCount--,this.bitBuffer>>this.bitCount&1}receiveBits(t){let s=0;for(let i=0;i<t;i++)s=s<<1|this.readBit();return s<1<<t-1&&(s=s-(1<<t)+1),s}receiveUnsignedBits(t){if(t<0||t>16)throw new Error(`Invalid bit count: ${t} (must be 0-16)`);if(t===0)return 0;let s=0;for(let i=0;i<t;i++)s=s<<1|this.readBit();return s}idct(t){const s=new Float32Array(64);for(let i=0;i<8;i++){const o=i*8;for(let n=0;n<8;n++){let r=0;for(let e=0;e<8;e++){const c=e===0?1/Math.sqrt(2):1;r+=c*t[o+e]*Math.cos((2*n+1)*e*Math.PI/16)}s[o+n]=r/2}}for(let i=0;i<8;i++)for(let o=0;o<8;o++){let n=0;for(let r=0;r<8;r++){const e=r===0?1/Math.sqrt(2):1;n+=e*s[r*8+i]*Math.cos((2*o+1)*r*Math.PI/16)}t[o*8+i]=Math.max(0,Math.min(255,Math.round(n/2+128)))}}convertToRGB(){const t=new Uint8Array(this.width*this.height*4);if(this.components.length===1){const s=this.components[0];for(let i=0;i<this.height;i++)for(let o=0;o<this.width;o++){const n=Math.floor(i/8),r=Math.floor(o/8),e=i%8,c=o%8;if(n<s.blocks.length&&r<s.blocks[0].length){const a=s.blocks[n][r][e*8+c
1],h=(i*this.width+o)*4;t[h]=a,t[h+1]=a,t[h+2]=a,t[h+3]=255}}}else{const[s,i,o]=this.components,n=Math.max(...this.components.map(e=>e.h)),r=Math.max(...this.components.map(e=>e.v));for(let e=0;e<this.height;e++)for(let c=0;c<this.width;c++){const a=Math.floor(e*s.v/r),h=Math.floor(c*s.h/n),l=Math.floor(a/8),f=Math.floor(h/8),m=a%8,d=h%8;let p=0;l<s.blocks.length&&f<s.blocks[0].length&&(p=s.blocks[l][f][m*8+d]);const w=Math.floor(e*i.v/r),b=Math.floor(c*i.h/n),u=Math.floor(w/8),g=Math.floor(b/8),C=w%8,O=b%8;let F=0;u<i.blocks.length&&g<i.blocks[0].length&&(F=i.blocks[u][g][C*8+O]-128);const M=Math.floor(e*o.v/r),B=Math.floor(c*o.h/n),T=Math.floor(M/8),P=Math.floor(B/8),A=M%8,D=B%8;let y=0;T<o.blocks.length&&P<o.blocks[0].length&&(y=o.blocks[T][P][A*8+D]-128);const R=Math.max(0,Math.min(255,Math.round(p+1.402*y))),U=Math.max(0,Math.min(255,Math.round(p-.344136*F-.714136*y))),j=Math.max(0,Math.min(255,Math.round(p+1.772*F))),k=(e*this.width+c)*4;t[k]=R,t[k+1]=U,t[k+2]=j,t[k+3]=255}}return t}}export{V as JPEGDecoder};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.