@signalk/freeboard-sk
Version:
Openlayers chart plotter implementation for Signal K
2 lines (1 loc) • 1.3 kB
JavaScript
import{e as h}from"./chunk-FDERIQAA.js";function g(o,n){let e=o.length-n,i=0;do{for(let a=n;a>0;a--)o[i+n]+=o[i],i++;e-=n}while(e>0)}function u(o,n,e){let i=0,a=o.length,l=a/e;for(;a>n;){for(let t=n;t>0;--t)o[i+n]+=o[i],++i;a-=n}let c=o.slice();for(let t=0;t<l;++t)for(let r=0;r<e;++r)o[e*t+r]=c[(e-r-1)*l+t]}function f(o,n,e,i,a,l){if(!n||n===1)return o;for(let r=0;r<a.length;++r){if(a[r]%8!==0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(a[r]!==a[0])throw new Error("When decoding with predictor, all samples must have the same size.")}let c=a[0]/8,t=l===2?1:a.length;for(let r=0;r<i&&!(r*t*e*c>=o.byteLength);++r){let s;if(n===2){switch(a[0]){case 8:s=new Uint8Array(o,r*t*e*c,t*e*c);break;case 16:s=new Uint16Array(o,r*t*e*c,t*e*c/2);break;case 32:s=new Uint32Array(o,r*t*e*c,t*e*c/4);break;default:throw new Error(`Predictor 2 not allowed with ${a[0]} bits per sample.`)}g(s,t,c)}else n===3&&(s=new Uint8Array(o,r*t*e*c,t*e*c),u(s,t,c))}return o}var d=class{decode(n,e){return h(this,null,function*(){let i=yield this.decodeBlock(e),a=n.Predictor||1;if(a!==1){let l=!n.StripOffsets,c=l?n.TileWidth:n.ImageWidth,t=l?n.TileLength:n.RowsPerStrip||n.ImageLength;return f(i,a,c,t,n.BitsPerSample,n.PlanarConfiguration)}return i})}};export{d as a};