@cornerstonejs/dicom-image-loader 2.1.21 → 2.2.0

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.
@@ -8,23 +8,21 @@ export function initialize(decodeConfig) {
8
8
  return Promise.resolve();
9
9
  }
10
10
  return new Promise((resolve, reject) => {
11
- import('../../codecs/jpegLossless').then((jpeg) => {
12
- local.jpeg = jpeg;
11
+ import('jpeg-lossless-decoder-js').then(({ Decoder }) => {
12
+ const decoder = new Decoder();
13
+ local.jpeg = decoder;
13
14
  resolve();
14
15
  }, reject);
15
16
  });
16
17
  }
17
18
  async function decodeJPEGLossless(imageFrame, pixelData) {
18
19
  await initialize();
19
- if (typeof local.jpeg === 'undefined' ||
20
- typeof local.jpeg.lossless === 'undefined' ||
21
- typeof local.jpeg.lossless.Decoder === 'undefined') {
20
+ if (typeof local.jpeg === 'undefined') {
22
21
  throw new Error('No JPEG Lossless decoder loaded');
23
22
  }
24
23
  const byteOutput = imageFrame.bitsAllocated <= 8 ? 1 : 2;
25
24
  const buffer = pixelData.buffer;
26
- const decoder = new local.jpeg.lossless.Decoder();
27
- const decompressedData = decoder.decode(buffer, pixelData.byteOffset, pixelData.length, byteOutput);
25
+ const decompressedData = local.jpeg.decode(buffer, pixelData.byteOffset, pixelData.length, byteOutput);
28
26
  if (imageFrame.pixelRepresentation === 0) {
29
27
  if (imageFrame.bitsAllocated === 16) {
30
28
  imageFrame.pixelData = new Uint16Array(decompressedData.buffer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/dicom-image-loader",
3
- "version": "2.1.21",
3
+ "version": "2.2.0",
4
4
  "description": "Cornerstone Image Loader for DICOM WADO-URI and WADO-RS and Local file",
5
5
  "keywords": [
6
6
  "DICOM",
@@ -111,11 +111,12 @@
111
111
  "@cornerstonejs/codec-openjpeg": "^1.2.2",
112
112
  "@cornerstonejs/codec-openjph": "^2.4.5",
113
113
  "comlink": "^4.4.1",
114
+ "jpeg-lossless-decoder-js": "^2.1.0",
114
115
  "pako": "^2.0.4",
115
116
  "uuid": "^9.0.0"
116
117
  },
117
118
  "peerDependencies": {
118
- "@cornerstonejs/core": "^2.1.21",
119
+ "@cornerstonejs/core": "^2.2.0",
119
120
  "dicom-parser": "^1.8.9"
120
121
  },
121
122
  "lint-staged": {
@@ -130,5 +131,5 @@
130
131
  "path": "./node_modules/cz-conventional-changelog"
131
132
  }
132
133
  },
133
- "gitHead": "3b76c5efbec0b40a07f8d82bc804aa327fcabf1a"
134
+ "gitHead": "519da333af96c5726ee913e929b1c022cf633d1d"
134
135
  }
@@ -1,7 +0,0 @@
1
- export = jpeg.lossless.Utils;
2
- export = jpeg.lossless.Utils;
3
- declare namespace Utils {
4
- function createArray(length: any, ...args: any[]): any[];
5
- function makeCRCTable(): number[];
6
- function crc32(dataView: any): number;
7
- }
@@ -1,1218 +0,0 @@
1
- (function (f) {
2
- if (typeof exports === 'object' && typeof module !== 'undefined') {
3
- module.exports = f();
4
- }
5
- else if (typeof define === 'function' && define.amd) {
6
- define([], f);
7
- }
8
- else {
9
- var g;
10
- if (typeof window !== 'undefined') {
11
- g = window;
12
- }
13
- else if (typeof global !== 'undefined') {
14
- g = global;
15
- }
16
- else if (typeof self !== 'undefined') {
17
- g = self;
18
- }
19
- else {
20
- g = this;
21
- }
22
- g.jpeg = f();
23
- }
24
- })(function () {
25
- var define, module, exports;
26
- return (function e(t, n, r) {
27
- function s(o, u) {
28
- if (!n[o]) {
29
- if (!t[o]) {
30
- var a = typeof require === 'function' && require;
31
- if (!u && a) {
32
- return a(o, !0);
33
- }
34
- if (i) {
35
- return i(o, !0);
36
- }
37
- var f = new Error("Cannot find module '" + o + "'");
38
- throw ((f.code = 'MODULE_NOT_FOUND'), f);
39
- }
40
- var l = (n[o] = { exports: {} });
41
- t[o][0].call(l.exports, function (e) {
42
- var n = t[o][1][e];
43
- return s(n ? n : e);
44
- }, l, l.exports, e, t, n, r);
45
- }
46
- return n[o].exports;
47
- }
48
- var i = typeof require === 'function' && require;
49
- for (var o = 0; o < r.length; o++) {
50
- s(r[o]);
51
- }
52
- return s;
53
- })({
54
- 1: [
55
- function (require, module, exports) {
56
- var jpeg = jpeg || {};
57
- jpeg.lossless = jpeg.lossless || {};
58
- jpeg.lossless.ComponentSpec =
59
- jpeg.lossless.ComponentSpec ||
60
- function () {
61
- this.hSamp = 0;
62
- this.quantTableSel = 0;
63
- this.vSamp = 0;
64
- };
65
- var moduleType = typeof module;
66
- if (moduleType !== 'undefined' && module.exports) {
67
- module.exports = jpeg.lossless.ComponentSpec;
68
- }
69
- },
70
- {},
71
- ],
72
- 2: [
73
- function (require, module, exports) {
74
- var jpeg = jpeg || {};
75
- jpeg.lossless = jpeg.lossless || {};
76
- jpeg.lossless.DataStream =
77
- jpeg.lossless.DataStream ||
78
- function (data, offset, length) {
79
- this.buffer = new Uint8Array(data, offset, length);
80
- this.index = 0;
81
- };
82
- jpeg.lossless.DataStream.prototype.get16 = function () {
83
- var value = (this.buffer[this.index] << 8) + this.buffer[this.index + 1];
84
- this.index += 2;
85
- return value;
86
- };
87
- jpeg.lossless.DataStream.prototype.get8 = function () {
88
- var value = this.buffer[this.index];
89
- this.index += 1;
90
- return value;
91
- };
92
- var moduleType = typeof module;
93
- if (moduleType !== 'undefined' && module.exports) {
94
- module.exports = jpeg.lossless.DataStream;
95
- }
96
- },
97
- {},
98
- ],
99
- 3: [
100
- function (require, module, exports) {
101
- var jpeg = jpeg || {};
102
- jpeg.lossless = jpeg.lossless || {};
103
- jpeg.lossless.DataStream =
104
- jpeg.lossless.DataStream ||
105
- (typeof require !== 'undefined'
106
- ? require('./data-stream.js')
107
- : null);
108
- jpeg.lossless.HuffmanTable =
109
- jpeg.lossless.HuffmanTable ||
110
- (typeof require !== 'undefined'
111
- ? require('./huffman-table.js')
112
- : null);
113
- jpeg.lossless.QuantizationTable =
114
- jpeg.lossless.QuantizationTable ||
115
- (typeof require !== 'undefined'
116
- ? require('./quantization-table.js')
117
- : null);
118
- jpeg.lossless.ScanHeader =
119
- jpeg.lossless.ScanHeader ||
120
- (typeof require !== 'undefined'
121
- ? require('./scan-header.js')
122
- : null);
123
- jpeg.lossless.FrameHeader =
124
- jpeg.lossless.FrameHeader ||
125
- (typeof require !== 'undefined'
126
- ? require('./frame-header.js')
127
- : null);
128
- jpeg.lossless.Utils =
129
- jpeg.lossless.Utils ||
130
- (typeof require !== 'undefined' ? require('./utils.js') : null);
131
- jpeg.lossless.Decoder =
132
- jpeg.lossless.Decoder ||
133
- function (buffer, numBytes) {
134
- this.buffer = buffer;
135
- this.frame = new jpeg.lossless.FrameHeader();
136
- this.huffTable = new jpeg.lossless.HuffmanTable();
137
- this.quantTable = new jpeg.lossless.QuantizationTable();
138
- this.scan = new jpeg.lossless.ScanHeader();
139
- this.DU = jpeg.lossless.Utils.createArray(10, 4, 64);
140
- this.HuffTab = jpeg.lossless.Utils.createArray(4, 2, 50 * 256);
141
- this.IDCT_Source = [];
142
- this.nBlock = [];
143
- this.acTab = jpeg.lossless.Utils.createArray(10, 1);
144
- this.dcTab = jpeg.lossless.Utils.createArray(10, 1);
145
- this.qTab = jpeg.lossless.Utils.createArray(10, 1);
146
- this.marker = 0;
147
- this.markerIndex = 0;
148
- this.numComp = 0;
149
- this.restartInterval = 0;
150
- this.selection = 0;
151
- this.xDim = 0;
152
- this.yDim = 0;
153
- this.xLoc = 0;
154
- this.yLoc = 0;
155
- this.numBytes = 0;
156
- this.outputData = null;
157
- this.restarting = false;
158
- this.mask = 0;
159
- if (typeof numBytes !== 'undefined') {
160
- this.numBytes = numBytes;
161
- }
162
- };
163
- jpeg.lossless.Decoder.IDCT_P = [
164
- 0, 5, 40, 16, 45, 2, 7, 42, 21, 56, 8, 61, 18, 47, 1, 4, 41, 23, 58,
165
- 13, 32, 24, 37, 10, 63, 17, 44, 3, 6, 43, 20, 57, 15, 34, 29, 48,
166
- 53, 26, 39, 9, 60, 19, 46, 22, 59, 12, 33, 31, 50, 55, 25, 36, 11,
167
- 62, 14, 35, 28, 49, 52, 27, 38, 30, 51, 54,
168
- ];
169
- jpeg.lossless.Decoder.TABLE = [
170
- 0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12,
171
- 17, 25, 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53, 10, 19, 23, 32,
172
- 39, 45, 52, 54, 20, 22, 33, 38, 46, 51, 55, 60, 21, 34, 37, 47, 50,
173
- 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63,
174
- ];
175
- jpeg.lossless.Decoder.MAX_HUFFMAN_SUBTREE = 50;
176
- jpeg.lossless.Decoder.MSB = 0x80000000;
177
- jpeg.lossless.Decoder.RESTART_MARKER_BEGIN = 0xffd0;
178
- jpeg.lossless.Decoder.RESTART_MARKER_END = 0xffd7;
179
- jpeg.lossless.Decoder.prototype.decompress = function (buffer, offset, length) {
180
- return this.decode(buffer, offset, length).buffer;
181
- };
182
- jpeg.lossless.Decoder.prototype.decode = function (buffer, offset, length, numBytes) {
183
- var current, scanNum = 0, pred = [], i, compN, temp = [], index = [], mcuNum;
184
- if (typeof buffer !== 'undefined') {
185
- this.buffer = buffer;
186
- }
187
- if (typeof numBytes !== 'undefined') {
188
- this.numBytes = numBytes;
189
- }
190
- this.stream = new jpeg.lossless.DataStream(this.buffer, offset, length);
191
- this.buffer = null;
192
- this.xLoc = 0;
193
- this.yLoc = 0;
194
- current = this.stream.get16();
195
- if (current !== 0xffd8) {
196
- throw new Error('Not a JPEG file');
197
- }
198
- current = this.stream.get16();
199
- while (current >> 4 !== 0x0ffc || current === 0xffc4) {
200
- switch (current) {
201
- case 0xffc4:
202
- this.huffTable.read(this.stream, this.HuffTab);
203
- break;
204
- case 0xffcc:
205
- throw new Error("Program doesn't support arithmetic coding. (format throw new IOException)");
206
- case 0xffdb:
207
- this.quantTable.read(this.stream, jpeg.lossless.Decoder.TABLE);
208
- break;
209
- case 0xffdd:
210
- this.restartInterval = this.readNumber();
211
- break;
212
- case 0xffe0:
213
- case 0xffe1:
214
- case 0xffe2:
215
- case 0xffe3:
216
- case 0xffe4:
217
- case 0xffe5:
218
- case 0xffe6:
219
- case 0xffe7:
220
- case 0xffe8:
221
- case 0xffe9:
222
- case 0xffea:
223
- case 0xffeb:
224
- case 0xffec:
225
- case 0xffed:
226
- case 0xffee:
227
- case 0xffef:
228
- this.readApp();
229
- break;
230
- case 0xfffe:
231
- this.readComment();
232
- break;
233
- default:
234
- if (current >> 8 !== 0xff) {
235
- throw new Error('ERROR: format throw new IOException! (decode)');
236
- }
237
- }
238
- current = this.stream.get16();
239
- }
240
- if (current < 0xffc0 || current > 0xffc7) {
241
- throw new Error('ERROR: could not handle arithmetic code!');
242
- }
243
- this.frame.read(this.stream);
244
- current = this.stream.get16();
245
- do {
246
- while (current !== 0x0ffda) {
247
- switch (current) {
248
- case 0xffc4:
249
- this.huffTable.read(this.stream, this.HuffTab);
250
- break;
251
- case 0xffcc:
252
- throw new Error("Program doesn't support arithmetic coding. (format throw new IOException)");
253
- case 0xffdb:
254
- this.quantTable.read(this.stream, jpeg.lossless.Decoder.TABLE);
255
- break;
256
- case 0xffdd:
257
- this.restartInterval = this.readNumber();
258
- break;
259
- case 0xffe0:
260
- case 0xffe1:
261
- case 0xffe2:
262
- case 0xffe3:
263
- case 0xffe4:
264
- case 0xffe5:
265
- case 0xffe6:
266
- case 0xffe7:
267
- case 0xffe8:
268
- case 0xffe9:
269
- case 0xffea:
270
- case 0xffeb:
271
- case 0xffec:
272
- case 0xffed:
273
- case 0xffee:
274
- case 0xffef:
275
- this.readApp();
276
- break;
277
- case 0xfffe:
278
- this.readComment();
279
- break;
280
- default:
281
- if (current >> 8 !== 0xff) {
282
- throw new Error('ERROR: format throw new IOException! (Parser.decode)');
283
- }
284
- }
285
- current = this.stream.get16();
286
- }
287
- this.precision = this.frame.precision;
288
- this.components = this.frame.components;
289
- if (!this.numBytes) {
290
- this.numBytes = parseInt(Math.ceil(this.precision / 8));
291
- }
292
- if (this.numBytes == 1) {
293
- this.mask = 0xff;
294
- }
295
- else {
296
- this.mask = 0xffff;
297
- }
298
- this.scan.read(this.stream);
299
- this.numComp = this.scan.numComp;
300
- this.selection = this.scan.selection;
301
- if (this.numBytes === 1) {
302
- if (this.numComp === 3) {
303
- this.getter = this.getValueRGB;
304
- this.setter = this.setValueRGB;
305
- this.output = this.outputRGB;
306
- }
307
- else {
308
- this.getter = this.getValue8;
309
- this.setter = this.setValue8;
310
- this.output = this.outputSingle;
311
- }
312
- }
313
- else {
314
- this.getter = this.getValue16;
315
- this.setter = this.setValue16;
316
- this.output = this.outputSingle;
317
- }
318
- switch (this.selection) {
319
- case 2:
320
- this.selector = this.select2;
321
- break;
322
- case 3:
323
- this.selector = this.select3;
324
- break;
325
- case 4:
326
- this.selector = this.select4;
327
- break;
328
- case 5:
329
- this.selector = this.select5;
330
- break;
331
- case 6:
332
- this.selector = this.select6;
333
- break;
334
- case 7:
335
- this.selector = this.select7;
336
- break;
337
- default:
338
- this.selector = this.select1;
339
- break;
340
- }
341
- this.scanComps = this.scan.components;
342
- this.quantTables = this.quantTable.quantTables;
343
- for (i = 0; i < this.numComp; i += 1) {
344
- compN = this.scanComps[i].scanCompSel;
345
- this.qTab[i] =
346
- this.quantTables[this.components[compN].quantTableSel];
347
- this.nBlock[i] =
348
- this.components[compN].vSamp * this.components[compN].hSamp;
349
- this.dcTab[i] = this.HuffTab[this.scanComps[i].dcTabSel][0];
350
- this.acTab[i] = this.HuffTab[this.scanComps[i].acTabSel][1];
351
- }
352
- this.xDim = this.frame.dimX;
353
- this.yDim = this.frame.dimY;
354
- if (this.numBytes == 1) {
355
- this.outputData = new Uint8Array(new ArrayBuffer(this.xDim * this.yDim * this.numBytes * this.numComp));
356
- }
357
- else {
358
- this.outputData = new Uint16Array(new ArrayBuffer(this.xDim * this.yDim * this.numBytes * this.numComp));
359
- }
360
- scanNum += 1;
361
- while (true) {
362
- temp[0] = 0;
363
- index[0] = 0;
364
- for (i = 0; i < 10; i += 1) {
365
- pred[i] = 1 << (this.precision - 1);
366
- }
367
- if (this.restartInterval === 0) {
368
- current = this.decodeUnit(pred, temp, index);
369
- while (current === 0 &&
370
- this.xLoc < this.xDim &&
371
- this.yLoc < this.yDim) {
372
- this.output(pred);
373
- current = this.decodeUnit(pred, temp, index);
374
- }
375
- break;
376
- }
377
- for (mcuNum = 0; mcuNum < this.restartInterval; mcuNum += 1) {
378
- this.restarting = mcuNum == 0;
379
- current = this.decodeUnit(pred, temp, index);
380
- this.output(pred);
381
- if (current !== 0) {
382
- break;
383
- }
384
- }
385
- if (current === 0) {
386
- if (this.markerIndex !== 0) {
387
- current = 0xff00 | this.marker;
388
- this.markerIndex = 0;
389
- }
390
- else {
391
- current = this.stream.get16();
392
- }
393
- }
394
- if (!(current >= jpeg.lossless.Decoder.RESTART_MARKER_BEGIN &&
395
- current <= jpeg.lossless.Decoder.RESTART_MARKER_END)) {
396
- break;
397
- }
398
- }
399
- if (current === 0xffdc && scanNum === 1) {
400
- this.readNumber();
401
- current = this.stream.get16();
402
- }
403
- } while (current !== 0xffd9 &&
404
- this.xLoc < this.xDim &&
405
- this.yLoc < this.yDim &&
406
- scanNum === 0);
407
- return this.outputData;
408
- };
409
- jpeg.lossless.Decoder.prototype.decodeUnit = function (prev, temp, index) {
410
- if (this.numComp == 1) {
411
- return this.decodeSingle(prev, temp, index);
412
- }
413
- else if (this.numComp == 3) {
414
- return this.decodeRGB(prev, temp, index);
415
- }
416
- return -1;
417
- };
418
- jpeg.lossless.Decoder.prototype.select1 = function (compOffset) {
419
- return this.getPreviousX(compOffset);
420
- };
421
- jpeg.lossless.Decoder.prototype.select2 = function (compOffset) {
422
- return this.getPreviousY(compOffset);
423
- };
424
- jpeg.lossless.Decoder.prototype.select3 = function (compOffset) {
425
- return this.getPreviousXY(compOffset);
426
- };
427
- jpeg.lossless.Decoder.prototype.select4 = function (compOffset) {
428
- return (this.getPreviousX(compOffset) +
429
- this.getPreviousY(compOffset) -
430
- this.getPreviousXY(compOffset));
431
- };
432
- jpeg.lossless.Decoder.prototype.select5 = function (compOffset) {
433
- return (this.getPreviousX(compOffset) +
434
- ((this.getPreviousY(compOffset) -
435
- this.getPreviousXY(compOffset)) >>
436
- 1));
437
- };
438
- jpeg.lossless.Decoder.prototype.select6 = function (compOffset) {
439
- return (this.getPreviousY(compOffset) +
440
- ((this.getPreviousX(compOffset) -
441
- this.getPreviousXY(compOffset)) >>
442
- 1));
443
- };
444
- jpeg.lossless.Decoder.prototype.select7 = function (compOffset) {
445
- return ((this.getPreviousX(compOffset) + this.getPreviousY(compOffset)) /
446
- 2);
447
- };
448
- jpeg.lossless.Decoder.prototype.decodeRGB = function (prev, temp, index) {
449
- var value, actab, dctab, qtab, ctrC, i, k, j;
450
- prev[0] = this.selector(0);
451
- prev[1] = this.selector(1);
452
- prev[2] = this.selector(2);
453
- for (ctrC = 0; ctrC < this.numComp; ctrC += 1) {
454
- qtab = this.qTab[ctrC];
455
- actab = this.acTab[ctrC];
456
- dctab = this.dcTab[ctrC];
457
- for (i = 0; i < this.nBlock[ctrC]; i += 1) {
458
- for (k = 0; k < this.IDCT_Source.length; k += 1) {
459
- this.IDCT_Source[k] = 0;
460
- }
461
- value = this.getHuffmanValue(dctab, temp, index);
462
- if (value >= 0xff00) {
463
- return value;
464
- }
465
- prev[ctrC] = this.IDCT_Source[0] =
466
- prev[ctrC] + this.getn(index, value, temp, index);
467
- this.IDCT_Source[0] *= qtab[0];
468
- for (j = 1; j < 64; j += 1) {
469
- value = this.getHuffmanValue(actab, temp, index);
470
- if (value >= 0xff00) {
471
- return value;
472
- }
473
- j += value >> 4;
474
- if ((value & 0x0f) === 0) {
475
- if (value >> 4 === 0) {
476
- break;
477
- }
478
- }
479
- else {
480
- this.IDCT_Source[jpeg.lossless.Decoder.IDCT_P[j]] =
481
- this.getn(index, value & 0x0f, temp, index) * qtab[j];
482
- }
483
- }
484
- }
485
- }
486
- return 0;
487
- };
488
- jpeg.lossless.Decoder.prototype.decodeSingle = function (prev, temp, index) {
489
- var value, i, n, nRestart;
490
- if (this.restarting) {
491
- this.restarting = false;
492
- prev[0] = 1 << (this.frame.precision - 1);
493
- }
494
- else {
495
- prev[0] = this.selector();
496
- }
497
- for (i = 0; i < this.nBlock[0]; i += 1) {
498
- value = this.getHuffmanValue(this.dcTab[0], temp, index);
499
- if (value >= 0xff00) {
500
- return value;
501
- }
502
- n = this.getn(prev, value, temp, index);
503
- nRestart = n >> 8;
504
- if (nRestart >= jpeg.lossless.Decoder.RESTART_MARKER_BEGIN &&
505
- nRestart <= jpeg.lossless.Decoder.RESTART_MARKER_END) {
506
- return nRestart;
507
- }
508
- prev[0] += n;
509
- }
510
- return 0;
511
- };
512
- jpeg.lossless.Decoder.prototype.getHuffmanValue = function (table, temp, index) {
513
- var code, input, mask;
514
- mask = 0xffff;
515
- if (index[0] < 8) {
516
- temp[0] <<= 8;
517
- input = this.stream.get8();
518
- if (input === 0xff) {
519
- this.marker = this.stream.get8();
520
- if (this.marker !== 0) {
521
- this.markerIndex = 9;
522
- }
523
- }
524
- temp[0] |= input;
525
- }
526
- else {
527
- index[0] -= 8;
528
- }
529
- code = table[temp[0] >> index[0]];
530
- if ((code & jpeg.lossless.Decoder.MSB) !== 0) {
531
- if (this.markerIndex !== 0) {
532
- this.markerIndex = 0;
533
- return 0xff00 | this.marker;
534
- }
535
- temp[0] &= mask >> (16 - index[0]);
536
- temp[0] <<= 8;
537
- input = this.stream.get8();
538
- if (input === 0xff) {
539
- this.marker = this.stream.get8();
540
- if (this.marker !== 0) {
541
- this.markerIndex = 9;
542
- }
543
- }
544
- temp[0] |= input;
545
- code = table[(code & 0xff) * 256 + (temp[0] >> index[0])];
546
- index[0] += 8;
547
- }
548
- index[0] += 8 - (code >> 8);
549
- if (index[0] < 0) {
550
- throw new Error(`index=${index[0]} temp=${temp[0]} code=${code} in HuffmanValue()`);
551
- }
552
- if (index[0] < this.markerIndex) {
553
- this.markerIndex = 0;
554
- return 0xff00 | this.marker;
555
- }
556
- temp[0] &= mask >> (16 - index[0]);
557
- return code & 0xff;
558
- };
559
- jpeg.lossless.Decoder.prototype.getn = function (PRED, n, temp, index) {
560
- var result, one, n_one, mask, input;
561
- one = 1;
562
- n_one = -1;
563
- mask = 0xffff;
564
- if (n === 0) {
565
- return 0;
566
- }
567
- if (n === 16) {
568
- if (PRED[0] >= 0) {
569
- return -32768;
570
- }
571
- return 32768;
572
- }
573
- index[0] -= n;
574
- if (index[0] >= 0) {
575
- if (index[0] < this.markerIndex && !this.isLastPixel()) {
576
- this.markerIndex = 0;
577
- return (0xff00 | this.marker) << 8;
578
- }
579
- result = temp[0] >> index[0];
580
- temp[0] &= mask >> (16 - index[0]);
581
- }
582
- else {
583
- temp[0] <<= 8;
584
- input = this.stream.get8();
585
- if (input === 0xff) {
586
- this.marker = this.stream.get8();
587
- if (this.marker !== 0) {
588
- this.markerIndex = 9;
589
- }
590
- }
591
- temp[0] |= input;
592
- index[0] += 8;
593
- if (index[0] < 0) {
594
- if (this.markerIndex !== 0) {
595
- this.markerIndex = 0;
596
- return (0xff00 | this.marker) << 8;
597
- }
598
- temp[0] <<= 8;
599
- input = this.stream.get8();
600
- if (input === 0xff) {
601
- this.marker = this.stream.get8();
602
- if (this.marker !== 0) {
603
- this.markerIndex = 9;
604
- }
605
- }
606
- temp[0] |= input;
607
- index[0] += 8;
608
- }
609
- if (index[0] < 0) {
610
- throw new Error(`index=${index[0]} in getn()`);
611
- }
612
- if (index[0] < this.markerIndex) {
613
- this.markerIndex = 0;
614
- return (0xff00 | this.marker) << 8;
615
- }
616
- result = temp[0] >> index[0];
617
- temp[0] &= mask >> (16 - index[0]);
618
- }
619
- if (result < one << (n - 1)) {
620
- result += (n_one << n) + 1;
621
- }
622
- return result;
623
- };
624
- jpeg.lossless.Decoder.prototype.getPreviousX = function (compOffset) {
625
- if (this.xLoc > 0) {
626
- return this.getter(this.yLoc * this.xDim + this.xLoc - 1, compOffset);
627
- }
628
- else if (this.yLoc > 0) {
629
- return this.getPreviousY(compOffset);
630
- }
631
- return 1 << (this.frame.precision - 1);
632
- };
633
- jpeg.lossless.Decoder.prototype.getPreviousXY = function (compOffset) {
634
- if (this.xLoc > 0 && this.yLoc > 0) {
635
- return this.getter((this.yLoc - 1) * this.xDim + this.xLoc - 1, compOffset);
636
- }
637
- return this.getPreviousY(compOffset);
638
- };
639
- jpeg.lossless.Decoder.prototype.getPreviousY = function (compOffset) {
640
- if (this.yLoc > 0) {
641
- return this.getter((this.yLoc - 1) * this.xDim + this.xLoc, compOffset);
642
- }
643
- return this.getPreviousX(compOffset);
644
- };
645
- jpeg.lossless.Decoder.prototype.isLastPixel = function () {
646
- return this.xLoc === this.xDim - 1 && this.yLoc === this.yDim - 1;
647
- };
648
- jpeg.lossless.Decoder.prototype.outputSingle = function (PRED) {
649
- if (this.xLoc < this.xDim && this.yLoc < this.yDim) {
650
- this.setter(this.yLoc * this.xDim + this.xLoc, this.mask & PRED[0]);
651
- this.xLoc += 1;
652
- if (this.xLoc >= this.xDim) {
653
- this.yLoc += 1;
654
- this.xLoc = 0;
655
- }
656
- }
657
- };
658
- jpeg.lossless.Decoder.prototype.outputRGB = function (PRED) {
659
- var offset = this.yLoc * this.xDim + this.xLoc;
660
- if (this.xLoc < this.xDim && this.yLoc < this.yDim) {
661
- this.setter(offset, PRED[0], 0);
662
- this.setter(offset, PRED[1], 1);
663
- this.setter(offset, PRED[2], 2);
664
- this.xLoc += 1;
665
- if (this.xLoc >= this.xDim) {
666
- this.yLoc += 1;
667
- this.xLoc = 0;
668
- }
669
- }
670
- };
671
- jpeg.lossless.Decoder.prototype.setValue8 = function (index, val) {
672
- this.outputData[index] = val;
673
- };
674
- jpeg.lossless.Decoder.prototype.getValue8 = function (index) {
675
- return this.outputData[index];
676
- };
677
- var littleEndian = (function () {
678
- var buffer = new ArrayBuffer(2);
679
- new DataView(buffer).setInt16(0, 256, true);
680
- return new Int16Array(buffer)[0] === 256;
681
- })();
682
- if (littleEndian) {
683
- jpeg.lossless.Decoder.prototype.setValue16 =
684
- jpeg.lossless.Decoder.prototype.setValue8;
685
- jpeg.lossless.Decoder.prototype.getValue16 =
686
- jpeg.lossless.Decoder.prototype.getValue8;
687
- }
688
- else {
689
- jpeg.lossless.Decoder.prototype.setValue16 = function (index, val) {
690
- this.outputData[index] =
691
- ((val & 0xff) << 8) | ((val >> 8) & 0xff);
692
- };
693
- jpeg.lossless.Decoder.prototype.getValue16 = function (index) {
694
- var val = this.outputData[index];
695
- return ((val & 0xff) << 8) | ((val >> 8) & 0xff);
696
- };
697
- }
698
- jpeg.lossless.Decoder.prototype.setValueRGB = function (index, val, compOffset) {
699
- this.outputData[index * 3 + compOffset] = val;
700
- };
701
- jpeg.lossless.Decoder.prototype.getValueRGB = function (index, compOffset) {
702
- return this.outputData[index * 3 + compOffset];
703
- };
704
- jpeg.lossless.Decoder.prototype.readApp = function () {
705
- var count = 0, length = this.stream.get16();
706
- count += 2;
707
- while (count < length) {
708
- this.stream.get8();
709
- count += 1;
710
- }
711
- return length;
712
- };
713
- jpeg.lossless.Decoder.prototype.readComment = function () {
714
- var sb = '', count = 0, length;
715
- length = this.stream.get16();
716
- count += 2;
717
- while (count < length) {
718
- sb += this.stream.get8();
719
- count += 1;
720
- }
721
- return sb;
722
- };
723
- jpeg.lossless.Decoder.prototype.readNumber = function () {
724
- var Ld = this.stream.get16();
725
- if (Ld !== 4) {
726
- throw new Error('ERROR: Define number format throw new IOException [Ld!=4]');
727
- }
728
- return this.stream.get16();
729
- };
730
- var moduleType = typeof module;
731
- if (moduleType !== 'undefined' && module.exports) {
732
- module.exports = jpeg.lossless.Decoder;
733
- }
734
- },
735
- {
736
- './data-stream.js': 2,
737
- './frame-header.js': 4,
738
- './huffman-table.js': 5,
739
- './quantization-table.js': 7,
740
- './scan-header.js': 9,
741
- './utils.js': 10,
742
- },
743
- ],
744
- 4: [
745
- function (require, module, exports) {
746
- var jpeg = jpeg || {};
747
- jpeg.lossless = jpeg.lossless || {};
748
- jpeg.lossless.ComponentSpec =
749
- jpeg.lossless.ComponentSpec ||
750
- (typeof require !== 'undefined'
751
- ? require('./component-spec.js')
752
- : null);
753
- jpeg.lossless.DataStream =
754
- jpeg.lossless.DataStream ||
755
- (typeof require !== 'undefined'
756
- ? require('./data-stream.js')
757
- : null);
758
- jpeg.lossless.FrameHeader =
759
- jpeg.lossless.FrameHeader ||
760
- function () {
761
- this.components = [];
762
- this.dimX = 0;
763
- this.dimY = 0;
764
- this.numComp = 0;
765
- this.precision = 0;
766
- };
767
- jpeg.lossless.FrameHeader.prototype.read = function (data) {
768
- var count = 0, length, i, c, temp;
769
- length = data.get16();
770
- count += 2;
771
- this.precision = data.get8();
772
- count += 1;
773
- this.dimY = data.get16();
774
- count += 2;
775
- this.dimX = data.get16();
776
- count += 2;
777
- this.numComp = data.get8();
778
- count += 1;
779
- for (i = 1; i <= this.numComp; i += 1) {
780
- if (count > length) {
781
- throw new Error('ERROR: frame format error');
782
- }
783
- c = data.get8();
784
- count += 1;
785
- if (count >= length) {
786
- throw new Error('ERROR: frame format error [c>=Lf]');
787
- }
788
- temp = data.get8();
789
- count += 1;
790
- if (!this.components[c]) {
791
- this.components[c] = new jpeg.lossless.ComponentSpec();
792
- }
793
- this.components[c].hSamp = temp >> 4;
794
- this.components[c].vSamp = temp & 0x0f;
795
- this.components[c].quantTableSel = data.get8();
796
- count += 1;
797
- }
798
- if (count !== length) {
799
- throw new Error('ERROR: frame format error [Lf!=count]');
800
- }
801
- return 1;
802
- };
803
- var moduleType = typeof module;
804
- if (moduleType !== 'undefined' && module.exports) {
805
- module.exports = jpeg.lossless.FrameHeader;
806
- }
807
- },
808
- { './component-spec.js': 1, './data-stream.js': 2 },
809
- ],
810
- 5: [
811
- function (require, module, exports) {
812
- var jpeg = jpeg || {};
813
- jpeg.lossless = jpeg.lossless || {};
814
- jpeg.lossless.DataStream =
815
- jpeg.lossless.DataStream ||
816
- (typeof require !== 'undefined'
817
- ? require('./data-stream.js')
818
- : null);
819
- jpeg.lossless.Utils =
820
- jpeg.lossless.Utils ||
821
- (typeof require !== 'undefined' ? require('./utils.js') : null);
822
- jpeg.lossless.HuffmanTable =
823
- jpeg.lossless.HuffmanTable ||
824
- function () {
825
- this.l = jpeg.lossless.Utils.createArray(4, 2, 16);
826
- this.th = [];
827
- this.v = jpeg.lossless.Utils.createArray(4, 2, 16, 200);
828
- this.tc = jpeg.lossless.Utils.createArray(4, 2);
829
- this.tc[0][0] = 0;
830
- this.tc[1][0] = 0;
831
- this.tc[2][0] = 0;
832
- this.tc[3][0] = 0;
833
- this.tc[0][1] = 0;
834
- this.tc[1][1] = 0;
835
- this.tc[2][1] = 0;
836
- this.tc[3][1] = 0;
837
- this.th[0] = 0;
838
- this.th[1] = 0;
839
- this.th[2] = 0;
840
- this.th[3] = 0;
841
- };
842
- jpeg.lossless.HuffmanTable.MSB = 0x80000000;
843
- jpeg.lossless.HuffmanTable.prototype.read = function (data, HuffTab) {
844
- var count = 0, length, temp, t, c, i, j;
845
- length = data.get16();
846
- count += 2;
847
- while (count < length) {
848
- temp = data.get8();
849
- count += 1;
850
- t = temp & 0x0f;
851
- if (t > 3) {
852
- throw new Error('ERROR: Huffman table ID > 3');
853
- }
854
- c = temp >> 4;
855
- if (c > 2) {
856
- throw new Error('ERROR: Huffman table [Table class > 2 ]');
857
- }
858
- this.th[t] = 1;
859
- this.tc[t][c] = 1;
860
- for (i = 0; i < 16; i += 1) {
861
- this.l[t][c][i] = data.get8();
862
- count += 1;
863
- }
864
- for (i = 0; i < 16; i += 1) {
865
- for (j = 0; j < this.l[t][c][i]; j += 1) {
866
- if (count > length) {
867
- throw new Error('ERROR: Huffman table format error [count>Lh]');
868
- }
869
- this.v[t][c][i][j] = data.get8();
870
- count += 1;
871
- }
872
- }
873
- }
874
- if (count !== length) {
875
- throw new Error('ERROR: Huffman table format error [count!=Lf]');
876
- }
877
- for (i = 0; i < 4; i += 1) {
878
- for (j = 0; j < 2; j += 1) {
879
- if (this.tc[i][j] !== 0) {
880
- this.buildHuffTable(HuffTab[i][j], this.l[i][j], this.v[i][j]);
881
- }
882
- }
883
- }
884
- return 1;
885
- };
886
- jpeg.lossless.HuffmanTable.prototype.buildHuffTable = function (tab, L, V) {
887
- var currentTable, temp, k, i, j, n;
888
- temp = 256;
889
- k = 0;
890
- for (i = 0; i < 8; i += 1) {
891
- for (j = 0; j < L[i]; j += 1) {
892
- for (n = 0; n < temp >> (i + 1); n += 1) {
893
- tab[k] = V[i][j] | ((i + 1) << 8);
894
- k += 1;
895
- }
896
- }
897
- }
898
- for (i = 1; k < 256; i += 1, k += 1) {
899
- tab[k] = i | jpeg.lossless.HuffmanTable.MSB;
900
- }
901
- currentTable = 1;
902
- k = 0;
903
- for (i = 8; i < 16; i += 1) {
904
- for (j = 0; j < L[i]; j += 1) {
905
- for (n = 0; n < temp >> (i - 7); n += 1) {
906
- tab[currentTable * 256 + k] = V[i][j] | ((i + 1) << 8);
907
- k += 1;
908
- }
909
- if (k >= 256) {
910
- if (k > 256) {
911
- throw new Error('ERROR: Huffman table error(1)!');
912
- }
913
- k = 0;
914
- currentTable += 1;
915
- }
916
- }
917
- }
918
- };
919
- var moduleType = typeof module;
920
- if (moduleType !== 'undefined' && module.exports) {
921
- module.exports = jpeg.lossless.HuffmanTable;
922
- }
923
- },
924
- { './data-stream.js': 2, './utils.js': 10 },
925
- ],
926
- 6: [
927
- function (require, module, exports) {
928
- var jpeg = jpeg || {};
929
- jpeg.lossless = jpeg.lossless || {};
930
- jpeg.lossless.ComponentSpec =
931
- jpeg.lossless.ComponentSpec ||
932
- (typeof require !== 'undefined'
933
- ? require('./component-spec.js')
934
- : null);
935
- jpeg.lossless.DataStream =
936
- jpeg.lossless.DataStream ||
937
- (typeof require !== 'undefined'
938
- ? require('./data-stream.js')
939
- : null);
940
- jpeg.lossless.Decoder =
941
- jpeg.lossless.Decoder ||
942
- (typeof require !== 'undefined' ? require('./decoder.js') : null);
943
- jpeg.lossless.FrameHeader =
944
- jpeg.lossless.FrameHeader ||
945
- (typeof require !== 'undefined'
946
- ? require('./frame-header.js')
947
- : null);
948
- jpeg.lossless.HuffmanTable =
949
- jpeg.lossless.HuffmanTable ||
950
- (typeof require !== 'undefined'
951
- ? require('./huffman-table.js')
952
- : null);
953
- jpeg.lossless.QuantizationTable =
954
- jpeg.lossless.QuantizationTable ||
955
- (typeof require !== 'undefined'
956
- ? require('./quantization-table.js')
957
- : null);
958
- jpeg.lossless.ScanComponent =
959
- jpeg.lossless.ScanComponent ||
960
- (typeof require !== 'undefined'
961
- ? require('./scan-component.js')
962
- : null);
963
- jpeg.lossless.ScanHeader =
964
- jpeg.lossless.ScanHeader ||
965
- (typeof require !== 'undefined'
966
- ? require('./scan-header.js')
967
- : null);
968
- jpeg.lossless.Utils =
969
- jpeg.lossless.Utils ||
970
- (typeof require !== 'undefined' ? require('./utils.js') : null);
971
- var moduleType = typeof module;
972
- if (moduleType !== 'undefined' && module.exports) {
973
- module.exports = jpeg;
974
- }
975
- },
976
- {
977
- './component-spec.js': 1,
978
- './data-stream.js': 2,
979
- './decoder.js': 3,
980
- './frame-header.js': 4,
981
- './huffman-table.js': 5,
982
- './quantization-table.js': 7,
983
- './scan-component.js': 8,
984
- './scan-header.js': 9,
985
- './utils.js': 10,
986
- },
987
- ],
988
- 7: [
989
- function (require, module, exports) {
990
- var jpeg = jpeg || {};
991
- jpeg.lossless = jpeg.lossless || {};
992
- jpeg.lossless.DataStream =
993
- jpeg.lossless.DataStream ||
994
- (typeof require !== 'undefined'
995
- ? require('./data-stream.js')
996
- : null);
997
- jpeg.lossless.Utils =
998
- jpeg.lossless.Utils ||
999
- (typeof require !== 'undefined' ? require('./utils.js') : null);
1000
- jpeg.lossless.QuantizationTable =
1001
- jpeg.lossless.QuantizationTable ||
1002
- function () {
1003
- this.precision = [];
1004
- this.tq = [];
1005
- this.quantTables = jpeg.lossless.Utils.createArray(4, 64);
1006
- this.tq[0] = 0;
1007
- this.tq[1] = 0;
1008
- this.tq[2] = 0;
1009
- this.tq[3] = 0;
1010
- };
1011
- jpeg.lossless.QuantizationTable.enhanceQuantizationTable = function (qtab, table) {
1012
- var i;
1013
- for (i = 0; i < 8; i += 1) {
1014
- qtab[table[0 * 8 + i]] *= 90;
1015
- qtab[table[4 * 8 + i]] *= 90;
1016
- qtab[table[2 * 8 + i]] *= 118;
1017
- qtab[table[6 * 8 + i]] *= 49;
1018
- qtab[table[5 * 8 + i]] *= 71;
1019
- qtab[table[1 * 8 + i]] *= 126;
1020
- qtab[table[7 * 8 + i]] *= 25;
1021
- qtab[table[3 * 8 + i]] *= 106;
1022
- }
1023
- for (i = 0; i < 8; i += 1) {
1024
- qtab[table[0 + 8 * i]] *= 90;
1025
- qtab[table[4 + 8 * i]] *= 90;
1026
- qtab[table[2 + 8 * i]] *= 118;
1027
- qtab[table[6 + 8 * i]] *= 49;
1028
- qtab[table[5 + 8 * i]] *= 71;
1029
- qtab[table[1 + 8 * i]] *= 126;
1030
- qtab[table[7 + 8 * i]] *= 25;
1031
- qtab[table[3 + 8 * i]] *= 106;
1032
- }
1033
- for (i = 0; i < 64; i += 1) {
1034
- qtab[i] >>= 6;
1035
- }
1036
- };
1037
- jpeg.lossless.QuantizationTable.prototype.read = function (data, table) {
1038
- var count = 0, length, temp, t, i;
1039
- length = data.get16();
1040
- count += 2;
1041
- while (count < length) {
1042
- temp = data.get8();
1043
- count += 1;
1044
- t = temp & 0x0f;
1045
- if (t > 3) {
1046
- throw new Error('ERROR: Quantization table ID > 3');
1047
- }
1048
- this.precision[t] = temp >> 4;
1049
- if (this.precision[t] === 0) {
1050
- this.precision[t] = 8;
1051
- }
1052
- else if (this.precision[t] === 1) {
1053
- this.precision[t] = 16;
1054
- }
1055
- else {
1056
- throw new Error('ERROR: Quantization table precision error');
1057
- }
1058
- this.tq[t] = 1;
1059
- if (this.precision[t] === 8) {
1060
- for (i = 0; i < 64; i += 1) {
1061
- if (count > length) {
1062
- throw new Error('ERROR: Quantization table format error');
1063
- }
1064
- this.quantTables[t][i] = data.get8();
1065
- count += 1;
1066
- }
1067
- jpeg.lossless.QuantizationTable.enhanceQuantizationTable(this.quantTables[t], table);
1068
- }
1069
- else {
1070
- for (i = 0; i < 64; i += 1) {
1071
- if (count > length) {
1072
- throw new Error('ERROR: Quantization table format error');
1073
- }
1074
- this.quantTables[t][i] = data.get16();
1075
- count += 2;
1076
- }
1077
- jpeg.lossless.QuantizationTable.enhanceQuantizationTable(this.quantTables[t], table);
1078
- }
1079
- }
1080
- if (count !== length) {
1081
- throw new Error('ERROR: Quantization table error [count!=Lq]');
1082
- }
1083
- return 1;
1084
- };
1085
- var moduleType = typeof module;
1086
- if (moduleType !== 'undefined' && module.exports) {
1087
- module.exports = jpeg.lossless.QuantizationTable;
1088
- }
1089
- },
1090
- { './data-stream.js': 2, './utils.js': 10 },
1091
- ],
1092
- 8: [
1093
- function (require, module, exports) {
1094
- var jpeg = jpeg || {};
1095
- jpeg.lossless = jpeg.lossless || {};
1096
- jpeg.lossless.ScanComponent =
1097
- jpeg.lossless.ScanComponent ||
1098
- function () {
1099
- this.acTabSel = 0;
1100
- this.dcTabSel = 0;
1101
- this.scanCompSel = 0;
1102
- };
1103
- var moduleType = typeof module;
1104
- if (moduleType !== 'undefined' && module.exports) {
1105
- module.exports = jpeg.lossless.ScanComponent;
1106
- }
1107
- },
1108
- {},
1109
- ],
1110
- 9: [
1111
- function (require, module, exports) {
1112
- var jpeg = jpeg || {};
1113
- jpeg.lossless = jpeg.lossless || {};
1114
- jpeg.lossless.DataStream =
1115
- jpeg.lossless.DataStream ||
1116
- (typeof require !== 'undefined'
1117
- ? require('./data-stream.js')
1118
- : null);
1119
- jpeg.lossless.ScanComponent =
1120
- jpeg.lossless.ScanComponent ||
1121
- (typeof require !== 'undefined'
1122
- ? require('./scan-component.js')
1123
- : null);
1124
- jpeg.lossless.ScanHeader =
1125
- jpeg.lossless.ScanHeader ||
1126
- function () {
1127
- this.ah = 0;
1128
- this.al = 0;
1129
- this.numComp = 0;
1130
- this.selection = 0;
1131
- this.spectralEnd = 0;
1132
- this.components = [];
1133
- };
1134
- jpeg.lossless.ScanHeader.prototype.read = function (data) {
1135
- var count = 0, length, i, temp;
1136
- length = data.get16();
1137
- count += 2;
1138
- this.numComp = data.get8();
1139
- count += 1;
1140
- for (i = 0; i < this.numComp; i += 1) {
1141
- this.components[i] = new jpeg.lossless.ScanComponent();
1142
- if (count > length) {
1143
- throw new Error('ERROR: scan header format error');
1144
- }
1145
- this.components[i].scanCompSel = data.get8();
1146
- count += 1;
1147
- temp = data.get8();
1148
- count += 1;
1149
- this.components[i].dcTabSel = temp >> 4;
1150
- this.components[i].acTabSel = temp & 0x0f;
1151
- }
1152
- this.selection = data.get8();
1153
- count += 1;
1154
- this.spectralEnd = data.get8();
1155
- count += 1;
1156
- temp = data.get8();
1157
- this.ah = temp >> 4;
1158
- this.al = temp & 0x0f;
1159
- count += 1;
1160
- if (count !== length) {
1161
- throw new Error('ERROR: scan header format error [count!=Ns]');
1162
- }
1163
- return 1;
1164
- };
1165
- var moduleType = typeof module;
1166
- if (moduleType !== 'undefined' && module.exports) {
1167
- module.exports = jpeg.lossless.ScanHeader;
1168
- }
1169
- },
1170
- { './data-stream.js': 2, './scan-component.js': 8 },
1171
- ],
1172
- 10: [
1173
- function (require, module, exports) {
1174
- var jpeg = jpeg || {};
1175
- jpeg.lossless = jpeg.lossless || {};
1176
- jpeg.lossless.Utils = jpeg.lossless.Utils || {};
1177
- jpeg.lossless.Utils.createArray = function (length) {
1178
- var arr = new Array(length || 0), i = length;
1179
- if (arguments.length > 1) {
1180
- var args = Array.prototype.slice.call(arguments, 1);
1181
- while (i--) {
1182
- arr[length - 1 - i] = jpeg.lossless.Utils.createArray.apply(this, args);
1183
- }
1184
- }
1185
- return arr;
1186
- };
1187
- jpeg.lossless.Utils.makeCRCTable = function () {
1188
- var c;
1189
- var crcTable = [];
1190
- for (var n = 0; n < 256; n++) {
1191
- c = n;
1192
- for (var k = 0; k < 8; k++) {
1193
- c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
1194
- }
1195
- crcTable[n] = c;
1196
- }
1197
- return crcTable;
1198
- };
1199
- jpeg.lossless.Utils.crc32 = function (dataView) {
1200
- var uint8view = new Uint8Array(dataView.buffer);
1201
- var crcTable = jpeg.lossless.Utils.crcTable ||
1202
- (jpeg.lossless.Utils.crcTable =
1203
- jpeg.lossless.Utils.makeCRCTable());
1204
- var crc = 0 ^ -1;
1205
- for (var i = 0; i < uint8view.length; i++) {
1206
- crc = (crc >>> 8) ^ crcTable[(crc ^ uint8view[i]) & 0xff];
1207
- }
1208
- return (crc ^ -1) >>> 0;
1209
- };
1210
- var moduleType = typeof module;
1211
- if (moduleType !== 'undefined' && module.exports) {
1212
- module.exports = jpeg.lossless.Utils;
1213
- }
1214
- },
1215
- {},
1216
- ],
1217
- }, {}, [6])(6);
1218
- });