geotiff 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-browser/geotiff.js +3 -2
- package/dist-browser/geotiff.js.map +1 -1
- package/dist-module/compression/basedecoder.d.ts +4 -0
- package/dist-module/compression/basedecoder.d.ts.map +1 -1
- package/dist-module/compression/basedecoder.js +6 -0
- package/dist-module/compression/index.d.ts +4 -4
- package/dist-module/compression/index.d.ts.map +1 -1
- package/dist-module/compression/index.js +4 -4
- package/dist-module/compression/jpeg.d.ts +6 -1
- package/dist-module/compression/jpeg.d.ts.map +1 -1
- package/dist-module/compression/jpeg.js +50 -5
- package/dist-module/compression/lzw.js +1 -1
- package/dist-module/compression/webimage.d.ts +1 -1
- package/dist-module/compression/webimage.d.ts.map +1 -1
- package/dist-module/compression/webimage.js +1 -1
- package/dist-module/dataslice.d.ts.map +1 -1
- package/dist-module/dataslice.js +2 -2
- package/dist-module/dataview64.d.ts +2 -2
- package/dist-module/dataview64.d.ts.map +1 -1
- package/dist-module/dataview64.js +4 -4
- package/dist-module/geotiff.d.ts +171 -45
- package/dist-module/geotiff.d.ts.map +1 -1
- package/dist-module/geotiff.js +119 -20
- package/dist-module/geotiffimage.d.ts +79 -112
- package/dist-module/geotiffimage.d.ts.map +1 -1
- package/dist-module/geotiffimage.js +99 -71
- package/dist-module/geotiffwriter.js +2 -2
- package/dist-module/globals.d.ts +48 -40
- package/dist-module/globals.d.ts.map +1 -1
- package/dist-module/globals.js +14 -10
- package/dist-module/imagefiledirectory.d.ts +2 -2
- package/dist-module/imagefiledirectory.d.ts.map +1 -1
- package/dist-module/imagefiledirectory.js +23 -12
- package/dist-module/logging.js +7 -7
- package/dist-module/pool.js +1 -1
- package/dist-module/predictor.js +1 -1
- package/dist-module/resample.d.ts +18 -18
- package/dist-module/resample.d.ts.map +1 -1
- package/dist-module/resample.js +12 -12
- package/dist-module/source/basesource.d.ts +7 -7
- package/dist-module/source/basesource.d.ts.map +1 -1
- package/dist-module/source/basesource.js +7 -7
- package/dist-module/source/blockedsource.d.ts +10 -10
- package/dist-module/source/blockedsource.d.ts.map +1 -1
- package/dist-module/source/blockedsource.js +12 -9
- package/dist-module/source/client/base.d.ts +8 -10
- package/dist-module/source/client/base.d.ts.map +1 -1
- package/dist-module/source/client/base.js +4 -3
- package/dist-module/source/client/fetch.d.ts +2 -7
- package/dist-module/source/client/fetch.d.ts.map +1 -1
- package/dist-module/source/client/fetch.js +7 -2
- package/dist-module/source/client/http.d.ts +4 -1
- package/dist-module/source/client/http.d.ts.map +1 -1
- package/dist-module/source/client/http.js +4 -4
- package/dist-module/source/client/xhr.d.ts +4 -1
- package/dist-module/source/client/xhr.d.ts.map +1 -1
- package/dist-module/source/client/xhr.js +1 -1
- package/dist-module/source/file.js +4 -4
- package/dist-module/source/filereader.js +1 -1
- package/dist-module/source/httputils.d.ts +14 -6
- package/dist-module/source/httputils.d.ts.map +1 -1
- package/dist-module/source/httputils.js +13 -12
- package/dist-module/source/remote.d.ts +31 -22
- package/dist-module/source/remote.d.ts.map +1 -1
- package/dist-module/source/remote.js +37 -13
- package/dist-module/utils.d.ts +7 -1
- package/dist-module/utils.d.ts.map +1 -1
- package/dist-module/utils.js +6 -0
- package/dist-module/worker/create.js +1 -1
- package/dist-node/compression/basedecoder.d.ts +4 -0
- package/dist-node/compression/basedecoder.d.ts.map +1 -1
- package/dist-node/compression/basedecoder.js +6 -0
- package/dist-node/compression/basedecoder.js.map +1 -1
- package/dist-node/compression/index.d.ts +4 -4
- package/dist-node/compression/index.d.ts.map +1 -1
- package/dist-node/compression/index.js +4 -4
- package/dist-node/compression/jpeg.d.ts +6 -1
- package/dist-node/compression/jpeg.d.ts.map +1 -1
- package/dist-node/compression/jpeg.js +50 -5
- package/dist-node/compression/jpeg.js.map +1 -1
- package/dist-node/compression/lzw.js +1 -1
- package/dist-node/compression/lzw.js.map +1 -1
- package/dist-node/compression/webimage.js +1 -1
- package/dist-node/compression/webimage.js.map +1 -1
- package/dist-node/dataslice.js +2 -2
- package/dist-node/dataslice.js.map +1 -1
- package/dist-node/dataview64.d.ts +2 -2
- package/dist-node/dataview64.d.ts.map +1 -1
- package/dist-node/dataview64.js +4 -4
- package/dist-node/dataview64.js.map +1 -1
- package/dist-node/geotiff.d.ts +171 -45
- package/dist-node/geotiff.d.ts.map +1 -1
- package/dist-node/geotiff.js +118 -20
- package/dist-node/geotiff.js.map +1 -1
- package/dist-node/geotiffimage.d.ts +80 -113
- package/dist-node/geotiffimage.d.ts.map +1 -1
- package/dist-node/geotiffimage.js +99 -71
- package/dist-node/geotiffimage.js.map +1 -1
- package/dist-node/geotiffwriter.js +2 -2
- package/dist-node/geotiffwriter.js.map +1 -1
- package/dist-node/globals.d.ts +48 -40
- package/dist-node/globals.d.ts.map +1 -1
- package/dist-node/globals.js +14 -10
- package/dist-node/globals.js.map +1 -1
- package/dist-node/imagefiledirectory.d.ts +2 -2
- package/dist-node/imagefiledirectory.d.ts.map +1 -1
- package/dist-node/imagefiledirectory.js +23 -12
- package/dist-node/imagefiledirectory.js.map +1 -1
- package/dist-node/logging.js +7 -7
- package/dist-node/logging.js.map +1 -1
- package/dist-node/pool.js +1 -1
- package/dist-node/pool.js.map +1 -1
- package/dist-node/predictor.js +1 -1
- package/dist-node/predictor.js.map +1 -1
- package/dist-node/resample.d.ts +18 -18
- package/dist-node/resample.d.ts.map +1 -1
- package/dist-node/resample.js +12 -12
- package/dist-node/source/basesource.d.ts +7 -7
- package/dist-node/source/basesource.d.ts.map +1 -1
- package/dist-node/source/basesource.js +7 -7
- package/dist-node/source/basesource.js.map +1 -1
- package/dist-node/source/blockedsource.d.ts +10 -10
- package/dist-node/source/blockedsource.d.ts.map +1 -1
- package/dist-node/source/blockedsource.js +12 -9
- package/dist-node/source/blockedsource.js.map +1 -1
- package/dist-node/source/client/base.d.ts +8 -10
- package/dist-node/source/client/base.d.ts.map +1 -1
- package/dist-node/source/client/base.js +4 -3
- package/dist-node/source/client/base.js.map +1 -1
- package/dist-node/source/client/fetch.d.ts +2 -6
- package/dist-node/source/client/fetch.d.ts.map +1 -1
- package/dist-node/source/client/fetch.js +7 -2
- package/dist-node/source/client/fetch.js.map +1 -1
- package/dist-node/source/client/http.d.ts +4 -1
- package/dist-node/source/client/http.d.ts.map +1 -1
- package/dist-node/source/client/http.js +4 -4
- package/dist-node/source/client/http.js.map +1 -1
- package/dist-node/source/client/xhr.d.ts +4 -1
- package/dist-node/source/client/xhr.d.ts.map +1 -1
- package/dist-node/source/client/xhr.js +1 -1
- package/dist-node/source/client/xhr.js.map +1 -1
- package/dist-node/source/file.js +4 -4
- package/dist-node/source/file.js.map +1 -1
- package/dist-node/source/filereader.js +1 -1
- package/dist-node/source/filereader.js.map +1 -1
- package/dist-node/source/httputils.d.ts +14 -6
- package/dist-node/source/httputils.d.ts.map +1 -1
- package/dist-node/source/httputils.js +13 -12
- package/dist-node/source/httputils.js.map +1 -1
- package/dist-node/source/remote.d.ts +31 -22
- package/dist-node/source/remote.d.ts.map +1 -1
- package/dist-node/source/remote.js +37 -13
- package/dist-node/source/remote.js.map +1 -1
- package/dist-node/utils.d.ts +7 -1
- package/dist-node/utils.d.ts.map +1 -1
- package/dist-node/utils.js +6 -0
- package/dist-node/utils.js.map +1 -1
- package/dist-node/worker/create.js +1 -1
- package/dist-node/worker/create.js.map +1 -1
- package/package.json +3 -54
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basedecoder.d.ts","sourceRoot":"","sources":["../../src/compression/basedecoder.js"],"names":[],"mappings":"AAEA;IACE,6BAEC;IADC,gBAA4B;IAG9B,kCAaC;CACF"}
|
|
1
|
+
{"version":3,"file":"basedecoder.d.ts","sourceRoot":"","sources":["../../src/compression/basedecoder.js"],"names":[],"mappings":"AAEA;IACE,6BAEC;IADC,gBAA4B;IAG9B;;OAEG;IACH,gCAEC;IAED,kCAaC;CACF"}
|
|
@@ -3,6 +3,12 @@ export default class BaseDecoder {
|
|
|
3
3
|
constructor(parameters) {
|
|
4
4
|
this.parameters = parameters;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* @abstract
|
|
8
|
+
*/
|
|
9
|
+
decodeBlock(_buffer) {
|
|
10
|
+
throw new Error('decodeBlock not implemented');
|
|
11
|
+
}
|
|
6
12
|
async decode(buffer) {
|
|
7
13
|
const decoded = await this.decodeBlock(buffer);
|
|
8
14
|
const { tileWidth, tileHeight, predictor, bitsPerSample, planarConfiguration, } = this.parameters;
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* Register a decoder for a specific compression method or a range of compressions
|
|
7
7
|
* @param {(NumberOrUndefined|(NumberOrUndefined[]))} cases ids of the compression methods to register for
|
|
8
8
|
* @param {function():Promise} importFn the function to import the decoder
|
|
9
|
-
* @param {function():Promise} decoderParameterFn
|
|
9
|
+
* @param {function(import("../imagefiledirectory").ImageFileDirectory):Promise} decoderParameterFn
|
|
10
10
|
* @param {boolean} preferWorker_ Whether to prefer running the decoder in a worker
|
|
11
11
|
*/
|
|
12
|
-
export function addDecoder(cases: (NumberOrUndefined | (NumberOrUndefined[])), importFn: () => Promise<any>, decoderParameterFn?: () => Promise<any>, preferWorker_?: boolean): void;
|
|
12
|
+
export function addDecoder(cases: (NumberOrUndefined | (NumberOrUndefined[])), importFn: () => Promise<any>, decoderParameterFn?: (arg0: import("../imagefiledirectory").ImageFileDirectory) => Promise<any>, preferWorker_?: boolean): void;
|
|
13
13
|
/**
|
|
14
14
|
* Get the required decoder parameters for a specific compression method
|
|
15
15
|
* @param {NumberOrUndefined} compression
|
|
@@ -25,10 +25,10 @@ export function getDecoderParameters(compression: NumberOrUndefined, fileDirecto
|
|
|
25
25
|
export function getDecoder(compression: number, decoderParameters: DecoderParameters): Promise<import("./basedecoder.js").default>;
|
|
26
26
|
/**
|
|
27
27
|
* Whether to prefer running the decoder in a worker
|
|
28
|
-
* @param {
|
|
28
|
+
* @param {number|undefined} compression the compression method identifier
|
|
29
29
|
* @returns {boolean}
|
|
30
30
|
*/
|
|
31
|
-
export function preferWorker(compression:
|
|
31
|
+
export function preferWorker(compression: number | undefined): boolean;
|
|
32
32
|
export type DecoderParameters = {
|
|
33
33
|
tileWidth: number;
|
|
34
34
|
tileHeight: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compression/index.js"],"names":[],"mappings":"AA6BA;;;GAGG;AAEH;;;;;;GAMG;AACH,kCALW,CAAC,iBAAiB,GAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC,YACzC,kBAAkB,uBAClB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compression/index.js"],"names":[],"mappings":"AA6BA;;;GAGG;AAEH;;;;;;GAMG;AACH,kCALW,CAAC,iBAAiB,GAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC,YACzC,kBAAkB,uBAClB,CAAS,IAAkD,EAAlD,OAAO,uBAAuB,EAAE,kBAAkB,iBAAS,kBACpE,OAAO,QASjB;AAED;;;;GAIG;AACH,kDAHW,iBAAiB,iBACjB,OAAO,0BAA0B,EAAE,kBAAkB,gBAQ/D;AAED;;;;;GAKG;AACH,wCAJW,MAAM,qBACN,iBAAiB,GACf,OAAO,CAAC,OAAO,kBAAkB,EAAE,OAAO,CAAC,CASvD;AAED;;;;GAIG;AACH,0CAHW,MAAM,GAAC,SAAS,GACd,OAAO,CAOnB;;eApFa,MAAM;gBACN,MAAM;yBACN,MAAM;mBACN,MAAM;eACN,MAAM;;;;;gCAuBP,CAAC,MAAM,GAAC,SAAS,CAAC"}
|
|
@@ -9,8 +9,8 @@ const registry = new Map();
|
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
11
|
* Default decoder parameter retrieval function
|
|
12
|
-
* @param {import(
|
|
13
|
-
* @returns {DecoderParameters}
|
|
12
|
+
* @param {import("../imagefiledirectory").ImageFileDirectory} fileDirectory
|
|
13
|
+
* @returns {Promise<DecoderParameters>}
|
|
14
14
|
*/
|
|
15
15
|
async function defaultDecoderParameterFn(fileDirectory) {
|
|
16
16
|
const isTiled = !fileDirectory.hasTag('StripOffsets');
|
|
@@ -30,7 +30,7 @@ async function defaultDecoderParameterFn(fileDirectory) {
|
|
|
30
30
|
* Register a decoder for a specific compression method or a range of compressions
|
|
31
31
|
* @param {(NumberOrUndefined|(NumberOrUndefined[]))} cases ids of the compression methods to register for
|
|
32
32
|
* @param {function():Promise} importFn the function to import the decoder
|
|
33
|
-
* @param {function():Promise} decoderParameterFn
|
|
33
|
+
* @param {function(import("../imagefiledirectory").ImageFileDirectory):Promise} decoderParameterFn
|
|
34
34
|
* @param {boolean} preferWorker_ Whether to prefer running the decoder in a worker
|
|
35
35
|
*/
|
|
36
36
|
export function addDecoder(cases, importFn, decoderParameterFn = defaultDecoderParameterFn, preferWorker_ = true) {
|
|
@@ -69,7 +69,7 @@ export async function getDecoder(compression, decoderParameters) {
|
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Whether to prefer running the decoder in a worker
|
|
72
|
-
* @param {
|
|
72
|
+
* @param {number|undefined} compression the compression method identifier
|
|
73
73
|
* @returns {boolean}
|
|
74
74
|
*/
|
|
75
75
|
export function preferWorker(compression) {
|
|
@@ -2,6 +2,11 @@ export default class JpegDecoder extends BaseDecoder {
|
|
|
2
2
|
reader: JpegStreamReader;
|
|
3
3
|
decodeBlock(buffer: any): ArrayBuffer;
|
|
4
4
|
}
|
|
5
|
+
export type HuffmanNode = (number | HuffmanNode)[];
|
|
6
|
+
export type Code = {
|
|
7
|
+
children: HuffmanNode;
|
|
8
|
+
index: number;
|
|
9
|
+
};
|
|
5
10
|
import BaseDecoder from './basedecoder.js';
|
|
6
11
|
declare class JpegStreamReader {
|
|
7
12
|
jfif: {
|
|
@@ -25,8 +30,8 @@ declare class JpegStreamReader {
|
|
|
25
30
|
quantizationTables: any[];
|
|
26
31
|
huffmanTablesAC: any[];
|
|
27
32
|
huffmanTablesDC: any[];
|
|
33
|
+
frames: any[];
|
|
28
34
|
resetFrames(): void;
|
|
29
|
-
frames: any[] | undefined;
|
|
30
35
|
parse(data: any): void;
|
|
31
36
|
resetInterval: number | undefined;
|
|
32
37
|
getResult(): Uint8Array<ArrayBuffer>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jpeg.d.ts","sourceRoot":"","sources":["../../src/compression/jpeg.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jpeg.d.ts","sourceRoot":"","sources":["../../src/compression/jpeg.js"],"names":[],"mappings":"AAg6BA;IAGI,yBAAoC;IAMtC,sCAIC;CACF;0BA13Ba,CAAC,MAAM,GAAC,WAAW,CAAC,EAAE;mBACtB;IAAC,QAAQ,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC;wBArD5B,kBAAkB;AAqmB1C;IAEI;;;;;;;;;;;aAAgB;IAChB;;;;;aAAiB;IAEjB,0BAA4B;IAC5B,uBAAyB;IACzB,uBAAyB;IACzB,cAAgB;IAGlB,oBAEC;IAED,uBA2PC;IA5CO,kCAAiC;IA8CzC,qCA4CC;CACF"}
|
|
@@ -45,22 +45,38 @@ const dctCos6 = 1567; // cos(6*pi/16)
|
|
|
45
45
|
const dctSin6 = 3784; // sin(6*pi/16)
|
|
46
46
|
const dctSqrt2 = 5793; // sqrt(2)
|
|
47
47
|
const dctSqrt1d2 = 2896; // sqrt(2) / 2
|
|
48
|
+
/** @typedef {(number|HuffmanNode)[]} HuffmanNode */
|
|
49
|
+
/** @typedef {{children: HuffmanNode, index: number}} Code */
|
|
50
|
+
/**
|
|
51
|
+
* @param {Uint8Array<ArrayBuffer>} codeLengths
|
|
52
|
+
* @param {Uint8Array<ArrayBuffer>} values
|
|
53
|
+
* @returns {HuffmanNode}
|
|
54
|
+
*/
|
|
48
55
|
function buildHuffmanTable(codeLengths, values) {
|
|
49
56
|
let k = 0;
|
|
57
|
+
/** @type {Array<Code>} */
|
|
50
58
|
const code = [];
|
|
51
59
|
let length = 16;
|
|
52
60
|
while (length > 0 && !codeLengths[length - 1]) {
|
|
53
61
|
--length;
|
|
54
62
|
}
|
|
55
63
|
code.push({ children: [], index: 0 });
|
|
64
|
+
/** @type {Code|undefined} */
|
|
56
65
|
let p = code[0];
|
|
66
|
+
/** @type {Code|undefined} */
|
|
57
67
|
let q;
|
|
58
68
|
for (let i = 0; i < length; i++) {
|
|
59
69
|
for (let j = 0; j < codeLengths[i]; j++) {
|
|
60
70
|
p = code.pop();
|
|
71
|
+
if (!p) {
|
|
72
|
+
throw new Error('buildHuffmanTable: codeLength mismatch');
|
|
73
|
+
}
|
|
61
74
|
p.children[p.index] = values[k];
|
|
62
75
|
while (p.index > 0) {
|
|
63
76
|
p = code.pop();
|
|
77
|
+
if (!p) {
|
|
78
|
+
throw new Error('buildHuffmanTable: codeLength mismatch');
|
|
79
|
+
}
|
|
64
80
|
}
|
|
65
81
|
p.index++;
|
|
66
82
|
code.push(p);
|
|
@@ -131,6 +147,9 @@ function decodeScan(data, initialOffset, frame, components, resetInterval, spect
|
|
|
131
147
|
}
|
|
132
148
|
function receiveAndExtend(length) {
|
|
133
149
|
const n = receive(length);
|
|
150
|
+
if (n === undefined) {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
134
153
|
if (n >= 1 << (length - 1)) {
|
|
135
154
|
return n;
|
|
136
155
|
}
|
|
@@ -144,6 +163,9 @@ function decodeScan(data, initialOffset, frame, components, resetInterval, spect
|
|
|
144
163
|
let k = 1;
|
|
145
164
|
while (k < 64) {
|
|
146
165
|
const rs = decodeHuffman(component.huffmanTableAC);
|
|
166
|
+
if (rs === null) {
|
|
167
|
+
throw new Error('Unexpected end of data in AC coefficient decoding');
|
|
168
|
+
}
|
|
147
169
|
const s = rs & 15;
|
|
148
170
|
const r = rs >> 4;
|
|
149
171
|
if (s === 0) {
|
|
@@ -162,7 +184,11 @@ function decodeScan(data, initialOffset, frame, components, resetInterval, spect
|
|
|
162
184
|
}
|
|
163
185
|
function decodeDCFirst(component, zz) {
|
|
164
186
|
const t = decodeHuffman(component.huffmanTableDC);
|
|
165
|
-
const
|
|
187
|
+
const value = receiveAndExtend(t);
|
|
188
|
+
if (value === undefined) {
|
|
189
|
+
throw new Error('Unexpected end of data in DC coefficient decoding');
|
|
190
|
+
}
|
|
191
|
+
const diff = t === 0 ? 0 : (value << successive);
|
|
166
192
|
component.pred += diff;
|
|
167
193
|
zz[0] = component.pred;
|
|
168
194
|
}
|
|
@@ -179,11 +205,18 @@ function decodeScan(data, initialOffset, frame, components, resetInterval, spect
|
|
|
179
205
|
const e = spectralEnd;
|
|
180
206
|
while (k <= e) {
|
|
181
207
|
const rs = decodeHuffman(component.huffmanTableAC);
|
|
208
|
+
if (rs === null) {
|
|
209
|
+
throw new Error('Unexpected end of data in AC coefficient decoding');
|
|
210
|
+
}
|
|
182
211
|
const s = rs & 15;
|
|
183
212
|
const r = rs >> 4;
|
|
184
213
|
if (s === 0) {
|
|
185
214
|
if (r < 15) {
|
|
186
|
-
|
|
215
|
+
const value = receive(r);
|
|
216
|
+
if (value === undefined) {
|
|
217
|
+
throw new Error('Unexpected end of data in AC coefficient decoding');
|
|
218
|
+
}
|
|
219
|
+
eobrun = value + (1 << r) - 1;
|
|
187
220
|
break;
|
|
188
221
|
}
|
|
189
222
|
k += 16;
|
|
@@ -191,7 +224,11 @@ function decodeScan(data, initialOffset, frame, components, resetInterval, spect
|
|
|
191
224
|
else {
|
|
192
225
|
k += r;
|
|
193
226
|
const z = dctZigZag[k];
|
|
194
|
-
|
|
227
|
+
const value = receiveAndExtend(s);
|
|
228
|
+
if (value === undefined) {
|
|
229
|
+
throw new Error('Unexpected end of data in AC coefficient decoding');
|
|
230
|
+
}
|
|
231
|
+
zz[z] = value * (1 << successive);
|
|
195
232
|
k++;
|
|
196
233
|
}
|
|
197
234
|
}
|
|
@@ -208,11 +245,18 @@ function decodeScan(data, initialOffset, frame, components, resetInterval, spect
|
|
|
208
245
|
switch (successiveACState) {
|
|
209
246
|
case 0: { // initial state
|
|
210
247
|
const rs = decodeHuffman(component.huffmanTableAC);
|
|
248
|
+
if (rs === null) {
|
|
249
|
+
throw new Error('Unexpected end of data in AC coefficient decoding');
|
|
250
|
+
}
|
|
211
251
|
const s = rs & 15;
|
|
212
252
|
r = rs >> 4;
|
|
213
253
|
if (s === 0) {
|
|
214
254
|
if (r < 15) {
|
|
215
|
-
|
|
255
|
+
const value = receive(r);
|
|
256
|
+
if (value === undefined) {
|
|
257
|
+
throw new Error('Unexpected end of data in AC coefficient decoding');
|
|
258
|
+
}
|
|
259
|
+
eobrun = value + (1 << r);
|
|
216
260
|
successiveACState = 4;
|
|
217
261
|
}
|
|
218
262
|
else {
|
|
@@ -547,7 +591,7 @@ class JpegStreamReader {
|
|
|
547
591
|
this.quantizationTables = [];
|
|
548
592
|
this.huffmanTablesAC = [];
|
|
549
593
|
this.huffmanTablesDC = [];
|
|
550
|
-
this.
|
|
594
|
+
this.frames = [];
|
|
551
595
|
}
|
|
552
596
|
resetFrames() {
|
|
553
597
|
this.frames = [];
|
|
@@ -699,6 +743,7 @@ class JpegStreamReader {
|
|
|
699
743
|
scanLines: readUint16(),
|
|
700
744
|
samplesPerLine: readUint16(),
|
|
701
745
|
components: {},
|
|
746
|
+
/** @type {any[]} */
|
|
702
747
|
componentsOrder: [],
|
|
703
748
|
};
|
|
704
749
|
const componentsCount = data[offset++];
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* formats like WebP when supported.
|
|
6
6
|
*/
|
|
7
7
|
export default class WebImageDecoder extends BaseDecoder {
|
|
8
|
-
decodeBlock(buffer: any): Promise<
|
|
8
|
+
decodeBlock(buffer: any): Promise<ArrayBuffer>;
|
|
9
9
|
}
|
|
10
10
|
import BaseDecoder from './basedecoder.js';
|
|
11
11
|
//# sourceMappingURL=webimage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webimage.d.ts","sourceRoot":"","sources":["../../src/compression/webimage.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH;IAUE
|
|
1
|
+
{"version":3,"file":"webimage.d.ts","sourceRoot":"","sources":["../../src/compression/webimage.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH;IAUE,+CAoCC;CACF;wBAvDuB,kBAAkB"}
|
|
@@ -29,7 +29,7 @@ export default class WebImageDecoder extends BaseDecoder {
|
|
|
29
29
|
}
|
|
30
30
|
// Draw the image onto the canvas to extract the pixel data.
|
|
31
31
|
// Note: createImageBitmap always returns RGBA data.
|
|
32
|
-
const ctx = canvas.getContext('2d');
|
|
32
|
+
const ctx = /** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d'));
|
|
33
33
|
ctx.drawImage(imageBitmap, 0, 0);
|
|
34
34
|
const imageData = ctx.getImageData(0, 0, imageBitmap.width, imageBitmap.height).data;
|
|
35
35
|
// Return the correct channels to the caller
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataslice.d.ts","sourceRoot":"","sources":["../src/dataslice.js"],"names":[],"mappings":"AAAA;IACE,iFAKC;IAJC,yBAA0C;IAC1C,kBAA+B;IAC/B,mBAAiC;IACjC,cAAuB;IAGzB,uBAEC;IAED,oBAEC;IAED,wBAEC;IAED,mBAEC;IAED,kBAEC;IAED,0CAEC;IAED,+
|
|
1
|
+
{"version":3,"file":"dataslice.d.ts","sourceRoot":"","sources":["../src/dataslice.js"],"names":[],"mappings":"AAAA;IACE,iFAKC;IAJC,yBAA0C;IAC1C,kBAA+B;IAC/B,mBAAiC;IACjC,cAAuB;IAGzB,uBAEC;IAED,oBAEC;IAED,wBAEC;IAED,mBAEC;IAED,kBAEC;IAED,0CAEC;IAED,+BAEC;IAED,8BAEC;IAED,gCAIC;IAED,+BAIC;IAED,gCAIC;IAED,+BAIC;IAED,iCAIC;IAED,iCAIC;IAED,gCAuBC;IAGD,+BAyBC;IAED,gCAKC;CACF"}
|
package/dist-module/dataslice.js
CHANGED
|
@@ -24,10 +24,10 @@ export default class DataSlice {
|
|
|
24
24
|
return this.sliceOffset <= offset && this.sliceTop >= offset + length;
|
|
25
25
|
}
|
|
26
26
|
readUint8(offset) {
|
|
27
|
-
return this._dataView.getUint8(offset - this._sliceOffset
|
|
27
|
+
return this._dataView.getUint8(offset - this._sliceOffset);
|
|
28
28
|
}
|
|
29
29
|
readInt8(offset) {
|
|
30
|
-
return this._dataView.getInt8(offset - this._sliceOffset
|
|
30
|
+
return this._dataView.getInt8(offset - this._sliceOffset);
|
|
31
31
|
}
|
|
32
32
|
readUint16(offset) {
|
|
33
33
|
return this._dataView.getUint16(offset - this._sliceOffset, this._littleEndian);
|
|
@@ -4,8 +4,8 @@ export default class DataView64 {
|
|
|
4
4
|
get buffer(): any;
|
|
5
5
|
getUint64(offset: any, littleEndian: any): number;
|
|
6
6
|
getInt64(offset: any, littleEndian: any): number;
|
|
7
|
-
getUint8(offset: any
|
|
8
|
-
getInt8(offset: any
|
|
7
|
+
getUint8(offset: any): number;
|
|
8
|
+
getInt8(offset: any): number;
|
|
9
9
|
getUint16(offset: any, littleEndian: any): number;
|
|
10
10
|
getInt16(offset: any, littleEndian: any): number;
|
|
11
11
|
getUint32(offset: any, littleEndian: any): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataview64.d.ts","sourceRoot":"","sources":["../src/dataview64.js"],"names":[],"mappings":"AAEA;IACE,8BAEC;IADC,yBAA0C;IAG5C,kBAEC;IAED,kDAuBC;IAGD,iDAsBC;IAED,
|
|
1
|
+
{"version":3,"file":"dataview64.d.ts","sourceRoot":"","sources":["../src/dataview64.js"],"names":[],"mappings":"AAEA;IACE,8BAEC;IADC,yBAA0C;IAG5C,kBAEC;IAED,kDAuBC;IAGD,iDAsBC;IAED,8BAEC;IAED,6BAEC;IAED,kDAEC;IAED,iDAEC;IAED,kDAEC;IAED,iDAEC;IAED,mDAEC;IAED,mDAEC;IAED,mDAEC;CACF"}
|
|
@@ -50,11 +50,11 @@ export default class DataView64 {
|
|
|
50
50
|
}
|
|
51
51
|
return value;
|
|
52
52
|
}
|
|
53
|
-
getUint8(offset
|
|
54
|
-
return this._dataView.getUint8(offset
|
|
53
|
+
getUint8(offset) {
|
|
54
|
+
return this._dataView.getUint8(offset);
|
|
55
55
|
}
|
|
56
|
-
getInt8(offset
|
|
57
|
-
return this._dataView.getInt8(offset
|
|
56
|
+
getInt8(offset) {
|
|
57
|
+
return this._dataView.getInt8(offset);
|
|
58
58
|
}
|
|
59
59
|
getUint16(offset, littleEndian) {
|
|
60
60
|
return this._dataView.getUint16(offset, littleEndian);
|