pdfjs-dist 2.1.266 → 2.5.207
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.
- package/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8382 -18492
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +20417 -29816
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25688 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +58239 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +403 -0
- package/es5/web/pdf_viewer.js +7742 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1475 -4897
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +750 -899
- package/lib/core/arithmetic_decoder.js +81 -97
- package/lib/core/bidi.js +54 -46
- package/lib/core/ccitt.js +88 -81
- package/lib/core/ccitt_stream.js +15 -14
- package/lib/core/cff_parser.js +235 -183
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +447 -542
- package/lib/core/cmap.js +222 -264
- package/lib/core/colorspace.js +699 -863
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +379 -437
- package/lib/core/document.js +573 -660
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +1103 -868
- package/lib/core/font_renderer.js +135 -178
- package/lib/core/fonts.js +570 -491
- package/lib/core/function.js +291 -288
- package/lib/core/glyphlist.js +4527 -4526
- package/lib/core/image.js +145 -149
- package/lib/core/image_utils.js +170 -0
- package/lib/core/jbig2.js +325 -316
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +21 -26
- package/lib/core/jpg.js +284 -232
- package/lib/core/jpx.js +161 -143
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2929 -2929
- package/lib/core/murmurhash3.js +90 -101
- package/lib/core/obj.js +1183 -1157
- package/lib/core/operator_list.js +99 -67
- package/lib/core/parser.js +972 -911
- package/lib/core/pattern.js +87 -70
- package/lib/core/pdf_manager.js +150 -315
- package/lib/core/primitives.js +83 -56
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +94 -74
- package/lib/core/type1_parser.js +87 -69
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +193 -390
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +741 -972
- package/lib/display/api.js +1500 -1791
- package/lib/display/api_compatibility.js +12 -17
- package/lib/display/canvas.js +165 -165
- package/lib/display/content_disposition.js +40 -59
- package/lib/display/display_utils.js +515 -0
- package/lib/display/fetch_stream.js +183 -298
- package/lib/display/font_loader.js +273 -413
- package/lib/display/metadata.js +86 -98
- package/lib/display/network.js +266 -359
- package/lib/display/network_utils.js +25 -18
- package/lib/display/node_stream.js +285 -458
- package/lib/display/pattern_helper.js +113 -65
- package/lib/display/svg.js +1166 -901
- package/lib/display/text_layer.js +156 -132
- package/lib/display/transport_stream.js +262 -278
- package/lib/display/webgl.js +70 -83
- package/lib/display/worker_options.js +3 -3
- package/lib/display/xml_parser.js +303 -392
- package/lib/examples/node/domstubs.js +40 -37
- package/lib/pdf.js +226 -59
- package/lib/pdf.worker.js +14 -6
- package/lib/shared/compatibility.js +3 -246
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +327 -332
- package/lib/shared/util.js +266 -416
- package/lib/test/unit/annotation_spec.js +1555 -701
- package/lib/test/unit/api_spec.js +802 -604
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +84 -69
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +74 -76
- package/lib/test/unit/colorspace_spec.js +166 -161
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +181 -181
- package/lib/test/unit/custom_spec.js +20 -22
- package/lib/test/unit/display_svg_spec.js +34 -39
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +16 -21
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +83 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +46 -30
- package/lib/test/unit/message_handler_spec.js +173 -159
- package/lib/test/unit/metadata_spec.js +69 -69
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +13 -61
- package/lib/test/unit/network_utils_spec.js +183 -119
- package/lib/test/unit/node_stream_spec.js +78 -92
- package/lib/test/unit/parser_spec.js +172 -114
- package/lib/test/unit/pdf_find_controller_spec.js +55 -86
- package/lib/test/unit/pdf_find_utils_spec.js +32 -32
- package/lib/test/unit/pdf_history_spec.js +32 -32
- package/lib/test/unit/primitives_spec.js +140 -125
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +131 -143
- package/lib/test/unit/testreporter.js +19 -19
- package/lib/test/unit/type1_parser_spec.js +42 -42
- package/lib/test/unit/ui_utils_spec.js +297 -459
- package/lib/test/unit/unicode_spec.js +38 -38
- package/lib/test/unit/util_spec.js +121 -305
- package/lib/web/annotation_layer_builder.js +66 -103
- package/lib/web/app.js +1328 -1214
- package/lib/web/app_options.js +105 -107
- package/lib/web/base_viewer.js +824 -838
- package/lib/web/chromecom.js +165 -252
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +39 -55
- package/lib/web/firefox_print_service.js +37 -27
- package/lib/web/firefoxcom.js +212 -363
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +32 -30
- package/lib/web/interfaces.js +80 -254
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +113 -131
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +221 -306
- package/lib/web/pdf_find_bar.js +136 -170
- package/lib/web/pdf_find_controller.js +491 -548
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +397 -406
- package/lib/web/pdf_link_service.js +304 -348
- package/lib/web/pdf_outline_viewer.js +140 -175
- package/lib/web/pdf_page_view.js +452 -523
- package/lib/web/pdf_presentation_mode.js +308 -357
- package/lib/web/pdf_print_service.js +90 -104
- package/lib/web/pdf_rendering_queue.js +84 -108
- package/lib/web/pdf_sidebar.js +276 -306
- package/lib/web/pdf_sidebar_resizer.js +92 -119
- package/lib/web/pdf_single_page_viewer.js +77 -126
- package/lib/web/pdf_thumbnail_view.js +276 -297
- package/lib/web/pdf_thumbnail_viewer.js +186 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +82 -286
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +282 -339
- package/lib/web/toolbar.js +217 -210
- package/lib/web/ui_utils.js +267 -420
- package/lib/web/view_history.js +52 -226
- package/lib/web/viewer_compatibility.js +21 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +35 -25
- package/web/pdf_viewer.js +3489 -4855
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -494
- package/lib/shared/streams_polyfill.js +0 -43
- package/lib/shared/url_polyfill.js +0 -56
- package/lib/test/unit/dom_utils_spec.js +0 -89
package/lib/core/ccitt.js
CHANGED
@@ -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
|
5
|
+
* Copyright 2020 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.
|
@@ -26,49 +26,47 @@ Object.defineProperty(exports, "__esModule", {
|
|
26
26
|
});
|
27
27
|
exports.CCITTFaxDecoder = void 0;
|
28
28
|
|
29
|
-
var _util = require("../shared/util");
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
function CCITTFaxDecoder(source) {
|
51
|
-
|
52
|
-
|
53
|
-
if (!source || typeof source.next !== 'function') {
|
29
|
+
var _util = require("../shared/util.js");
|
30
|
+
|
31
|
+
const CCITTFaxDecoder = function CCITTFaxDecoder() {
|
32
|
+
const ccittEOL = -2;
|
33
|
+
const ccittEOF = -1;
|
34
|
+
const twoDimPass = 0;
|
35
|
+
const twoDimHoriz = 1;
|
36
|
+
const twoDimVert0 = 2;
|
37
|
+
const twoDimVertR1 = 3;
|
38
|
+
const twoDimVertL1 = 4;
|
39
|
+
const twoDimVertR2 = 5;
|
40
|
+
const twoDimVertL2 = 6;
|
41
|
+
const twoDimVertR3 = 7;
|
42
|
+
const twoDimVertL3 = 8;
|
43
|
+
const twoDimTable = [[-1, -1], [-1, -1], [7, twoDimVertL3], [7, twoDimVertR3], [6, twoDimVertL2], [6, twoDimVertL2], [6, twoDimVertR2], [6, twoDimVertR2], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [4, twoDimPass], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimHoriz], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertL1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [3, twoDimVertR1], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0], [1, twoDimVert0]];
|
44
|
+
const whiteTable1 = [[-1, -1], [12, ccittEOL], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [11, 1792], [11, 1792], [12, 1984], [12, 2048], [12, 2112], [12, 2176], [12, 2240], [12, 2304], [11, 1856], [11, 1856], [11, 1920], [11, 1920], [12, 2368], [12, 2432], [12, 2496], [12, 2560]];
|
45
|
+
const whiteTable2 = [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [8, 29], [8, 29], [8, 30], [8, 30], [8, 45], [8, 45], [8, 46], [8, 46], [7, 22], [7, 22], [7, 22], [7, 22], [7, 23], [7, 23], [7, 23], [7, 23], [8, 47], [8, 47], [8, 48], [8, 48], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [6, 13], [7, 20], [7, 20], [7, 20], [7, 20], [8, 33], [8, 33], [8, 34], [8, 34], [8, 35], [8, 35], [8, 36], [8, 36], [8, 37], [8, 37], [8, 38], [8, 38], [7, 19], [7, 19], [7, 19], [7, 19], [8, 31], [8, 31], [8, 32], [8, 32], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 1], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [6, 12], [8, 53], [8, 53], [8, 54], [8, 54], [7, 26], [7, 26], [7, 26], [7, 26], [8, 39], [8, 39], [8, 40], [8, 40], [8, 41], [8, 41], [8, 42], [8, 42], [8, 43], [8, 43], [8, 44], [8, 44], [7, 21], [7, 21], [7, 21], [7, 21], [7, 28], [7, 28], [7, 28], [7, 28], [8, 61], [8, 61], [8, 62], [8, 62], [8, 63], [8, 63], [8, 0], [8, 0], [8, 320], [8, 320], [8, 384], [8, 384], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [5, 11], [7, 27], [7, 27], [7, 27], [7, 27], [8, 59], [8, 59], [8, 60], [8, 60], [9, 1472], [9, 1536], [9, 1600], [9, 1728], [7, 18], [7, 18], [7, 18], [7, 18], [7, 24], [7, 24], [7, 24], [7, 24], [8, 49], [8, 49], [8, 50], [8, 50], [8, 51], [8, 51], [8, 52], [8, 52], [7, 25], [7, 25], [7, 25], [7, 25], [8, 55], [8, 55], [8, 56], [8, 56], [8, 57], [8, 57], [8, 58], [8, 58], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 192], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [6, 1664], [8, 448], [8, 448], [8, 512], [8, 512], [9, 704], [9, 768], [8, 640], [8, 640], [8, 576], [8, 576], [9, 832], [9, 896], [9, 960], [9, 1024], [9, 1088], [9, 1152], [9, 1216], [9, 1280], [9, 1344], [9, 1408], [7, 256], [7, 256], [7, 256], [7, 256], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 2], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [4, 3], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 128], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 8], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [5, 9], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 16], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [6, 17], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [4, 5], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 14], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [6, 15], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [5, 64], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 6], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7], [4, 7]];
|
46
|
+
const blackTable1 = [[-1, -1], [-1, -1], [12, ccittEOL], [12, ccittEOL], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [-1, -1], [11, 1792], [11, 1792], [11, 1792], [11, 1792], [12, 1984], [12, 1984], [12, 2048], [12, 2048], [12, 2112], [12, 2112], [12, 2176], [12, 2176], [12, 2240], [12, 2240], [12, 2304], [12, 2304], [11, 1856], [11, 1856], [11, 1856], [11, 1856], [11, 1920], [11, 1920], [11, 1920], [11, 1920], [12, 2368], [12, 2368], [12, 2432], [12, 2432], [12, 2496], [12, 2496], [12, 2560], [12, 2560], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [10, 18], [12, 52], [12, 52], [13, 640], [13, 704], [13, 768], [13, 832], [12, 55], [12, 55], [12, 56], [12, 56], [13, 1280], [13, 1344], [13, 1408], [13, 1472], [12, 59], [12, 59], [12, 60], [12, 60], [13, 1536], [13, 1600], [11, 24], [11, 24], [11, 24], [11, 24], [11, 25], [11, 25], [11, 25], [11, 25], [13, 1664], [13, 1728], [12, 320], [12, 320], [12, 384], [12, 384], [12, 448], [12, 448], [13, 512], [13, 576], [12, 53], [12, 53], [12, 54], [12, 54], [13, 896], [13, 960], [13, 1024], [13, 1088], [13, 1152], [13, 1216], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64], [10, 64]];
|
47
|
+
const blackTable2 = [[8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [8, 13], [11, 23], [11, 23], [12, 50], [12, 51], [12, 44], [12, 45], [12, 46], [12, 47], [12, 57], [12, 58], [12, 61], [12, 256], [10, 16], [10, 16], [10, 16], [10, 16], [10, 17], [10, 17], [10, 17], [10, 17], [12, 48], [12, 49], [12, 62], [12, 63], [12, 30], [12, 31], [12, 32], [12, 33], [12, 40], [12, 41], [11, 22], [11, 22], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [8, 14], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 10], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [7, 11], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [9, 15], [12, 128], [12, 192], [12, 26], [12, 27], [12, 28], [12, 29], [11, 19], [11, 19], [11, 20], [11, 20], [12, 34], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [11, 21], [11, 21], [12, 42], [12, 43], [10, 0], [10, 0], [10, 0], [10, 0], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12], [7, 12]];
|
48
|
+
const blackTable3 = [[-1, -1], [-1, -1], [-1, -1], [-1, -1], [6, 9], [6, 8], [5, 7], [5, 7], [4, 6], [4, 6], [4, 6], [4, 6], [4, 5], [4, 5], [4, 5], [4, 5], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 1], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [3, 4], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 3], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]];
|
49
|
+
|
50
|
+
function CCITTFaxDecoder(source, options = {}) {
|
51
|
+
if (!source || typeof source.next !== "function") {
|
54
52
|
throw new Error('CCITTFaxDecoder - invalid "source" parameter.');
|
55
53
|
}
|
56
54
|
|
57
55
|
this.source = source;
|
58
56
|
this.eof = false;
|
59
|
-
this.encoding = options
|
60
|
-
this.eoline = options
|
61
|
-
this.byteAlign = options
|
62
|
-
this.columns = options
|
63
|
-
this.rows = options
|
64
|
-
|
57
|
+
this.encoding = options.K || 0;
|
58
|
+
this.eoline = options.EndOfLine || false;
|
59
|
+
this.byteAlign = options.EncodedByteAlign || false;
|
60
|
+
this.columns = options.Columns || 1728;
|
61
|
+
this.rows = options.Rows || 0;
|
62
|
+
let eoblock = options.EndOfBlock;
|
65
63
|
|
66
64
|
if (eoblock === null || eoblock === undefined) {
|
67
65
|
eoblock = true;
|
68
66
|
}
|
69
67
|
|
70
68
|
this.eoblock = eoblock;
|
71
|
-
this.black = options
|
69
|
+
this.black = options.BlackIs1 || false;
|
72
70
|
this.codingLine = new Uint32Array(this.columns + 1);
|
73
71
|
this.refLine = new Uint32Array(this.columns + 2);
|
74
72
|
this.codingLine[0] = this.columns;
|
@@ -79,7 +77,7 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
79
77
|
this.inputBuf = 0;
|
80
78
|
this.outputBits = 0;
|
81
79
|
this.rowsDone = false;
|
82
|
-
|
80
|
+
let code1;
|
83
81
|
|
84
82
|
while ((code1 = this._lookBits(12)) === 0) {
|
85
83
|
this._eatBits(1);
|
@@ -97,15 +95,15 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
97
95
|
}
|
98
96
|
|
99
97
|
CCITTFaxDecoder.prototype = {
|
100
|
-
readNextChar
|
98
|
+
readNextChar() {
|
101
99
|
if (this.eof) {
|
102
100
|
return -1;
|
103
101
|
}
|
104
102
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
103
|
+
const refLine = this.refLine;
|
104
|
+
const codingLine = this.codingLine;
|
105
|
+
const columns = this.columns;
|
106
|
+
let refPos, blackPixels, bits, i;
|
109
107
|
|
110
108
|
if (this.outputBits === 0) {
|
111
109
|
if (this.rowsDone) {
|
@@ -117,7 +115,7 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
117
115
|
}
|
118
116
|
|
119
117
|
this.err = false;
|
120
|
-
|
118
|
+
let code1, code2, code3;
|
121
119
|
|
122
120
|
if (this.nextLine2D) {
|
123
121
|
for (i = 0; codingLine[i] < columns; ++i) {
|
@@ -301,7 +299,7 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
301
299
|
break;
|
302
300
|
|
303
301
|
default:
|
304
|
-
(0, _util.info)(
|
302
|
+
(0, _util.info)("bad 2d code");
|
305
303
|
|
306
304
|
this._addPixels(columns, 0);
|
307
305
|
|
@@ -332,7 +330,7 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
332
330
|
}
|
333
331
|
}
|
334
332
|
|
335
|
-
|
333
|
+
let gotEOL = false;
|
336
334
|
|
337
335
|
if (this.byteAlign) {
|
338
336
|
this.inputBits &= ~7;
|
@@ -389,7 +387,7 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
389
387
|
code1 = this._lookBits(12);
|
390
388
|
|
391
389
|
if (code1 !== 1) {
|
392
|
-
(0, _util.info)(
|
390
|
+
(0, _util.info)("bad rtc code: " + code1);
|
393
391
|
}
|
394
392
|
|
395
393
|
this._eatBits(12);
|
@@ -438,10 +436,10 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
438
436
|
this.row++;
|
439
437
|
}
|
440
438
|
|
441
|
-
|
439
|
+
let c;
|
442
440
|
|
443
441
|
if (this.outputBits >= 8) {
|
444
|
-
c = this.codingPos & 1 ? 0 :
|
442
|
+
c = this.codingPos & 1 ? 0 : 0xff;
|
445
443
|
this.outputBits -= 8;
|
446
444
|
|
447
445
|
if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
|
@@ -457,7 +455,7 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
457
455
|
c <<= bits;
|
458
456
|
|
459
457
|
if (!(this.codingPos & 1)) {
|
460
|
-
c |=
|
458
|
+
c |= 0xff >> 8 - bits;
|
461
459
|
}
|
462
460
|
|
463
461
|
this.outputBits -= bits;
|
@@ -466,7 +464,7 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
466
464
|
c <<= this.outputBits;
|
467
465
|
|
468
466
|
if (!(this.codingPos & 1)) {
|
469
|
-
c |=
|
467
|
+
c |= 0xff >> 8 - this.outputBits;
|
470
468
|
}
|
471
469
|
|
472
470
|
bits -= this.outputBits;
|
@@ -484,18 +482,19 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
484
482
|
}
|
485
483
|
|
486
484
|
if (this.black) {
|
487
|
-
c ^=
|
485
|
+
c ^= 0xff;
|
488
486
|
}
|
489
487
|
|
490
488
|
return c;
|
491
489
|
},
|
492
|
-
|
493
|
-
|
494
|
-
|
490
|
+
|
491
|
+
_addPixels(a1, blackPixels) {
|
492
|
+
const codingLine = this.codingLine;
|
493
|
+
let codingPos = this.codingPos;
|
495
494
|
|
496
495
|
if (a1 > codingLine[codingPos]) {
|
497
496
|
if (a1 > this.columns) {
|
498
|
-
(0, _util.info)(
|
497
|
+
(0, _util.info)("row is wrong length");
|
499
498
|
this.err = true;
|
500
499
|
a1 = this.columns;
|
501
500
|
}
|
@@ -509,13 +508,14 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
509
508
|
|
510
509
|
this.codingPos = codingPos;
|
511
510
|
},
|
512
|
-
|
513
|
-
|
514
|
-
|
511
|
+
|
512
|
+
_addPixelsNeg(a1, blackPixels) {
|
513
|
+
const codingLine = this.codingLine;
|
514
|
+
let codingPos = this.codingPos;
|
515
515
|
|
516
516
|
if (a1 > codingLine[codingPos]) {
|
517
517
|
if (a1 > this.columns) {
|
518
|
-
(0, _util.info)(
|
518
|
+
(0, _util.info)("row is wrong length");
|
519
519
|
this.err = true;
|
520
520
|
a1 = this.columns;
|
521
521
|
}
|
@@ -527,7 +527,7 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
527
527
|
codingLine[codingPos] = a1;
|
528
528
|
} else if (a1 < codingLine[codingPos]) {
|
529
529
|
if (a1 < 0) {
|
530
|
-
(0, _util.info)(
|
530
|
+
(0, _util.info)("invalid code");
|
531
531
|
this.err = true;
|
532
532
|
a1 = 0;
|
533
533
|
}
|
@@ -541,11 +541,12 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
541
541
|
|
542
542
|
this.codingPos = codingPos;
|
543
543
|
},
|
544
|
-
_findTableCode: function _findTableCode(start, end, table, limit) {
|
545
|
-
var limitValue = limit || 0;
|
546
544
|
|
547
|
-
|
548
|
-
|
545
|
+
_findTableCode(start, end, table, limit) {
|
546
|
+
const limitValue = limit || 0;
|
547
|
+
|
548
|
+
for (let i = start; i <= end; ++i) {
|
549
|
+
let code = this._lookBits(i);
|
549
550
|
|
550
551
|
if (code === ccittEOF) {
|
551
552
|
return [true, 1, false];
|
@@ -556,7 +557,7 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
556
557
|
}
|
557
558
|
|
558
559
|
if (!limitValue || code >= limitValue) {
|
559
|
-
|
560
|
+
const p = table[code - limitValue];
|
560
561
|
|
561
562
|
if (p[0] === i) {
|
562
563
|
this._eatBits(i);
|
@@ -568,9 +569,10 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
568
569
|
|
569
570
|
return [false, 0, false];
|
570
571
|
},
|
571
|
-
|
572
|
-
|
573
|
-
|
572
|
+
|
573
|
+
_getTwoDimCode() {
|
574
|
+
let code = 0;
|
575
|
+
let p;
|
574
576
|
|
575
577
|
if (this.eoblock) {
|
576
578
|
code = this._lookBits(7);
|
@@ -582,19 +584,20 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
582
584
|
return p[1];
|
583
585
|
}
|
584
586
|
} else {
|
585
|
-
|
587
|
+
const result = this._findTableCode(1, 7, twoDimTable);
|
586
588
|
|
587
589
|
if (result[0] && result[2]) {
|
588
590
|
return result[1];
|
589
591
|
}
|
590
592
|
}
|
591
593
|
|
592
|
-
(0, _util.info)(
|
594
|
+
(0, _util.info)("Bad two dim code");
|
593
595
|
return ccittEOF;
|
594
596
|
},
|
595
|
-
|
596
|
-
|
597
|
-
|
597
|
+
|
598
|
+
_getWhiteCode() {
|
599
|
+
let code = 0;
|
600
|
+
let p;
|
598
601
|
|
599
602
|
if (this.eoblock) {
|
600
603
|
code = this._lookBits(12);
|
@@ -615,7 +618,7 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
615
618
|
return p[1];
|
616
619
|
}
|
617
620
|
} else {
|
618
|
-
|
621
|
+
let result = this._findTableCode(1, 9, whiteTable2);
|
619
622
|
|
620
623
|
if (result[0]) {
|
621
624
|
return result[1];
|
@@ -628,14 +631,15 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
628
631
|
}
|
629
632
|
}
|
630
633
|
|
631
|
-
(0, _util.info)(
|
634
|
+
(0, _util.info)("bad white code");
|
632
635
|
|
633
636
|
this._eatBits(1);
|
634
637
|
|
635
638
|
return 1;
|
636
639
|
},
|
637
|
-
|
638
|
-
|
640
|
+
|
641
|
+
_getBlackCode() {
|
642
|
+
let code, p;
|
639
643
|
|
640
644
|
if (this.eoblock) {
|
641
645
|
code = this._lookBits(13);
|
@@ -658,7 +662,7 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
658
662
|
return p[1];
|
659
663
|
}
|
660
664
|
} else {
|
661
|
-
|
665
|
+
let result = this._findTableCode(2, 6, blackTable3);
|
662
666
|
|
663
667
|
if (result[0]) {
|
664
668
|
return result[1];
|
@@ -677,14 +681,15 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
677
681
|
}
|
678
682
|
}
|
679
683
|
|
680
|
-
(0, _util.info)(
|
684
|
+
(0, _util.info)("bad black code");
|
681
685
|
|
682
686
|
this._eatBits(1);
|
683
687
|
|
684
688
|
return 1;
|
685
689
|
},
|
686
|
-
|
687
|
-
|
690
|
+
|
691
|
+
_lookBits(n) {
|
692
|
+
let c;
|
688
693
|
|
689
694
|
while (this.inputBits < n) {
|
690
695
|
if ((c = this.source.next()) === -1) {
|
@@ -692,20 +697,22 @@ var CCITTFaxDecoder = function CCITTFaxDecoder() {
|
|
692
697
|
return ccittEOF;
|
693
698
|
}
|
694
699
|
|
695
|
-
return this.inputBuf << n - this.inputBits &
|
700
|
+
return this.inputBuf << n - this.inputBits & 0xffff >> 16 - n;
|
696
701
|
}
|
697
702
|
|
698
703
|
this.inputBuf = this.inputBuf << 8 | c;
|
699
704
|
this.inputBits += 8;
|
700
705
|
}
|
701
706
|
|
702
|
-
return this.inputBuf >> this.inputBits - n &
|
707
|
+
return this.inputBuf >> this.inputBits - n & 0xffff >> 16 - n;
|
703
708
|
},
|
704
|
-
|
709
|
+
|
710
|
+
_eatBits(n) {
|
705
711
|
if ((this.inputBits -= n) < 0) {
|
706
712
|
this.inputBits = 0;
|
707
713
|
}
|
708
714
|
}
|
715
|
+
|
709
716
|
};
|
710
717
|
return CCITTFaxDecoder;
|
711
718
|
}();
|
package/lib/core/ccitt_stream.js
CHANGED
@@ -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
|
5
|
+
* Copyright 2020 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.
|
@@ -26,11 +26,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
26
26
|
});
|
27
27
|
exports.CCITTFaxStream = void 0;
|
28
28
|
|
29
|
-
var _primitives = require("./primitives");
|
29
|
+
var _primitives = require("./primitives.js");
|
30
30
|
|
31
|
-
var _ccitt = require("./ccitt");
|
31
|
+
var _ccitt = require("./ccitt.js");
|
32
32
|
|
33
|
-
var _stream = require("./stream");
|
33
|
+
var _stream = require("./stream.js");
|
34
34
|
|
35
35
|
var CCITTFaxStream = function CCITTFaxStreamClosure() {
|
36
36
|
function CCITTFaxStream(str, maybeLength, params) {
|
@@ -41,19 +41,20 @@ var CCITTFaxStream = function CCITTFaxStreamClosure() {
|
|
41
41
|
params = _primitives.Dict.empty;
|
42
42
|
}
|
43
43
|
|
44
|
-
|
45
|
-
next
|
44
|
+
const source = {
|
45
|
+
next() {
|
46
46
|
return str.getByte();
|
47
47
|
}
|
48
|
+
|
48
49
|
};
|
49
50
|
this.ccittFaxDecoder = new _ccitt.CCITTFaxDecoder(source, {
|
50
|
-
K: params.get(
|
51
|
-
EndOfLine: params.get(
|
52
|
-
EncodedByteAlign: params.get(
|
53
|
-
Columns: params.get(
|
54
|
-
Rows: params.get(
|
55
|
-
EndOfBlock: params.get(
|
56
|
-
BlackIs1: params.get(
|
51
|
+
K: params.get("K"),
|
52
|
+
EndOfLine: params.get("EndOfLine"),
|
53
|
+
EncodedByteAlign: params.get("EncodedByteAlign"),
|
54
|
+
Columns: params.get("Columns"),
|
55
|
+
Rows: params.get("Rows"),
|
56
|
+
EndOfBlock: params.get("EndOfBlock"),
|
57
|
+
BlackIs1: params.get("BlackIs1")
|
57
58
|
});
|
58
59
|
|
59
60
|
_stream.DecodeStream.call(this, maybeLength);
|
@@ -63,7 +64,7 @@ var CCITTFaxStream = function CCITTFaxStreamClosure() {
|
|
63
64
|
|
64
65
|
CCITTFaxStream.prototype.readBlock = function () {
|
65
66
|
while (!this.eof) {
|
66
|
-
|
67
|
+
const c = this.ccittFaxDecoder.readNextChar();
|
67
68
|
|
68
69
|
if (c === -1) {
|
69
70
|
this.eof = true;
|