pdfjs-dist 2.0.489 → 2.2.228

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.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (169) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +18515 -11402
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +1 -1
  6. package/build/pdf.worker.js +48266 -37137
  7. package/build/pdf.worker.js.map +1 -1
  8. package/build/pdf.worker.min.js +1 -1
  9. package/external/url/url-lib.js +627 -0
  10. package/image_decoders/pdf.image_decoders.js +11350 -0
  11. package/image_decoders/pdf.image_decoders.js.map +1 -0
  12. package/image_decoders/pdf.image_decoders.min.js +1 -0
  13. package/lib/core/annotation.js +587 -242
  14. package/lib/core/arithmetic_decoder.js +275 -245
  15. package/lib/core/bidi.js +65 -6
  16. package/lib/core/ccitt.js +173 -18
  17. package/lib/core/ccitt_stream.js +15 -6
  18. package/lib/core/cff_parser.js +433 -61
  19. package/lib/core/charsets.js +5 -4
  20. package/lib/core/chunked_stream.js +400 -152
  21. package/lib/core/cmap.js +326 -87
  22. package/lib/core/colorspace.js +874 -594
  23. package/lib/core/core_utils.js +147 -0
  24. package/lib/core/crypto.js +290 -45
  25. package/lib/core/document.js +560 -268
  26. package/lib/core/encodings.js +19 -10
  27. package/lib/core/evaluator.js +1005 -360
  28. package/lib/core/font_renderer.js +331 -97
  29. package/lib/core/fonts.js +812 -195
  30. package/lib/core/function.js +284 -71
  31. package/lib/core/glyphlist.js +4 -3
  32. package/lib/core/image.js +169 -62
  33. package/lib/core/image_utils.js +111 -0
  34. package/lib/core/jbig2.js +479 -66
  35. package/lib/core/jbig2_stream.js +19 -8
  36. package/lib/core/jpeg_stream.js +38 -13
  37. package/lib/core/jpg.js +253 -29
  38. package/lib/core/jpx.js +396 -6
  39. package/lib/core/jpx_stream.js +18 -6
  40. package/lib/core/metrics.js +15 -15
  41. package/lib/core/murmurhash3.js +56 -34
  42. package/lib/core/obj.js +1354 -488
  43. package/lib/core/operator_list.js +144 -31
  44. package/lib/core/parser.js +539 -191
  45. package/lib/core/pattern.js +148 -14
  46. package/lib/core/pdf_manager.js +323 -133
  47. package/lib/core/primitives.js +111 -24
  48. package/lib/core/ps_parser.js +134 -45
  49. package/lib/core/standard_fonts.js +17 -17
  50. package/lib/core/stream.js +313 -34
  51. package/lib/core/type1_parser.js +143 -13
  52. package/lib/core/unicode.js +32 -5
  53. package/lib/core/worker.js +217 -190
  54. package/lib/core/worker_stream.js +277 -0
  55. package/lib/display/annotation_layer.js +450 -133
  56. package/lib/display/api.js +1597 -784
  57. package/lib/display/api_compatibility.js +11 -13
  58. package/lib/display/canvas.js +360 -44
  59. package/lib/display/content_disposition.js +83 -32
  60. package/lib/display/display_utils.js +747 -0
  61. package/lib/display/fetch_stream.js +221 -90
  62. package/lib/display/font_loader.js +468 -236
  63. package/lib/display/metadata.js +38 -16
  64. package/lib/display/network.js +635 -428
  65. package/lib/display/network_utils.js +32 -19
  66. package/lib/display/node_stream.js +367 -175
  67. package/lib/display/pattern_helper.js +81 -31
  68. package/lib/display/svg.js +1235 -519
  69. package/lib/display/text_layer.js +153 -29
  70. package/lib/display/transport_stream.js +345 -94
  71. package/lib/display/webgl.js +64 -18
  72. package/lib/display/worker_options.js +5 -4
  73. package/lib/display/xml_parser.js +166 -53
  74. package/lib/examples/node/domstubs.js +60 -4
  75. package/lib/pdf.js +36 -14
  76. package/lib/pdf.worker.js +5 -3
  77. package/lib/shared/compatibility.js +158 -564
  78. package/lib/shared/global_scope.js +2 -2
  79. package/lib/shared/is_node.js +4 -4
  80. package/lib/shared/message_handler.js +521 -0
  81. package/lib/shared/streams_polyfill.js +21 -17
  82. package/lib/shared/url_polyfill.js +56 -0
  83. package/lib/shared/util.js +243 -710
  84. package/lib/test/unit/annotation_spec.js +870 -401
  85. package/lib/test/unit/api_spec.js +657 -345
  86. package/lib/test/unit/bidi_spec.js +7 -7
  87. package/lib/test/unit/cff_parser_spec.js +54 -11
  88. package/lib/test/unit/clitests_helper.js +10 -8
  89. package/lib/test/unit/cmap_spec.js +95 -41
  90. package/lib/test/unit/colorspace_spec.js +115 -63
  91. package/lib/test/unit/core_utils_spec.js +191 -0
  92. package/lib/test/unit/crypto_spec.js +17 -5
  93. package/lib/test/unit/custom_spec.js +43 -55
  94. package/lib/test/unit/display_svg_spec.js +34 -18
  95. package/lib/test/unit/display_utils_spec.js +273 -0
  96. package/lib/test/unit/document_spec.js +8 -13
  97. package/lib/test/unit/encodings_spec.js +25 -45
  98. package/lib/test/unit/evaluator_spec.js +38 -15
  99. package/lib/test/unit/fetch_stream_spec.js +109 -0
  100. package/lib/test/unit/function_spec.js +17 -5
  101. package/lib/test/unit/jasmine-boot.js +33 -20
  102. package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
  103. package/lib/test/unit/metadata_spec.js +71 -11
  104. package/lib/test/unit/murmurhash3_spec.js +3 -3
  105. package/lib/test/unit/network_spec.js +19 -54
  106. package/lib/test/unit/network_utils_spec.js +91 -14
  107. package/lib/test/unit/node_stream_spec.js +56 -32
  108. package/lib/test/unit/parser_spec.js +162 -71
  109. package/lib/test/unit/pdf_find_controller_spec.js +230 -0
  110. package/lib/test/unit/pdf_find_utils_spec.js +63 -0
  111. package/lib/test/unit/pdf_history_spec.js +21 -9
  112. package/lib/test/unit/primitives_spec.js +53 -20
  113. package/lib/test/unit/stream_spec.js +12 -4
  114. package/lib/test/unit/test_utils.js +273 -56
  115. package/lib/test/unit/testreporter.js +21 -3
  116. package/lib/test/unit/type1_parser_spec.js +8 -6
  117. package/lib/test/unit/ui_utils_spec.js +454 -16
  118. package/lib/test/unit/unicode_spec.js +18 -15
  119. package/lib/test/unit/util_spec.js +87 -128
  120. package/lib/web/annotation_layer_builder.js +39 -22
  121. package/lib/web/app.js +1290 -588
  122. package/lib/web/app_options.js +100 -62
  123. package/lib/web/base_viewer.js +511 -182
  124. package/lib/web/chromecom.js +261 -117
  125. package/lib/web/debugger.js +166 -22
  126. package/lib/web/download_manager.js +32 -13
  127. package/lib/web/firefox_print_service.js +20 -10
  128. package/lib/web/firefoxcom.js +315 -80
  129. package/lib/web/genericcom.js +89 -30
  130. package/lib/web/genericl10n.js +142 -30
  131. package/lib/web/grab_to_pan.js +28 -4
  132. package/lib/web/interfaces.js +170 -47
  133. package/lib/web/overlay_manager.js +235 -85
  134. package/lib/web/password_prompt.js +22 -14
  135. package/lib/web/pdf_attachment_viewer.js +38 -18
  136. package/lib/web/pdf_cursor_tools.js +39 -16
  137. package/lib/web/pdf_document_properties.js +255 -136
  138. package/lib/web/pdf_find_bar.js +84 -40
  139. package/lib/web/pdf_find_controller.js +495 -184
  140. package/lib/web/pdf_find_utils.js +111 -0
  141. package/lib/web/pdf_history.js +190 -53
  142. package/lib/web/pdf_link_service.js +138 -77
  143. package/lib/web/pdf_outline_viewer.js +122 -46
  144. package/lib/web/pdf_page_view.js +191 -67
  145. package/lib/web/pdf_presentation_mode.js +99 -34
  146. package/lib/web/pdf_print_service.js +61 -13
  147. package/lib/web/pdf_rendering_queue.js +28 -9
  148. package/lib/web/pdf_sidebar.js +141 -81
  149. package/lib/web/pdf_sidebar_resizer.js +42 -16
  150. package/lib/web/pdf_single_page_viewer.js +74 -66
  151. package/lib/web/pdf_thumbnail_view.js +104 -33
  152. package/lib/web/pdf_thumbnail_viewer.js +66 -26
  153. package/lib/web/pdf_viewer.component.js +112 -32
  154. package/lib/web/pdf_viewer.js +91 -52
  155. package/lib/web/preferences.js +284 -89
  156. package/lib/web/secondary_toolbar.js +165 -40
  157. package/lib/web/text_layer_builder.js +134 -59
  158. package/lib/web/toolbar.js +78 -43
  159. package/lib/web/ui_utils.js +462 -136
  160. package/lib/web/view_history.js +215 -67
  161. package/lib/web/viewer_compatibility.js +4 -13
  162. package/package.json +5 -4
  163. package/web/pdf_viewer.css +79 -11
  164. package/web/pdf_viewer.js +6107 -3748
  165. package/web/pdf_viewer.js.map +1 -1
  166. package/lib/display/dom_utils.js +0 -309
  167. package/lib/test/unit/dom_utils_spec.js +0 -89
  168. package/lib/test/unit/fonts_spec.js +0 -81
  169. package/lib/web/dom_events.js +0 -137
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2017 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -24,244 +24,257 @@
24
24
  Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
