@cornerstonejs/dicom-image-loader 0.1.5 → 0.2.1
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/README.md +7 -223
- package/dist/610.bundle.min.js +2 -0
- package/dist/610.bundle.min.js.map +1 -0
- package/dist/610.bundle.min.worker.js +2 -0
- package/dist/610.bundle.min.worker.js.map +1 -0
- package/dist/945.bundle.min.js +2 -0
- package/dist/945.bundle.min.js.map +1 -0
- package/dist/945.bundle.min.worker.js +2 -0
- package/dist/945.bundle.min.worker.js.map +1 -0
- package/dist/cornerstoneDICOMImageLoader.bundle.min.js +2 -0
- package/dist/cornerstoneDICOMImageLoader.bundle.min.js.map +1 -0
- package/dist/cornerstoneDICOMImageLoaderNoWebWorkers.bundle.min.js +2 -0
- package/dist/cornerstoneDICOMImageLoaderNoWebWorkers.bundle.min.js.map +1 -0
- package/dist/dynamic-import/5004fdc02f329ce53b69.wasm +0 -0
- package/dist/dynamic-import/610.min.worker.js +2 -0
- package/dist/dynamic-import/610.min.worker.js.map +1 -0
- package/dist/dynamic-import/65916ef3def695744bda.wasm +0 -0
- package/dist/dynamic-import/75788f12450d4c5ed494.wasm +0 -0
- package/dist/dynamic-import/945.min.worker.js +2 -0
- package/dist/dynamic-import/945.min.worker.js.map +1 -0
- package/dist/dynamic-import/c22b37c3488e1d6c3aa4.wasm +0 -0
- package/dist/dynamic-import/cornerstoneDICOMImageLoader.min.js +2 -0
- package/dist/dynamic-import/cornerstoneDICOMImageLoader.min.js.map +1 -0
- package/dist/dynamic-import/index.worker.min.worker.js +2 -0
- package/dist/dynamic-import/index.worker.min.worker.js.map +1 -0
- package/dist/index.worker.bundle.min.worker.js +2 -0
- package/dist/index.worker.bundle.min.worker.js.map +1 -0
- package/package.json +31 -15
- package/.browserslistrc +0 -6
- package/babel.config.json +0 -11
package/README.md
CHANGED
|
@@ -1,225 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
[![NPM downloads][npm-downloads-image]][npm-url]
|
|
3
|
-
[![MIT License][license-image]][license-url]
|
|
4
|
-
[![Build Status][travis-image]][travis-url]
|
|
5
|
-
[![Coverage Status][coverage-image]][coverage-url]
|
|
1
|
+
# DICOM Image Loader
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
This package provides a DICOM image loader for the Cornerstone library.
|
|
4
|
+
This is the successor to the [cornerstoneWADOImageLoader] which provides the following
|
|
5
|
+
benefits:
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
HTTP based server that returns DICOM P10 instances (e.g.
|
|
13
|
-
[Orthanc](http://www.orthanc-server.com/) or custom servers)
|
|
14
|
-
|
|
15
|
-
## Key Features
|
|
16
|
-
|
|
17
|
-
- Implements a
|
|
18
|
-
[cornerstone ImageLoader](https://github.com/cornerstonejs/cornerstone/wiki/ImageLoader)
|
|
19
|
-
for DICOM P10 Instances via a HTTP get request.
|
|
20
|
-
- Can be used with a WADO-URI server
|
|
21
|
-
- Can be used with Orthanc's file endpoint
|
|
22
|
-
- Can be used with any server that returns DICOM P10 instances via HTTP GET
|
|
23
|
-
- Implements a
|
|
24
|
-
[cornerstone ImageLoader](https://github.com/cornerstonejs/cornerstone/wiki/ImageLoader)
|
|
25
|
-
for WADO-RS (DICOMWeb)
|
|
26
|
-
- Supports many popular transfer syntaxes and photometric interpretations
|
|
27
|
-
[see full list](https://github.com/cornerstonejs/cornerstoneWADOImageLoader/blob/master/docs/TransferSyntaxes.md)
|
|
28
|
-
and [codec](docs/Codecs.md) for more information.
|
|
29
|
-
- Framework to execute CPU intensive tasks in [web workers](docs/WebWorkers.md)
|
|
30
|
-
- Used for image decoding
|
|
31
|
-
- Can be used for your own CPU intensive tasks (e.g. image processing)
|
|
32
|
-
|
|
33
|
-
## Live Examples
|
|
34
|
-
|
|
35
|
-
[Click here for a live example of this library in use!](http://rawgithub.com/cornerstonejs/cornerstoneWADOImageLoader/master/examples/index.html)
|
|
36
|
-
|
|
37
|
-
You can also see it in action with the
|
|
38
|
-
[cornerstoneDemo application](https://github.com/chafey/cornerstoneDemo).
|
|
39
|
-
|
|
40
|
-
## Install
|
|
41
|
-
|
|
42
|
-
Get the distributed unminimized file:
|
|
43
|
-
|
|
44
|
-
- [cornerstoneWADOImageLoader.js](https://unpkg.com/cornerstone-wado-image-loader)
|
|
45
|
-
|
|
46
|
-
or the distributed minimized file:
|
|
47
|
-
|
|
48
|
-
- [cornerstoneWADOImageLoader.bundle.min.js](https://unpkg.com/cornerstone-wado-image-loader)
|
|
49
|
-
|
|
50
|
-
## Usage
|
|
51
|
-
|
|
52
|
-
The cornerstoneWADOImageLoader depends on the following external libraries which
|
|
53
|
-
should be loaded before cornerstoneWADOImageLoader.js:
|
|
54
|
-
|
|
55
|
-
1. [dicomParser](https://github.com/cornerstonejs/dicomParser)
|
|
56
|
-
2. [cornerstone](https://github.com/cornerstonejs/cornerstone)
|
|
57
|
-
|
|
58
|
-
_New in 1.0.0_: Specify the cornerstone instance you want to register the loader
|
|
59
|
-
with.
|
|
60
|
-
|
|
61
|
-
```javascript
|
|
62
|
-
cornerstoneWADOImageLoader.external.cornerstone = cornerstone;
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Have your code configure the web worker framework:
|
|
66
|
-
|
|
67
|
-
```javascript
|
|
68
|
-
var config = {
|
|
69
|
-
maxWebWorkers: navigator.hardwareConcurrency || 1,
|
|
70
|
-
startWebWorkersOnDemand: true,
|
|
71
|
-
};
|
|
72
|
-
cornerstoneWADOImageLoader.webWorkerManager.initialize(config);
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
See the [web workers](docs/WebWorkers.md) documentation for more details on
|
|
76
|
-
configuring.
|
|
77
|
-
|
|
78
|
-
## Upgrade to CWIL v4.x
|
|
79
|
-
|
|
80
|
-
Cornerstone-WADO-Image-Loader (CWIL) v4.0.x has been released, which adds
|
|
81
|
-
support for using WebAssembly (WASM) builds of each codec. This significantly
|
|
82
|
-
improves image decoding performance and enables us to load codec at runtime when
|
|
83
|
-
needed dynamically, which reduces the build time and complexity.
|
|
84
|
-
|
|
85
|
-
In addition, we have improved the image loading performance in CWIL v4.x. In
|
|
86
|
-
previous versions of CWIL, image loading includes fetching AND decoding an image
|
|
87
|
-
before returning a promise completion, preventing more requests from being made
|
|
88
|
-
until the queue is empty. This limitation has been fixed in CWIL v4, which
|
|
89
|
-
separates image retrieval and decoding into two steps. Now after an image is
|
|
90
|
-
retrieved, a new request is sent to the server immediately.
|
|
91
|
-
|
|
92
|
-
| | Improvement |
|
|
93
|
-
| ------------------- | -------------------------------------------------- |
|
|
94
|
-
| CWIL Bundle Size | 30x smaller (3.0 MB vs 87 kb with dynamic import) |
|
|
95
|
-
| JPEG Baseline Codec | 4.5x faster (2.87 ms for 512x512 16 bit CT Slice) |
|
|
96
|
-
| JPEG 2000 Codec | 1.8x faster (41.02 ms for 512x512 16 bit CT Slice) |
|
|
97
|
-
|
|
98
|
-
### Steps to upgrade
|
|
99
|
-
|
|
100
|
-
#### Dynamic Import
|
|
101
|
-
|
|
102
|
-
In v4.x, we have added dynamic importing support for the codecs as needed. To be
|
|
103
|
-
able to use such feature, instead of
|
|
104
|
-
|
|
105
|
-
```js
|
|
106
|
-
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
you need to do:
|
|
110
|
-
|
|
111
|
-
```js
|
|
112
|
-
import cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader/dist/dynamic-import/cornerstoneWADOImageLoader.min.js';
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
This way, codecs are loaded dynamically when needed. You have another option to
|
|
116
|
-
create an alias in the webpack config file as we do
|
|
117
|
-
[here](https://github.com/OHIF/Viewers/blob/33307d3cd28599cbb4d7189560afdd7f65033ab8/platform/viewer/.webpack/webpack.pwa.js#L65)
|
|
118
|
-
for OHIF Viewer.
|
|
119
|
-
|
|
120
|
-
```js
|
|
121
|
-
resolve: {
|
|
122
|
-
alias: {
|
|
123
|
-
'cornerstone-wado-image-loader':
|
|
124
|
-
'cornerstone-wado-image-loader/dist/dynamic-import/cornerstoneWADOImageLoader.min.js',
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
In addition WASM builds of the codec files should be made available in the build
|
|
130
|
-
folder. We use `CopyWebpackPlugin` to copy the WASM files to the build folder.
|
|
131
|
-
See
|
|
132
|
-
[here](https://github.com/OHIF/Viewers/blob/33307d3cd28599cbb4d7189560afdd7f65033ab8/platform/viewer/.webpack/webpack.pwa.js#L100)
|
|
133
|
-
for how we do it in OHIF Viewer.
|
|
134
|
-
|
|
135
|
-
```js
|
|
136
|
-
plugins: [
|
|
137
|
-
new CopyWebpackPlugin([
|
|
138
|
-
{
|
|
139
|
-
from:
|
|
140
|
-
'../../../node_modules/cornerstone-wado-image-loader/dist/dynamic-import',
|
|
141
|
-
to: DIST_DIR,
|
|
142
|
-
},
|
|
143
|
-
]),
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
Note 1: You need to give the correct path in the `CopyWebpackPlugin`, the above
|
|
147
|
-
path is relative to the `node_modules` folder in the OHIF Viewer.
|
|
148
|
-
|
|
149
|
-
Note 2: For other http servers like IIS, you need to configure it to serve WASM
|
|
150
|
-
files with the correct MIME type.
|
|
151
|
-
|
|
152
|
-
## Troubleshooting
|
|
153
|
-
|
|
154
|
-
Having problems viewing your images with cornerstonWADOImageLoader? Check out
|
|
155
|
-
the
|
|
156
|
-
[troubleshooting guide](https://github.com/cornerstonejs/cornerstoneWADOImageLoader/wiki/troubleshooting).
|
|
157
|
-
|
|
158
|
-
## Backlog
|
|
159
|
-
|
|
160
|
-
- Support for images with pixel padding
|
|
161
|
-
- Support for high bit (e.g. mask out burned in overlays)
|
|
162
|
-
- Free up DICOM P10 instance after decoding to reduce memory consumption
|
|
163
|
-
- Add support for compressed images to WADO-RS loader
|
|
164
|
-
- Look at using EMSCRIPTEN based build of IJG for JPEG
|
|
165
|
-
- Consolidate all EMSCRIPTEN codecs into one build to cut down on memory use and
|
|
166
|
-
startup times
|
|
167
|
-
- Add support for bulk data items to WADO-RS Loader
|
|
168
|
-
- Add events to webWorkerManager so its activity can be monitored
|
|
169
|
-
- Add support for issuing progress events from web worker tasks
|
|
170
|
-
|
|
171
|
-
# FAQ
|
|
172
|
-
|
|
173
|
-
_Why is this a separate library from cornerstone?_
|
|
174
|
-
|
|
175
|
-
Mainly to avoid adding a dependency to cornerstone for the DICOM parsing
|
|
176
|
-
library. While cornerstone is intended to be used to display medical images that
|
|
177
|
-
are stored in DICOM, cornerstone aims to simplify the use of medical imaging and
|
|
178
|
-
therefore tries to hide some of the complexity that exists within DICOM. It is
|
|
179
|
-
also desirable to support display of non DICOM images so a DICOM independent
|
|
180
|
-
image model makes sense.
|
|
181
|
-
|
|
182
|
-
_How do I build this library myself?_
|
|
183
|
-
|
|
184
|
-
See the documentation [here](docs/Building.md)
|
|
185
|
-
|
|
186
|
-
_How do I add my own custom web worker tasks?_
|
|
187
|
-
|
|
188
|
-
See the documentation [here](docs/WebWorkers.md)
|
|
189
|
-
|
|
190
|
-
_How do I create imageIds that work with this image loader?_
|
|
191
|
-
|
|
192
|
-
See the documentation [here](docs/ImageIds.md)
|
|
193
|
-
|
|
194
|
-
# What Transfer Syntaxes are supported?
|
|
195
|
-
|
|
196
|
-
See [transfer syntaxes](docs/TransferSyntaxes.md)
|
|
197
|
-
|
|
198
|
-
# Copyright
|
|
199
|
-
|
|
200
|
-
Copyright 2016 Chris Hafey [chafey@gmail.com](mailto:chafey@gmail.com)
|
|
201
|
-
|
|
202
|
-
<!--
|
|
203
|
-
LINKS
|
|
204
|
-
-->
|
|
205
|
-
|
|
206
|
-
<!-- prettier-ignore-start -->
|
|
207
|
-
|
|
208
|
-
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
|
|
209
|
-
[license-url]: LICENSE
|
|
210
|
-
|
|
211
|
-
[npm-url]: https://npmjs.org/package/cornerstone-wado-image-loader
|
|
212
|
-
[npm-version-image]: http://img.shields.io/npm/v/cornerstone-wado-image-loader.svg?style=flat
|
|
213
|
-
[npm-downloads-image]: http://img.shields.io/npm/dm/cornerstone-wado-image-loader.svg?style=flat
|
|
214
|
-
|
|
215
|
-
[travis-url]: http://travis-ci.org/cornerstonejs/cornerstoneWADOImageLoader
|
|
216
|
-
[travis-image]: https://travis-ci.org/cornerstonejs/cornerstoneWADOImageLoader.svg?branch=master
|
|
217
|
-
|
|
218
|
-
[coverage-url]: https://coveralls.io/github/cornerstonejs/cornerstoneWADOImageLoader?branch=master
|
|
219
|
-
[coverage-image]: https://coveralls.io/repos/github/cornerstonejs/cornerstoneWADOImageLoader/badge.svg?branch=master
|
|
220
|
-
|
|
221
|
-
<!-- prettier-ignore-end -->
|
|
222
|
-
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
```
|
|
7
|
+
- Typescript support (and type definitions)
|
|
8
|
+
- Better developer experience (e.g. mono repo, linting, etc)
|
|
9
|
+
- In Future: better handling of web worker loading
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(this.webpackChunkcornerstoneDICOMImageLoader=this.webpackChunkcornerstoneDICOMImageLoader||[]).push([[610],{610:function(s,e){!function(t){if("object"==typeof e&&void 0!==s)s.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).jpeg=t()}}((function(){return function s(e,t,o){function r(a,n){if(!t[a]){if(!e[a]){var l="function"==typeof require&&require;if(!n&&l)return l(a,!0);if(i)return i(a,!0);var h=new Error("Cannot find module '"+a+"'");throw h.code="MODULE_NOT_FOUND",h}var c=t[a]={exports:{}};e[a][0].call(c.exports,(function(s){var t=e[a][1][s];return r(t||s)}),c,c.exports,s,e,t,o)}return t[a].exports}for(var i="function"==typeof require&&require,a=0;a<o.length;a++)r(o[a]);return r}({1:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.ComponentSpec=o.lossless.ComponentSpec||function(){this.hSamp=0,this.quantTableSel=0,this.vSamp=0},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.ComponentSpec)},{}],2:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.DataStream=o.lossless.DataStream||function(s,e,t){this.buffer=new Uint8Array(s,e,t),this.index=0},o.lossless.DataStream.prototype.get16=function(){var s=(this.buffer[this.index]<<8)+this.buffer[this.index+1];return this.index+=2,s},o.lossless.DataStream.prototype.get8=function(){var s=this.buffer[this.index];return this.index+=1,s},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.DataStream)},{}],3:[function(s,e,t){var o,r=r||{};r.lossless=r.lossless||{},r.lossless.DataStream=r.lossless.DataStream||(void 0!==s?s("./data-stream.js"):null),r.lossless.HuffmanTable=r.lossless.HuffmanTable||(void 0!==s?s("./huffman-table.js"):null),r.lossless.QuantizationTable=r.lossless.QuantizationTable||(void 0!==s?s("./quantization-table.js"):null),r.lossless.ScanHeader=r.lossless.ScanHeader||(void 0!==s?s("./scan-header.js"):null),r.lossless.FrameHeader=r.lossless.FrameHeader||(void 0!==s?s("./frame-header.js"):null),r.lossless.Utils=r.lossless.Utils||(void 0!==s?s("./utils.js"):null),r.lossless.Decoder=r.lossless.Decoder||function(s,e){this.buffer=s,this.frame=new r.lossless.FrameHeader,this.huffTable=new r.lossless.HuffmanTable,this.quantTable=new r.lossless.QuantizationTable,this.scan=new r.lossless.ScanHeader,this.DU=r.lossless.Utils.createArray(10,4,64),this.HuffTab=r.lossless.Utils.createArray(4,2,12800),this.IDCT_Source=[],this.nBlock=[],this.acTab=r.lossless.Utils.createArray(10,1),this.dcTab=r.lossless.Utils.createArray(10,1),this.qTab=r.lossless.Utils.createArray(10,1),this.marker=0,this.markerIndex=0,this.numComp=0,this.restartInterval=0,this.selection=0,this.xDim=0,this.yDim=0,this.xLoc=0,this.yLoc=0,this.numBytes=0,this.outputData=null,this.restarting=!1,this.mask=0,void 0!==e&&(this.numBytes=e)},r.lossless.Decoder.IDCT_P=[0,5,40,16,45,2,7,42,21,56,8,61,18,47,1,4,41,23,58,13,32,24,37,10,63,17,44,3,6,43,20,57,15,34,29,48,53,26,39,9,60,19,46,22,59,12,33,31,50,55,25,36,11,62,14,35,28,49,52,27,38,30,51,54],r.lossless.Decoder.TABLE=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],r.lossless.Decoder.MAX_HUFFMAN_SUBTREE=50,r.lossless.Decoder.MSB=2147483648,r.lossless.Decoder.RESTART_MARKER_BEGIN=65488,r.lossless.Decoder.RESTART_MARKER_END=65495,r.lossless.Decoder.prototype.decompress=function(s,e,t){return this.decode(s,e,t).buffer},r.lossless.Decoder.prototype.decode=function(s,e,t,o){var i,a,n,l,h=0,c=[],u=[],f=[];if(void 0!==s&&(this.buffer=s),void 0!==o&&(this.numBytes=o),this.stream=new r.lossless.DataStream(this.buffer,e,t),this.buffer=null,this.xLoc=0,this.yLoc=0,65496!==(i=this.stream.get16()))throw new Error("Not a JPEG file");for(i=this.stream.get16();i>>4!=4092||65476===i;){switch(i){case 65476:this.huffTable.read(this.stream,this.HuffTab);break;case 65484:throw new Error("Program doesn't support arithmetic coding. (format throw new IOException)");case 65499:this.quantTable.read(this.stream,r.lossless.Decoder.TABLE);break;case 65501:this.restartInterval=this.readNumber();break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:this.readApp();break;case 65534:this.readComment();break;default:if(i>>8!=255)throw new Error("ERROR: format throw new IOException! (decode)")}i=this.stream.get16()}if(i<65472||i>65479)throw new Error("ERROR: could not handle arithmetic code!");this.frame.read(this.stream),i=this.stream.get16();do{for(;65498!==i;){switch(i){case 65476:this.huffTable.read(this.stream,this.HuffTab);break;case 65484:throw new Error("Program doesn't support arithmetic coding. (format throw new IOException)");case 65499:this.quantTable.read(this.stream,r.lossless.Decoder.TABLE);break;case 65501:this.restartInterval=this.readNumber();break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:this.readApp();break;case 65534:this.readComment();break;default:if(i>>8!=255)throw new Error("ERROR: format throw new IOException! (Parser.decode)")}i=this.stream.get16()}switch(this.precision=this.frame.precision,this.components=this.frame.components,this.numBytes||(this.numBytes=parseInt(Math.ceil(this.precision/8))),1==this.numBytes?this.mask=255:this.mask=65535,this.scan.read(this.stream),this.numComp=this.scan.numComp,this.selection=this.scan.selection,1===this.numBytes?3===this.numComp?(this.getter=this.getValueRGB,this.setter=this.setValueRGB,this.output=this.outputRGB):(this.getter=this.getValue8,this.setter=this.setValue8,this.output=this.outputSingle):(this.getter=this.getValue16,this.setter=this.setValue16,this.output=this.outputSingle),this.selection){case 2:this.selector=this.select2;break;case 3:this.selector=this.select3;break;case 4:this.selector=this.select4;break;case 5:this.selector=this.select5;break;case 6:this.selector=this.select6;break;case 7:this.selector=this.select7;break;default:this.selector=this.select1}for(this.scanComps=this.scan.components,this.quantTables=this.quantTable.quantTables,a=0;a<this.numComp;a+=1)n=this.scanComps[a].scanCompSel,this.qTab[a]=this.quantTables[this.components[n].quantTableSel],this.nBlock[a]=this.components[n].vSamp*this.components[n].hSamp,this.dcTab[a]=this.HuffTab[this.scanComps[a].dcTabSel][0],this.acTab[a]=this.HuffTab[this.scanComps[a].acTabSel][1];for(this.xDim=this.frame.dimX,this.yDim=this.frame.dimY,1==this.numBytes?this.outputData=new Uint8Array(new ArrayBuffer(this.xDim*this.yDim*this.numBytes*this.numComp)):this.outputData=new Uint16Array(new ArrayBuffer(this.xDim*this.yDim*this.numBytes*this.numComp)),h+=1;;){for(u[0]=0,f[0]=0,a=0;a<10;a+=1)c[a]=1<<this.precision-1;if(0===this.restartInterval){for(i=this.decodeUnit(c,u,f);0===i&&this.xLoc<this.xDim&&this.yLoc<this.yDim;)this.output(c),i=this.decodeUnit(c,u,f);break}for(l=0;l<this.restartInterval&&(this.restarting=0==l,i=this.decodeUnit(c,u,f),this.output(c),0===i);l+=1);if(0===i&&(0!==this.markerIndex?(i=65280|this.marker,this.markerIndex=0):i=this.stream.get16()),!(i>=r.lossless.Decoder.RESTART_MARKER_BEGIN&&i<=r.lossless.Decoder.RESTART_MARKER_END))break}65500===i&&1===h&&(this.readNumber(),i=this.stream.get16())}while(65497!==i&&this.xLoc<this.xDim&&this.yLoc<this.yDim&&0===h);return this.outputData},r.lossless.Decoder.prototype.decodeUnit=function(s,e,t){return 1==this.numComp?this.decodeSingle(s,e,t):3==this.numComp?this.decodeRGB(s,e,t):-1},r.lossless.Decoder.prototype.select1=function(s){return this.getPreviousX(s)},r.lossless.Decoder.prototype.select2=function(s){return this.getPreviousY(s)},r.lossless.Decoder.prototype.select3=function(s){return this.getPreviousXY(s)},r.lossless.Decoder.prototype.select4=function(s){return this.getPreviousX(s)+this.getPreviousY(s)-this.getPreviousXY(s)},r.lossless.Decoder.prototype.select5=function(s){return this.getPreviousX(s)+(this.getPreviousY(s)-this.getPreviousXY(s)>>1)},r.lossless.Decoder.prototype.select6=function(s){return this.getPreviousY(s)+(this.getPreviousX(s)-this.getPreviousXY(s)>>1)},r.lossless.Decoder.prototype.select7=function(s){return(this.getPreviousX(s)+this.getPreviousY(s))/2},r.lossless.Decoder.prototype.decodeRGB=function(s,e,t){var o,i,a,n,l,h,c,u;for(s[0]=this.selector(0),s[1]=this.selector(1),s[2]=this.selector(2),l=0;l<this.numComp;l+=1)for(n=this.qTab[l],i=this.acTab[l],a=this.dcTab[l],h=0;h<this.nBlock[l];h+=1){for(c=0;c<this.IDCT_Source.length;c+=1)this.IDCT_Source[c]=0;if((o=this.getHuffmanValue(a,e,t))>=65280)return o;for(s[l]=this.IDCT_Source[0]=s[l]+this.getn(t,o,e,t),this.IDCT_Source[0]*=n[0],u=1;u<64;u+=1){if((o=this.getHuffmanValue(i,e,t))>=65280)return o;if(u+=o>>4,0==(15&o)){if(o>>4==0)break}else this.IDCT_Source[r.lossless.Decoder.IDCT_P[u]]=this.getn(t,15&o,e,t)*n[u]}}return 0},r.lossless.Decoder.prototype.decodeSingle=function(s,e,t){var o,i,a,n;for(this.restarting?(this.restarting=!1,s[0]=1<<this.frame.precision-1):s[0]=this.selector(),i=0;i<this.nBlock[0];i+=1){if((o=this.getHuffmanValue(this.dcTab[0],e,t))>=65280)return o;if((n=(a=this.getn(s,o,e,t))>>8)>=r.lossless.Decoder.RESTART_MARKER_BEGIN&&n<=r.lossless.Decoder.RESTART_MARKER_END)return n;s[0]+=a}return 0},r.lossless.Decoder.prototype.getHuffmanValue=function(s,e,t){var o,i;if(65535,t[0]<8?(e[0]<<=8,255===(i=this.stream.get8())&&(this.marker=this.stream.get8(),0!==this.marker&&(this.markerIndex=9)),e[0]|=i):t[0]-=8,0!=((o=s[e[0]>>t[0]])&r.lossless.Decoder.MSB)){if(0!==this.markerIndex)return this.markerIndex=0,65280|this.marker;e[0]&=65535>>16-t[0],e[0]<<=8,255===(i=this.stream.get8())&&(this.marker=this.stream.get8(),0!==this.marker&&(this.markerIndex=9)),e[0]|=i,o=s[256*(255&o)+(e[0]>>t[0])],t[0]+=8}if(t[0]+=8-(o>>8),t[0]<0)throw new Error(`index=${t[0]} temp=${e[0]} code=${o} in HuffmanValue()`);return t[0]<this.markerIndex?(this.markerIndex=0,65280|this.marker):(e[0]&=65535>>16-t[0],255&o)},r.lossless.Decoder.prototype.getn=function(s,e,t,o){var r,i;if(1,-1,65535,0===e)return 0;if(16===e)return s[0]>=0?-32768:32768;if(o[0]-=e,o[0]>=0){if(o[0]<this.markerIndex&&!this.isLastPixel())return this.markerIndex=0,(65280|this.marker)<<8;r=t[0]>>o[0],t[0]&=65535>>16-o[0]}else{if(t[0]<<=8,255===(i=this.stream.get8())&&(this.marker=this.stream.get8(),0!==this.marker&&(this.markerIndex=9)),t[0]|=i,o[0]+=8,o[0]<0){if(0!==this.markerIndex)return this.markerIndex=0,(65280|this.marker)<<8;t[0]<<=8,255===(i=this.stream.get8())&&(this.marker=this.stream.get8(),0!==this.marker&&(this.markerIndex=9)),t[0]|=i,o[0]+=8}if(o[0]<0)throw new Error(`index=${o[0]} in getn()`);if(o[0]<this.markerIndex)return this.markerIndex=0,(65280|this.marker)<<8;r=t[0]>>o[0],t[0]&=65535>>16-o[0]}return r<1<<e-1&&(r+=1+(-1<<e)),r},r.lossless.Decoder.prototype.getPreviousX=function(s){return this.xLoc>0?this.getter(this.yLoc*this.xDim+this.xLoc-1,s):this.yLoc>0?this.getPreviousY(s):1<<this.frame.precision-1},r.lossless.Decoder.prototype.getPreviousXY=function(s){return this.xLoc>0&&this.yLoc>0?this.getter((this.yLoc-1)*this.xDim+this.xLoc-1,s):this.getPreviousY(s)},r.lossless.Decoder.prototype.getPreviousY=function(s){return this.yLoc>0?this.getter((this.yLoc-1)*this.xDim+this.xLoc,s):this.getPreviousX(s)},r.lossless.Decoder.prototype.isLastPixel=function(){return this.xLoc===this.xDim-1&&this.yLoc===this.yDim-1},r.lossless.Decoder.prototype.outputSingle=function(s){this.xLoc<this.xDim&&this.yLoc<this.yDim&&(this.setter(this.yLoc*this.xDim+this.xLoc,this.mask&s[0]),this.xLoc+=1,this.xLoc>=this.xDim&&(this.yLoc+=1,this.xLoc=0))},r.lossless.Decoder.prototype.outputRGB=function(s){var e=this.yLoc*this.xDim+this.xLoc;this.xLoc<this.xDim&&this.yLoc<this.yDim&&(this.setter(e,s[0],0),this.setter(e,s[1],1),this.setter(e,s[2],2),this.xLoc+=1,this.xLoc>=this.xDim&&(this.yLoc+=1,this.xLoc=0))},r.lossless.Decoder.prototype.setValue8=function(s,e){this.outputData[s]=e},r.lossless.Decoder.prototype.getValue8=function(s){return this.outputData[s]},(o=new ArrayBuffer(2),new DataView(o).setInt16(0,256,!0),256===new Int16Array(o)[0])?(r.lossless.Decoder.prototype.setValue16=r.lossless.Decoder.prototype.setValue8,r.lossless.Decoder.prototype.getValue16=r.lossless.Decoder.prototype.getValue8):(r.lossless.Decoder.prototype.setValue16=function(s,e){this.outputData[s]=(255&e)<<8|e>>8&255},r.lossless.Decoder.prototype.getValue16=function(s){var e=this.outputData[s];return(255&e)<<8|e>>8&255}),r.lossless.Decoder.prototype.setValueRGB=function(s,e,t){this.outputData[3*s+t]=e},r.lossless.Decoder.prototype.getValueRGB=function(s,e){return this.outputData[3*s+e]},r.lossless.Decoder.prototype.readApp=function(){var s=0,e=this.stream.get16();for(s+=2;s<e;)this.stream.get8(),s+=1;return e},r.lossless.Decoder.prototype.readComment=function(){var s,e="",t=0;for(s=this.stream.get16(),t+=2;t<s;)e+=this.stream.get8(),t+=1;return e},r.lossless.Decoder.prototype.readNumber=function(){if(4!==this.stream.get16())throw new Error("ERROR: Define number format throw new IOException [Ld!=4]");return this.stream.get16()},"undefined"!==typeof e&&e.exports&&(e.exports=r.lossless.Decoder)},{"./data-stream.js":2,"./frame-header.js":4,"./huffman-table.js":5,"./quantization-table.js":7,"./scan-header.js":9,"./utils.js":10}],4:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.ComponentSpec=o.lossless.ComponentSpec||(void 0!==s?s("./component-spec.js"):null),o.lossless.DataStream=o.lossless.DataStream||(void 0!==s?s("./data-stream.js"):null),o.lossless.FrameHeader=o.lossless.FrameHeader||function(){this.components=[],this.dimX=0,this.dimY=0,this.numComp=0,this.precision=0},o.lossless.FrameHeader.prototype.read=function(s){var e,t,r,i,a=0;for(e=s.get16(),a+=2,this.precision=s.get8(),a+=1,this.dimY=s.get16(),a+=2,this.dimX=s.get16(),a+=2,this.numComp=s.get8(),a+=1,t=1;t<=this.numComp;t+=1){if(a>e)throw new Error("ERROR: frame format error");if(r=s.get8(),(a+=1)>=e)throw new Error("ERROR: frame format error [c>=Lf]");i=s.get8(),a+=1,this.components[r]||(this.components[r]=new o.lossless.ComponentSpec),this.components[r].hSamp=i>>4,this.components[r].vSamp=15&i,this.components[r].quantTableSel=s.get8(),a+=1}if(a!==e)throw new Error("ERROR: frame format error [Lf!=count]");return 1},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.FrameHeader)},{"./component-spec.js":1,"./data-stream.js":2}],5:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.DataStream=o.lossless.DataStream||(void 0!==s?s("./data-stream.js"):null),o.lossless.Utils=o.lossless.Utils||(void 0!==s?s("./utils.js"):null),o.lossless.HuffmanTable=o.lossless.HuffmanTable||function(){this.l=o.lossless.Utils.createArray(4,2,16),this.th=[],this.v=o.lossless.Utils.createArray(4,2,16,200),this.tc=o.lossless.Utils.createArray(4,2),this.tc[0][0]=0,this.tc[1][0]=0,this.tc[2][0]=0,this.tc[3][0]=0,this.tc[0][1]=0,this.tc[1][1]=0,this.tc[2][1]=0,this.tc[3][1]=0,this.th[0]=0,this.th[1]=0,this.th[2]=0,this.th[3]=0},o.lossless.HuffmanTable.MSB=2147483648,o.lossless.HuffmanTable.prototype.read=function(s,e){var t,o,r,i,a,n,l=0;for(t=s.get16(),l+=2;l<t;){if(l+=1,(r=15&(o=s.get8()))>3)throw new Error("ERROR: Huffman table ID > 3");if((i=o>>4)>2)throw new Error("ERROR: Huffman table [Table class > 2 ]");for(this.th[r]=1,this.tc[r][i]=1,a=0;a<16;a+=1)this.l[r][i][a]=s.get8(),l+=1;for(a=0;a<16;a+=1)for(n=0;n<this.l[r][i][a];n+=1){if(l>t)throw new Error("ERROR: Huffman table format error [count>Lh]");this.v[r][i][a][n]=s.get8(),l+=1}}if(l!==t)throw new Error("ERROR: Huffman table format error [count!=Lf]");for(a=0;a<4;a+=1)for(n=0;n<2;n+=1)0!==this.tc[a][n]&&this.buildHuffTable(e[a][n],this.l[a][n],this.v[a][n]);return 1},o.lossless.HuffmanTable.prototype.buildHuffTable=function(s,e,t){var r,i,a,n,l;for(256,i=0,a=0;a<8;a+=1)for(n=0;n<e[a];n+=1)for(l=0;l<256>>a+1;l+=1)s[i]=t[a][n]|a+1<<8,i+=1;for(a=1;i<256;a+=1,i+=1)s[i]=a|o.lossless.HuffmanTable.MSB;for(r=1,i=0,a=8;a<16;a+=1)for(n=0;n<e[a];n+=1){for(l=0;l<256>>a-7;l+=1)s[256*r+i]=t[a][n]|a+1<<8,i+=1;if(i>=256){if(i>256)throw new Error("ERROR: Huffman table error(1)!");i=0,r+=1}}},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.HuffmanTable)},{"./data-stream.js":2,"./utils.js":10}],6:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.ComponentSpec=o.lossless.ComponentSpec||(void 0!==s?s("./component-spec.js"):null),o.lossless.DataStream=o.lossless.DataStream||(void 0!==s?s("./data-stream.js"):null),o.lossless.Decoder=o.lossless.Decoder||(void 0!==s?s("./decoder.js"):null),o.lossless.FrameHeader=o.lossless.FrameHeader||(void 0!==s?s("./frame-header.js"):null),o.lossless.HuffmanTable=o.lossless.HuffmanTable||(void 0!==s?s("./huffman-table.js"):null),o.lossless.QuantizationTable=o.lossless.QuantizationTable||(void 0!==s?s("./quantization-table.js"):null),o.lossless.ScanComponent=o.lossless.ScanComponent||(void 0!==s?s("./scan-component.js"):null),o.lossless.ScanHeader=o.lossless.ScanHeader||(void 0!==s?s("./scan-header.js"):null),o.lossless.Utils=o.lossless.Utils||(void 0!==s?s("./utils.js"):null),"undefined"!==typeof e&&e.exports&&(e.exports=o)},{"./component-spec.js":1,"./data-stream.js":2,"./decoder.js":3,"./frame-header.js":4,"./huffman-table.js":5,"./quantization-table.js":7,"./scan-component.js":8,"./scan-header.js":9,"./utils.js":10}],7:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.DataStream=o.lossless.DataStream||(void 0!==s?s("./data-stream.js"):null),o.lossless.Utils=o.lossless.Utils||(void 0!==s?s("./utils.js"):null),o.lossless.QuantizationTable=o.lossless.QuantizationTable||function(){this.precision=[],this.tq=[],this.quantTables=o.lossless.Utils.createArray(4,64),this.tq[0]=0,this.tq[1]=0,this.tq[2]=0,this.tq[3]=0},o.lossless.QuantizationTable.enhanceQuantizationTable=function(s,e){var t;for(t=0;t<8;t+=1)s[e[0+t]]*=90,s[e[32+t]]*=90,s[e[16+t]]*=118,s[e[48+t]]*=49,s[e[40+t]]*=71,s[e[8+t]]*=126,s[e[56+t]]*=25,s[e[24+t]]*=106;for(t=0;t<8;t+=1)s[e[0+8*t]]*=90,s[e[4+8*t]]*=90,s[e[2+8*t]]*=118,s[e[6+8*t]]*=49,s[e[5+8*t]]*=71,s[e[1+8*t]]*=126,s[e[7+8*t]]*=25,s[e[3+8*t]]*=106;for(t=0;t<64;t+=1)s[t]>>=6},o.lossless.QuantizationTable.prototype.read=function(s,e){var t,r,i,a,n=0;for(t=s.get16(),n+=2;n<t;){if(n+=1,(i=15&(r=s.get8()))>3)throw new Error("ERROR: Quantization table ID > 3");if(this.precision[i]=r>>4,0===this.precision[i])this.precision[i]=8;else{if(1!==this.precision[i])throw new Error("ERROR: Quantization table precision error");this.precision[i]=16}if(this.tq[i]=1,8===this.precision[i]){for(a=0;a<64;a+=1){if(n>t)throw new Error("ERROR: Quantization table format error");this.quantTables[i][a]=s.get8(),n+=1}o.lossless.QuantizationTable.enhanceQuantizationTable(this.quantTables[i],e)}else{for(a=0;a<64;a+=1){if(n>t)throw new Error("ERROR: Quantization table format error");this.quantTables[i][a]=s.get16(),n+=2}o.lossless.QuantizationTable.enhanceQuantizationTable(this.quantTables[i],e)}}if(n!==t)throw new Error("ERROR: Quantization table error [count!=Lq]");return 1},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.QuantizationTable)},{"./data-stream.js":2,"./utils.js":10}],8:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.ScanComponent=o.lossless.ScanComponent||function(){this.acTabSel=0,this.dcTabSel=0,this.scanCompSel=0},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.ScanComponent)},{}],9:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.DataStream=o.lossless.DataStream||(void 0!==s?s("./data-stream.js"):null),o.lossless.ScanComponent=o.lossless.ScanComponent||(void 0!==s?s("./scan-component.js"):null),o.lossless.ScanHeader=o.lossless.ScanHeader||function(){this.ah=0,this.al=0,this.numComp=0,this.selection=0,this.spectralEnd=0,this.components=[]},o.lossless.ScanHeader.prototype.read=function(s){var e,t,r,i=0;for(e=s.get16(),i+=2,this.numComp=s.get8(),i+=1,t=0;t<this.numComp;t+=1){if(this.components[t]=new o.lossless.ScanComponent,i>e)throw new Error("ERROR: scan header format error");this.components[t].scanCompSel=s.get8(),i+=1,r=s.get8(),i+=1,this.components[t].dcTabSel=r>>4,this.components[t].acTabSel=15&r}if(this.selection=s.get8(),i+=1,this.spectralEnd=s.get8(),i+=1,r=s.get8(),this.ah=r>>4,this.al=15&r,(i+=1)!==e)throw new Error("ERROR: scan header format error [count!=Ns]");return 1},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.ScanHeader)},{"./data-stream.js":2,"./scan-component.js":8}],10:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.Utils=o.lossless.Utils||{},o.lossless.Utils.createArray=function(s){var e=new Array(s||0),t=s;if(arguments.length>1)for(var r=Array.prototype.slice.call(arguments,1);t--;)e[s-1-t]=o.lossless.Utils.createArray.apply(this,r);return e},o.lossless.Utils.makeCRCTable=function(){for(var s,e=[],t=0;t<256;t++){s=t;for(var o=0;o<8;o++)s=1&s?3988292384^s>>>1:s>>>1;e[t]=s}return e},o.lossless.Utils.crc32=function(s){for(var e=new Uint8Array(s.buffer),t=o.lossless.Utils.crcTable||(o.lossless.Utils.crcTable=o.lossless.Utils.makeCRCTable()),r=-1,i=0;i<e.length;i++)r=r>>>8^t[255&(r^e[i])];return(-1^r)>>>0},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.Utils)},{}]},{},[6])(6)}))}}]);
|
|
2
|
+
//# sour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2I,EAGhB,OAAOsB,GAGTpK,EAAKgB,SAASmB,MAAMkI,MAAQ,SAAUC,GAQpC,IAPA,IAAIC,EAAY,IAAI9I,WAAW6I,EAAS9I,QACpC4I,EACFpK,EAAKgB,SAASmB,MAAMiI,WACnBpK,EAAKgB,SAASmB,MAAMiI,SACnBpK,EAAKgB,SAASmB,MAAMgI,gBACpBK,GAAM,EAED9J,EAAI,EAAGA,EAAI6J,EAAUxJ,OAAQL,IACpC8J,EAAOA,IAAQ,EAAKJ,EAAgC,KAAtBI,EAAMD,EAAU7J,KAGhD,QAAe,EAAP8J,KAAc,GAOL,qBAFK/K,GAEUA,EAAOD,UACvCC,EAAOD,QAAUQ,EAAKgB,SAASmB,QAGnC,KAGJ,GACA,CAAC,GAl/DI,CAm/DL","sources":["webpack://cornerstoneDICOMImageLoader/../codecs/jpegLossless.js"],"sourcesContent":["/* eslint-disable */\n\n(function (f) {\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = f();\n } else if (typeof define === 'function' && define.amd) {\n define([], f);\n } else {\n var g;\n\n if (typeof window !== 'undefined') {\n g = window;\n } else if (typeof global !== 'undefined') {\n g = global;\n } else if (typeof self !== 'undefined') {\n g = self;\n } else {\n g = this;\n }\n g.jpeg = f();\n }\n})(function () {\n var define, module, exports;\n\n return (function e(t, n, r) {\n function s(o, u) {\n if (!n[o]) {\n if (!t[o]) {\n var a = typeof require === 'function' && require;\n\n if (!u && a) {\n return a(o, !0);\n }\n if (i) {\n return i(o, !0);\n }\n var f = new Error(\"Cannot find module '\" + o + \"'\");\n\n throw ((f.code = 'MODULE_NOT_FOUND'), f);\n }\n var l = (n[o] = { exports: {} });\n\n t[o][0].call(\n l.exports,\n function (e) {\n var n = t[o][1][e];\n\n return s(n ? n : e);\n },\n l,\n l.exports,\n e,\n t,\n n,\n r\n );\n }\n\n return n[o].exports;\n }\n var i = typeof require === 'function' && require;\n\n for (var o = 0; o < r.length; o++) {\n s(r[o]);\n }\n\n return s;\n })(\n {\n 1: [\n function (require, module, exports) {\n /*\n * Copyright (C) 2015 Michael Martinez\n * Changes: Added support for selection values 2-7, fixed minor bugs &\n * warnings, split into multiple class files, and general clean up.\n *\n * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.\n */\n\n /*\n * Copyright (C) Helmut Dersch\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n /*jslint browser: true, node: true */\n /*global require, module */\n\n /*** Imports ***/\n var jpeg = jpeg || {};\n\n jpeg.lossless = jpeg.lossless || {};\n\n /*** Constructor ***/\n jpeg.lossless.ComponentSpec =\n jpeg.lossless.ComponentSpec ||\n function () {\n this.hSamp = 0; // Horizontal sampling factor\n this.quantTableSel = 0; // Quantization table destination selector\n this.vSamp = 0; // Vertical\n };\n\n /*** Exports ***/\n\n var moduleType = typeof module;\n\n if (moduleType !== 'undefined' && module.exports) {\n module.exports = jpeg.lossless.ComponentSpec;\n }\n },\n {},\n ],\n 2: [\n function (require, module, exports) {\n /*\n * Copyright (C) 2015 Michael Martinez\n * Changes: Added support for selection values 2-7, fixed minor bugs &\n * warnings, split into multiple class files, and general clean up.\n *\n * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.\n */\n\n /*\n * Copyright (C) Helmut Dersch\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n /*jslint browser: true, node: true */\n /*global require, module */\n /*** Imports ***/\n var jpeg = jpeg || {};\n\n jpeg.lossless = jpeg.lossless || {};\n\n /*** Constructor ***/\n jpeg.lossless.DataStream =\n jpeg.lossless.DataStream ||\n function (data, offset, length) {\n // Note: DataView is much slower than Int8Array\n // this.buffer = new DataView(data, offset, length);\n this.buffer = new Uint8Array(data, offset, length);\n this.index = 0;\n };\n jpeg.lossless.DataStream.prototype.get16 = function () {\n // var value = this.buffer.getUint16(this.index, false);\n var value =\n (this.buffer[this.index] << 8) + this.buffer[this.index + 1]; // DataView is big-endian by default\n\n this.index += 2;\n\n return value;\n };\n jpeg.lossless.DataStream.prototype.get8 = function () {\n // var value = this.buffer.getUint8(this.index);\n var value = this.buffer[this.index];\n\n this.index += 1;\n\n return value;\n };\n\n /*** Exports ***/\n\n var moduleType = typeof module;\n\n if (moduleType !== 'undefined' && module.exports) {\n module.exports = jpeg.lossless.DataStream;\n }\n },\n {},\n ],\n 3: [\n function (require, module, exports) {\n /*\n * Copyright (C) 2015 Michael Martinez\n * Changes: Added support for selection values 2-7, fixed minor bugs &\n * warnings, split into multiple class files, and general clean up.\n *\n * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.\n */\n\n /*\n * Copyright (C) Helmut Dersch\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n /*jslint browser: true, node: true */\n /*global require, module */\n /*** Imports ***/\n var jpeg = jpeg || {};\n\n jpeg.lossless = jpeg.lossless || {};\n jpeg.lossless.DataStream =\n jpeg.lossless.DataStream ||\n (typeof require !== 'undefined'\n ? require('./data-stream.js')\n : null);\n jpeg.lossless.HuffmanTable =\n jpeg.lossless.HuffmanTable ||\n (typeof require !== 'undefined'\n ? require('./huffman-table.js')\n : null);\n jpeg.lossless.QuantizationTable =\n jpeg.lossless.QuantizationTable ||\n (typeof require !== 'undefined'\n ? require('./quantization-table.js')\n : null);\n jpeg.lossless.ScanHeader =\n jpeg.lossless.ScanHeader ||\n (typeof require !== 'undefined'\n ? require('./scan-header.js')\n : null);\n jpeg.lossless.FrameHeader =\n jpeg.lossless.FrameHeader ||\n (typeof require !== 'undefined'\n ? require('./frame-header.js')\n : null);\n jpeg.lossless.Utils =\n jpeg.lossless.Utils ||\n (typeof require !== 'undefined' ? require('./utils.js') : null);\n\n /*** Constructor ***/\n\n /**\n * The Decoder constructor.\n * @property {number} xDim - size of x dimension\n * @property {number} yDim - size of y dimension\n * @property {number} numComp - number of components\n * @property {number} numBytes - number of bytes per component\n * @type {Function}\n */\n jpeg.lossless.Decoder =\n jpeg.lossless.Decoder ||\n function (buffer, numBytes) {\n this.buffer = buffer;\n this.frame = new jpeg.lossless.FrameHeader();\n this.huffTable = new jpeg.lossless.HuffmanTable();\n this.quantTable = new jpeg.lossless.QuantizationTable();\n this.scan = new jpeg.lossless.ScanHeader();\n this.DU = jpeg.lossless.Utils.createArray(10, 4, 64); // at most 10 data units in a MCU, at most 4 data units in one component\n this.HuffTab = jpeg.lossless.Utils.createArray(4, 2, 50 * 256);\n this.IDCT_Source = [];\n this.nBlock = []; // number of blocks in the i-th Comp in a scan\n this.acTab = jpeg.lossless.Utils.createArray(10, 1); // ac HuffTab for the i-th Comp in a scan\n this.dcTab = jpeg.lossless.Utils.createArray(10, 1); // dc HuffTab for the i-th Comp in a scan\n this.qTab = jpeg.lossless.Utils.createArray(10, 1); // quantization table for the i-th Comp in a scan\n this.marker = 0;\n this.markerIndex = 0;\n this.numComp = 0;\n this.restartInterval = 0;\n this.selection = 0;\n this.xDim = 0;\n this.yDim = 0;\n this.xLoc = 0;\n this.yLoc = 0;\n this.numBytes = 0;\n this.outputData = null;\n this.restarting = false;\n this.mask = 0;\n\n if (typeof numBytes !== 'undefined') {\n this.numBytes = numBytes;\n }\n };\n\n /*** Static Pseudo-constants ***/\n\n jpeg.lossless.Decoder.IDCT_P = [\n 0, 5, 40, 16, 45, 2, 7, 42, 21, 56, 8, 61, 18, 47, 1, 4, 41, 23, 58,\n 13, 32, 24, 37, 10, 63, 17, 44, 3, 6, 43, 20, 57, 15, 34, 29, 48,\n 53, 26, 39, 9, 60, 19, 46, 22, 59, 12, 33, 31, 50, 55, 25, 36, 11,\n 62, 14, 35, 28, 49, 52, 27, 38, 30, 51, 54,\n ];\n jpeg.lossless.Decoder.TABLE = [\n 0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42, 3, 8, 12,\n 17, 25, 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53, 10, 19, 23, 32,\n 39, 45, 52, 54, 20, 22, 33, 38, 46, 51, 55, 60, 21, 34, 37, 47, 50,\n 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63,\n ];\n jpeg.lossless.Decoder.MAX_HUFFMAN_SUBTREE = 50;\n jpeg.lossless.Decoder.MSB = 0x80000000;\n jpeg.lossless.Decoder.RESTART_MARKER_BEGIN = 0xffd0;\n jpeg.lossless.Decoder.RESTART_MARKER_END = 0xffd7;\n\n /*** Prototype Methods ***/\n\n /**\n * Returns decompressed data.\n * @param {ArrayBuffer} buffer\n * @param {number} [offset]\n * @param {number} [length]\n * @returns {ArrayBufer}\n */\n jpeg.lossless.Decoder.prototype.decompress = function (\n buffer,\n offset,\n length\n ) {\n return this.decode(buffer, offset, length).buffer;\n };\n jpeg.lossless.Decoder.prototype.decode = function (\n buffer,\n offset,\n length,\n numBytes\n ) {\n /*jslint bitwise: true */\n\n var current,\n scanNum = 0,\n pred = [],\n i,\n compN,\n temp = [],\n index = [],\n mcuNum;\n\n if (typeof buffer !== 'undefined') {\n this.buffer = buffer;\n }\n\n if (typeof numBytes !== 'undefined') {\n this.numBytes = numBytes;\n }\n\n this.stream = new jpeg.lossless.DataStream(\n this.buffer,\n offset,\n length\n );\n this.buffer = null;\n\n this.xLoc = 0;\n this.yLoc = 0;\n current = this.stream.get16();\n\n if (current !== 0xffd8) {\n // SOI\n throw new Error('Not a JPEG file');\n }\n\n current = this.stream.get16();\n\n while (current >> 4 !== 0x0ffc || current === 0xffc4) {\n // SOF 0~15\n switch (current) {\n case 0xffc4: // DHT\n this.huffTable.read(this.stream, this.HuffTab);\n break;\n case 0xffcc: // DAC\n throw new Error(\n \"Program doesn't support arithmetic coding. (format throw new IOException)\"\n );\n case 0xffdb:\n this.quantTable.read(\n this.stream,\n jpeg.lossless.Decoder.TABLE\n );\n break;\n case 0xffdd:\n this.restartInterval = this.readNumber();\n break;\n case 0xffe0:\n case 0xffe1:\n case 0xffe2:\n case 0xffe3:\n case 0xffe4:\n case 0xffe5:\n case 0xffe6:\n case 0xffe7:\n case 0xffe8:\n case 0xffe9:\n case 0xffea:\n case 0xffeb:\n case 0xffec:\n case 0xffed:\n case 0xffee:\n case 0xffef:\n this.readApp();\n break;\n case 0xfffe:\n this.readComment();\n break;\n default:\n if (current >> 8 !== 0xff) {\n throw new Error(\n 'ERROR: format throw new IOException! (decode)'\n );\n }\n }\n\n current = this.stream.get16();\n }\n\n if (current < 0xffc0 || current > 0xffc7) {\n throw new Error('ERROR: could not handle arithmetic code!');\n }\n\n this.frame.read(this.stream);\n current = this.stream.get16();\n\n do {\n while (current !== 0x0ffda) {\n // SOS\n switch (current) {\n case 0xffc4: // DHT\n this.huffTable.read(this.stream, this.HuffTab);\n break;\n case 0xffcc: // DAC\n throw new Error(\n \"Program doesn't support arithmetic coding. (format throw new IOException)\"\n );\n case 0xffdb:\n this.quantTable.read(\n this.stream,\n jpeg.lossless.Decoder.TABLE\n );\n break;\n case 0xffdd:\n this.restartInterval = this.readNumber();\n break;\n case 0xffe0:\n case 0xffe1:\n case 0xffe2:\n case 0xffe3:\n case 0xffe4:\n case 0xffe5:\n case 0xffe6:\n case 0xffe7:\n case 0xffe8:\n case 0xffe9:\n case 0xffea:\n case 0xffeb:\n case 0xffec:\n case 0xffed:\n case 0xffee:\n case 0xffef:\n this.readApp();\n break;\n case 0xfffe:\n this.readComment();\n break;\n default:\n if (current >> 8 !== 0xff) {\n throw new Error(\n 'ERROR: format throw new IOException! (Parser.decode)'\n );\n }\n }\n\n current = this.stream.get16();\n }\n\n this.precision = this.frame.precision;\n this.components = this.frame.components;\n\n if (!this.numBytes) {\n this.numBytes = parseInt(Math.ceil(this.precision / 8));\n }\n\n if (this.numBytes == 1) {\n this.mask = 0xff;\n } else {\n this.mask = 0xffff;\n }\n\n this.scan.read(this.stream);\n this.numComp = this.scan.numComp;\n this.selection = this.scan.selection;\n\n if (this.numBytes === 1) {\n if (this.numComp === 3) {\n this.getter = this.getValueRGB;\n this.setter = this.setValueRGB;\n this.output = this.outputRGB;\n } else {\n this.getter = this.getValue8;\n this.setter = this.setValue8;\n this.output = this.outputSingle;\n }\n } else {\n this.getter = this.getValue16;\n this.setter = this.setValue16;\n this.output = this.outputSingle;\n }\n\n switch (this.selection) {\n case 2:\n this.selector = this.select2;\n break;\n case 3:\n this.selector = this.select3;\n break;\n case 4:\n this.selector = this.select4;\n break;\n case 5:\n this.selector = this.select5;\n break;\n case 6:\n this.selector = this.select6;\n break;\n case 7:\n this.selector = this.select7;\n break;\n default:\n this.selector = this.select1;\n break;\n }\n\n this.scanComps = this.scan.components;\n this.quantTables = this.quantTable.quantTables;\n\n for (i = 0; i < this.numComp; i += 1) {\n compN = this.scanComps[i].scanCompSel;\n this.qTab[i] =\n this.quantTables[this.components[compN].quantTableSel];\n this.nBlock[i] =\n this.components[compN].vSamp * this.components[compN].hSamp;\n this.dcTab[i] = this.HuffTab[this.scanComps[i].dcTabSel][0];\n this.acTab[i] = this.HuffTab[this.scanComps[i].acTabSel][1];\n }\n\n this.xDim = this.frame.dimX;\n this.yDim = this.frame.dimY;\n if (this.numBytes == 1) {\n this.outputData = new Uint8Array(\n new ArrayBuffer(\n this.xDim * this.yDim * this.numBytes * this.numComp\n )\n );\n } else {\n this.outputData = new Uint16Array(\n new ArrayBuffer(\n this.xDim * this.yDim * this.numBytes * this.numComp\n )\n );\n }\n\n scanNum += 1;\n\n while (true) {\n // Decode one scan\n temp[0] = 0;\n index[0] = 0;\n\n for (i = 0; i < 10; i += 1) {\n pred[i] = 1 << (this.precision - 1);\n }\n\n if (this.restartInterval === 0) {\n current = this.decodeUnit(pred, temp, index);\n\n while (\n current === 0 &&\n this.xLoc < this.xDim &&\n this.yLoc < this.yDim\n ) {\n this.output(pred);\n current = this.decodeUnit(pred, temp, index);\n }\n\n break; //current=MARKER\n }\n\n for (mcuNum = 0; mcuNum < this.restartInterval; mcuNum += 1) {\n this.restarting = mcuNum == 0;\n current = this.decodeUnit(pred, temp, index);\n this.output(pred);\n\n if (current !== 0) {\n break;\n }\n }\n\n if (current === 0) {\n if (this.markerIndex !== 0) {\n current = 0xff00 | this.marker;\n this.markerIndex = 0;\n } else {\n current = this.stream.get16();\n }\n }\n\n if (\n !(\n current >= jpeg.lossless.Decoder.RESTART_MARKER_BEGIN &&\n current <= jpeg.lossless.Decoder.RESTART_MARKER_END\n )\n ) {\n break; //current=MARKER\n }\n }\n\n if (current === 0xffdc && scanNum === 1) {\n //DNL\n this.readNumber();\n current = this.stream.get16();\n }\n } while (\n current !== 0xffd9 &&\n this.xLoc < this.xDim &&\n this.yLoc < this.yDim &&\n scanNum === 0\n );\n\n return this.outputData;\n };\n jpeg.lossless.Decoder.prototype.decodeUnit = function (\n prev,\n temp,\n index\n ) {\n if (this.numComp == 1) {\n return this.decodeSingle(prev, temp, index);\n } else if (this.numComp == 3) {\n return this.decodeRGB(prev, temp, index);\n }\n\n return -1;\n };\n jpeg.lossless.Decoder.prototype.select1 = function (compOffset) {\n return this.getPreviousX(compOffset);\n };\n jpeg.lossless.Decoder.prototype.select2 = function (compOffset) {\n return this.getPreviousY(compOffset);\n };\n jpeg.lossless.Decoder.prototype.select3 = function (compOffset) {\n return this.getPreviousXY(compOffset);\n };\n jpeg.lossless.Decoder.prototype.select4 = function (compOffset) {\n return (\n this.getPreviousX(compOffset) +\n this.getPreviousY(compOffset) -\n this.getPreviousXY(compOffset)\n );\n };\n jpeg.lossless.Decoder.prototype.select5 = function (compOffset) {\n return (\n this.getPreviousX(compOffset) +\n ((this.getPreviousY(compOffset) -\n this.getPreviousXY(compOffset)) >>\n 1)\n );\n };\n jpeg.lossless.Decoder.prototype.select6 = function (compOffset) {\n return (\n this.getPreviousY(compOffset) +\n ((this.getPreviousX(compOffset) -\n this.getPreviousXY(compOffset)) >>\n 1)\n );\n };\n jpeg.lossless.Decoder.prototype.select7 = function (compOffset) {\n return (\n (this.getPreviousX(compOffset) + this.getPreviousY(compOffset)) /\n 2\n );\n };\n jpeg.lossless.Decoder.prototype.decodeRGB = function (\n prev,\n temp,\n index\n ) {\n /*jslint bitwise: true */\n\n var value, actab, dctab, qtab, ctrC, i, k, j;\n\n prev[0] = this.selector(0);\n prev[1] = this.selector(1);\n prev[2] = this.selector(2);\n\n for (ctrC = 0; ctrC < this.numComp; ctrC += 1) {\n qtab = this.qTab[ctrC];\n actab = this.acTab[ctrC];\n dctab = this.dcTab[ctrC];\n for (i = 0; i < this.nBlock[ctrC]; i += 1) {\n for (k = 0; k < this.IDCT_Source.length; k += 1) {\n this.IDCT_Source[k] = 0;\n }\n\n value = this.getHuffmanValue(dctab, temp, index);\n\n if (value >= 0xff00) {\n return value;\n }\n\n prev[ctrC] = this.IDCT_Source[0] =\n prev[ctrC] + this.getn(index, value, temp, index);\n this.IDCT_Source[0] *= qtab[0];\n\n for (j = 1; j < 64; j += 1) {\n value = this.getHuffmanValue(actab, temp, index);\n\n if (value >= 0xff00) {\n return value;\n }\n\n j += value >> 4;\n\n if ((value & 0x0f) === 0) {\n if (value >> 4 === 0) {\n break;\n }\n } else {\n this.IDCT_Source[jpeg.lossless.Decoder.IDCT_P[j]] =\n this.getn(index, value & 0x0f, temp, index) * qtab[j];\n }\n }\n }\n }\n\n return 0;\n };\n jpeg.lossless.Decoder.prototype.decodeSingle = function (\n prev,\n temp,\n index\n ) {\n /*jslint bitwise: true */\n\n var value, i, n, nRestart;\n\n if (this.restarting) {\n this.restarting = false;\n prev[0] = 1 << (this.frame.precision - 1);\n } else {\n prev[0] = this.selector();\n }\n\n for (i = 0; i < this.nBlock[0]; i += 1) {\n value = this.getHuffmanValue(this.dcTab[0], temp, index);\n if (value >= 0xff00) {\n return value;\n }\n\n n = this.getn(prev, value, temp, index);\n nRestart = n >> 8;\n\n if (\n nRestart >= jpeg.lossless.Decoder.RESTART_MARKER_BEGIN &&\n nRestart <= jpeg.lossless.Decoder.RESTART_MARKER_END\n ) {\n return nRestart;\n }\n\n prev[0] += n;\n }\n\n return 0;\n };\n // Huffman table for fast search: (HuffTab) 8-bit Look up table 2-layer search architecture, 1st-layer represent 256 node (8 bits) if codeword-length > 8\n // bits, then the entry of 1st-layer = (# of 2nd-layer table) | MSB and it is stored in the 2nd-layer Size of tables in each layer are 256.\n // HuffTab[*][*][0-256] is always the only 1st-layer table.\n //\n // An entry can be: (1) (# of 2nd-layer table) | MSB , for code length > 8 in 1st-layer (2) (Code length) << 8 | HuffVal\n //\n // HuffmanValue(table HuffTab[x][y] (ex) HuffmanValue(HuffTab[1][0],...)\n // ):\n // return: Huffman Value of table\n // 0xFF?? if it receives a MARKER\n // Parameter: table HuffTab[x][y] (ex) HuffmanValue(HuffTab[1][0],...)\n // temp temp storage for remainded bits\n // index index to bit of temp\n // in FILE pointer\n // Effect:\n // temp store new remainded bits\n // index change to new index\n // in change to new position\n // NOTE:\n // Initial by temp=0; index=0;\n // NOTE: (explain temp and index)\n // temp: is always in the form at calling time or returning time\n // | byte 4 | byte 3 | byte 2 | byte 1 |\n // | 0 | 0 | 00000000 | 00000??? | if not a MARKER\n // ^index=3 (from 0 to 15)\n // 321\n // NOTE (marker and marker_index):\n // If get a MARKER from 'in', marker=the low-byte of the MARKER\n // and marker_index=9\n // If marker_index=9 then index is always > 8, or HuffmanValue()\n // will not be called\n jpeg.lossless.Decoder.prototype.getHuffmanValue = function (\n table,\n temp,\n index\n ) {\n /*jslint bitwise: true */\n\n var code, input, mask;\n\n mask = 0xffff;\n\n if (index[0] < 8) {\n temp[0] <<= 8;\n input = this.stream.get8();\n if (input === 0xff) {\n this.marker = this.stream.get8();\n if (this.marker !== 0) {\n this.markerIndex = 9;\n }\n }\n temp[0] |= input;\n } else {\n index[0] -= 8;\n }\n\n code = table[temp[0] >> index[0]];\n\n if ((code & jpeg.lossless.Decoder.MSB) !== 0) {\n if (this.markerIndex !== 0) {\n this.markerIndex = 0;\n\n return 0xff00 | this.marker;\n }\n\n temp[0] &= mask >> (16 - index[0]);\n temp[0] <<= 8;\n input = this.stream.get8();\n\n if (input === 0xff) {\n this.marker = this.stream.get8();\n if (this.marker !== 0) {\n this.markerIndex = 9;\n }\n }\n\n temp[0] |= input;\n code = table[(code & 0xff) * 256 + (temp[0] >> index[0])];\n index[0] += 8;\n }\n\n index[0] += 8 - (code >> 8);\n\n if (index[0] < 0) {\n throw new Error(\n `index=${index[0]} temp=${temp[0]} code=${code} in HuffmanValue()`\n );\n }\n\n if (index[0] < this.markerIndex) {\n this.markerIndex = 0;\n\n return 0xff00 | this.marker;\n }\n\n temp[0] &= mask >> (16 - index[0]);\n\n return code & 0xff;\n };\n jpeg.lossless.Decoder.prototype.getn = function (\n PRED,\n n,\n temp,\n index\n ) {\n /*jslint bitwise: true */\n\n var result, one, n_one, mask, input;\n\n one = 1;\n n_one = -1;\n mask = 0xffff;\n\n if (n === 0) {\n return 0;\n }\n\n if (n === 16) {\n if (PRED[0] >= 0) {\n return -32768;\n }\n\n return 32768;\n }\n\n index[0] -= n;\n\n if (index[0] >= 0) {\n if (index[0] < this.markerIndex && !this.isLastPixel()) {\n // this was corrupting the last pixel in some cases\n this.markerIndex = 0;\n\n return (0xff00 | this.marker) << 8;\n }\n\n result = temp[0] >> index[0];\n temp[0] &= mask >> (16 - index[0]);\n } else {\n temp[0] <<= 8;\n input = this.stream.get8();\n\n if (input === 0xff) {\n this.marker = this.stream.get8();\n if (this.marker !== 0) {\n this.markerIndex = 9;\n }\n }\n\n temp[0] |= input;\n index[0] += 8;\n\n if (index[0] < 0) {\n if (this.markerIndex !== 0) {\n this.markerIndex = 0;\n\n return (0xff00 | this.marker) << 8;\n }\n\n temp[0] <<= 8;\n input = this.stream.get8();\n\n if (input === 0xff) {\n this.marker = this.stream.get8();\n if (this.marker !== 0) {\n this.markerIndex = 9;\n }\n }\n\n temp[0] |= input;\n index[0] += 8;\n }\n\n if (index[0] < 0) {\n throw new Error(`index=${index[0]} in getn()`);\n }\n\n if (index[0] < this.markerIndex) {\n this.markerIndex = 0;\n\n return (0xff00 | this.marker) << 8;\n }\n\n result = temp[0] >> index[0];\n temp[0] &= mask >> (16 - index[0]);\n }\n\n if (result < one << (n - 1)) {\n result += (n_one << n) + 1;\n }\n\n return result;\n };\n jpeg.lossless.Decoder.prototype.getPreviousX = function (compOffset) {\n /*jslint bitwise: true */\n\n if (this.xLoc > 0) {\n return this.getter(\n this.yLoc * this.xDim + this.xLoc - 1,\n compOffset\n );\n } else if (this.yLoc > 0) {\n return this.getPreviousY(compOffset);\n }\n\n return 1 << (this.frame.precision - 1);\n };\n\n jpeg.lossless.Decoder.prototype.getPreviousXY = function (\n compOffset\n ) {\n /*jslint bitwise: true */\n\n if (this.xLoc > 0 && this.yLoc > 0) {\n return this.getter(\n (this.yLoc - 1) * this.xDim + this.xLoc - 1,\n compOffset\n );\n }\n\n return this.getPreviousY(compOffset);\n };\n jpeg.lossless.Decoder.prototype.getPreviousY = function (compOffset) {\n /*jslint bitwise: true */\n\n if (this.yLoc > 0) {\n return this.getter(\n (this.yLoc - 1) * this.xDim + this.xLoc,\n compOffset\n );\n }\n\n return this.getPreviousX(compOffset);\n };\n jpeg.lossless.Decoder.prototype.isLastPixel = function () {\n return this.xLoc === this.xDim - 1 && this.yLoc === this.yDim - 1;\n };\n jpeg.lossless.Decoder.prototype.outputSingle = function (PRED) {\n if (this.xLoc < this.xDim && this.yLoc < this.yDim) {\n this.setter(\n this.yLoc * this.xDim + this.xLoc,\n this.mask & PRED[0]\n );\n\n this.xLoc += 1;\n\n if (this.xLoc >= this.xDim) {\n this.yLoc += 1;\n this.xLoc = 0;\n }\n }\n };\n jpeg.lossless.Decoder.prototype.outputRGB = function (PRED) {\n var offset = this.yLoc * this.xDim + this.xLoc;\n\n if (this.xLoc < this.xDim && this.yLoc < this.yDim) {\n this.setter(offset, PRED[0], 0);\n this.setter(offset, PRED[1], 1);\n this.setter(offset, PRED[2], 2);\n\n this.xLoc += 1;\n\n if (this.xLoc >= this.xDim) {\n this.yLoc += 1;\n this.xLoc = 0;\n }\n }\n };\n\n jpeg.lossless.Decoder.prototype.setValue8 = function (index, val) {\n this.outputData[index] = val;\n };\n\n jpeg.lossless.Decoder.prototype.getValue8 = function (index) {\n return this.outputData[index]; // mask should not be necessary because outputData is either Int8Array or Int16Array\n };\n\n var littleEndian = (function () {\n var buffer = new ArrayBuffer(2);\n\n new DataView(buffer).setInt16(0, 256, true /* littleEndian */);\n // Int16Array uses the platform's endianness.\n return new Int16Array(buffer)[0] === 256;\n })();\n\n if (littleEndian) {\n // just reading from an array is fine then. Int16Array will use platform endianness.\n jpeg.lossless.Decoder.prototype.setValue16 =\n jpeg.lossless.Decoder.prototype.setValue8;\n jpeg.lossless.Decoder.prototype.getValue16 =\n jpeg.lossless.Decoder.prototype.getValue8;\n } else {\n // If platform is big-endian, we will need to convert to little-endian\n jpeg.lossless.Decoder.prototype.setValue16 = function (index, val) {\n this.outputData[index] =\n ((val & 0xff) << 8) | ((val >> 8) & 0xff);\n };\n\n jpeg.lossless.Decoder.prototype.getValue16 = function (index) {\n var val = this.outputData[index];\n\n return ((val & 0xff) << 8) | ((val >> 8) & 0xff);\n };\n }\n\n jpeg.lossless.Decoder.prototype.setValueRGB = function (\n index,\n val,\n compOffset\n ) {\n // this.outputData.setUint8(index * 3 + compOffset, val);\n this.outputData[index * 3 + compOffset] = val;\n };\n\n jpeg.lossless.Decoder.prototype.getValueRGB = function (\n index,\n compOffset\n ) {\n // return this.outputData.getUint8(index * 3 + compOffset);\n return this.outputData[index * 3 + compOffset];\n };\n jpeg.lossless.Decoder.prototype.readApp = function () {\n var count = 0,\n length = this.stream.get16();\n\n count += 2;\n\n while (count < length) {\n this.stream.get8();\n count += 1;\n }\n\n return length;\n };\n jpeg.lossless.Decoder.prototype.readComment = function () {\n var sb = '',\n count = 0,\n length;\n\n length = this.stream.get16();\n count += 2;\n\n while (count < length) {\n sb += this.stream.get8();\n count += 1;\n }\n\n return sb;\n };\n jpeg.lossless.Decoder.prototype.readNumber = function () {\n var Ld = this.stream.get16();\n\n if (Ld !== 4) {\n throw new Error(\n 'ERROR: Define number format throw new IOException [Ld!=4]'\n );\n }\n\n return this.stream.get16();\n };\n /*** Exports ***/\n\n var moduleType = typeof module;\n\n if (moduleType !== 'undefined' && module.exports) {\n module.exports = jpeg.lossless.Decoder;\n }\n },\n {\n './data-stream.js': 2,\n './frame-header.js': 4,\n './huffman-table.js': 5,\n './quantization-table.js': 7,\n './scan-header.js': 9,\n './utils.js': 10,\n },\n ],\n 4: [\n function (require, module, exports) {\n /*\n * Copyright (C) 2015 Michael Martinez\n * Changes: Added support for selection values 2-7, fixed minor bugs &\n * warnings, split into multiple class files, and general clean up.\n *\n * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.\n */\n\n /*\n * Copyright (C) Helmut Dersch\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n /*jslint browser: true, node: true */\n /*global require, module */\n /*** Imports ***/\n var jpeg = jpeg || {};\n\n jpeg.lossless = jpeg.lossless || {};\n jpeg.lossless.ComponentSpec =\n jpeg.lossless.ComponentSpec ||\n (typeof require !== 'undefined'\n ? require('./component-spec.js')\n : null);\n jpeg.lossless.DataStream =\n jpeg.lossless.DataStream ||\n (typeof require !== 'undefined'\n ? require('./data-stream.js')\n : null);\n\n /*** Constructor ***/\n jpeg.lossless.FrameHeader =\n jpeg.lossless.FrameHeader ||\n function () {\n this.components = []; // Components\n this.dimX = 0; // Number of samples per line\n this.dimY = 0; // Number of lines\n this.numComp = 0; // Number of component in the frame\n this.precision = 0; // Sample Precision (from the original image)\n };\n /*** Prototype Methods ***/\n\n jpeg.lossless.FrameHeader.prototype.read = function (data) {\n /*jslint bitwise: true */\n\n var count = 0,\n length,\n i,\n c,\n temp;\n\n length = data.get16();\n count += 2;\n\n this.precision = data.get8();\n count += 1;\n\n this.dimY = data.get16();\n count += 2;\n\n this.dimX = data.get16();\n count += 2;\n\n this.numComp = data.get8();\n count += 1;\n for (i = 1; i <= this.numComp; i += 1) {\n if (count > length) {\n throw new Error('ERROR: frame format error');\n }\n\n c = data.get8();\n count += 1;\n\n if (count >= length) {\n throw new Error('ERROR: frame format error [c>=Lf]');\n }\n\n temp = data.get8();\n count += 1;\n\n if (!this.components[c]) {\n this.components[c] = new jpeg.lossless.ComponentSpec();\n }\n\n this.components[c].hSamp = temp >> 4;\n this.components[c].vSamp = temp & 0x0f;\n this.components[c].quantTableSel = data.get8();\n count += 1;\n }\n\n if (count !== length) {\n throw new Error('ERROR: frame format error [Lf!=count]');\n }\n\n return 1;\n };\n\n /*** Exports ***/\n\n var moduleType = typeof module;\n\n if (moduleType !== 'undefined' && module.exports) {\n module.exports = jpeg.lossless.FrameHeader;\n }\n },\n { './component-spec.js': 1, './data-stream.js': 2 },\n ],\n 5: [\n function (require, module, exports) {\n /*\n * Copyright (C) 2015 Michael Martinez\n * Changes: Added support for selection values 2-7, fixed minor bugs &\n * warnings, split into multiple class files, and general clean up.\n *\n * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.\n */\n\n /*\n * Copyright (C) Helmut Dersch\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n /*jslint browser: true, node: true */\n /*global require, module */\n\n /*** Imports ***/\n var jpeg = jpeg || {};\n\n jpeg.lossless = jpeg.lossless || {};\n jpeg.lossless.DataStream =\n jpeg.lossless.DataStream ||\n (typeof require !== 'undefined'\n ? require('./data-stream.js')\n : null);\n jpeg.lossless.Utils =\n jpeg.lossless.Utils ||\n (typeof require !== 'undefined' ? require('./utils.js') : null);\n\n /*** Constructor ***/\n jpeg.lossless.HuffmanTable =\n jpeg.lossless.HuffmanTable ||\n function () {\n this.l = jpeg.lossless.Utils.createArray(4, 2, 16);\n this.th = [];\n this.v = jpeg.lossless.Utils.createArray(4, 2, 16, 200);\n this.tc = jpeg.lossless.Utils.createArray(4, 2);\n\n this.tc[0][0] = 0;\n this.tc[1][0] = 0;\n this.tc[2][0] = 0;\n this.tc[3][0] = 0;\n this.tc[0][1] = 0;\n this.tc[1][1] = 0;\n this.tc[2][1] = 0;\n this.tc[3][1] = 0;\n this.th[0] = 0;\n this.th[1] = 0;\n this.th[2] = 0;\n this.th[3] = 0;\n };\n /*** Static Pseudo-constants ***/\n\n jpeg.lossless.HuffmanTable.MSB = 0x80000000;\n\n /*** Prototype Methods ***/\n\n jpeg.lossless.HuffmanTable.prototype.read = function (data, HuffTab) {\n /*jslint bitwise: true */\n\n var count = 0,\n length,\n temp,\n t,\n c,\n i,\n j;\n\n length = data.get16();\n count += 2;\n\n while (count < length) {\n temp = data.get8();\n count += 1;\n t = temp & 0x0f;\n if (t > 3) {\n throw new Error('ERROR: Huffman table ID > 3');\n }\n\n c = temp >> 4;\n if (c > 2) {\n throw new Error('ERROR: Huffman table [Table class > 2 ]');\n }\n\n this.th[t] = 1;\n this.tc[t][c] = 1;\n\n for (i = 0; i < 16; i += 1) {\n this.l[t][c][i] = data.get8();\n count += 1;\n }\n\n for (i = 0; i < 16; i += 1) {\n for (j = 0; j < this.l[t][c][i]; j += 1) {\n if (count > length) {\n throw new Error(\n 'ERROR: Huffman table format error [count>Lh]'\n );\n }\n\n this.v[t][c][i][j] = data.get8();\n count += 1;\n }\n }\n }\n\n if (count !== length) {\n throw new Error('ERROR: Huffman table format error [count!=Lf]');\n }\n\n for (i = 0; i < 4; i += 1) {\n for (j = 0; j < 2; j += 1) {\n if (this.tc[i][j] !== 0) {\n this.buildHuffTable(\n HuffTab[i][j],\n this.l[i][j],\n this.v[i][j]\n );\n }\n }\n }\n\n return 1;\n };\n // Build_HuffTab()\n // Parameter: t table ID\n // c table class ( 0 for DC, 1 for AC )\n // L[i] # of codewords which length is i\n // V[i][j] Huffman Value (length=i)\n // Effect:\n // build up HuffTab[t][c] using L and V.\n jpeg.lossless.HuffmanTable.prototype.buildHuffTable = function (\n tab,\n L,\n V\n ) {\n /*jslint bitwise: true */\n\n var currentTable, temp, k, i, j, n;\n\n temp = 256;\n k = 0;\n\n for (i = 0; i < 8; i += 1) {\n // i+1 is Code length\n for (j = 0; j < L[i]; j += 1) {\n for (n = 0; n < temp >> (i + 1); n += 1) {\n tab[k] = V[i][j] | ((i + 1) << 8);\n k += 1;\n }\n }\n }\n\n for (i = 1; k < 256; i += 1, k += 1) {\n tab[k] = i | jpeg.lossless.HuffmanTable.MSB;\n }\n\n currentTable = 1;\n k = 0;\n\n for (i = 8; i < 16; i += 1) {\n // i+1 is Code length\n for (j = 0; j < L[i]; j += 1) {\n for (n = 0; n < temp >> (i - 7); n += 1) {\n tab[currentTable * 256 + k] = V[i][j] | ((i + 1) << 8);\n k += 1;\n }\n\n if (k >= 256) {\n if (k > 256) {\n throw new Error('ERROR: Huffman table error(1)!');\n }\n\n k = 0;\n currentTable += 1;\n }\n }\n }\n };\n\n /*** Exports ***/\n\n var moduleType = typeof module;\n\n if (moduleType !== 'undefined' && module.exports) {\n module.exports = jpeg.lossless.HuffmanTable;\n }\n },\n { './data-stream.js': 2, './utils.js': 10 },\n ],\n 6: [\n function (require, module, exports) {\n /*jslint browser: true, node: true */\n /*global require, module */\n\n /*** Imports ****/\n\n /**\n * jpeg\n * @type {*|{}}\n */\n var jpeg = jpeg || {};\n\n /**\n * jpeg.lossless\n * @type {*|{}}\n */\n jpeg.lossless = jpeg.lossless || {};\n\n jpeg.lossless.ComponentSpec =\n jpeg.lossless.ComponentSpec ||\n (typeof require !== 'undefined'\n ? require('./component-spec.js')\n : null);\n jpeg.lossless.DataStream =\n jpeg.lossless.DataStream ||\n (typeof require !== 'undefined'\n ? require('./data-stream.js')\n : null);\n jpeg.lossless.Decoder =\n jpeg.lossless.Decoder ||\n (typeof require !== 'undefined' ? require('./decoder.js') : null);\n jpeg.lossless.FrameHeader =\n jpeg.lossless.FrameHeader ||\n (typeof require !== 'undefined'\n ? require('./frame-header.js')\n : null);\n jpeg.lossless.HuffmanTable =\n jpeg.lossless.HuffmanTable ||\n (typeof require !== 'undefined'\n ? require('./huffman-table.js')\n : null);\n jpeg.lossless.QuantizationTable =\n jpeg.lossless.QuantizationTable ||\n (typeof require !== 'undefined'\n ? require('./quantization-table.js')\n : null);\n jpeg.lossless.ScanComponent =\n jpeg.lossless.ScanComponent ||\n (typeof require !== 'undefined'\n ? require('./scan-component.js')\n : null);\n jpeg.lossless.ScanHeader =\n jpeg.lossless.ScanHeader ||\n (typeof require !== 'undefined'\n ? require('./scan-header.js')\n : null);\n jpeg.lossless.Utils =\n jpeg.lossless.Utils ||\n (typeof require !== 'undefined' ? require('./utils.js') : null);\n\n /*** Exports ***/\n var moduleType = typeof module;\n\n if (moduleType !== 'undefined' && module.exports) {\n module.exports = jpeg;\n }\n },\n {\n './component-spec.js': 1,\n './data-stream.js': 2,\n './decoder.js': 3,\n './frame-header.js': 4,\n './huffman-table.js': 5,\n './quantization-table.js': 7,\n './scan-component.js': 8,\n './scan-header.js': 9,\n './utils.js': 10,\n },\n ],\n 7: [\n function (require, module, exports) {\n /*\n * Copyright (C) 2015 Michael Martinez\n * Changes: Added support for selection values 2-7, fixed minor bugs &\n * warnings, split into multiple class files, and general clean up.\n *\n * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.\n */\n\n /*\n * Copyright (C) Helmut Dersch\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n /*jslint browser: true, node: true */\n /*global require, module */\n /*** Imports ***/\n var jpeg = jpeg || {};\n\n jpeg.lossless = jpeg.lossless || {};\n jpeg.lossless.DataStream =\n jpeg.lossless.DataStream ||\n (typeof require !== 'undefined'\n ? require('./data-stream.js')\n : null);\n jpeg.lossless.Utils =\n jpeg.lossless.Utils ||\n (typeof require !== 'undefined' ? require('./utils.js') : null);\n\n /*** Constructor ***/\n jpeg.lossless.QuantizationTable =\n jpeg.lossless.QuantizationTable ||\n function () {\n this.precision = []; // Quantization precision 8 or 16\n this.tq = []; // 1: this table is presented\n this.quantTables = jpeg.lossless.Utils.createArray(4, 64); // Tables\n\n this.tq[0] = 0;\n this.tq[1] = 0;\n this.tq[2] = 0;\n this.tq[3] = 0;\n };\n /*** Static Methods ***/\n\n jpeg.lossless.QuantizationTable.enhanceQuantizationTable = function (\n qtab,\n table\n ) {\n /*jslint bitwise: true */\n\n var i;\n\n for (i = 0; i < 8; i += 1) {\n qtab[table[0 * 8 + i]] *= 90;\n qtab[table[4 * 8 + i]] *= 90;\n qtab[table[2 * 8 + i]] *= 118;\n qtab[table[6 * 8 + i]] *= 49;\n qtab[table[5 * 8 + i]] *= 71;\n qtab[table[1 * 8 + i]] *= 126;\n qtab[table[7 * 8 + i]] *= 25;\n qtab[table[3 * 8 + i]] *= 106;\n }\n\n for (i = 0; i < 8; i += 1) {\n qtab[table[0 + 8 * i]] *= 90;\n qtab[table[4 + 8 * i]] *= 90;\n qtab[table[2 + 8 * i]] *= 118;\n qtab[table[6 + 8 * i]] *= 49;\n qtab[table[5 + 8 * i]] *= 71;\n qtab[table[1 + 8 * i]] *= 126;\n qtab[table[7 + 8 * i]] *= 25;\n qtab[table[3 + 8 * i]] *= 106;\n }\n\n for (i = 0; i < 64; i += 1) {\n qtab[i] >>= 6;\n }\n };\n\n /*** Prototype Methods ***/\n\n jpeg.lossless.QuantizationTable.prototype.read = function (\n data,\n table\n ) {\n /*jslint bitwise: true */\n\n var count = 0,\n length,\n temp,\n t,\n i;\n\n length = data.get16();\n count += 2;\n\n while (count < length) {\n temp = data.get8();\n count += 1;\n t = temp & 0x0f;\n\n if (t > 3) {\n throw new Error('ERROR: Quantization table ID > 3');\n }\n\n this.precision[t] = temp >> 4;\n\n if (this.precision[t] === 0) {\n this.precision[t] = 8;\n } else if (this.precision[t] === 1) {\n this.precision[t] = 16;\n } else {\n throw new Error('ERROR: Quantization table precision error');\n }\n\n this.tq[t] = 1;\n\n if (this.precision[t] === 8) {\n for (i = 0; i < 64; i += 1) {\n if (count > length) {\n throw new Error('ERROR: Quantization table format error');\n }\n\n this.quantTables[t][i] = data.get8();\n count += 1;\n }\n\n jpeg.lossless.QuantizationTable.enhanceQuantizationTable(\n this.quantTables[t],\n table\n );\n } else {\n for (i = 0; i < 64; i += 1) {\n if (count > length) {\n throw new Error('ERROR: Quantization table format error');\n }\n\n this.quantTables[t][i] = data.get16();\n count += 2;\n }\n\n jpeg.lossless.QuantizationTable.enhanceQuantizationTable(\n this.quantTables[t],\n table\n );\n }\n }\n\n if (count !== length) {\n throw new Error('ERROR: Quantization table error [count!=Lq]');\n }\n\n return 1;\n };\n /*** Exports ***/\n\n var moduleType = typeof module;\n\n if (moduleType !== 'undefined' && module.exports) {\n module.exports = jpeg.lossless.QuantizationTable;\n }\n },\n { './data-stream.js': 2, './utils.js': 10 },\n ],\n 8: [\n function (require, module, exports) {\n /*\n * Copyright (C) 2015 Michael Martinez\n * Changes: Added support for selection values 2-7, fixed minor bugs &\n * warnings, split into multiple class files, and general clean up.\n *\n * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.\n */\n\n /*\n * Copyright (C) Helmut Dersch\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n /*jslint browser: true, node: true */\n /*global require, module */\n /*** Imports ***/\n var jpeg = jpeg || {};\n\n jpeg.lossless = jpeg.lossless || {};\n\n /*** Constructor ***/\n jpeg.lossless.ScanComponent =\n jpeg.lossless.ScanComponent ||\n function () {\n this.acTabSel = 0; // AC table selector\n this.dcTabSel = 0; // DC table selector\n this.scanCompSel = 0; // Scan component selector\n };\n /*** Exports ***/\n\n var moduleType = typeof module;\n\n if (moduleType !== 'undefined' && module.exports) {\n module.exports = jpeg.lossless.ScanComponent;\n }\n },\n {},\n ],\n 9: [\n function (require, module, exports) {\n /*\n * Copyright (C) 2015 Michael Martinez\n * Changes: Added support for selection values 2-7, fixed minor bugs &\n * warnings, split into multiple class files, and general clean up.\n *\n * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.\n */\n\n /*\n * Copyright (C) Helmut Dersch\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n /*jslint browser: true, node: true */\n /*global require, module */\n /*** Imports ***/\n var jpeg = jpeg || {};\n\n jpeg.lossless = jpeg.lossless || {};\n jpeg.lossless.DataStream =\n jpeg.lossless.DataStream ||\n (typeof require !== 'undefined'\n ? require('./data-stream.js')\n : null);\n jpeg.lossless.ScanComponent =\n jpeg.lossless.ScanComponent ||\n (typeof require !== 'undefined'\n ? require('./scan-component.js')\n : null);\n\n /*** Constructor ***/\n jpeg.lossless.ScanHeader =\n jpeg.lossless.ScanHeader ||\n function () {\n this.ah = 0;\n this.al = 0;\n this.numComp = 0; // Number of components in the scan\n this.selection = 0; // Start of spectral or predictor selection\n this.spectralEnd = 0; // End of spectral selection\n this.components = [];\n };\n\n /*** Prototype Methods ***/\n\n jpeg.lossless.ScanHeader.prototype.read = function (data) {\n /*jslint bitwise: true */\n\n var count = 0,\n length,\n i,\n temp;\n\n length = data.get16();\n count += 2;\n\n this.numComp = data.get8();\n count += 1;\n\n for (i = 0; i < this.numComp; i += 1) {\n this.components[i] = new jpeg.lossless.ScanComponent();\n\n if (count > length) {\n throw new Error('ERROR: scan header format error');\n }\n\n this.components[i].scanCompSel = data.get8();\n count += 1;\n\n temp = data.get8();\n count += 1;\n\n this.components[i].dcTabSel = temp >> 4;\n this.components[i].acTabSel = temp & 0x0f;\n }\n\n this.selection = data.get8();\n count += 1;\n\n this.spectralEnd = data.get8();\n count += 1;\n\n temp = data.get8();\n this.ah = temp >> 4;\n this.al = temp & 0x0f;\n count += 1;\n\n if (count !== length) {\n throw new Error('ERROR: scan header format error [count!=Ns]');\n }\n\n return 1;\n };\n /*** Exports ***/\n\n var moduleType = typeof module;\n\n if (moduleType !== 'undefined' && module.exports) {\n module.exports = jpeg.lossless.ScanHeader;\n }\n },\n { './data-stream.js': 2, './scan-component.js': 8 },\n ],\n 10: [\n function (require, module, exports) {\n /*\n * Copyright (C) 2015 Michael Martinez\n * Changes: Added support for selection values 2-7, fixed minor bugs &\n * warnings, split into multiple class files, and general clean up.\n *\n * 08-25-2015: Helmut Dersch agreed to a license change from LGPL to MIT.\n */\n\n /*\n * Copyright (C) Helmut Dersch\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n /*jslint browser: true, node: true */\n /*global require, module */\n /*** Imports ***/\n var jpeg = jpeg || {};\n\n jpeg.lossless = jpeg.lossless || {};\n\n /*** Constructor ***/\n jpeg.lossless.Utils = jpeg.lossless.Utils || {};\n\n /*** Static methods ***/\n\n // http://stackoverflow.com/questions/966225/how-can-i-create-a-two-dimensional-array-in-javascript\n jpeg.lossless.Utils.createArray = function (length) {\n var arr = new Array(length || 0),\n i = length;\n\n if (arguments.length > 1) {\n var args = Array.prototype.slice.call(arguments, 1);\n\n while (i--) {\n arr[length - 1 - i] = jpeg.lossless.Utils.createArray.apply(\n this,\n args\n );\n }\n }\n\n return arr;\n };\n\n // http://stackoverflow.com/questions/18638900/javascript-crc32\n jpeg.lossless.Utils.makeCRCTable = function () {\n var c;\n var crcTable = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n }\n crcTable[n] = c;\n }\n\n return crcTable;\n };\n\n jpeg.lossless.Utils.crc32 = function (dataView) {\n var uint8view = new Uint8Array(dataView.buffer);\n var crcTable =\n jpeg.lossless.Utils.crcTable ||\n (jpeg.lossless.Utils.crcTable =\n jpeg.lossless.Utils.makeCRCTable());\n var crc = 0 ^ -1;\n\n for (var i = 0; i < uint8view.length; i++) {\n crc = (crc >>> 8) ^ crcTable[(crc ^ uint8view[i]) & 0xff];\n }\n\n return (crc ^ -1) >>> 0;\n };\n\n /*** Exports ***/\n\n var moduleType = typeof module;\n\n if (moduleType !== 'undefined' && module.exports) {\n module.exports = jpeg.lossless.Utils;\n }\n },\n {},\n ],\n },\n {},\n [6]\n )(6);\n});\n"],"names":["f","exports","module","define","amd","window","global","self","this","jpeg","e","t","n","r","s","o","u","a","require","i","Error","code","l","call","length","lossless","ComponentSpec","hSamp","quantTableSel","vSamp","DataStream","data","offset","buffer","Uint8Array","index","prototype","get16","value","get8","HuffmanTable","QuantizationTable","ScanHeader","FrameHeader","Utils","Decoder","numBytes","frame","huffTable","quantTable","scan","DU","createArray","HuffTab","IDCT_Source","nBlock","acTab","dcTab","qTab","marker","markerIndex","numComp","restartInterval","selection","xDim","yDim","xLoc","yLoc","outputData","restarting","mask","IDCT_P","TABLE","MAX_HUFFMAN_SUBTREE","MSB","RESTART_MARKER_BEGIN","RESTART_MARKER_END","decompress","decode","current","compN","mcuNum","scanNum","pred","temp","stream","read","readNumber","readApp","readComment","precision","components","parseInt","Math","ceil","getter","getValueRGB","setter","setValueRGB","output","outputRGB","getValue8","setValue8","outputSingle","getValue16","setValue16","selector","select2","select3","select4","select5","select6","select7","select1","scanComps","quantTables","scanCompSel","dcTabSel","acTabSel","dimX","dimY","ArrayBuffer","Uint16Array","decodeUnit","prev","decodeSingle","decodeRGB","compOffset","getPreviousX","getPreviousY","getPreviousXY","actab","dctab","qtab","ctrC","k","j","getHuffmanValue","getn","nRestart","table","input","PRED","result","isLastPixel","val","DataView","setInt16","Int16Array","count","sb","c","th","v","tc","buildHuffTable","tab","L","V","currentTable","ScanComponent","tq","enhanceQuantizationTable","ah","al","spectralEnd","arr","Array","arguments","args","slice","apply","makeCRCTable","crcTable","crc32","dataView","uint8view","crc"],"sourceRoot":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(self.webpackChunkcornerstoneDICOMImageLoader=self.webpackChunkcornerstoneDICOMImageLoader||[]).push([[610],{610:function(s,e){!function(t){if("object"==typeof e&&void 0!==s)s.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).jpeg=t()}}((function(){return function s(e,t,o){function r(a,n){if(!t[a]){if(!e[a]){var l="function"==typeof require&&require;if(!n&&l)return l(a,!0);if(i)return i(a,!0);var h=new Error("Cannot find module '"+a+"'");throw h.code="MODULE_NOT_FOUND",h}var c=t[a]={exports:{}};e[a][0].call(c.exports,(function(s){var t=e[a][1][s];return r(t||s)}),c,c.exports,s,e,t,o)}return t[a].exports}for(var i="function"==typeof require&&require,a=0;a<o.length;a++)r(o[a]);return r}({1:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.ComponentSpec=o.lossless.ComponentSpec||function(){this.hSamp=0,this.quantTableSel=0,this.vSamp=0},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.ComponentSpec)},{}],2:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.DataStream=o.lossless.DataStream||function(s,e,t){this.buffer=new Uint8Array(s,e,t),this.index=0},o.lossless.DataStream.prototype.get16=function(){var s=(this.buffer[this.index]<<8)+this.buffer[this.index+1];return this.index+=2,s},o.lossless.DataStream.prototype.get8=function(){var s=this.buffer[this.index];return this.index+=1,s},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.DataStream)},{}],3:[function(s,e,t){var o,r=r||{};r.lossless=r.lossless||{},r.lossless.DataStream=r.lossless.DataStream||(void 0!==s?s("./data-stream.js"):null),r.lossless.HuffmanTable=r.lossless.HuffmanTable||(void 0!==s?s("./huffman-table.js"):null),r.lossless.QuantizationTable=r.lossless.QuantizationTable||(void 0!==s?s("./quantization-table.js"):null),r.lossless.ScanHeader=r.lossless.ScanHeader||(void 0!==s?s("./scan-header.js"):null),r.lossless.FrameHeader=r.lossless.FrameHeader||(void 0!==s?s("./frame-header.js"):null),r.lossless.Utils=r.lossless.Utils||(void 0!==s?s("./utils.js"):null),r.lossless.Decoder=r.lossless.Decoder||function(s,e){this.buffer=s,this.frame=new r.lossless.FrameHeader,this.huffTable=new r.lossless.HuffmanTable,this.quantTable=new r.lossless.QuantizationTable,this.scan=new r.lossless.ScanHeader,this.DU=r.lossless.Utils.createArray(10,4,64),this.HuffTab=r.lossless.Utils.createArray(4,2,12800),this.IDCT_Source=[],this.nBlock=[],this.acTab=r.lossless.Utils.createArray(10,1),this.dcTab=r.lossless.Utils.createArray(10,1),this.qTab=r.lossless.Utils.createArray(10,1),this.marker=0,this.markerIndex=0,this.numComp=0,this.restartInterval=0,this.selection=0,this.xDim=0,this.yDim=0,this.xLoc=0,this.yLoc=0,this.numBytes=0,this.outputData=null,this.restarting=!1,this.mask=0,void 0!==e&&(this.numBytes=e)},r.lossless.Decoder.IDCT_P=[0,5,40,16,45,2,7,42,21,56,8,61,18,47,1,4,41,23,58,13,32,24,37,10,63,17,44,3,6,43,20,57,15,34,29,48,53,26,39,9,60,19,46,22,59,12,33,31,50,55,25,36,11,62,14,35,28,49,52,27,38,30,51,54],r.lossless.Decoder.TABLE=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],r.lossless.Decoder.MAX_HUFFMAN_SUBTREE=50,r.lossless.Decoder.MSB=2147483648,r.lossless.Decoder.RESTART_MARKER_BEGIN=65488,r.lossless.Decoder.RESTART_MARKER_END=65495,r.lossless.Decoder.prototype.decompress=function(s,e,t){return this.decode(s,e,t).buffer},r.lossless.Decoder.prototype.decode=function(s,e,t,o){var i,a,n,l,h=0,c=[],u=[],f=[];if(void 0!==s&&(this.buffer=s),void 0!==o&&(this.numBytes=o),this.stream=new r.lossless.DataStream(this.buffer,e,t),this.buffer=null,this.xLoc=0,this.yLoc=0,65496!==(i=this.stream.get16()))throw new Error("Not a JPEG file");for(i=this.stream.get16();i>>4!=4092||65476===i;){switch(i){case 65476:this.huffTable.read(this.stream,this.HuffTab);break;case 65484:throw new Error("Program doesn't support arithmetic coding. (format throw new IOException)");case 65499:this.quantTable.read(this.stream,r.lossless.Decoder.TABLE);break;case 65501:this.restartInterval=this.readNumber();break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:this.readApp();break;case 65534:this.readComment();break;default:if(i>>8!=255)throw new Error("ERROR: format throw new IOException! (decode)")}i=this.stream.get16()}if(i<65472||i>65479)throw new Error("ERROR: could not handle arithmetic code!");this.frame.read(this.stream),i=this.stream.get16();do{for(;65498!==i;){switch(i){case 65476:this.huffTable.read(this.stream,this.HuffTab);break;case 65484:throw new Error("Program doesn't support arithmetic coding. (format throw new IOException)");case 65499:this.quantTable.read(this.stream,r.lossless.Decoder.TABLE);break;case 65501:this.restartInterval=this.readNumber();break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:this.readApp();break;case 65534:this.readComment();break;default:if(i>>8!=255)throw new Error("ERROR: format throw new IOException! (Parser.decode)")}i=this.stream.get16()}switch(this.precision=this.frame.precision,this.components=this.frame.components,this.numBytes||(this.numBytes=parseInt(Math.ceil(this.precision/8))),1==this.numBytes?this.mask=255:this.mask=65535,this.scan.read(this.stream),this.numComp=this.scan.numComp,this.selection=this.scan.selection,1===this.numBytes?3===this.numComp?(this.getter=this.getValueRGB,this.setter=this.setValueRGB,this.output=this.outputRGB):(this.getter=this.getValue8,this.setter=this.setValue8,this.output=this.outputSingle):(this.getter=this.getValue16,this.setter=this.setValue16,this.output=this.outputSingle),this.selection){case 2:this.selector=this.select2;break;case 3:this.selector=this.select3;break;case 4:this.selector=this.select4;break;case 5:this.selector=this.select5;break;case 6:this.selector=this.select6;break;case 7:this.selector=this.select7;break;default:this.selector=this.select1}for(this.scanComps=this.scan.components,this.quantTables=this.quantTable.quantTables,a=0;a<this.numComp;a+=1)n=this.scanComps[a].scanCompSel,this.qTab[a]=this.quantTables[this.components[n].quantTableSel],this.nBlock[a]=this.components[n].vSamp*this.components[n].hSamp,this.dcTab[a]=this.HuffTab[this.scanComps[a].dcTabSel][0],this.acTab[a]=this.HuffTab[this.scanComps[a].acTabSel][1];for(this.xDim=this.frame.dimX,this.yDim=this.frame.dimY,1==this.numBytes?this.outputData=new Uint8Array(new ArrayBuffer(this.xDim*this.yDim*this.numBytes*this.numComp)):this.outputData=new Uint16Array(new ArrayBuffer(this.xDim*this.yDim*this.numBytes*this.numComp)),h+=1;;){for(u[0]=0,f[0]=0,a=0;a<10;a+=1)c[a]=1<<this.precision-1;if(0===this.restartInterval){for(i=this.decodeUnit(c,u,f);0===i&&this.xLoc<this.xDim&&this.yLoc<this.yDim;)this.output(c),i=this.decodeUnit(c,u,f);break}for(l=0;l<this.restartInterval&&(this.restarting=0==l,i=this.decodeUnit(c,u,f),this.output(c),0===i);l+=1);if(0===i&&(0!==this.markerIndex?(i=65280|this.marker,this.markerIndex=0):i=this.stream.get16()),!(i>=r.lossless.Decoder.RESTART_MARKER_BEGIN&&i<=r.lossless.Decoder.RESTART_MARKER_END))break}65500===i&&1===h&&(this.readNumber(),i=this.stream.get16())}while(65497!==i&&this.xLoc<this.xDim&&this.yLoc<this.yDim&&0===h);return this.outputData},r.lossless.Decoder.prototype.decodeUnit=function(s,e,t){return 1==this.numComp?this.decodeSingle(s,e,t):3==this.numComp?this.decodeRGB(s,e,t):-1},r.lossless.Decoder.prototype.select1=function(s){return this.getPreviousX(s)},r.lossless.Decoder.prototype.select2=function(s){return this.getPreviousY(s)},r.lossless.Decoder.prototype.select3=function(s){return this.getPreviousXY(s)},r.lossless.Decoder.prototype.select4=function(s){return this.getPreviousX(s)+this.getPreviousY(s)-this.getPreviousXY(s)},r.lossless.Decoder.prototype.select5=function(s){return this.getPreviousX(s)+(this.getPreviousY(s)-this.getPreviousXY(s)>>1)},r.lossless.Decoder.prototype.select6=function(s){return this.getPreviousY(s)+(this.getPreviousX(s)-this.getPreviousXY(s)>>1)},r.lossless.Decoder.prototype.select7=function(s){return(this.getPreviousX(s)+this.getPreviousY(s))/2},r.lossless.Decoder.prototype.decodeRGB=function(s,e,t){var o,i,a,n,l,h,c,u;for(s[0]=this.selector(0),s[1]=this.selector(1),s[2]=this.selector(2),l=0;l<this.numComp;l+=1)for(n=this.qTab[l],i=this.acTab[l],a=this.dcTab[l],h=0;h<this.nBlock[l];h+=1){for(c=0;c<this.IDCT_Source.length;c+=1)this.IDCT_Source[c]=0;if((o=this.getHuffmanValue(a,e,t))>=65280)return o;for(s[l]=this.IDCT_Source[0]=s[l]+this.getn(t,o,e,t),this.IDCT_Source[0]*=n[0],u=1;u<64;u+=1){if((o=this.getHuffmanValue(i,e,t))>=65280)return o;if(u+=o>>4,0==(15&o)){if(o>>4==0)break}else this.IDCT_Source[r.lossless.Decoder.IDCT_P[u]]=this.getn(t,15&o,e,t)*n[u]}}return 0},r.lossless.Decoder.prototype.decodeSingle=function(s,e,t){var o,i,a,n;for(this.restarting?(this.restarting=!1,s[0]=1<<this.frame.precision-1):s[0]=this.selector(),i=0;i<this.nBlock[0];i+=1){if((o=this.getHuffmanValue(this.dcTab[0],e,t))>=65280)return o;if((n=(a=this.getn(s,o,e,t))>>8)>=r.lossless.Decoder.RESTART_MARKER_BEGIN&&n<=r.lossless.Decoder.RESTART_MARKER_END)return n;s[0]+=a}return 0},r.lossless.Decoder.prototype.getHuffmanValue=function(s,e,t){var o,i;if(65535,t[0]<8?(e[0]<<=8,255===(i=this.stream.get8())&&(this.marker=this.stream.get8(),0!==this.marker&&(this.markerIndex=9)),e[0]|=i):t[0]-=8,0!=((o=s[e[0]>>t[0]])&r.lossless.Decoder.MSB)){if(0!==this.markerIndex)return this.markerIndex=0,65280|this.marker;e[0]&=65535>>16-t[0],e[0]<<=8,255===(i=this.stream.get8())&&(this.marker=this.stream.get8(),0!==this.marker&&(this.markerIndex=9)),e[0]|=i,o=s[256*(255&o)+(e[0]>>t[0])],t[0]+=8}if(t[0]+=8-(o>>8),t[0]<0)throw new Error(`index=${t[0]} temp=${e[0]} code=${o} in HuffmanValue()`);return t[0]<this.markerIndex?(this.markerIndex=0,65280|this.marker):(e[0]&=65535>>16-t[0],255&o)},r.lossless.Decoder.prototype.getn=function(s,e,t,o){var r,i;if(1,-1,65535,0===e)return 0;if(16===e)return s[0]>=0?-32768:32768;if(o[0]-=e,o[0]>=0){if(o[0]<this.markerIndex&&!this.isLastPixel())return this.markerIndex=0,(65280|this.marker)<<8;r=t[0]>>o[0],t[0]&=65535>>16-o[0]}else{if(t[0]<<=8,255===(i=this.stream.get8())&&(this.marker=this.stream.get8(),0!==this.marker&&(this.markerIndex=9)),t[0]|=i,o[0]+=8,o[0]<0){if(0!==this.markerIndex)return this.markerIndex=0,(65280|this.marker)<<8;t[0]<<=8,255===(i=this.stream.get8())&&(this.marker=this.stream.get8(),0!==this.marker&&(this.markerIndex=9)),t[0]|=i,o[0]+=8}if(o[0]<0)throw new Error(`index=${o[0]} in getn()`);if(o[0]<this.markerIndex)return this.markerIndex=0,(65280|this.marker)<<8;r=t[0]>>o[0],t[0]&=65535>>16-o[0]}return r<1<<e-1&&(r+=1+(-1<<e)),r},r.lossless.Decoder.prototype.getPreviousX=function(s){return this.xLoc>0?this.getter(this.yLoc*this.xDim+this.xLoc-1,s):this.yLoc>0?this.getPreviousY(s):1<<this.frame.precision-1},r.lossless.Decoder.prototype.getPreviousXY=function(s){return this.xLoc>0&&this.yLoc>0?this.getter((this.yLoc-1)*this.xDim+this.xLoc-1,s):this.getPreviousY(s)},r.lossless.Decoder.prototype.getPreviousY=function(s){return this.yLoc>0?this.getter((this.yLoc-1)*this.xDim+this.xLoc,s):this.getPreviousX(s)},r.lossless.Decoder.prototype.isLastPixel=function(){return this.xLoc===this.xDim-1&&this.yLoc===this.yDim-1},r.lossless.Decoder.prototype.outputSingle=function(s){this.xLoc<this.xDim&&this.yLoc<this.yDim&&(this.setter(this.yLoc*this.xDim+this.xLoc,this.mask&s[0]),this.xLoc+=1,this.xLoc>=this.xDim&&(this.yLoc+=1,this.xLoc=0))},r.lossless.Decoder.prototype.outputRGB=function(s){var e=this.yLoc*this.xDim+this.xLoc;this.xLoc<this.xDim&&this.yLoc<this.yDim&&(this.setter(e,s[0],0),this.setter(e,s[1],1),this.setter(e,s[2],2),this.xLoc+=1,this.xLoc>=this.xDim&&(this.yLoc+=1,this.xLoc=0))},r.lossless.Decoder.prototype.setValue8=function(s,e){this.outputData[s]=e},r.lossless.Decoder.prototype.getValue8=function(s){return this.outputData[s]},(o=new ArrayBuffer(2),new DataView(o).setInt16(0,256,!0),256===new Int16Array(o)[0])?(r.lossless.Decoder.prototype.setValue16=r.lossless.Decoder.prototype.setValue8,r.lossless.Decoder.prototype.getValue16=r.lossless.Decoder.prototype.getValue8):(r.lossless.Decoder.prototype.setValue16=function(s,e){this.outputData[s]=(255&e)<<8|e>>8&255},r.lossless.Decoder.prototype.getValue16=function(s){var e=this.outputData[s];return(255&e)<<8|e>>8&255}),r.lossless.Decoder.prototype.setValueRGB=function(s,e,t){this.outputData[3*s+t]=e},r.lossless.Decoder.prototype.getValueRGB=function(s,e){return this.outputData[3*s+e]},r.lossless.Decoder.prototype.readApp=function(){var s=0,e=this.stream.get16();for(s+=2;s<e;)this.stream.get8(),s+=1;return e},r.lossless.Decoder.prototype.readComment=function(){var s,e="",t=0;for(s=this.stream.get16(),t+=2;t<s;)e+=this.stream.get8(),t+=1;return e},r.lossless.Decoder.prototype.readNumber=function(){if(4!==this.stream.get16())throw new Error("ERROR: Define number format throw new IOException [Ld!=4]");return this.stream.get16()},"undefined"!==typeof e&&e.exports&&(e.exports=r.lossless.Decoder)},{"./data-stream.js":2,"./frame-header.js":4,"./huffman-table.js":5,"./quantization-table.js":7,"./scan-header.js":9,"./utils.js":10}],4:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.ComponentSpec=o.lossless.ComponentSpec||(void 0!==s?s("./component-spec.js"):null),o.lossless.DataStream=o.lossless.DataStream||(void 0!==s?s("./data-stream.js"):null),o.lossless.FrameHeader=o.lossless.FrameHeader||function(){this.components=[],this.dimX=0,this.dimY=0,this.numComp=0,this.precision=0},o.lossless.FrameHeader.prototype.read=function(s){var e,t,r,i,a=0;for(e=s.get16(),a+=2,this.precision=s.get8(),a+=1,this.dimY=s.get16(),a+=2,this.dimX=s.get16(),a+=2,this.numComp=s.get8(),a+=1,t=1;t<=this.numComp;t+=1){if(a>e)throw new Error("ERROR: frame format error");if(r=s.get8(),(a+=1)>=e)throw new Error("ERROR: frame format error [c>=Lf]");i=s.get8(),a+=1,this.components[r]||(this.components[r]=new o.lossless.ComponentSpec),this.components[r].hSamp=i>>4,this.components[r].vSamp=15&i,this.components[r].quantTableSel=s.get8(),a+=1}if(a!==e)throw new Error("ERROR: frame format error [Lf!=count]");return 1},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.FrameHeader)},{"./component-spec.js":1,"./data-stream.js":2}],5:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.DataStream=o.lossless.DataStream||(void 0!==s?s("./data-stream.js"):null),o.lossless.Utils=o.lossless.Utils||(void 0!==s?s("./utils.js"):null),o.lossless.HuffmanTable=o.lossless.HuffmanTable||function(){this.l=o.lossless.Utils.createArray(4,2,16),this.th=[],this.v=o.lossless.Utils.createArray(4,2,16,200),this.tc=o.lossless.Utils.createArray(4,2),this.tc[0][0]=0,this.tc[1][0]=0,this.tc[2][0]=0,this.tc[3][0]=0,this.tc[0][1]=0,this.tc[1][1]=0,this.tc[2][1]=0,this.tc[3][1]=0,this.th[0]=0,this.th[1]=0,this.th[2]=0,this.th[3]=0},o.lossless.HuffmanTable.MSB=2147483648,o.lossless.HuffmanTable.prototype.read=function(s,e){var t,o,r,i,a,n,l=0;for(t=s.get16(),l+=2;l<t;){if(l+=1,(r=15&(o=s.get8()))>3)throw new Error("ERROR: Huffman table ID > 3");if((i=o>>4)>2)throw new Error("ERROR: Huffman table [Table class > 2 ]");for(this.th[r]=1,this.tc[r][i]=1,a=0;a<16;a+=1)this.l[r][i][a]=s.get8(),l+=1;for(a=0;a<16;a+=1)for(n=0;n<this.l[r][i][a];n+=1){if(l>t)throw new Error("ERROR: Huffman table format error [count>Lh]");this.v[r][i][a][n]=s.get8(),l+=1}}if(l!==t)throw new Error("ERROR: Huffman table format error [count!=Lf]");for(a=0;a<4;a+=1)for(n=0;n<2;n+=1)0!==this.tc[a][n]&&this.buildHuffTable(e[a][n],this.l[a][n],this.v[a][n]);return 1},o.lossless.HuffmanTable.prototype.buildHuffTable=function(s,e,t){var r,i,a,n,l;for(256,i=0,a=0;a<8;a+=1)for(n=0;n<e[a];n+=1)for(l=0;l<256>>a+1;l+=1)s[i]=t[a][n]|a+1<<8,i+=1;for(a=1;i<256;a+=1,i+=1)s[i]=a|o.lossless.HuffmanTable.MSB;for(r=1,i=0,a=8;a<16;a+=1)for(n=0;n<e[a];n+=1){for(l=0;l<256>>a-7;l+=1)s[256*r+i]=t[a][n]|a+1<<8,i+=1;if(i>=256){if(i>256)throw new Error("ERROR: Huffman table error(1)!");i=0,r+=1}}},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.HuffmanTable)},{"./data-stream.js":2,"./utils.js":10}],6:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.ComponentSpec=o.lossless.ComponentSpec||(void 0!==s?s("./component-spec.js"):null),o.lossless.DataStream=o.lossless.DataStream||(void 0!==s?s("./data-stream.js"):null),o.lossless.Decoder=o.lossless.Decoder||(void 0!==s?s("./decoder.js"):null),o.lossless.FrameHeader=o.lossless.FrameHeader||(void 0!==s?s("./frame-header.js"):null),o.lossless.HuffmanTable=o.lossless.HuffmanTable||(void 0!==s?s("./huffman-table.js"):null),o.lossless.QuantizationTable=o.lossless.QuantizationTable||(void 0!==s?s("./quantization-table.js"):null),o.lossless.ScanComponent=o.lossless.ScanComponent||(void 0!==s?s("./scan-component.js"):null),o.lossless.ScanHeader=o.lossless.ScanHeader||(void 0!==s?s("./scan-header.js"):null),o.lossless.Utils=o.lossless.Utils||(void 0!==s?s("./utils.js"):null),"undefined"!==typeof e&&e.exports&&(e.exports=o)},{"./component-spec.js":1,"./data-stream.js":2,"./decoder.js":3,"./frame-header.js":4,"./huffman-table.js":5,"./quantization-table.js":7,"./scan-component.js":8,"./scan-header.js":9,"./utils.js":10}],7:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.DataStream=o.lossless.DataStream||(void 0!==s?s("./data-stream.js"):null),o.lossless.Utils=o.lossless.Utils||(void 0!==s?s("./utils.js"):null),o.lossless.QuantizationTable=o.lossless.QuantizationTable||function(){this.precision=[],this.tq=[],this.quantTables=o.lossless.Utils.createArray(4,64),this.tq[0]=0,this.tq[1]=0,this.tq[2]=0,this.tq[3]=0},o.lossless.QuantizationTable.enhanceQuantizationTable=function(s,e){var t;for(t=0;t<8;t+=1)s[e[0+t]]*=90,s[e[32+t]]*=90,s[e[16+t]]*=118,s[e[48+t]]*=49,s[e[40+t]]*=71,s[e[8+t]]*=126,s[e[56+t]]*=25,s[e[24+t]]*=106;for(t=0;t<8;t+=1)s[e[0+8*t]]*=90,s[e[4+8*t]]*=90,s[e[2+8*t]]*=118,s[e[6+8*t]]*=49,s[e[5+8*t]]*=71,s[e[1+8*t]]*=126,s[e[7+8*t]]*=25,s[e[3+8*t]]*=106;for(t=0;t<64;t+=1)s[t]>>=6},o.lossless.QuantizationTable.prototype.read=function(s,e){var t,r,i,a,n=0;for(t=s.get16(),n+=2;n<t;){if(n+=1,(i=15&(r=s.get8()))>3)throw new Error("ERROR: Quantization table ID > 3");if(this.precision[i]=r>>4,0===this.precision[i])this.precision[i]=8;else{if(1!==this.precision[i])throw new Error("ERROR: Quantization table precision error");this.precision[i]=16}if(this.tq[i]=1,8===this.precision[i]){for(a=0;a<64;a+=1){if(n>t)throw new Error("ERROR: Quantization table format error");this.quantTables[i][a]=s.get8(),n+=1}o.lossless.QuantizationTable.enhanceQuantizationTable(this.quantTables[i],e)}else{for(a=0;a<64;a+=1){if(n>t)throw new Error("ERROR: Quantization table format error");this.quantTables[i][a]=s.get16(),n+=2}o.lossless.QuantizationTable.enhanceQuantizationTable(this.quantTables[i],e)}}if(n!==t)throw new Error("ERROR: Quantization table error [count!=Lq]");return 1},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.QuantizationTable)},{"./data-stream.js":2,"./utils.js":10}],8:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.ScanComponent=o.lossless.ScanComponent||function(){this.acTabSel=0,this.dcTabSel=0,this.scanCompSel=0},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.ScanComponent)},{}],9:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.DataStream=o.lossless.DataStream||(void 0!==s?s("./data-stream.js"):null),o.lossless.ScanComponent=o.lossless.ScanComponent||(void 0!==s?s("./scan-component.js"):null),o.lossless.ScanHeader=o.lossless.ScanHeader||function(){this.ah=0,this.al=0,this.numComp=0,this.selection=0,this.spectralEnd=0,this.components=[]},o.lossless.ScanHeader.prototype.read=function(s){var e,t,r,i=0;for(e=s.get16(),i+=2,this.numComp=s.get8(),i+=1,t=0;t<this.numComp;t+=1){if(this.components[t]=new o.lossless.ScanComponent,i>e)throw new Error("ERROR: scan header format error");this.components[t].scanCompSel=s.get8(),i+=1,r=s.get8(),i+=1,this.components[t].dcTabSel=r>>4,this.components[t].acTabSel=15&r}if(this.selection=s.get8(),i+=1,this.spectralEnd=s.get8(),i+=1,r=s.get8(),this.ah=r>>4,this.al=15&r,(i+=1)!==e)throw new Error("ERROR: scan header format error [count!=Ns]");return 1},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.ScanHeader)},{"./data-stream.js":2,"./scan-component.js":8}],10:[function(s,e,t){var o=o||{};o.lossless=o.lossless||{},o.lossless.Utils=o.lossless.Utils||{},o.lossless.Utils.createArray=function(s){var e=new Array(s||0),t=s;if(arguments.length>1)for(var r=Array.prototype.slice.call(arguments,1);t--;)e[s-1-t]=o.lossless.Utils.createArray.apply(this,r);return e},o.lossless.Utils.makeCRCTable=function(){for(var s,e=[],t=0;t<256;t++){s=t;for(var o=0;o<8;o++)s=1&s?3988292384^s>>>1:s>>>1;e[t]=s}return e},o.lossless.Utils.crc32=function(s){for(var e=new Uint8Array(s.buffer),t=o.lossless.Utils.crcTable||(o.lossless.Utils.crcTable=o.lossless.Utils.makeCRCTable()),r=-1,i=0;i<e.length;i++)r=r>>>8^t[255&(r^e[i])];return(-1^r)>>>0},"undefined"!==typeof e&&e.exports&&(e.exports=o.lossless.Utils)},{}]},{},[6])(6)}))}}]);
|
|
2
|
+
//# sourceMappingURL=610.bundle.min.worker.js.map
|