- var ArithmeticDecoder = function ArithmeticDecoderClosure() {
28
- var QeTable = [{
29
- qe: 0x5601,
30
- nmps: 1,
31
- nlps: 1,
32
- switchFlag: 1
33
- }, {
34
- qe: 0x3401,
35
- nmps: 2,
36
- nlps: 6,
37
- switchFlag: 0
38
- }, {
39
- qe: 0x1801,
40
- nmps: 3,
41
- nlps: 9,
42
- switchFlag: 0
43
- }, {
44
- qe: 0x0AC1,
45
- nmps: 4,
46
- nlps: 12,
47
- switchFlag: 0
48
- }, {
49
- qe: 0x0521,
50
- nmps: 5,
51
- nlps: 29,
52
- switchFlag: 0
53
- }, {
54
- qe: 0x0221,
55
- nmps: 38,
56
- nlps: 33,
57
- switchFlag: 0
58
- }, {
59
- qe: 0x5601,
60
- nmps: 7,
61
- nlps: 6,
62
- switchFlag: 1
63
- }, {
64
- qe: 0x5401,
65
- nmps: 8,
66
- nlps: 14,
67
- switchFlag: 0
68
- }, {
69
- qe: 0x4801,
70
- nmps: 9,
71
- nlps: 14,
72
- switchFlag: 0
73
- }, {
74
- qe: 0x3801,
75
- nmps: 10,
76
- nlps: 14,
77
- switchFlag: 0
78
- }, {
79
- qe: 0x3001,
80
- nmps: 11,
81
- nlps: 17,
82
- switchFlag: 0
83
- }, {
84
- qe: 0x2401,
85
- nmps: 12,
86
- nlps: 18,
87
- switchFlag: 0
88
- }, {
89
- qe: 0x1C01,
90
- nmps: 13,
91
- nlps: 20,
92
- switchFlag: 0
93
- }, {
94
- qe: 0x1601,
95
- nmps: 29,
96
- nlps: 21,
97
- switchFlag: 0
98
- }, {
99
- qe: 0x5601,
100
- nmps: 15,
101
- nlps: 14,
102
- switchFlag: 1
103
- }, {
104
- qe: 0x5401,
105
- nmps: 16,
106
- nlps: 14,
107
- switchFlag: 0
108
- }, {
109
- qe: 0x5101,
110
- nmps: 17,
111
- nlps: 15,
112
- switchFlag: 0
113
- }, {
114
- qe: 0x4801,
115
- nmps: 18,
116
- nlps: 16,
117
- switchFlag: 0
118
- }, {
119
- qe: 0x3801,
120
- nmps: 19,
121
- nlps: 17,
122
- switchFlag: 0
123
- }, {
124
- qe: 0x3401,
125
- nmps: 20,
126
- nlps: 18,
127
- switchFlag: 0
128
- }, {
129
- qe: 0x3001,
130
- nmps: 21,
131
- nlps: 19,
132
- switchFlag: 0
133
- }, {
134
- qe: 0x2801,
135
- nmps: 22,
136
- nlps: 19,
137
- switchFlag: 0
138
- }, {
139
- qe: 0x2401,
140
- nmps: 23,
141
- nlps: 20,
142
- switchFlag: 0
143
- }, {
144
- qe: 0x2201,
145
- nmps: 24,
146
- nlps: 21,
147
- switchFlag: 0
148
- }, {
149
- qe: 0x1C01,
150
- nmps: 25,
151
- nlps: 22,
152
- switchFlag: 0
153
- }, {
154
- qe: 0x1801,
155
- nmps: 26,
156
- nlps: 23,
157
- switchFlag: 0
158
- }, {
159
- qe: 0x1601,
160
- nmps: 27,
161
- nlps: 24,
162
- switchFlag: 0
163
- }, {
164
- qe: 0x1401,
165
- nmps: 28,
166
- nlps: 25,
167
- switchFlag: 0
168
- }, {
169
- qe: 0x1201,
170
- nmps: 29,
171
- nlps: 26,
172
- switchFlag: 0
173
- }, {
174
- qe: 0x1101,
175
- nmps: 30,
176
- nlps: 27,
177
- switchFlag: 0
178
- }, {
179
- qe: 0x0AC1,
180
- nmps: 31,
181
- nlps: 28,
182
- switchFlag: 0
183
- }, {
184
- qe: 0x09C1,
185
- nmps: 32,
186
- nlps: 29,
187
- switchFlag: 0
188
- }, {
189
- qe: 0x08A1,
190
- nmps: 33,
191
- nlps: 30,
192
- switchFlag: 0
193
- }, {
194
- qe: 0x0521,
195
- nmps: 34,
196
- nlps: 31,
197
- switchFlag: 0
198
- }, {
199
- qe: 0x0441,
200
- nmps: 35,
201
- nlps: 32,
202
- switchFlag: 0
203
- }, {
204
- qe: 0x02A1,
205
- nmps: 36,
206
- nlps: 33,
207
- switchFlag: 0
208
- }, {
209
- qe: 0x0221,
210
- nmps: 37,
211
- nlps: 34,
212
- switchFlag: 0
213
- }, {
214
- qe: 0x0141,
215
- nmps: 38,
216
- nlps: 35,
217
- switchFlag: 0
218
- }, {
219
- qe: 0x0111,
220
- nmps: 39,
221
- nlps: 36,
222
- switchFlag: 0
223
- }, {
224
- qe: 0x0085,
225
- nmps: 40,
226
- nlps: 37,
227
- switchFlag: 0
228
- }, {
229
- qe: 0x0049,
230
- nmps: 41,
231
- nlps: 38,
232
- switchFlag: 0
233
- }, {
234
- qe: 0x0025,
235
- nmps: 42,
236
- nlps: 39,
237
- switchFlag: 0
238
- }, {
239
- qe: 0x0015,
240
- nmps: 43,
241
- nlps: 40,
242
- switchFlag: 0
243
- }, {
244
- qe: 0x0009,
245
- nmps: 44,
246
- nlps: 41,
247
- switchFlag: 0
248
- }, {
249
- qe: 0x0005,
250
- nmps: 45,
251
- nlps: 42,
252
- switchFlag: 0
253
- }, {
254
- qe: 0x0001,
255
- nmps: 45,
256
- nlps: 43,
257
- switchFlag: 0
258
- }, {
259
- qe: 0x5601,
260
- nmps: 46,
261
- nlps: 46,
262
- switchFlag: 0
263
- }];
27
+ exports.ArithmeticDecoder = void 0;
28
+
29
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
30
+
31
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
32
+
33
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
34
+
35
+ var QeTable = [{
36
+ qe: 0x5601,
37
+ nmps: 1,
38
+ nlps: 1,
39
+ switchFlag: 1
40
+ }, {
41
+ qe: 0x3401,
42
+ nmps: 2,
43
+ nlps: 6,
44
+ switchFlag: 0
45
+ }, {
46
+ qe: 0x1801,
47
+ nmps: 3,
48
+ nlps: 9,
49
+ switchFlag: 0
50
+ }, {
51
+ qe: 0x0AC1,
52
+ nmps: 4,
53
+ nlps: 12,
54
+ switchFlag: 0
55
+ }, {
56
+ qe: 0x0521,
57
+ nmps: 5,
58
+ nlps: 29,
59
+ switchFlag: 0
60
+ }, {
61
+ qe: 0x0221,
62
+ nmps: 38,
63
+ nlps: 33,
64
+ switchFlag: 0
65
+ }, {
66
+ qe: 0x5601,
67
+ nmps: 7,
68
+ nlps: 6,
69
+ switchFlag: 1
70
+ }, {
71
+ qe: 0x5401,
72
+ nmps: 8,
73
+ nlps: 14,
74
+ switchFlag: 0
75
+ }, {
76
+ qe: 0x4801,
77
+ nmps: 9,
78
+ nlps: 14,
79
+ switchFlag: 0
80
+ }, {
81
+ qe: 0x3801,
82
+ nmps: 10,
83
+ nlps: 14,
84
+ switchFlag: 0
85
+ }, {
86
+ qe: 0x3001,
87
+ nmps: 11,
88
+ nlps: 17,
89
+ switchFlag: 0
90
+ }, {
91
+ qe: 0x2401,
92
+ nmps: 12,
93
+ nlps: 18,
94
+ switchFlag: 0
95
+ }, {
96
+ qe: 0x1C01,
97
+ nmps: 13,
98
+ nlps: 20,
99
+ switchFlag: 0
100
+ }, {
101
+ qe: 0x1601,
102
+ nmps: 29,
103
+ nlps: 21,
104
+ switchFlag: 0
105
+ }, {
106
+ qe: 0x5601,
107
+ nmps: 15,
108
+ nlps: 14,
109
+ switchFlag: 1
110
+ }, {
111
+ qe: 0x5401,
112
+ nmps: 16,
113
+ nlps: 14,
114
+ switchFlag: 0
115
+ }, {
116
+ qe: 0x5101,
117
+ nmps: 17,
118
+ nlps: 15,
119
+ switchFlag: 0
120
+ }, {
121
+ qe: 0x4801,
122
+ nmps: 18,
123
+ nlps: 16,
124
+ switchFlag: 0
125
+ }, {
126
+ qe: 0x3801,
127
+ nmps: 19,
128
+ nlps: 17,
129
+ switchFlag: 0
130
+ }, {
131
+ qe: 0x3401,
132
+ nmps: 20,
133
+ nlps: 18,
134
+ switchFlag: 0
135
+ }, {
136
+ qe: 0x3001,
137
+ nmps: 21,
138
+ nlps: 19,
139
+ switchFlag: 0
140
+ }, {
141
+ qe: 0x2801,
142
+ nmps: 22,
143
+ nlps: 19,
144
+ switchFlag: 0
145
+ }, {
146
+ qe: 0x2401,
147
+ nmps: 23,
148
+ nlps: 20,
149
+ switchFlag: 0
150
+ }, {
151
+ qe: 0x2201,
152
+ nmps: 24,
153
+ nlps: 21,
154
+ switchFlag: 0
155
+ }, {
156
+ qe: 0x1C01,
157
+ nmps: 25,
158
+ nlps: 22,
159
+ switchFlag: 0
160
+ }, {
161
+ qe: 0x1801,
162
+ nmps: 26,
163
+ nlps: 23,
164
+ switchFlag: 0
165
+ }, {
166
+ qe: 0x1601,
167
+ nmps: 27,
168
+ nlps: 24,
169
+ switchFlag: 0
170
+ }, {
171
+ qe: 0x1401,
172
+ nmps: 28,
173
+ nlps: 25,
174
+ switchFlag: 0
175
+ }, {
176
+ qe: 0x1201,
177
+ nmps: 29,
178
+ nlps: 26,
179
+ switchFlag: 0
180
+ }, {
181
+ qe: 0x1101,
182
+ nmps: 30,
183
+ nlps: 27,
184
+ switchFlag: 0
185
+ }, {
186
+ qe: 0x0AC1,
187
+ nmps: 31,
188
+ nlps: 28,
189
+ switchFlag: 0
190
+ }, {
191
+ qe: 0x09C1,
192
+ nmps: 32,
193
+ nlps: 29,
194
+ switchFlag: 0
195
+ }, {
196
+ qe: 0x08A1,
197
+ nmps: 33,
198
+ nlps: 30,
199
+ switchFlag: 0
200
+ }, {
201
+ qe: 0x0521,
202
+ nmps: 34,
203
+ nlps: 31,
204
+ switchFlag: 0
205
+ }, {
206
+ qe: 0x0441,
207
+ nmps: 35,
208
+ nlps: 32,
209
+ switchFlag: 0
210
+ }, {
211
+ qe: 0x02A1,
212
+ nmps: 36,
213
+ nlps: 33,
214
+ switchFlag: 0
215
+ }, {
216
+ qe: 0x0221,
217
+ nmps: 37,
218
+ nlps: 34,
219
+ switchFlag: 0
220
+ }, {
221
+ qe: 0x0141,
222
+ nmps: 38,
223
+ nlps: 35,
224
+ switchFlag: 0
225
+ }, {
226
+ qe: 0x0111,
227
+ nmps: 39,
228
+ nlps: 36,
229
+ switchFlag: 0
230
+ }, {
231
+ qe: 0x0085,
232
+ nmps: 40,
233
+ nlps: 37,
234
+ switchFlag: 0
235
+ }, {
236
+ qe: 0x0049,
237
+ nmps: 41,
238
+ nlps: 38,
239
+ switchFlag: 0
240
+ }, {
241
+ qe: 0x0025,
242
+ nmps: 42,
243
+ nlps: 39,
244
+ switchFlag: 0
245
+ }, {
246
+ qe: 0x0015,
247
+ nmps: 43,
248
+ nlps: 40,
249
+ switchFlag: 0
250
+ }, {
251
+ qe: 0x0009,
252
+ nmps: 44,
253
+ nlps: 41,
254
+ switchFlag: 0
255
+ }, {
256
+ qe: 0x0005,
257
+ nmps: 45,
258
+ nlps: 42,
259
+ switchFlag: 0
260
+ }, {
261
+ qe: 0x0001,
262
+ nmps: 45,
263
+ nlps: 43,
264
+ switchFlag: 0
265
+ }, {
266
+ qe: 0x5601,
267
+ nmps: 46,
268
+ nlps: 46,
269
+ switchFlag: 0
270
+ }];
271
+
272
+ var ArithmeticDecoder =
273
+ /*#__PURE__*/
274
+ function () {
264
275
  function ArithmeticDecoder(data, start, end) {
276
+ _classCallCheck(this, ArithmeticDecoder);
277
+
265
278
  this.data = data;
266
279
  this.bp = start;
267
280
  this.dataEnd = end;
@@ -273,13 +286,15 @@ var ArithmeticDecoder = function ArithmeticDecoderClosure() {
273
286
  this.ct -= 7;
274
287
  this.a = 0x8000;
275
288
  }
276
- ArithmeticDecoder.prototype = {
277
- byteIn: function ArithmeticDecoder_byteIn() {
289
+
290
+ _createClass(ArithmeticDecoder, [{
291
+ key: "byteIn",
292
+ value: function byteIn() {
278
293
  var data = this.data;
279
294
  var bp = this.bp;
295
+
280
296
  if (data[bp] === 0xFF) {
281
- var b1 = data[bp + 1];
282
- if (b1 > 0x8F) {
297
+ if (data[bp + 1] > 0x8F) {
283
298
  this.clow += 0xFF00;
284
299
  this.ct = 8;
285
300
  } else {
@@ -294,18 +309,22 @@ var ArithmeticDecoder = function ArithmeticDecoderClosure() {
294
309
  this.ct = 8;
295
310
  this.bp = bp;
296
311
  }
312
+
297
313
  if (this.clow > 0xFFFF) {
298
314
  this.chigh += this.clow >> 16;
299
315
  this.clow &= 0xFFFF;
300
316
  }
301
- },
302
- readBit: function ArithmeticDecoder_readBit(contexts, pos) {
317
+ }
318
+ }, {
319
+ key: "readBit",
320
+ value: function readBit(contexts, pos) {
303
321
  var cx_index = contexts[pos] >> 1,
304
322
  cx_mps = contexts[pos] & 1;
305
323
  var qeTableIcx = QeTable[cx_index];
306
324
  var qeIcx = qeTableIcx.qe;
307
325
  var d;
308
326
  var a = this.a - qeIcx;
327
+
309
328
  if (this.chigh < qeIcx) {
310
329
  if (a < qeIcx) {
311
330
  a = qeIcx;
@@ -314,42 +333,53 @@ var ArithmeticDecoder = function ArithmeticDecoderClosure() {
314
333
  } else {
315
334
  a = qeIcx;
316
335
  d = 1 ^ cx_mps;
336
+
317
337
  if (qeTableIcx.switchFlag === 1) {
318
338
  cx_mps = d;
319
339
  }
340
+
320
341
  cx_index = qeTableIcx.nlps;
321
342
  }
322
343
  } else {
323
344
  this.chigh -= qeIcx;
345
+
324
346
  if ((a & 0x8000) !== 0) {
325
347
  this.a = a;
326
348
  return cx_mps;
327
349
  }
350
+
328
351
  if (a < qeIcx) {
329
352
  d = 1 ^ cx_mps;
353
+
330
354
  if (qeTableIcx.switchFlag === 1) {
331
355
  cx_mps = d;
332
356
  }
357
+
333
358
  cx_index = qeTableIcx.nlps;
334
359
  } else {
335
360
  d = cx_mps;
336
361
  cx_index = qeTableIcx.nmps;
337
362
  }
338
363
  }
364
+
339
365
  do {
340
366
  if (this.ct === 0) {
341
367
  this.byteIn();
342
368
  }
369
+
343
370
  a <<= 1;
344
371
  this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
345
372
  this.clow = this.clow << 1 & 0xFFFF;
346
373
  this.ct--;
347
374
  } while ((a & 0x8000) === 0);
375
+
348
376
  this.a = a;
349
377
  contexts[pos] = cx_index << 1 | cx_mps;
350
378
  return d;
351
379
  }
352
- };
380
+ }]);
381
+
353
382
  return ArithmeticDecoder;
354
383
  }();
384
+
355
385
  exports.ArithmeticDecoder = ArithmeticDecoder;