2012-09-01 07:48:21 +09:00
|
|
|
/* Copyright 2012 Mozilla Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2020-10-03 19:26:25 +09:00
|
|
|
/* eslint-disable no-var */
|
2012-06-17 05:15:42 +09:00
|
|
|
|
2020-01-08 03:59:16 +09:00
|
|
|
import { BaseException, shadow } from "../shared/util.js";
|
|
|
|
import { log2, readInt8, readUint16, readUint32 } from "./core_utils.js";
|
2020-01-02 20:00:16 +09:00
|
|
|
import { ArithmeticDecoder } from "./arithmetic_decoder.js";
|
|
|
|
import { CCITTFaxDecoder } from "./ccitt.js";
|
2015-11-22 01:32:47 +09:00
|
|
|
|
2019-10-01 20:10:14 +09:00
|
|
|
class Jbig2Error extends BaseException {
|
|
|
|
constructor(msg) {
|
|
|
|
super(`JBIG2 error: ${msg}`);
|
2017-06-29 05:51:31 +09:00
|
|
|
}
|
2019-10-01 20:10:14 +09:00
|
|
|
}
|
2017-06-29 05:51:31 +09:00
|
|
|
|
2012-06-17 05:15:42 +09:00
|
|
|
var Jbig2Image = (function Jbig2ImageClosure() {
|
2012-06-22 19:36:56 +09:00
|
|
|
// Utility data structures
|
|
|
|
function ContextCache() {}
|
|
|
|
|
|
|
|
ContextCache.prototype = {
|
2017-04-27 19:58:44 +09:00
|
|
|
getContexts(id) {
|
2014-03-09 21:03:45 +09:00
|
|
|
if (id in this) {
|
2012-06-22 19:36:56 +09:00
|
|
|
return this[id];
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2014-05-11 01:03:54 +09:00
|
|
|
return (this[id] = new Int8Array(1 << 16));
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
},
|
2012-06-22 19:36:56 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
function DecodingContext(data, start, end) {
|
|
|
|
this.data = data;
|
|
|
|
this.start = start;
|
|
|
|
this.end = end;
|
|
|
|
}
|
|
|
|
|
|
|
|
DecodingContext.prototype = {
|
|
|
|
get decoder() {
|
|
|
|
var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
return shadow(this, "decoder", decoder);
|
2012-06-22 19:36:56 +09:00
|
|
|
},
|
|
|
|
get contextCache() {
|
|
|
|
var cache = new ContextCache();
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
return shadow(this, "contextCache", cache);
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
},
|
2012-06-22 19:36:56 +09:00
|
|
|
};
|
|
|
|
|
2012-06-19 05:03:20 +09:00
|
|
|
// Annex A. Arithmetic Integer Decoding Procedure
|
|
|
|
// A.2 Procedure for decoding values
|
|
|
|
function decodeInteger(contextCache, procedure, decoder) {
|
2012-06-22 19:36:56 +09:00
|
|
|
var contexts = contextCache.getContexts(procedure);
|
2012-06-19 05:03:20 +09:00
|
|
|
var prev = 1;
|
2014-05-11 01:03:54 +09:00
|
|
|
|
|
|
|
function readBits(length) {
|
|
|
|
var v = 0;
|
|
|
|
for (var i = 0; i < length; i++) {
|
|
|
|
var bit = decoder.readBit(contexts, prev);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
prev =
|
|
|
|
prev < 256 ? (prev << 1) | bit : (((prev << 1) | bit) & 511) | 256;
|
2014-05-11 01:03:54 +09:00
|
|
|
v = (v << 1) | bit;
|
2012-06-19 05:03:20 +09:00
|
|
|
}
|
2014-05-11 01:03:54 +09:00
|
|
|
return v >>> 0;
|
2012-06-19 05:03:20 +09:00
|
|
|
}
|
2014-05-11 01:03:54 +09:00
|
|
|
|
|
|
|
var sign = readBits(1);
|
2019-12-25 23:54:34 +09:00
|
|
|
// prettier-ignore
|
2020-01-13 03:47:13 +09:00
|
|
|
/* eslint-disable no-nested-ternary */
|
2014-05-11 01:03:54 +09:00
|
|
|
var value = readBits(1) ?
|
|
|
|
(readBits(1) ?
|
|
|
|
(readBits(1) ?
|
|
|
|
(readBits(1) ?
|
|
|
|
(readBits(1) ?
|
|
|
|
(readBits(32) + 4436) :
|
|
|
|
readBits(12) + 340) :
|
|
|
|
readBits(8) + 84) :
|
|
|
|
readBits(6) + 20) :
|
|
|
|
readBits(4) + 4) :
|
|
|
|
readBits(2);
|
2020-01-13 03:47:13 +09:00
|
|
|
/* eslint-enable no-nested-ternary */
|
|
|
|
if (sign === 0) {
|
|
|
|
return value;
|
|
|
|
} else if (value > 0) {
|
|
|
|
return -value;
|
|
|
|
}
|
|
|
|
return null;
|
2012-06-19 05:03:20 +09:00
|
|
|
}
|
2012-06-22 19:36:56 +09:00
|
|
|
|
2012-06-19 05:03:20 +09:00
|
|
|
// A.3 The IAID decoding procedure
|
|
|
|
function decodeIAID(contextCache, decoder, codeLength) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var contexts = contextCache.getContexts("IAID");
|
2012-06-19 05:03:20 +09:00
|
|
|
|
|
|
|
var prev = 1;
|
|
|
|
for (var i = 0; i < codeLength; i++) {
|
2013-08-04 07:42:37 +09:00
|
|
|
var bit = decoder.readBit(contexts, prev);
|
2014-03-05 01:28:53 +09:00
|
|
|
prev = (prev << 1) | bit;
|
2012-06-19 05:03:20 +09:00
|
|
|
}
|
2014-03-09 21:03:45 +09:00
|
|
|
if (codeLength < 31) {
|
2012-06-19 05:03:20 +09:00
|
|
|
return prev & ((1 << codeLength) - 1);
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
return prev & 0x7fffffff;
|
2012-06-19 05:03:20 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
// 7.3 Segment types
|
2012-06-17 05:15:42 +09:00
|
|
|
var SegmentTypes = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
"SymbolDictionary",
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
"IntermediateTextRegion",
|
|
|
|
null,
|
|
|
|
"ImmediateTextRegion",
|
|
|
|
"ImmediateLosslessTextRegion",
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
"PatternDictionary",
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
"IntermediateHalftoneRegion",
|
|
|
|
null,
|
|
|
|
"ImmediateHalftoneRegion",
|
|
|
|
"ImmediateLosslessHalftoneRegion",
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
"IntermediateGenericRegion",
|
|
|
|
null,
|
|
|
|
"ImmediateGenericRegion",
|
|
|
|
"ImmediateLosslessGenericRegion",
|
|
|
|
"IntermediateGenericRefinementRegion",
|
|
|
|
null,
|
|
|
|
"ImmediateGenericRefinementRegion",
|
|
|
|
"ImmediateLosslessGenericRefinementRegion",
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
"PageInformation",
|
|
|
|
"EndOfPage",
|
|
|
|
"EndOfStripe",
|
|
|
|
"EndOfFile",
|
|
|
|
"Profiles",
|
|
|
|
"Tables",
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
"Extension",
|
2012-06-17 05:15:42 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
var CodingTemplates = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[
|
|
|
|
{ x: -1, y: -2 },
|
|
|
|
{ x: 0, y: -2 },
|
|
|
|
{ x: 1, y: -2 },
|
|
|
|
{ x: -2, y: -1 },
|
|
|
|
{ x: -1, y: -1 },
|
|
|
|
{ x: 0, y: -1 },
|
|
|
|
{ x: 1, y: -1 },
|
|
|
|
{ x: 2, y: -1 },
|
|
|
|
{ x: -4, y: 0 },
|
|
|
|
{ x: -3, y: 0 },
|
|
|
|
{ x: -2, y: 0 },
|
|
|
|
{ x: -1, y: 0 },
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{ x: -1, y: -2 },
|
|
|
|
{ x: 0, y: -2 },
|
|
|
|
{ x: 1, y: -2 },
|
|
|
|
{ x: 2, y: -2 },
|
|
|
|
{ x: -2, y: -1 },
|
|
|
|
{ x: -1, y: -1 },
|
|
|
|
{ x: 0, y: -1 },
|
|
|
|
{ x: 1, y: -1 },
|
|
|
|
{ x: 2, y: -1 },
|
|
|
|
{ x: -3, y: 0 },
|
|
|
|
{ x: -2, y: 0 },
|
|
|
|
{ x: -1, y: 0 },
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{ x: -1, y: -2 },
|
|
|
|
{ x: 0, y: -2 },
|
|
|
|
{ x: 1, y: -2 },
|
|
|
|
{ x: -2, y: -1 },
|
|
|
|
{ x: -1, y: -1 },
|
|
|
|
{ x: 0, y: -1 },
|
|
|
|
{ x: 1, y: -1 },
|
|
|
|
{ x: -2, y: 0 },
|
|
|
|
{ x: -1, y: 0 },
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{ x: -3, y: -1 },
|
|
|
|
{ x: -2, y: -1 },
|
|
|
|
{ x: -1, y: -1 },
|
|
|
|
{ x: 0, y: -1 },
|
|
|
|
{ x: 1, y: -1 },
|
|
|
|
{ x: -4, y: 0 },
|
|
|
|
{ x: -3, y: 0 },
|
|
|
|
{ x: -2, y: 0 },
|
|
|
|
{ x: -1, y: 0 },
|
|
|
|
],
|
2012-06-17 05:15:42 +09:00
|
|
|
];
|
|
|
|
|
2012-06-22 07:26:24 +09:00
|
|
|
var RefinementTemplates = [
|
|
|
|
{
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
coding: [
|
|
|
|
{ x: 0, y: -1 },
|
|
|
|
{ x: 1, y: -1 },
|
|
|
|
{ x: -1, y: 0 },
|
|
|
|
],
|
|
|
|
reference: [
|
|
|
|
{ x: 0, y: -1 },
|
|
|
|
{ x: 1, y: -1 },
|
|
|
|
{ x: -1, y: 0 },
|
|
|
|
{ x: 0, y: 0 },
|
|
|
|
{ x: 1, y: 0 },
|
|
|
|
{ x: -1, y: 1 },
|
|
|
|
{ x: 0, y: 1 },
|
|
|
|
{ x: 1, y: 1 },
|
|
|
|
],
|
2012-06-22 07:26:24 +09:00
|
|
|
},
|
|
|
|
{
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
coding: [
|
|
|
|
{ x: -1, y: -1 },
|
|
|
|
{ x: 0, y: -1 },
|
|
|
|
{ x: 1, y: -1 },
|
|
|
|
{ x: -1, y: 0 },
|
|
|
|
],
|
|
|
|
reference: [
|
|
|
|
{ x: 0, y: -1 },
|
|
|
|
{ x: -1, y: 0 },
|
|
|
|
{ x: 0, y: 0 },
|
|
|
|
{ x: 1, y: 0 },
|
|
|
|
{ x: 0, y: 1 },
|
|
|
|
{ x: 1, y: 1 },
|
|
|
|
],
|
|
|
|
},
|
2012-06-22 07:26:24 +09:00
|
|
|
];
|
|
|
|
|
2014-08-01 15:38:13 +09:00
|
|
|
// See 6.2.5.7 Decoding the bitmap.
|
2012-06-17 05:15:42 +09:00
|
|
|
var ReusedContexts = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
0x9b25, // 10011 0110010 0101
|
2014-08-01 15:38:13 +09:00
|
|
|
0x0795, // 0011 110010 101
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
0x00e5, // 001 11001 01
|
|
|
|
0x0195, // 011001 0101
|
2012-06-17 05:15:42 +09:00
|
|
|
];
|
|
|
|
|
2012-06-22 07:26:24 +09:00
|
|
|
var RefinementReusedContexts = [
|
|
|
|
0x0020, // '000' + '0' (coding) + '00010000' + '0' (reference)
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
0x0008, // '0000' + '001000'
|
2012-06-22 07:26:24 +09:00
|
|
|
];
|
|
|
|
|
2014-08-01 22:29:03 +09:00
|
|
|
function decodeBitmapTemplate0(width, height, decodingContext) {
|
|
|
|
var decoder = decodingContext.decoder;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var contexts = decodingContext.contextCache.getContexts("GB");
|
|
|
|
var contextLabel,
|
|
|
|
i,
|
|
|
|
j,
|
|
|
|
pixel,
|
|
|
|
row,
|
|
|
|
row1,
|
|
|
|
row2,
|
|
|
|
bitmap = [];
|
2014-08-01 22:29:03 +09:00
|
|
|
|
|
|
|
// ...ooooo....
|
|
|
|
// ..ooooooo... Context template for current pixel (X)
|
|
|
|
// .ooooX...... (concatenate values of 'o'-pixels to get contextLabel)
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var OLD_PIXEL_MASK = 0x7bf7; // 01111 0111111 0111
|
2014-08-01 22:29:03 +09:00
|
|
|
|
|
|
|
for (i = 0; i < height; i++) {
|
|
|
|
row = bitmap[i] = new Uint8Array(width);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
row1 = i < 1 ? row : bitmap[i - 1];
|
|
|
|
row2 = i < 2 ? row : bitmap[i - 2];
|
2014-08-01 22:29:03 +09:00
|
|
|
|
|
|
|
// At the beginning of each row:
|
|
|
|
// Fill contextLabel with pixels that are above/right of (X)
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
contextLabel =
|
|
|
|
(row2[0] << 13) |
|
|
|
|
(row2[1] << 12) |
|
|
|
|
(row2[2] << 11) |
|
|
|
|
(row1[0] << 7) |
|
|
|
|
(row1[1] << 6) |
|
|
|
|
(row1[2] << 5) |
|
|
|
|
(row1[3] << 4);
|
2014-08-01 22:29:03 +09:00
|
|
|
|
|
|
|
for (j = 0; j < width; j++) {
|
|
|
|
row[j] = pixel = decoder.readBit(contexts, contextLabel);
|
|
|
|
|
|
|
|
// At each pixel: Clear contextLabel pixels that are shifted
|
|
|
|
// out of the context, then add new ones.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
contextLabel =
|
|
|
|
((contextLabel & OLD_PIXEL_MASK) << 1) |
|
|
|
|
(j + 3 < width ? row2[j + 3] << 11 : 0) |
|
|
|
|
(j + 4 < width ? row1[j + 4] << 4 : 0) |
|
|
|
|
pixel;
|
2014-08-01 22:29:03 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
|
2012-06-22 07:26:24 +09:00
|
|
|
// 6.2 Generic Region Decoding Procedure
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
function decodeBitmap(
|
|
|
|
mmr,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
templateIndex,
|
|
|
|
prediction,
|
|
|
|
skip,
|
|
|
|
at,
|
|
|
|
decodingContext
|
|
|
|
) {
|
2014-03-09 21:03:45 +09:00
|
|
|
if (mmr) {
|
2020-01-24 17:48:21 +09:00
|
|
|
const input = new Reader(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
decodingContext.data,
|
|
|
|
decodingContext.start,
|
|
|
|
decodingContext.end
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
return decodeMMRBitmap(input, width, height, false);
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
|
2014-08-01 22:29:03 +09:00
|
|
|
// Use optimized version for the most common case
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (
|
|
|
|
templateIndex === 0 &&
|
|
|
|
!skip &&
|
|
|
|
!prediction &&
|
|
|
|
at.length === 4 &&
|
|
|
|
at[0].x === 3 &&
|
|
|
|
at[0].y === -1 &&
|
|
|
|
at[1].x === -3 &&
|
|
|
|
at[1].y === -1 &&
|
|
|
|
at[2].x === 2 &&
|
|
|
|
at[2].y === -2 &&
|
|
|
|
at[3].x === -2 &&
|
|
|
|
at[3].y === -2
|
|
|
|
) {
|
2014-08-01 22:29:03 +09:00
|
|
|
return decodeBitmapTemplate0(width, height, decodingContext);
|
|
|
|
}
|
|
|
|
|
2012-06-17 05:15:42 +09:00
|
|
|
var useskip = !!skip;
|
|
|
|
var template = CodingTemplates[templateIndex].concat(at);
|
2014-02-28 18:53:09 +09:00
|
|
|
|
|
|
|
// Sorting is non-standard, and it is not required. But sorting increases
|
|
|
|
// the number of template bits that can be reused from the previous
|
|
|
|
// contextLabel in the main loop.
|
2020-04-14 19:28:14 +09:00
|
|
|
template.sort(function (a, b) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
return a.y - b.y || a.x - b.x;
|
2014-02-28 18:53:09 +09:00
|
|
|
});
|
|
|
|
|
2012-06-17 05:15:42 +09:00
|
|
|
var templateLength = template.length;
|
2014-02-28 18:53:09 +09:00
|
|
|
var templateX = new Int8Array(templateLength);
|
|
|
|
var templateY = new Int8Array(templateLength);
|
|
|
|
var changingTemplateEntries = [];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var reuseMask = 0,
|
|
|
|
minX = 0,
|
|
|
|
maxX = 0,
|
|
|
|
minY = 0;
|
2014-04-08 06:42:54 +09:00
|
|
|
var c, k;
|
2014-02-28 18:53:09 +09:00
|
|
|
|
2014-04-08 06:42:54 +09:00
|
|
|
for (k = 0; k < templateLength; k++) {
|
2012-06-17 05:15:42 +09:00
|
|
|
templateX[k] = template[k].x;
|
|
|
|
templateY[k] = template[k].y;
|
2014-02-28 18:53:09 +09:00
|
|
|
minX = Math.min(minX, template[k].x);
|
|
|
|
maxX = Math.max(maxX, template[k].x);
|
|
|
|
minY = Math.min(minY, template[k].y);
|
|
|
|
// Check if the template pixel appears in two consecutive context labels,
|
|
|
|
// so it can be reused. Otherwise, we add it to the list of changing
|
|
|
|
// template entries.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (
|
|
|
|
k < templateLength - 1 &&
|
|
|
|
template[k].y === template[k + 1].y &&
|
|
|
|
template[k].x === template[k + 1].x - 1
|
|
|
|
) {
|
2014-02-28 18:53:09 +09:00
|
|
|
reuseMask |= 1 << (templateLength - 1 - k);
|
|
|
|
} else {
|
|
|
|
changingTemplateEntries.push(k);
|
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
}
|
2014-02-28 18:53:09 +09:00
|
|
|
var changingEntriesLength = changingTemplateEntries.length;
|
2012-06-22 07:26:24 +09:00
|
|
|
|
2014-03-08 01:26:56 +09:00
|
|
|
var changingTemplateX = new Int8Array(changingEntriesLength);
|
|
|
|
var changingTemplateY = new Int8Array(changingEntriesLength);
|
|
|
|
var changingTemplateBit = new Uint16Array(changingEntriesLength);
|
2014-04-08 06:42:54 +09:00
|
|
|
for (c = 0; c < changingEntriesLength; c++) {
|
2014-03-08 01:26:56 +09:00
|
|
|
k = changingTemplateEntries[c];
|
|
|
|
changingTemplateX[c] = template[k].x;
|
|
|
|
changingTemplateY[c] = template[k].y;
|
|
|
|
changingTemplateBit[c] = 1 << (templateLength - 1 - k);
|
|
|
|
}
|
2014-03-07 20:12:45 +09:00
|
|
|
|
|
|
|
// Get the safe bounding box edges from the width, height, minX, maxX, minY
|
|
|
|
var sbb_left = -minX;
|
|
|
|
var sbb_top = -minY;
|
|
|
|
var sbb_right = width - maxX;
|
|
|
|
|
2012-06-22 07:26:24 +09:00
|
|
|
var pseudoPixelContext = ReusedContexts[templateIndex];
|
2014-03-08 01:30:24 +09:00
|
|
|
var row = new Uint8Array(width);
|
2012-06-17 05:15:42 +09:00
|
|
|
var bitmap = [];
|
2012-06-22 19:36:56 +09:00
|
|
|
|
|
|
|
var decoder = decodingContext.decoder;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var contexts = decodingContext.contextCache.getContexts("GB");
|
|
|
|
|
|
|
|
var ltp = 0,
|
|
|
|
j,
|
|
|
|
i0,
|
|
|
|
j0,
|
|
|
|
contextLabel = 0,
|
|
|
|
bit,
|
|
|
|
shift;
|
2012-06-17 05:15:42 +09:00
|
|
|
for (var i = 0; i < height; i++) {
|
|
|
|
if (prediction) {
|
2013-08-04 07:42:37 +09:00
|
|
|
var sltp = decoder.readBit(contexts, pseudoPixelContext);
|
2012-06-17 05:15:42 +09:00
|
|
|
ltp ^= sltp;
|
2014-03-07 19:51:04 +09:00
|
|
|
if (ltp) {
|
2014-03-08 01:30:24 +09:00
|
|
|
bitmap.push(row); // duplicate previous row
|
2014-03-07 19:51:04 +09:00
|
|
|
continue;
|
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
}
|
2014-03-08 01:30:24 +09:00
|
|
|
row = new Uint8Array(row);
|
2012-06-17 05:15:42 +09:00
|
|
|
bitmap.push(row);
|
2014-02-28 18:53:09 +09:00
|
|
|
for (j = 0; j < width; j++) {
|
2012-06-17 05:15:42 +09:00
|
|
|
if (useskip && skip[i][j]) {
|
|
|
|
row[j] = 0;
|
|
|
|
continue;
|
|
|
|
}
|
2014-02-28 18:53:09 +09:00
|
|
|
// Are we in the middle of a scanline, so we can reuse contextLabel
|
|
|
|
// bits?
|
2014-03-07 20:12:45 +09:00
|
|
|
if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
|
2014-02-28 18:53:09 +09:00
|
|
|
// If yes, we can just shift the bits that are reusable and only
|
|
|
|
// fetch the remaining ones.
|
|
|
|
contextLabel = (contextLabel << 1) & reuseMask;
|
2014-03-08 01:26:56 +09:00
|
|
|
for (k = 0; k < changingEntriesLength; k++) {
|
|
|
|
i0 = i + changingTemplateY[k];
|
|
|
|
j0 = j + changingTemplateX[k];
|
|
|
|
bit = bitmap[i0][j0];
|
|
|
|
if (bit) {
|
|
|
|
bit = changingTemplateBit[k];
|
|
|
|
contextLabel |= bit;
|
|
|
|
}
|
2014-02-28 18:53:09 +09:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// compute the contextLabel from scratch
|
|
|
|
contextLabel = 0;
|
2014-03-08 01:26:56 +09:00
|
|
|
shift = templateLength - 1;
|
2014-03-07 20:12:45 +09:00
|
|
|
for (k = 0; k < templateLength; k++, shift--) {
|
2014-02-28 18:53:09 +09:00
|
|
|
j0 = j + templateX[k];
|
2014-03-07 20:12:45 +09:00
|
|
|
if (j0 >= 0 && j0 < width) {
|
|
|
|
i0 = i + templateY[k];
|
|
|
|
if (i0 >= 0) {
|
|
|
|
bit = bitmap[i0][j0];
|
|
|
|
if (bit) {
|
|
|
|
contextLabel |= bit << shift;
|
|
|
|
}
|
|
|
|
}
|
2014-02-28 18:53:09 +09:00
|
|
|
}
|
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
}
|
2013-08-04 07:42:37 +09:00
|
|
|
var pixel = decoder.readBit(contexts, contextLabel);
|
2012-06-17 05:15:42 +09:00
|
|
|
row[j] = pixel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
|
2012-06-22 07:26:24 +09:00
|
|
|
// 6.3.2 Generic Refinement Region Decoding Procedure
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
function decodeRefinement(
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
templateIndex,
|
|
|
|
referenceBitmap,
|
|
|
|
offsetX,
|
|
|
|
offsetY,
|
|
|
|
prediction,
|
|
|
|
at,
|
|
|
|
decodingContext
|
|
|
|
) {
|
2012-06-22 07:26:24 +09:00
|
|
|
var codingTemplate = RefinementTemplates[templateIndex].coding;
|
2014-03-09 21:03:45 +09:00
|
|
|
if (templateIndex === 0) {
|
2012-06-22 07:26:24 +09:00
|
|
|
codingTemplate = codingTemplate.concat([at[0]]);
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-22 07:26:24 +09:00
|
|
|
var codingTemplateLength = codingTemplate.length;
|
|
|
|
var codingTemplateX = new Int32Array(codingTemplateLength);
|
|
|
|
var codingTemplateY = new Int32Array(codingTemplateLength);
|
2014-04-08 06:42:54 +09:00
|
|
|
var k;
|
|
|
|
for (k = 0; k < codingTemplateLength; k++) {
|
2012-06-22 07:26:24 +09:00
|
|
|
codingTemplateX[k] = codingTemplate[k].x;
|
|
|
|
codingTemplateY[k] = codingTemplate[k].y;
|
|
|
|
}
|
2014-03-09 21:03:45 +09:00
|
|
|
|
2012-06-22 07:26:24 +09:00
|
|
|
var referenceTemplate = RefinementTemplates[templateIndex].reference;
|
2014-03-09 21:03:45 +09:00
|
|
|
if (templateIndex === 0) {
|
2012-06-22 07:26:24 +09:00
|
|
|
referenceTemplate = referenceTemplate.concat([at[1]]);
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-22 07:26:24 +09:00
|
|
|
var referenceTemplateLength = referenceTemplate.length;
|
|
|
|
var referenceTemplateX = new Int32Array(referenceTemplateLength);
|
|
|
|
var referenceTemplateY = new Int32Array(referenceTemplateLength);
|
2014-04-08 06:42:54 +09:00
|
|
|
for (k = 0; k < referenceTemplateLength; k++) {
|
2012-06-22 07:26:24 +09:00
|
|
|
referenceTemplateX[k] = referenceTemplate[k].x;
|
|
|
|
referenceTemplateY[k] = referenceTemplate[k].y;
|
|
|
|
}
|
|
|
|
var referenceWidth = referenceBitmap[0].length;
|
|
|
|
var referenceHeight = referenceBitmap.length;
|
|
|
|
|
|
|
|
var pseudoPixelContext = RefinementReusedContexts[templateIndex];
|
|
|
|
var bitmap = [];
|
2012-06-22 19:36:56 +09:00
|
|
|
|
|
|
|
var decoder = decodingContext.decoder;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var contexts = decodingContext.contextCache.getContexts("GR");
|
2012-06-22 07:26:24 +09:00
|
|
|
|
|
|
|
var ltp = 0;
|
|
|
|
for (var i = 0; i < height; i++) {
|
|
|
|
if (prediction) {
|
2013-08-04 07:42:37 +09:00
|
|
|
var sltp = decoder.readBit(contexts, pseudoPixelContext);
|
2012-06-22 07:26:24 +09:00
|
|
|
ltp ^= sltp;
|
2014-03-10 22:58:32 +09:00
|
|
|
if (ltp) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("prediction is not supported");
|
2014-03-10 22:58:32 +09:00
|
|
|
}
|
2012-06-22 07:26:24 +09:00
|
|
|
}
|
|
|
|
var row = new Uint8Array(width);
|
|
|
|
bitmap.push(row);
|
|
|
|
for (var j = 0; j < width; j++) {
|
2014-04-08 06:42:54 +09:00
|
|
|
var i0, j0;
|
2012-06-22 07:26:24 +09:00
|
|
|
var contextLabel = 0;
|
2014-04-08 06:42:54 +09:00
|
|
|
for (k = 0; k < codingTemplateLength; k++) {
|
|
|
|
i0 = i + codingTemplateY[k];
|
|
|
|
j0 = j + codingTemplateX[k];
|
2014-03-09 21:03:45 +09:00
|
|
|
if (i0 < 0 || j0 < 0 || j0 >= width) {
|
2012-06-22 07:26:24 +09:00
|
|
|
contextLabel <<= 1; // out of bound pixel
|
2014-03-09 21:03:45 +09:00
|
|
|
} else {
|
2012-06-22 07:26:24 +09:00
|
|
|
contextLabel = (contextLabel << 1) | bitmap[i0][j0];
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-22 07:26:24 +09:00
|
|
|
}
|
2014-04-08 06:42:54 +09:00
|
|
|
for (k = 0; k < referenceTemplateLength; k++) {
|
2017-04-26 22:47:59 +09:00
|
|
|
i0 = i + referenceTemplateY[k] - offsetY;
|
|
|
|
j0 = j + referenceTemplateX[k] - offsetX;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (
|
|
|
|
i0 < 0 ||
|
|
|
|
i0 >= referenceHeight ||
|
|
|
|
j0 < 0 ||
|
|
|
|
j0 >= referenceWidth
|
|
|
|
) {
|
2012-06-22 07:26:24 +09:00
|
|
|
contextLabel <<= 1; // out of bound pixel
|
2014-03-09 21:03:45 +09:00
|
|
|
} else {
|
2012-06-22 07:26:24 +09:00
|
|
|
contextLabel = (contextLabel << 1) | referenceBitmap[i0][j0];
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-22 07:26:24 +09:00
|
|
|
}
|
2013-08-04 07:42:37 +09:00
|
|
|
var pixel = decoder.readBit(contexts, contextLabel);
|
2012-06-22 07:26:24 +09:00
|
|
|
row[j] = pixel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
|
2012-06-19 05:03:20 +09:00
|
|
|
// 6.5.5 Decoding the symbol dictionary
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
function decodeSymbolDictionary(
|
|
|
|
huffman,
|
|
|
|
refinement,
|
|
|
|
symbols,
|
|
|
|
numberOfNewSymbols,
|
|
|
|
numberOfExportedSymbols,
|
|
|
|
huffmanTables,
|
|
|
|
templateIndex,
|
|
|
|
at,
|
|
|
|
refinementTemplateIndex,
|
|
|
|
refinementAt,
|
|
|
|
decodingContext,
|
|
|
|
huffmanInput
|
|
|
|
) {
|
2018-01-24 00:04:07 +09:00
|
|
|
if (huffman && refinement) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("symbol refinement with Huffman is not supported");
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-19 05:03:20 +09:00
|
|
|
|
|
|
|
var newSymbols = [];
|
|
|
|
var currentHeight = 0;
|
2012-06-22 07:26:24 +09:00
|
|
|
var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
|
2012-06-22 19:36:56 +09:00
|
|
|
|
|
|
|
var decoder = decodingContext.decoder;
|
|
|
|
var contextCache = decodingContext.contextCache;
|
2018-01-24 00:04:07 +09:00
|
|
|
let tableB1, symbolWidths;
|
|
|
|
if (huffman) {
|
|
|
|
tableB1 = getStandardTable(1); // standard table B.1
|
|
|
|
symbolWidths = [];
|
|
|
|
symbolCodeLength = Math.max(symbolCodeLength, 1); // 6.5.8.2.3
|
|
|
|
}
|
2012-06-22 19:36:56 +09:00
|
|
|
|
2012-06-19 05:03:20 +09:00
|
|
|
while (newSymbols.length < numberOfNewSymbols) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var deltaHeight = huffman
|
|
|
|
? huffmanTables.tableDeltaHeight.decode(huffmanInput)
|
|
|
|
: decodeInteger(contextCache, "IADH", decoder); // 6.5.6
|
2012-06-19 05:03:20 +09:00
|
|
|
currentHeight += deltaHeight;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
let currentWidth = 0,
|
|
|
|
totalWidth = 0;
|
2020-01-24 17:48:21 +09:00
|
|
|
const firstSymbol = huffman ? symbolWidths.length : 0;
|
2012-06-19 05:03:20 +09:00
|
|
|
while (true) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var deltaWidth = huffman
|
|
|
|
? huffmanTables.tableDeltaWidth.decode(huffmanInput)
|
|
|
|
: decodeInteger(contextCache, "IADW", decoder); // 6.5.7
|
2014-03-09 21:03:45 +09:00
|
|
|
if (deltaWidth === null) {
|
2012-06-19 05:03:20 +09:00
|
|
|
break; // OOB
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-19 05:03:20 +09:00
|
|
|
currentWidth += deltaWidth;
|
2018-01-24 00:04:07 +09:00
|
|
|
totalWidth += currentWidth;
|
2012-06-22 07:26:24 +09:00
|
|
|
var bitmap;
|
|
|
|
if (refinement) {
|
|
|
|
// 6.5.8.2 Refinement/aggregate-coded symbol bitmap
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var numberOfInstances = decodeInteger(contextCache, "IAAI", decoder);
|
2014-03-09 21:03:45 +09:00
|
|
|
if (numberOfInstances > 1) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
bitmap = decodeTextRegion(
|
|
|
|
huffman,
|
|
|
|
refinement,
|
|
|
|
currentWidth,
|
|
|
|
currentHeight,
|
|
|
|
0,
|
|
|
|
numberOfInstances,
|
|
|
|
1, // strip size
|
|
|
|
symbols.concat(newSymbols),
|
|
|
|
symbolCodeLength,
|
|
|
|
0, // transposed
|
|
|
|
0, // ds offset
|
|
|
|
1, // top left 7.4.3.1.1
|
|
|
|
0, // OR operator
|
|
|
|
huffmanTables,
|
|
|
|
refinementTemplateIndex,
|
|
|
|
refinementAt,
|
|
|
|
decodingContext,
|
|
|
|
0,
|
|
|
|
huffmanInput
|
|
|
|
);
|
2014-03-24 14:35:07 +09:00
|
|
|
} else {
|
|
|
|
var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var rdx = decodeInteger(contextCache, "IARDX", decoder); // 6.4.11.3
|
|
|
|
var rdy = decodeInteger(contextCache, "IARDY", decoder); // 6.4.11.4
|
|
|
|
var symbol =
|
|
|
|
symbolId < symbols.length
|
|
|
|
? symbols[symbolId]
|
|
|
|
: newSymbols[symbolId - symbols.length];
|
|
|
|
bitmap = decodeRefinement(
|
|
|
|
currentWidth,
|
|
|
|
currentHeight,
|
|
|
|
refinementTemplateIndex,
|
|
|
|
symbol,
|
|
|
|
rdx,
|
|
|
|
rdy,
|
|
|
|
false,
|
|
|
|
refinementAt,
|
|
|
|
decodingContext
|
|
|
|
);
|
2014-03-24 14:35:07 +09:00
|
|
|
}
|
2018-01-24 00:04:07 +09:00
|
|
|
newSymbols.push(bitmap);
|
|
|
|
} else if (huffman) {
|
|
|
|
// Store only symbol width and decode a collective bitmap when the
|
|
|
|
// height class is done.
|
|
|
|
symbolWidths.push(currentWidth);
|
2012-06-22 07:26:24 +09:00
|
|
|
} else {
|
|
|
|
// 6.5.8.1 Direct-coded symbol bitmap
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
bitmap = decodeBitmap(
|
|
|
|
false,
|
|
|
|
currentWidth,
|
|
|
|
currentHeight,
|
|
|
|
templateIndex,
|
|
|
|
false,
|
|
|
|
null,
|
|
|
|
at,
|
|
|
|
decodingContext
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
newSymbols.push(bitmap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (huffman && !refinement) {
|
|
|
|
// 6.5.9 Height class collective bitmap
|
2020-01-24 17:48:21 +09:00
|
|
|
const bitmapSize = huffmanTables.tableBitmapSize.decode(huffmanInput);
|
2018-01-24 00:04:07 +09:00
|
|
|
huffmanInput.byteAlign();
|
|
|
|
let collectiveBitmap;
|
|
|
|
if (bitmapSize === 0) {
|
|
|
|
// Uncompressed collective bitmap
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
collectiveBitmap = readUncompressedBitmap(
|
|
|
|
huffmanInput,
|
|
|
|
totalWidth,
|
|
|
|
currentHeight
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
} else {
|
|
|
|
// MMR collective bitmap
|
2020-01-24 17:48:21 +09:00
|
|
|
const originalEnd = huffmanInput.end;
|
|
|
|
const bitmapEnd = huffmanInput.position + bitmapSize;
|
2018-01-24 00:04:07 +09:00
|
|
|
huffmanInput.end = bitmapEnd;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
collectiveBitmap = decodeMMRBitmap(
|
|
|
|
huffmanInput,
|
|
|
|
totalWidth,
|
|
|
|
currentHeight,
|
|
|
|
false
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
huffmanInput.end = originalEnd;
|
|
|
|
huffmanInput.position = bitmapEnd;
|
|
|
|
}
|
2020-01-24 17:48:21 +09:00
|
|
|
const numberOfSymbolsDecoded = symbolWidths.length;
|
2018-01-24 00:04:07 +09:00
|
|
|
if (firstSymbol === numberOfSymbolsDecoded - 1) {
|
|
|
|
// collectiveBitmap is a single symbol.
|
|
|
|
newSymbols.push(collectiveBitmap);
|
|
|
|
} else {
|
|
|
|
// Divide collectiveBitmap into symbols.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
let i,
|
|
|
|
y,
|
|
|
|
xMin = 0,
|
|
|
|
xMax,
|
|
|
|
bitmapWidth,
|
|
|
|
symbolBitmap;
|
2018-01-24 00:04:07 +09:00
|
|
|
for (i = firstSymbol; i < numberOfSymbolsDecoded; i++) {
|
|
|
|
bitmapWidth = symbolWidths[i];
|
|
|
|
xMax = xMin + bitmapWidth;
|
|
|
|
symbolBitmap = [];
|
|
|
|
for (y = 0; y < currentHeight; y++) {
|
|
|
|
symbolBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
|
|
|
|
}
|
|
|
|
newSymbols.push(symbolBitmap);
|
|
|
|
xMin = xMax;
|
|
|
|
}
|
2012-06-22 07:26:24 +09:00
|
|
|
}
|
2012-06-19 05:03:20 +09:00
|
|
|
}
|
|
|
|
}
|
2018-01-24 00:04:07 +09:00
|
|
|
|
2012-06-19 05:03:20 +09:00
|
|
|
// 6.5.10 Exported symbols
|
|
|
|
var exportedSymbols = [];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var flags = [],
|
|
|
|
currentFlag = false;
|
2012-06-26 14:32:59 +09:00
|
|
|
var totalSymbolsLength = symbols.length + numberOfNewSymbols;
|
|
|
|
while (flags.length < totalSymbolsLength) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var runLength = huffman
|
|
|
|
? tableB1.decode(huffmanInput)
|
|
|
|
: decodeInteger(contextCache, "IAEX", decoder);
|
2014-03-09 21:03:45 +09:00
|
|
|
while (runLength--) {
|
2012-06-19 05:03:20 +09:00
|
|
|
flags.push(currentFlag);
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-19 05:03:20 +09:00
|
|
|
currentFlag = !currentFlag;
|
|
|
|
}
|
2014-03-09 21:03:45 +09:00
|
|
|
for (var i = 0, ii = symbols.length; i < ii; i++) {
|
|
|
|
if (flags[i]) {
|
|
|
|
exportedSymbols.push(symbols[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (var j = 0; j < numberOfNewSymbols; i++, j++) {
|
|
|
|
if (flags[i]) {
|
|
|
|
exportedSymbols.push(newSymbols[j]);
|
|
|
|
}
|
|
|
|
}
|
2012-06-19 05:03:20 +09:00
|
|
|
return exportedSymbols;
|
|
|
|
}
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
function decodeTextRegion(
|
|
|
|
huffman,
|
|
|
|
refinement,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
defaultPixelValue,
|
|
|
|
numberOfSymbolInstances,
|
|
|
|
stripSize,
|
|
|
|
inputSymbols,
|
|
|
|
symbolCodeLength,
|
|
|
|
transposed,
|
|
|
|
dsOffset,
|
|
|
|
referenceCorner,
|
|
|
|
combinationOperator,
|
|
|
|
huffmanTables,
|
|
|
|
refinementTemplateIndex,
|
|
|
|
refinementAt,
|
|
|
|
decodingContext,
|
|
|
|
logStripSize,
|
|
|
|
huffmanInput
|
|
|
|
) {
|
2018-01-24 00:04:07 +09:00
|
|
|
if (huffman && refinement) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("refinement with Huffman is not supported");
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-19 05:03:20 +09:00
|
|
|
|
|
|
|
// Prepare bitmap
|
|
|
|
var bitmap = [];
|
2014-04-08 06:42:54 +09:00
|
|
|
var i, row;
|
|
|
|
for (i = 0; i < height; i++) {
|
|
|
|
row = new Uint8Array(width);
|
2012-06-19 05:03:20 +09:00
|
|
|
if (defaultPixelValue) {
|
2014-03-09 21:03:45 +09:00
|
|
|
for (var j = 0; j < width; j++) {
|
2012-06-19 05:03:20 +09:00
|
|
|
row[j] = defaultPixelValue;
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-19 05:03:20 +09:00
|
|
|
}
|
|
|
|
bitmap.push(row);
|
|
|
|
}
|
|
|
|
|
2012-06-22 19:36:56 +09:00
|
|
|
var decoder = decodingContext.decoder;
|
|
|
|
var contextCache = decodingContext.contextCache;
|
2018-01-24 00:04:07 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var stripT = huffman
|
|
|
|
? -huffmanTables.tableDeltaT.decode(huffmanInput)
|
|
|
|
: -decodeInteger(contextCache, "IADT", decoder); // 6.4.6
|
2012-06-19 05:03:20 +09:00
|
|
|
var firstS = 0;
|
2014-04-08 06:42:54 +09:00
|
|
|
i = 0;
|
2012-06-19 05:03:20 +09:00
|
|
|
while (i < numberOfSymbolInstances) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var deltaT = huffman
|
|
|
|
? huffmanTables.tableDeltaT.decode(huffmanInput)
|
|
|
|
: decodeInteger(contextCache, "IADT", decoder); // 6.4.6
|
2012-06-19 05:03:20 +09:00
|
|
|
stripT += deltaT;
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var deltaFirstS = huffman
|
|
|
|
? huffmanTables.tableFirstS.decode(huffmanInput)
|
|
|
|
: decodeInteger(contextCache, "IAFS", decoder); // 6.4.7
|
2012-06-19 05:03:20 +09:00
|
|
|
firstS += deltaFirstS;
|
|
|
|
var currentS = firstS;
|
|
|
|
do {
|
2018-01-24 00:04:07 +09:00
|
|
|
let currentT = 0; // 6.4.9
|
|
|
|
if (stripSize > 1) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
currentT = huffman
|
|
|
|
? huffmanInput.readBits(logStripSize)
|
|
|
|
: decodeInteger(contextCache, "IAIT", decoder);
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
2012-06-22 07:26:24 +09:00
|
|
|
var t = stripSize * stripT + currentT;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var symbolId = huffman
|
|
|
|
? huffmanTables.symbolIDTable.decode(huffmanInput)
|
|
|
|
: decodeIAID(contextCache, decoder, symbolCodeLength);
|
|
|
|
var applyRefinement =
|
|
|
|
refinement &&
|
|
|
|
(huffman
|
|
|
|
? huffmanInput.readBit()
|
|
|
|
: decodeInteger(contextCache, "IARI", decoder));
|
2012-06-19 05:03:20 +09:00
|
|
|
var symbolBitmap = inputSymbols[symbolId];
|
|
|
|
var symbolWidth = symbolBitmap[0].length;
|
|
|
|
var symbolHeight = symbolBitmap.length;
|
2012-06-22 07:26:24 +09:00
|
|
|
if (applyRefinement) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var rdw = decodeInteger(contextCache, "IARDW", decoder); // 6.4.11.1
|
|
|
|
var rdh = decodeInteger(contextCache, "IARDH", decoder); // 6.4.11.2
|
|
|
|
var rdx = decodeInteger(contextCache, "IARDX", decoder); // 6.4.11.3
|
|
|
|
var rdy = decodeInteger(contextCache, "IARDY", decoder); // 6.4.11.4
|
2012-06-22 07:26:24 +09:00
|
|
|
symbolWidth += rdw;
|
|
|
|
symbolHeight += rdh;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
symbolBitmap = decodeRefinement(
|
|
|
|
symbolWidth,
|
|
|
|
symbolHeight,
|
|
|
|
refinementTemplateIndex,
|
|
|
|
symbolBitmap,
|
|
|
|
(rdw >> 1) + rdx,
|
|
|
|
(rdh >> 1) + rdy,
|
|
|
|
false,
|
|
|
|
refinementAt,
|
|
|
|
decodingContext
|
|
|
|
);
|
2012-06-22 07:26:24 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight - 1);
|
|
|
|
var offsetS = currentS - (referenceCorner & 2 ? symbolWidth - 1 : 0);
|
2014-04-08 06:42:54 +09:00
|
|
|
var s2, t2, symbolRow;
|
2013-09-27 03:49:02 +09:00
|
|
|
if (transposed) {
|
2014-02-27 21:13:58 +09:00
|
|
|
// Place Symbol Bitmap from T1,S1
|
2014-04-08 06:42:54 +09:00
|
|
|
for (s2 = 0; s2 < symbolHeight; s2++) {
|
|
|
|
row = bitmap[offsetS + s2];
|
2013-09-27 03:49:02 +09:00
|
|
|
if (!row) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-04-08 06:42:54 +09:00
|
|
|
symbolRow = symbolBitmap[s2];
|
2013-09-27 03:49:02 +09:00
|
|
|
// To ignore Parts of Symbol bitmap which goes
|
|
|
|
// outside bitmap region
|
|
|
|
var maxWidth = Math.min(width - offsetT, symbolWidth);
|
|
|
|
switch (combinationOperator) {
|
|
|
|
case 0: // OR
|
2014-04-08 06:42:54 +09:00
|
|
|
for (t2 = 0; t2 < maxWidth; t2++) {
|
2013-09-27 03:49:02 +09:00
|
|
|
row[offsetT + t2] |= symbolRow[t2];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: // XOR
|
2014-04-08 06:42:54 +09:00
|
|
|
for (t2 = 0; t2 < maxWidth; t2++) {
|
2013-09-27 03:49:02 +09:00
|
|
|
row[offsetT + t2] ^= symbolRow[t2];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2017-06-29 05:51:31 +09:00
|
|
|
throw new Jbig2Error(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
`operator ${combinationOperator} is not supported`
|
|
|
|
);
|
2013-09-27 03:49:02 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
currentS += symbolHeight - 1;
|
|
|
|
} else {
|
2014-04-08 06:42:54 +09:00
|
|
|
for (t2 = 0; t2 < symbolHeight; t2++) {
|
|
|
|
row = bitmap[offsetT + t2];
|
2013-09-27 03:49:02 +09:00
|
|
|
if (!row) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-04-08 06:42:54 +09:00
|
|
|
symbolRow = symbolBitmap[t2];
|
2013-09-27 03:49:02 +09:00
|
|
|
switch (combinationOperator) {
|
|
|
|
case 0: // OR
|
2014-04-08 06:42:54 +09:00
|
|
|
for (s2 = 0; s2 < symbolWidth; s2++) {
|
2013-09-27 03:49:02 +09:00
|
|
|
row[offsetS + s2] |= symbolRow[s2];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: // XOR
|
2014-04-08 06:42:54 +09:00
|
|
|
for (s2 = 0; s2 < symbolWidth; s2++) {
|
2013-09-27 03:49:02 +09:00
|
|
|
row[offsetS + s2] ^= symbolRow[s2];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2017-06-29 05:51:31 +09:00
|
|
|
throw new Jbig2Error(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
`operator ${combinationOperator} is not supported`
|
|
|
|
);
|
2013-09-27 03:49:02 +09:00
|
|
|
}
|
2012-06-22 07:26:24 +09:00
|
|
|
}
|
2013-09-27 03:49:02 +09:00
|
|
|
currentS += symbolWidth - 1;
|
2012-06-19 05:03:20 +09:00
|
|
|
}
|
|
|
|
i++;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var deltaS = huffman
|
|
|
|
? huffmanTables.tableDeltaS.decode(huffmanInput)
|
|
|
|
: decodeInteger(contextCache, "IADS", decoder); // 6.4.8
|
2014-03-09 21:03:45 +09:00
|
|
|
if (deltaS === null) {
|
2012-06-19 05:03:20 +09:00
|
|
|
break; // OOB
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-19 05:03:20 +09:00
|
|
|
currentS += deltaS + dsOffset;
|
|
|
|
} while (true);
|
|
|
|
}
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
function decodePatternDictionary(
|
|
|
|
mmr,
|
|
|
|
patternWidth,
|
|
|
|
patternHeight,
|
|
|
|
maxPatternIndex,
|
|
|
|
template,
|
|
|
|
decodingContext
|
|
|
|
) {
|
2020-01-24 17:48:21 +09:00
|
|
|
const at = [];
|
2018-01-24 00:04:07 +09:00
|
|
|
if (!mmr) {
|
2017-08-08 21:38:29 +09:00
|
|
|
at.push({
|
2018-01-24 00:04:07 +09:00
|
|
|
x: -patternWidth,
|
|
|
|
y: 0,
|
2017-08-08 21:38:29 +09:00
|
|
|
});
|
2018-01-24 00:04:07 +09:00
|
|
|
if (template === 0) {
|
|
|
|
at.push({
|
|
|
|
x: -3,
|
|
|
|
y: -1,
|
|
|
|
});
|
|
|
|
at.push({
|
|
|
|
x: 2,
|
|
|
|
y: -2,
|
|
|
|
});
|
|
|
|
at.push({
|
|
|
|
x: -2,
|
|
|
|
y: -2,
|
|
|
|
});
|
|
|
|
}
|
2017-08-08 21:38:29 +09:00
|
|
|
}
|
2020-01-24 17:48:21 +09:00
|
|
|
const collectiveWidth = (maxPatternIndex + 1) * patternWidth;
|
|
|
|
const collectiveBitmap = decodeBitmap(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
mmr,
|
|
|
|
collectiveWidth,
|
|
|
|
patternHeight,
|
|
|
|
template,
|
|
|
|
false,
|
|
|
|
null,
|
|
|
|
at,
|
|
|
|
decodingContext
|
|
|
|
);
|
2017-08-08 21:38:29 +09:00
|
|
|
// Divide collective bitmap into patterns.
|
2020-01-24 21:21:16 +09:00
|
|
|
const patterns = [];
|
|
|
|
for (let i = 0; i <= maxPatternIndex; i++) {
|
|
|
|
const patternBitmap = [];
|
|
|
|
const xMin = patternWidth * i;
|
|
|
|
const xMax = xMin + patternWidth;
|
|
|
|
for (let y = 0; y < patternHeight; y++) {
|
2017-08-08 21:38:29 +09:00
|
|
|
patternBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
|
|
|
|
}
|
|
|
|
patterns.push(patternBitmap);
|
|
|
|
}
|
|
|
|
return patterns;
|
|
|
|
}
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
function decodeHalftoneRegion(
|
|
|
|
mmr,
|
|
|
|
patterns,
|
|
|
|
template,
|
|
|
|
regionWidth,
|
|
|
|
regionHeight,
|
|
|
|
defaultPixelValue,
|
|
|
|
enableSkip,
|
|
|
|
combinationOperator,
|
|
|
|
gridWidth,
|
|
|
|
gridHeight,
|
|
|
|
gridOffsetX,
|
|
|
|
gridOffsetY,
|
|
|
|
gridVectorX,
|
|
|
|
gridVectorY,
|
|
|
|
decodingContext
|
|
|
|
) {
|
2020-01-24 17:48:21 +09:00
|
|
|
const skip = null;
|
2017-08-08 21:38:29 +09:00
|
|
|
if (enableSkip) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("skip is not supported");
|
2017-08-08 21:38:29 +09:00
|
|
|
}
|
|
|
|
if (combinationOperator !== 0) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error(
|
|
|
|
"operator " +
|
|
|
|
combinationOperator +
|
|
|
|
" is not supported in halftone region"
|
|
|
|
);
|
2017-08-08 21:38:29 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
// Prepare bitmap.
|
2020-01-24 17:48:21 +09:00
|
|
|
const regionBitmap = [];
|
2017-08-08 21:38:29 +09:00
|
|
|
let i, j, row;
|
|
|
|
for (i = 0; i < regionHeight; i++) {
|
|
|
|
row = new Uint8Array(regionWidth);
|
|
|
|
if (defaultPixelValue) {
|
|
|
|
for (j = 0; j < regionWidth; j++) {
|
|
|
|
row[j] = defaultPixelValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
regionBitmap.push(row);
|
|
|
|
}
|
|
|
|
|
2020-01-24 17:48:21 +09:00
|
|
|
const numberOfPatterns = patterns.length;
|
|
|
|
const pattern0 = patterns[0];
|
|
|
|
const patternWidth = pattern0[0].length,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
patternHeight = pattern0.length;
|
2020-01-24 17:48:21 +09:00
|
|
|
const bitsPerValue = log2(numberOfPatterns);
|
|
|
|
const at = [];
|
2018-01-24 00:04:07 +09:00
|
|
|
if (!mmr) {
|
2017-08-08 21:38:29 +09:00
|
|
|
at.push({
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
x: template <= 1 ? 3 : 2,
|
2017-08-08 21:38:29 +09:00
|
|
|
y: -1,
|
|
|
|
});
|
2018-01-24 00:04:07 +09:00
|
|
|
if (template === 0) {
|
|
|
|
at.push({
|
|
|
|
x: -3,
|
|
|
|
y: -1,
|
|
|
|
});
|
|
|
|
at.push({
|
|
|
|
x: 2,
|
|
|
|
y: -2,
|
|
|
|
});
|
|
|
|
at.push({
|
|
|
|
x: -2,
|
|
|
|
y: -2,
|
|
|
|
});
|
|
|
|
}
|
2017-08-08 21:38:29 +09:00
|
|
|
}
|
|
|
|
// Annex C. Gray-scale Image Decoding Procedure.
|
2020-01-24 21:21:16 +09:00
|
|
|
const grayScaleBitPlanes = [];
|
|
|
|
let mmrInput, bitmap;
|
2018-01-24 00:04:07 +09:00
|
|
|
if (mmr) {
|
|
|
|
// MMR bit planes are in one continuous stream. Only EOFB codes indicate
|
|
|
|
// the end of each bitmap, so EOFBs must be decoded.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
mmrInput = new Reader(
|
|
|
|
decodingContext.data,
|
|
|
|
decodingContext.start,
|
|
|
|
decodingContext.end
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
2017-08-08 21:38:29 +09:00
|
|
|
for (i = bitsPerValue - 1; i >= 0; i--) {
|
2018-01-24 00:04:07 +09:00
|
|
|
if (mmr) {
|
|
|
|
bitmap = decodeMMRBitmap(mmrInput, gridWidth, gridHeight, true);
|
|
|
|
} else {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
bitmap = decodeBitmap(
|
|
|
|
false,
|
|
|
|
gridWidth,
|
|
|
|
gridHeight,
|
|
|
|
template,
|
|
|
|
false,
|
|
|
|
skip,
|
|
|
|
at,
|
|
|
|
decodingContext
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
|
|
|
grayScaleBitPlanes[i] = bitmap;
|
2017-08-08 21:38:29 +09:00
|
|
|
}
|
|
|
|
// 6.6.5.2 Rendering the patterns.
|
|
|
|
let mg, ng, bit, patternIndex, patternBitmap, x, y, patternRow, regionRow;
|
|
|
|
for (mg = 0; mg < gridHeight; mg++) {
|
|
|
|
for (ng = 0; ng < gridWidth; ng++) {
|
|
|
|
bit = 0;
|
|
|
|
patternIndex = 0;
|
|
|
|
for (j = bitsPerValue - 1; j >= 0; j--) {
|
|
|
|
bit = grayScaleBitPlanes[j][mg][ng] ^ bit; // Gray decoding
|
|
|
|
patternIndex |= bit << j;
|
|
|
|
}
|
|
|
|
patternBitmap = patterns[patternIndex];
|
|
|
|
x = (gridOffsetX + mg * gridVectorY + ng * gridVectorX) >> 8;
|
|
|
|
y = (gridOffsetY + mg * gridVectorX - ng * gridVectorY) >> 8;
|
|
|
|
// Draw patternBitmap at (x, y).
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (
|
|
|
|
x >= 0 &&
|
|
|
|
x + patternWidth <= regionWidth &&
|
|
|
|
y >= 0 &&
|
|
|
|
y + patternHeight <= regionHeight
|
|
|
|
) {
|
2017-08-08 21:38:29 +09:00
|
|
|
for (i = 0; i < patternHeight; i++) {
|
|
|
|
regionRow = regionBitmap[y + i];
|
|
|
|
patternRow = patternBitmap[i];
|
|
|
|
for (j = 0; j < patternWidth; j++) {
|
|
|
|
regionRow[x + j] |= patternRow[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
let regionX, regionY;
|
|
|
|
for (i = 0; i < patternHeight; i++) {
|
|
|
|
regionY = y + i;
|
|
|
|
if (regionY < 0 || regionY >= regionHeight) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
regionRow = regionBitmap[regionY];
|
|
|
|
patternRow = patternBitmap[i];
|
|
|
|
for (j = 0; j < patternWidth; j++) {
|
|
|
|
regionX = x + j;
|
|
|
|
if (regionX >= 0 && regionX < regionWidth) {
|
|
|
|
regionRow[regionX] |= patternRow[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return regionBitmap;
|
|
|
|
}
|
|
|
|
|
2012-06-17 05:15:42 +09:00
|
|
|
function readSegmentHeader(data, start) {
|
|
|
|
var segmentHeader = {};
|
|
|
|
segmentHeader.number = readUint32(data, start);
|
|
|
|
var flags = data[start + 4];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var segmentType = flags & 0x3f;
|
2014-03-09 21:03:45 +09:00
|
|
|
if (!SegmentTypes[segmentType]) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("invalid segment type: " + segmentType);
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
segmentHeader.type = segmentType;
|
|
|
|
segmentHeader.typeName = SegmentTypes[segmentType];
|
|
|
|
segmentHeader.deferredNonRetain = !!(flags & 0x80);
|
2014-03-09 21:03:45 +09:00
|
|
|
|
2012-06-17 05:15:42 +09:00
|
|
|
var pageAssociationFieldSize = !!(flags & 0x40);
|
|
|
|
var referredFlags = data[start + 5];
|
|
|
|
var referredToCount = (referredFlags >> 5) & 7;
|
|
|
|
var retainBits = [referredFlags & 31];
|
|
|
|
var position = start + 6;
|
2014-08-02 06:02:29 +09:00
|
|
|
if (referredFlags === 7) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
referredToCount = readUint32(data, position - 1) & 0x1fffffff;
|
2012-06-17 05:15:42 +09:00
|
|
|
position += 3;
|
|
|
|
var bytes = (referredToCount + 7) >> 3;
|
|
|
|
retainBits[0] = data[position++];
|
|
|
|
while (--bytes > 0) {
|
|
|
|
retainBits.push(data[position++]);
|
|
|
|
}
|
2014-08-02 06:02:29 +09:00
|
|
|
} else if (referredFlags === 5 || referredFlags === 6) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("invalid referred-to flags");
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
|
|
|
|
2012-06-17 05:15:42 +09:00
|
|
|
segmentHeader.retainBits = retainBits;
|
2020-01-13 03:47:13 +09:00
|
|
|
|
|
|
|
let referredToSegmentNumberSize = 4;
|
|
|
|
if (segmentHeader.number <= 256) {
|
|
|
|
referredToSegmentNumberSize = 1;
|
|
|
|
} else if (segmentHeader.number <= 65536) {
|
|
|
|
referredToSegmentNumberSize = 2;
|
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
var referredTo = [];
|
2014-04-08 06:42:54 +09:00
|
|
|
var i, ii;
|
|
|
|
for (i = 0; i < referredToCount; i++) {
|
2020-01-13 03:47:13 +09:00
|
|
|
let number;
|
|
|
|
if (referredToSegmentNumberSize === 1) {
|
|
|
|
number = data[position];
|
|
|
|
} else if (referredToSegmentNumberSize === 2) {
|
|
|
|
number = readUint16(data, position);
|
|
|
|
} else {
|
|
|
|
number = readUint32(data, position);
|
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
referredTo.push(number);
|
|
|
|
position += referredToSegmentNumberSize;
|
|
|
|
}
|
|
|
|
segmentHeader.referredTo = referredTo;
|
2014-03-09 21:03:45 +09:00
|
|
|
if (!pageAssociationFieldSize) {
|
2012-06-17 05:15:42 +09:00
|
|
|
segmentHeader.pageAssociation = data[position++];
|
2014-03-09 21:03:45 +09:00
|
|
|
} else {
|
2012-06-17 05:15:42 +09:00
|
|
|
segmentHeader.pageAssociation = readUint32(data, position);
|
|
|
|
position += 4;
|
|
|
|
}
|
|
|
|
segmentHeader.length = readUint32(data, position);
|
|
|
|
position += 4;
|
2014-03-09 21:03:45 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (segmentHeader.length === 0xffffffff) {
|
2013-02-23 23:04:17 +09:00
|
|
|
// 7.2.7 Segment data length, unknown segment length
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (segmentType === 38) {
|
|
|
|
// ImmediateGenericRegion
|
2013-02-23 23:04:17 +09:00
|
|
|
var genericRegionInfo = readRegionSegmentInformation(data, position);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var genericRegionSegmentFlags =
|
|
|
|
data[position + RegionSegmentInformationFieldLength];
|
2013-02-23 23:04:17 +09:00
|
|
|
var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
|
|
|
|
// searching for the segment end
|
|
|
|
var searchPatternLength = 6;
|
|
|
|
var searchPattern = new Uint8Array(searchPatternLength);
|
|
|
|
if (!genericRegionMmr) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
searchPattern[0] = 0xff;
|
|
|
|
searchPattern[1] = 0xac;
|
2013-02-23 23:04:17 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
searchPattern[2] = (genericRegionInfo.height >>> 24) & 0xff;
|
|
|
|
searchPattern[3] = (genericRegionInfo.height >> 16) & 0xff;
|
|
|
|
searchPattern[4] = (genericRegionInfo.height >> 8) & 0xff;
|
|
|
|
searchPattern[5] = genericRegionInfo.height & 0xff;
|
2014-04-08 06:42:54 +09:00
|
|
|
for (i = position, ii = data.length; i < ii; i++) {
|
2013-02-23 23:04:17 +09:00
|
|
|
var j = 0;
|
|
|
|
while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
|
|
|
|
j++;
|
|
|
|
}
|
2014-08-02 06:02:29 +09:00
|
|
|
if (j === searchPatternLength) {
|
2013-02-23 23:04:17 +09:00
|
|
|
segmentHeader.length = i + searchPatternLength;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (segmentHeader.length === 0xffffffff) {
|
|
|
|
throw new Jbig2Error("segment end was not found");
|
2013-02-23 23:04:17 +09:00
|
|
|
}
|
|
|
|
} else {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("invalid unknown segment length");
|
2013-02-23 23:04:17 +09:00
|
|
|
}
|
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
segmentHeader.headerEnd = position;
|
|
|
|
return segmentHeader;
|
|
|
|
}
|
|
|
|
|
|
|
|
function readSegments(header, data, start, end) {
|
|
|
|
var segments = [];
|
|
|
|
var position = start;
|
|
|
|
while (position < end) {
|
|
|
|
var segmentHeader = readSegmentHeader(data, position);
|
|
|
|
position = segmentHeader.headerEnd;
|
|
|
|
var segment = {
|
|
|
|
header: segmentHeader,
|
2017-04-27 19:58:44 +09:00
|
|
|
data,
|
2012-06-17 05:15:42 +09:00
|
|
|
};
|
|
|
|
if (!header.randomAccess) {
|
|
|
|
segment.start = position;
|
|
|
|
position += segmentHeader.length;
|
|
|
|
segment.end = position;
|
|
|
|
}
|
|
|
|
segments.push(segment);
|
2014-08-02 06:02:29 +09:00
|
|
|
if (segmentHeader.type === 51) {
|
2012-06-17 05:15:42 +09:00
|
|
|
break; // end of file is found
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
}
|
|
|
|
if (header.randomAccess) {
|
2012-06-26 14:32:59 +09:00
|
|
|
for (var i = 0, ii = segments.length; i < ii; i++) {
|
2012-06-17 05:15:42 +09:00
|
|
|
segments[i].start = position;
|
|
|
|
position += segments[i].header.length;
|
|
|
|
segments[i].end = position;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return segments;
|
|
|
|
}
|
|
|
|
|
2012-06-19 05:03:20 +09:00
|
|
|
// 7.4.1 Region segment information field
|
2012-06-17 05:15:42 +09:00
|
|
|
function readRegionSegmentInformation(data, start) {
|
|
|
|
return {
|
|
|
|
width: readUint32(data, start),
|
|
|
|
height: readUint32(data, start + 4),
|
|
|
|
x: readUint32(data, start + 8),
|
|
|
|
y: readUint32(data, start + 12),
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
combinationOperator: data[start + 16] & 7,
|
2012-06-17 05:15:42 +09:00
|
|
|
};
|
|
|
|
}
|
|
|
|
var RegionSegmentInformationFieldLength = 17;
|
|
|
|
|
|
|
|
function processSegment(segment, visitor) {
|
|
|
|
var header = segment.header;
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var data = segment.data,
|
|
|
|
position = segment.start,
|
|
|
|
end = segment.end;
|
2014-04-08 06:42:54 +09:00
|
|
|
var args, at, i, atLength;
|
2012-06-17 05:15:42 +09:00
|
|
|
switch (header.type) {
|
2012-06-19 05:03:20 +09:00
|
|
|
case 0: // SymbolDictionary
|
|
|
|
// 7.4.2 Symbol dictionary segment syntax
|
|
|
|
var dictionary = {};
|
|
|
|
var dictionaryFlags = readUint16(data, position); // 7.4.2.1.1
|
|
|
|
dictionary.huffman = !!(dictionaryFlags & 1);
|
|
|
|
dictionary.refinement = !!(dictionaryFlags & 2);
|
|
|
|
dictionary.huffmanDHSelector = (dictionaryFlags >> 2) & 3;
|
|
|
|
dictionary.huffmanDWSelector = (dictionaryFlags >> 4) & 3;
|
|
|
|
dictionary.bitmapSizeSelector = (dictionaryFlags >> 6) & 1;
|
|
|
|
dictionary.aggregationInstancesSelector = (dictionaryFlags >> 7) & 1;
|
|
|
|
dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
|
|
|
|
dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
|
|
|
|
dictionary.template = (dictionaryFlags >> 10) & 3;
|
|
|
|
dictionary.refinementTemplate = (dictionaryFlags >> 12) & 1;
|
|
|
|
position += 2;
|
|
|
|
if (!dictionary.huffman) {
|
2014-04-08 06:42:54 +09:00
|
|
|
atLength = dictionary.template === 0 ? 4 : 1;
|
|
|
|
at = [];
|
|
|
|
for (i = 0; i < atLength; i++) {
|
2012-06-19 05:03:20 +09:00
|
|
|
at.push({
|
|
|
|
x: readInt8(data, position),
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
y: readInt8(data, position + 1),
|
2012-06-19 05:03:20 +09:00
|
|
|
});
|
|
|
|
position += 2;
|
|
|
|
}
|
|
|
|
dictionary.at = at;
|
|
|
|
}
|
|
|
|
if (dictionary.refinement && !dictionary.refinementTemplate) {
|
2014-04-08 06:42:54 +09:00
|
|
|
at = [];
|
|
|
|
for (i = 0; i < 2; i++) {
|
2012-06-19 05:03:20 +09:00
|
|
|
at.push({
|
|
|
|
x: readInt8(data, position),
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
y: readInt8(data, position + 1),
|
2012-06-19 05:03:20 +09:00
|
|
|
});
|
|
|
|
position += 2;
|
|
|
|
}
|
|
|
|
dictionary.refinementAt = at;
|
|
|
|
}
|
|
|
|
dictionary.numberOfExportedSymbols = readUint32(data, position);
|
|
|
|
position += 4;
|
|
|
|
dictionary.numberOfNewSymbols = readUint32(data, position);
|
|
|
|
position += 4;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
args = [
|
|
|
|
dictionary,
|
|
|
|
header.number,
|
|
|
|
header.referredTo,
|
|
|
|
data,
|
|
|
|
position,
|
|
|
|
end,
|
|
|
|
];
|
2012-06-19 05:03:20 +09:00
|
|
|
break;
|
|
|
|
case 6: // ImmediateTextRegion
|
2012-07-10 02:13:03 +09:00
|
|
|
case 7: // ImmediateLosslessTextRegion
|
2012-06-19 05:03:20 +09:00
|
|
|
var textRegion = {};
|
|
|
|
textRegion.info = readRegionSegmentInformation(data, position);
|
|
|
|
position += RegionSegmentInformationFieldLength;
|
|
|
|
var textRegionSegmentFlags = readUint16(data, position);
|
|
|
|
position += 2;
|
|
|
|
textRegion.huffman = !!(textRegionSegmentFlags & 1);
|
|
|
|
textRegion.refinement = !!(textRegionSegmentFlags & 2);
|
2018-01-24 00:04:07 +09:00
|
|
|
textRegion.logStripSize = (textRegionSegmentFlags >> 2) & 3;
|
|
|
|
textRegion.stripSize = 1 << textRegion.logStripSize;
|
2012-06-19 05:03:20 +09:00
|
|
|
textRegion.referenceCorner = (textRegionSegmentFlags >> 4) & 3;
|
|
|
|
textRegion.transposed = !!(textRegionSegmentFlags & 64);
|
|
|
|
textRegion.combinationOperator = (textRegionSegmentFlags >> 7) & 3;
|
|
|
|
textRegion.defaultPixelValue = (textRegionSegmentFlags >> 9) & 1;
|
2013-02-23 13:08:46 +09:00
|
|
|
textRegion.dsOffset = (textRegionSegmentFlags << 17) >> 27;
|
2012-06-19 05:03:20 +09:00
|
|
|
textRegion.refinementTemplate = (textRegionSegmentFlags >> 15) & 1;
|
|
|
|
if (textRegion.huffman) {
|
|
|
|
var textRegionHuffmanFlags = readUint16(data, position);
|
|
|
|
position += 2;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
textRegion.huffmanFS = textRegionHuffmanFlags & 3;
|
2012-06-19 05:03:20 +09:00
|
|
|
textRegion.huffmanDS = (textRegionHuffmanFlags >> 2) & 3;
|
|
|
|
textRegion.huffmanDT = (textRegionHuffmanFlags >> 4) & 3;
|
|
|
|
textRegion.huffmanRefinementDW = (textRegionHuffmanFlags >> 6) & 3;
|
|
|
|
textRegion.huffmanRefinementDH = (textRegionHuffmanFlags >> 8) & 3;
|
|
|
|
textRegion.huffmanRefinementDX = (textRegionHuffmanFlags >> 10) & 3;
|
|
|
|
textRegion.huffmanRefinementDY = (textRegionHuffmanFlags >> 12) & 3;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
textRegion.huffmanRefinementSizeSelector = !!(
|
|
|
|
textRegionHuffmanFlags & 0x4000
|
|
|
|
);
|
2012-06-19 05:03:20 +09:00
|
|
|
}
|
|
|
|
if (textRegion.refinement && !textRegion.refinementTemplate) {
|
2014-04-08 06:42:54 +09:00
|
|
|
at = [];
|
|
|
|
for (i = 0; i < 2; i++) {
|
2012-06-19 05:03:20 +09:00
|
|
|
at.push({
|
|
|
|
x: readInt8(data, position),
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
y: readInt8(data, position + 1),
|
2012-06-19 05:03:20 +09:00
|
|
|
});
|
|
|
|
position += 2;
|
|
|
|
}
|
2012-06-22 07:26:24 +09:00
|
|
|
textRegion.refinementAt = at;
|
2012-06-19 05:03:20 +09:00
|
|
|
}
|
|
|
|
textRegion.numberOfSymbolInstances = readUint32(data, position);
|
|
|
|
position += 4;
|
|
|
|
args = [textRegion, header.referredTo, data, position, end];
|
|
|
|
break;
|
2017-08-08 21:38:29 +09:00
|
|
|
case 16: // PatternDictionary
|
|
|
|
// 7.4.4. Pattern dictionary segment syntax
|
2020-01-24 17:48:21 +09:00
|
|
|
const patternDictionary = {};
|
|
|
|
const patternDictionaryFlags = data[position++];
|
2017-08-08 21:38:29 +09:00
|
|
|
patternDictionary.mmr = !!(patternDictionaryFlags & 1);
|
|
|
|
patternDictionary.template = (patternDictionaryFlags >> 1) & 3;
|
|
|
|
patternDictionary.patternWidth = data[position++];
|
|
|
|
patternDictionary.patternHeight = data[position++];
|
|
|
|
patternDictionary.maxPatternIndex = readUint32(data, position);
|
|
|
|
position += 4;
|
|
|
|
args = [patternDictionary, header.number, data, position, end];
|
|
|
|
break;
|
|
|
|
case 22: // ImmediateHalftoneRegion
|
|
|
|
case 23: // ImmediateLosslessHalftoneRegion
|
|
|
|
// 7.4.5 Halftone region segment syntax
|
2020-01-24 17:48:21 +09:00
|
|
|
const halftoneRegion = {};
|
2017-08-08 21:38:29 +09:00
|
|
|
halftoneRegion.info = readRegionSegmentInformation(data, position);
|
|
|
|
position += RegionSegmentInformationFieldLength;
|
2020-01-24 17:48:21 +09:00
|
|
|
const halftoneRegionFlags = data[position++];
|
2017-08-08 21:38:29 +09:00
|
|
|
halftoneRegion.mmr = !!(halftoneRegionFlags & 1);
|
|
|
|
halftoneRegion.template = (halftoneRegionFlags >> 1) & 3;
|
|
|
|
halftoneRegion.enableSkip = !!(halftoneRegionFlags & 8);
|
|
|
|
halftoneRegion.combinationOperator = (halftoneRegionFlags >> 4) & 7;
|
|
|
|
halftoneRegion.defaultPixelValue = (halftoneRegionFlags >> 7) & 1;
|
|
|
|
halftoneRegion.gridWidth = readUint32(data, position);
|
|
|
|
position += 4;
|
|
|
|
halftoneRegion.gridHeight = readUint32(data, position);
|
|
|
|
position += 4;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
halftoneRegion.gridOffsetX = readUint32(data, position) & 0xffffffff;
|
2017-08-08 21:38:29 +09:00
|
|
|
position += 4;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
halftoneRegion.gridOffsetY = readUint32(data, position) & 0xffffffff;
|
2017-08-08 21:38:29 +09:00
|
|
|
position += 4;
|
|
|
|
halftoneRegion.gridVectorX = readUint16(data, position);
|
|
|
|
position += 2;
|
|
|
|
halftoneRegion.gridVectorY = readUint16(data, position);
|
|
|
|
position += 2;
|
|
|
|
args = [halftoneRegion, header.referredTo, data, position, end];
|
|
|
|
break;
|
2012-06-17 05:15:42 +09:00
|
|
|
case 38: // ImmediateGenericRegion
|
2012-07-10 02:13:03 +09:00
|
|
|
case 39: // ImmediateLosslessGenericRegion
|
2012-06-17 05:15:42 +09:00
|
|
|
var genericRegion = {};
|
|
|
|
genericRegion.info = readRegionSegmentInformation(data, position);
|
|
|
|
position += RegionSegmentInformationFieldLength;
|
|
|
|
var genericRegionSegmentFlags = data[position++];
|
|
|
|
genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
|
|
|
|
genericRegion.template = (genericRegionSegmentFlags >> 1) & 3;
|
2012-07-10 02:13:03 +09:00
|
|
|
genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
|
2012-06-17 05:15:42 +09:00
|
|
|
if (!genericRegion.mmr) {
|
2014-04-08 06:42:54 +09:00
|
|
|
atLength = genericRegion.template === 0 ? 4 : 1;
|
|
|
|
at = [];
|
|
|
|
for (i = 0; i < atLength; i++) {
|
2012-06-17 05:15:42 +09:00
|
|
|
at.push({
|
|
|
|
x: readInt8(data, position),
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
y: readInt8(data, position + 1),
|
2012-06-17 05:15:42 +09:00
|
|
|
});
|
|
|
|
position += 2;
|
|
|
|
}
|
|
|
|
genericRegion.at = at;
|
|
|
|
}
|
2012-06-19 05:03:20 +09:00
|
|
|
args = [genericRegion, data, position, end];
|
2012-06-17 05:15:42 +09:00
|
|
|
break;
|
|
|
|
case 48: // PageInformation
|
|
|
|
var pageInfo = {
|
|
|
|
width: readUint32(data, position),
|
|
|
|
height: readUint32(data, position + 4),
|
|
|
|
resolutionX: readUint32(data, position + 8),
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
resolutionY: readUint32(data, position + 12),
|
2012-06-17 05:15:42 +09:00
|
|
|
};
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
if (pageInfo.height === 0xffffffff) {
|
2012-06-17 05:15:42 +09:00
|
|
|
delete pageInfo.height;
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
var pageSegmentFlags = data[position + 16];
|
2017-01-19 22:00:36 +09:00
|
|
|
readUint16(data, position + 17); // pageStripingInformation
|
2012-06-17 05:15:42 +09:00
|
|
|
pageInfo.lossless = !!(pageSegmentFlags & 1);
|
|
|
|
pageInfo.refinement = !!(pageSegmentFlags & 2);
|
|
|
|
pageInfo.defaultPixelValue = (pageSegmentFlags >> 2) & 1;
|
|
|
|
pageInfo.combinationOperator = (pageSegmentFlags >> 3) & 3;
|
|
|
|
pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
|
|
|
|
pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
|
|
|
|
args = [pageInfo];
|
|
|
|
break;
|
2013-01-16 08:04:05 +09:00
|
|
|
case 49: // EndOfPage
|
|
|
|
break;
|
2012-06-22 14:50:04 +09:00
|
|
|
case 50: // EndOfStripe
|
|
|
|
break;
|
2012-06-17 05:15:42 +09:00
|
|
|
case 51: // EndOfFile
|
|
|
|
break;
|
2018-01-24 00:04:07 +09:00
|
|
|
case 53: // Tables
|
|
|
|
args = [header.number, data, position, end];
|
|
|
|
break;
|
2013-08-27 05:39:30 +09:00
|
|
|
case 62: // 7.4.15 defines 2 extension types which
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
// are comments and can be ignored.
|
2013-08-27 05:39:30 +09:00
|
|
|
break;
|
2012-06-17 05:15:42 +09:00
|
|
|
default:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error(
|
|
|
|
`segment type ${header.typeName}(${header.type})` +
|
|
|
|
" is not implemented"
|
|
|
|
);
|
2012-06-17 05:15:42 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var callbackName = "on" + header.typeName;
|
2014-03-09 21:03:45 +09:00
|
|
|
if (callbackName in visitor) {
|
2012-06-26 14:32:59 +09:00
|
|
|
visitor[callbackName].apply(visitor, args);
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
function processSegments(segments, visitor) {
|
2014-03-09 21:03:45 +09:00
|
|
|
for (var i = 0, ii = segments.length; i < ii; i++) {
|
2012-06-17 05:15:42 +09:00
|
|
|
processSegment(segments[i], visitor);
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
}
|
|
|
|
|
2012-06-19 05:03:20 +09:00
|
|
|
function parseJbig2Chunks(chunks) {
|
2012-06-17 05:15:42 +09:00
|
|
|
var visitor = new SimpleSegmentVisitor();
|
2012-06-26 14:32:59 +09:00
|
|
|
for (var i = 0, ii = chunks.length; i < ii; i++) {
|
2012-06-19 05:03:20 +09:00
|
|
|
var chunk = chunks[i];
|
|
|
|
var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
|
|
|
|
processSegments(segments, visitor);
|
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
return visitor.buffer;
|
|
|
|
}
|
|
|
|
|
2018-05-16 20:49:12 +09:00
|
|
|
function parseJbig2(data) {
|
2020-01-24 21:21:16 +09:00
|
|
|
const end = data.length;
|
|
|
|
let position = 0;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
|
|
|
|
if (
|
|
|
|
data[position] !== 0x97 ||
|
|
|
|
data[position + 1] !== 0x4a ||
|
|
|
|
data[position + 2] !== 0x42 ||
|
|
|
|
data[position + 3] !== 0x32 ||
|
|
|
|
data[position + 4] !== 0x0d ||
|
|
|
|
data[position + 5] !== 0x0a ||
|
|
|
|
data[position + 6] !== 0x1a ||
|
|
|
|
data[position + 7] !== 0x0a
|
|
|
|
) {
|
|
|
|
throw new Jbig2Error("parseJbig2 - invalid header.");
|
2018-05-16 20:49:12 +09:00
|
|
|
}
|
|
|
|
|
2020-01-24 17:48:21 +09:00
|
|
|
const header = Object.create(null);
|
2018-05-16 20:49:12 +09:00
|
|
|
position += 8;
|
|
|
|
const flags = data[position++];
|
|
|
|
header.randomAccess = !(flags & 1);
|
|
|
|
if (!(flags & 2)) {
|
|
|
|
header.numberOfPages = readUint32(data, position);
|
|
|
|
position += 4;
|
|
|
|
}
|
|
|
|
|
2020-01-24 17:48:21 +09:00
|
|
|
const segments = readSegments(header, data, position, end);
|
|
|
|
const visitor = new SimpleSegmentVisitor();
|
2018-05-16 20:49:12 +09:00
|
|
|
processSegments(segments, visitor);
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const { width, height } = visitor.currentPageInfo;
|
2018-05-16 20:49:12 +09:00
|
|
|
const bitPacked = visitor.buffer;
|
2020-01-24 17:48:21 +09:00
|
|
|
const imgData = new Uint8ClampedArray(width * height);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
let q = 0,
|
|
|
|
k = 0;
|
2018-05-16 20:49:12 +09:00
|
|
|
for (let i = 0; i < height; i++) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
let mask = 0,
|
|
|
|
buffer;
|
2018-05-16 20:49:12 +09:00
|
|
|
for (let j = 0; j < width; j++) {
|
|
|
|
if (!mask) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
mask = 128;
|
|
|
|
buffer = bitPacked[k++];
|
2018-05-16 20:49:12 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
imgData[q++] = buffer & mask ? 0 : 255;
|
2018-05-16 20:49:12 +09:00
|
|
|
mask >>= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
return { imgData, width, height };
|
2018-05-16 20:49:12 +09:00
|
|
|
}
|
|
|
|
|
2012-06-19 05:03:20 +09:00
|
|
|
function SimpleSegmentVisitor() {}
|
|
|
|
|
|
|
|
SimpleSegmentVisitor.prototype = {
|
2012-06-26 14:32:59 +09:00
|
|
|
onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
|
2012-06-17 05:15:42 +09:00
|
|
|
this.currentPageInfo = info;
|
|
|
|
var rowSize = (info.width + 7) >> 3;
|
2017-08-15 23:06:55 +09:00
|
|
|
var buffer = new Uint8ClampedArray(rowSize * info.height);
|
2014-02-27 21:13:58 +09:00
|
|
|
// The contents of ArrayBuffers are initialized to 0.
|
|
|
|
// Fill the buffer with 0xFF only if info.defaultPixelValue is set
|
|
|
|
if (info.defaultPixelValue) {
|
|
|
|
for (var i = 0, ii = buffer.length; i < ii; i++) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
buffer[i] = 0xff;
|
2014-02-27 21:13:58 +09:00
|
|
|
}
|
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
this.buffer = buffer;
|
2012-06-19 05:03:20 +09:00
|
|
|
},
|
|
|
|
drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
|
|
|
|
var pageInfo = this.currentPageInfo;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var width = regionInfo.width,
|
|
|
|
height = regionInfo.height;
|
2012-06-17 05:15:42 +09:00
|
|
|
var rowSize = (pageInfo.width + 7) >> 3;
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var combinationOperator = pageInfo.combinationOperatorOverride
|
|
|
|
? regionInfo.combinationOperator
|
|
|
|
: pageInfo.combinationOperator;
|
2012-06-17 05:15:42 +09:00
|
|
|
var buffer = this.buffer;
|
2016-12-10 22:28:27 +09:00
|
|
|
var mask0 = 128 >> (regionInfo.x & 7);
|
2014-03-08 01:29:14 +09:00
|
|
|
var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
|
2014-04-08 06:42:54 +09:00
|
|
|
var i, j, mask, offset;
|
2014-03-03 19:52:24 +09:00
|
|
|
switch (combinationOperator) {
|
|
|
|
case 0: // OR
|
2014-04-08 06:42:54 +09:00
|
|
|
for (i = 0; i < height; i++) {
|
|
|
|
mask = mask0;
|
|
|
|
offset = offset0;
|
|
|
|
for (j = 0; j < width; j++) {
|
2014-03-03 19:52:24 +09:00
|
|
|
if (bitmap[i][j]) {
|
|
|
|
buffer[offset] |= mask;
|
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
mask >>= 1;
|
|
|
|
if (!mask) {
|
|
|
|
mask = 128;
|
|
|
|
offset++;
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 01:29:14 +09:00
|
|
|
offset0 += rowSize;
|
2014-03-03 19:52:24 +09:00
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
break;
|
2014-03-03 19:52:24 +09:00
|
|
|
case 2: // XOR
|
2014-04-08 06:42:54 +09:00
|
|
|
for (i = 0; i < height; i++) {
|
|
|
|
mask = mask0;
|
|
|
|
offset = offset0;
|
|
|
|
for (j = 0; j < width; j++) {
|
2014-03-03 19:52:24 +09:00
|
|
|
if (bitmap[i][j]) {
|
|
|
|
buffer[offset] ^= mask;
|
|
|
|
}
|
2012-06-17 05:15:42 +09:00
|
|
|
mask >>= 1;
|
|
|
|
if (!mask) {
|
|
|
|
mask = 128;
|
|
|
|
offset++;
|
|
|
|
}
|
|
|
|
}
|
2014-03-08 01:29:14 +09:00
|
|
|
offset0 += rowSize;
|
2014-03-03 19:52:24 +09:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2017-06-29 05:51:31 +09:00
|
|
|
throw new Jbig2Error(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
`operator ${combinationOperator} is not supported`
|
|
|
|
);
|
2012-06-17 05:15:42 +09:00
|
|
|
}
|
2012-06-19 05:03:20 +09:00
|
|
|
},
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(
|
|
|
|
region,
|
|
|
|
data,
|
|
|
|
start,
|
|
|
|
end
|
|
|
|
) {
|
2012-06-19 05:03:20 +09:00
|
|
|
var regionInfo = region.info;
|
2012-06-22 19:36:56 +09:00
|
|
|
var decodingContext = new DecodingContext(data, start, end);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var bitmap = decodeBitmap(
|
|
|
|
region.mmr,
|
|
|
|
regionInfo.width,
|
|
|
|
regionInfo.height,
|
|
|
|
region.template,
|
|
|
|
region.prediction,
|
|
|
|
null,
|
|
|
|
region.at,
|
|
|
|
decodingContext
|
|
|
|
);
|
2012-06-19 05:03:20 +09:00
|
|
|
this.drawBitmap(regionInfo, bitmap);
|
|
|
|
},
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
|
2012-07-10 02:13:03 +09:00
|
|
|
this.onImmediateGenericRegion.apply(this, arguments);
|
|
|
|
},
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(
|
|
|
|
dictionary,
|
|
|
|
currentSegment,
|
|
|
|
referredSegments,
|
|
|
|
data,
|
|
|
|
start,
|
|
|
|
end
|
|
|
|
) {
|
2018-01-24 00:04:07 +09:00
|
|
|
let huffmanTables, huffmanInput;
|
2014-03-09 21:03:45 +09:00
|
|
|
if (dictionary.huffman) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
huffmanTables = getSymbolDictionaryHuffmanTables(
|
|
|
|
dictionary,
|
|
|
|
referredSegments,
|
|
|
|
this.customTables
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
huffmanInput = new Reader(data, start, end);
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-22 19:36:56 +09:00
|
|
|
|
2012-06-19 05:03:20 +09:00
|
|
|
// Combines exported symbols from all referred segments
|
2012-06-22 19:36:56 +09:00
|
|
|
var symbols = this.symbols;
|
2014-03-09 21:03:45 +09:00
|
|
|
if (!symbols) {
|
2012-06-22 19:36:56 +09:00
|
|
|
this.symbols = symbols = {};
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-22 19:36:56 +09:00
|
|
|
|
2012-06-19 05:03:20 +09:00
|
|
|
var inputSymbols = [];
|
2014-03-09 21:03:45 +09:00
|
|
|
for (var i = 0, ii = referredSegments.length; i < ii; i++) {
|
2020-01-24 17:48:21 +09:00
|
|
|
const referredSymbols = symbols[referredSegments[i]];
|
2018-01-24 00:04:07 +09:00
|
|
|
// referredSymbols is undefined when we have a reference to a Tables
|
|
|
|
// segment instead of a SymbolDictionary.
|
|
|
|
if (referredSymbols) {
|
|
|
|
inputSymbols = inputSymbols.concat(referredSymbols);
|
|
|
|
}
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-19 05:03:20 +09:00
|
|
|
|
2012-06-22 19:36:56 +09:00
|
|
|
var decodingContext = new DecodingContext(data, start, end);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
symbols[currentSegment] = decodeSymbolDictionary(
|
|
|
|
dictionary.huffman,
|
|
|
|
dictionary.refinement,
|
|
|
|
inputSymbols,
|
|
|
|
dictionary.numberOfNewSymbols,
|
|
|
|
dictionary.numberOfExportedSymbols,
|
|
|
|
huffmanTables,
|
|
|
|
dictionary.template,
|
|
|
|
dictionary.at,
|
|
|
|
dictionary.refinementTemplate,
|
|
|
|
dictionary.refinementAt,
|
|
|
|
decodingContext,
|
|
|
|
huffmanInput
|
|
|
|
);
|
2012-06-19 05:03:20 +09:00
|
|
|
},
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(
|
|
|
|
region,
|
|
|
|
referredSegments,
|
|
|
|
data,
|
|
|
|
start,
|
|
|
|
end
|
|
|
|
) {
|
2012-06-19 05:03:20 +09:00
|
|
|
var regionInfo = region.info;
|
2018-01-24 00:04:07 +09:00
|
|
|
let huffmanTables, huffmanInput;
|
2012-06-22 19:36:56 +09:00
|
|
|
|
2012-06-19 05:03:20 +09:00
|
|
|
// Combines exported symbols from all referred segments
|
2012-06-22 19:36:56 +09:00
|
|
|
var symbols = this.symbols;
|
2012-06-19 05:03:20 +09:00
|
|
|
var inputSymbols = [];
|
2014-03-09 21:03:45 +09:00
|
|
|
for (var i = 0, ii = referredSegments.length; i < ii; i++) {
|
2020-01-24 17:48:21 +09:00
|
|
|
const referredSymbols = symbols[referredSegments[i]];
|
2018-01-24 00:04:07 +09:00
|
|
|
// referredSymbols is undefined when we have a reference to a Tables
|
|
|
|
// segment instead of a SymbolDictionary.
|
|
|
|
if (referredSymbols) {
|
|
|
|
inputSymbols = inputSymbols.concat(referredSymbols);
|
|
|
|
}
|
2014-03-09 21:03:45 +09:00
|
|
|
}
|
2012-06-19 05:03:20 +09:00
|
|
|
var symbolCodeLength = log2(inputSymbols.length);
|
2018-01-24 00:04:07 +09:00
|
|
|
if (region.huffman) {
|
|
|
|
huffmanInput = new Reader(data, start, end);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
huffmanTables = getTextRegionHuffmanTables(
|
|
|
|
region,
|
|
|
|
referredSegments,
|
|
|
|
this.customTables,
|
|
|
|
inputSymbols.length,
|
|
|
|
huffmanInput
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
2012-06-19 05:03:20 +09:00
|
|
|
|
2012-06-22 19:36:56 +09:00
|
|
|
var decodingContext = new DecodingContext(data, start, end);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
var bitmap = decodeTextRegion(
|
|
|
|
region.huffman,
|
|
|
|
region.refinement,
|
|
|
|
regionInfo.width,
|
|
|
|
regionInfo.height,
|
|
|
|
region.defaultPixelValue,
|
|
|
|
region.numberOfSymbolInstances,
|
|
|
|
region.stripSize,
|
|
|
|
inputSymbols,
|
|
|
|
symbolCodeLength,
|
|
|
|
region.transposed,
|
|
|
|
region.dsOffset,
|
|
|
|
region.referenceCorner,
|
|
|
|
region.combinationOperator,
|
|
|
|
huffmanTables,
|
|
|
|
region.refinementTemplate,
|
|
|
|
region.refinementAt,
|
|
|
|
decodingContext,
|
|
|
|
region.logStripSize,
|
|
|
|
huffmanInput
|
|
|
|
);
|
2012-06-19 05:03:20 +09:00
|
|
|
this.drawBitmap(regionInfo, bitmap);
|
2012-07-10 02:13:03 +09:00
|
|
|
},
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
|
2014-03-09 21:03:45 +09:00
|
|
|
this.onImmediateTextRegion.apply(this, arguments);
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
},
|
2017-08-08 21:38:29 +09:00
|
|
|
onPatternDictionary(dictionary, currentSegment, data, start, end) {
|
|
|
|
let patterns = this.patterns;
|
|
|
|
if (!patterns) {
|
|
|
|
this.patterns = patterns = {};
|
|
|
|
}
|
2020-01-24 17:48:21 +09:00
|
|
|
const decodingContext = new DecodingContext(data, start, end);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
patterns[currentSegment] = decodePatternDictionary(
|
|
|
|
dictionary.mmr,
|
|
|
|
dictionary.patternWidth,
|
|
|
|
dictionary.patternHeight,
|
|
|
|
dictionary.maxPatternIndex,
|
|
|
|
dictionary.template,
|
|
|
|
decodingContext
|
|
|
|
);
|
2017-08-08 21:38:29 +09:00
|
|
|
},
|
|
|
|
onImmediateHalftoneRegion(region, referredSegments, data, start, end) {
|
|
|
|
// HalftoneRegion refers to exactly one PatternDictionary.
|
2020-01-24 17:48:21 +09:00
|
|
|
const patterns = this.patterns[referredSegments[0]];
|
|
|
|
const regionInfo = region.info;
|
|
|
|
const decodingContext = new DecodingContext(data, start, end);
|
|
|
|
const bitmap = decodeHalftoneRegion(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
region.mmr,
|
|
|
|
patterns,
|
|
|
|
region.template,
|
|
|
|
regionInfo.width,
|
|
|
|
regionInfo.height,
|
|
|
|
region.defaultPixelValue,
|
|
|
|
region.enableSkip,
|
|
|
|
region.combinationOperator,
|
|
|
|
region.gridWidth,
|
|
|
|
region.gridHeight,
|
|
|
|
region.gridOffsetX,
|
|
|
|
region.gridOffsetY,
|
|
|
|
region.gridVectorX,
|
|
|
|
region.gridVectorY,
|
|
|
|
decodingContext
|
|
|
|
);
|
2017-08-08 21:38:29 +09:00
|
|
|
this.drawBitmap(regionInfo, bitmap);
|
|
|
|
},
|
|
|
|
onImmediateLosslessHalftoneRegion() {
|
|
|
|
this.onImmediateHalftoneRegion.apply(this, arguments);
|
|
|
|
},
|
2018-01-24 00:04:07 +09:00
|
|
|
onTables(currentSegment, data, start, end) {
|
|
|
|
let customTables = this.customTables;
|
|
|
|
if (!customTables) {
|
|
|
|
this.customTables = customTables = {};
|
|
|
|
}
|
|
|
|
customTables[currentSegment] = decodeTablesSegment(data, start, end);
|
|
|
|
},
|
2012-06-19 05:03:20 +09:00
|
|
|
};
|
2012-06-17 05:15:42 +09:00
|
|
|
|
2018-01-24 00:04:07 +09:00
|
|
|
function HuffmanLine(lineData) {
|
|
|
|
if (lineData.length === 2) {
|
|
|
|
// OOB line.
|
|
|
|
this.isOOB = true;
|
|
|
|
this.rangeLow = 0;
|
|
|
|
this.prefixLength = lineData[0];
|
|
|
|
this.rangeLength = 0;
|
|
|
|
this.prefixCode = lineData[1];
|
|
|
|
this.isLowerRange = false;
|
|
|
|
} else {
|
|
|
|
// Normal, upper range or lower range line.
|
|
|
|
// Upper range lines are processed like normal lines.
|
|
|
|
this.isOOB = false;
|
|
|
|
this.rangeLow = lineData[0];
|
|
|
|
this.prefixLength = lineData[1];
|
|
|
|
this.rangeLength = lineData[2];
|
|
|
|
this.prefixCode = lineData[3];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
this.isLowerRange = lineData[4] === "lower";
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function HuffmanTreeNode(line) {
|
|
|
|
this.children = [];
|
|
|
|
if (line) {
|
|
|
|
// Leaf node
|
|
|
|
this.isLeaf = true;
|
|
|
|
this.rangeLength = line.rangeLength;
|
|
|
|
this.rangeLow = line.rangeLow;
|
|
|
|
this.isLowerRange = line.isLowerRange;
|
|
|
|
this.isOOB = line.isOOB;
|
|
|
|
} else {
|
|
|
|
// Intermediate or root node
|
|
|
|
this.isLeaf = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HuffmanTreeNode.prototype = {
|
|
|
|
buildTree(line, shift) {
|
2020-01-24 17:48:21 +09:00
|
|
|
const bit = (line.prefixCode >> shift) & 1;
|
2018-01-24 00:04:07 +09:00
|
|
|
if (shift <= 0) {
|
|
|
|
// Create a leaf node.
|
|
|
|
this.children[bit] = new HuffmanTreeNode(line);
|
|
|
|
} else {
|
|
|
|
// Create an intermediate node and continue recursively.
|
|
|
|
let node = this.children[bit];
|
|
|
|
if (!node) {
|
|
|
|
this.children[bit] = node = new HuffmanTreeNode(null);
|
|
|
|
}
|
|
|
|
node.buildTree(line, shift - 1);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
decodeNode(reader) {
|
|
|
|
if (this.isLeaf) {
|
|
|
|
if (this.isOOB) {
|
|
|
|
return null;
|
|
|
|
}
|
2020-01-24 17:48:21 +09:00
|
|
|
const htOffset = reader.readBits(this.rangeLength);
|
2018-01-24 00:04:07 +09:00
|
|
|
return this.rangeLow + (this.isLowerRange ? -htOffset : htOffset);
|
|
|
|
}
|
2020-01-24 17:48:21 +09:00
|
|
|
const node = this.children[reader.readBit()];
|
2018-01-24 00:04:07 +09:00
|
|
|
if (!node) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("invalid Huffman data");
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
|
|
|
return node.decodeNode(reader);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
function HuffmanTable(lines, prefixCodesDone) {
|
|
|
|
if (!prefixCodesDone) {
|
|
|
|
this.assignPrefixCodes(lines);
|
|
|
|
}
|
|
|
|
// Create Huffman tree.
|
|
|
|
this.rootNode = new HuffmanTreeNode(null);
|
2020-01-24 21:21:16 +09:00
|
|
|
for (let i = 0, ii = lines.length; i < ii; i++) {
|
|
|
|
const line = lines[i];
|
2018-01-24 00:04:07 +09:00
|
|
|
if (line.prefixLength > 0) {
|
|
|
|
this.rootNode.buildTree(line, line.prefixLength - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HuffmanTable.prototype = {
|
|
|
|
decode(reader) {
|
|
|
|
return this.rootNode.decodeNode(reader);
|
|
|
|
},
|
|
|
|
assignPrefixCodes(lines) {
|
|
|
|
// Annex B.3 Assigning the prefix codes.
|
2020-01-24 21:21:16 +09:00
|
|
|
const linesLength = lines.length;
|
|
|
|
let prefixLengthMax = 0;
|
|
|
|
for (let i = 0; i < linesLength; i++) {
|
2018-01-24 00:04:07 +09:00
|
|
|
prefixLengthMax = Math.max(prefixLengthMax, lines[i].prefixLength);
|
|
|
|
}
|
|
|
|
|
2020-01-24 17:48:21 +09:00
|
|
|
const histogram = new Uint32Array(prefixLengthMax + 1);
|
2020-01-24 21:21:16 +09:00
|
|
|
for (let i = 0; i < linesLength; i++) {
|
2018-01-24 00:04:07 +09:00
|
|
|
histogram[lines[i].prefixLength]++;
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
let currentLength = 1,
|
|
|
|
firstCode = 0,
|
|
|
|
currentCode,
|
|
|
|
currentTemp,
|
|
|
|
line;
|
2018-01-24 00:04:07 +09:00
|
|
|
histogram[0] = 0;
|
|
|
|
|
|
|
|
while (currentLength <= prefixLengthMax) {
|
|
|
|
firstCode = (firstCode + histogram[currentLength - 1]) << 1;
|
|
|
|
currentCode = firstCode;
|
|
|
|
currentTemp = 0;
|
|
|
|
while (currentTemp < linesLength) {
|
|
|
|
line = lines[currentTemp];
|
|
|
|
if (line.prefixLength === currentLength) {
|
|
|
|
line.prefixCode = currentCode;
|
|
|
|
currentCode++;
|
|
|
|
}
|
|
|
|
currentTemp++;
|
|
|
|
}
|
|
|
|
currentLength++;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
function decodeTablesSegment(data, start, end) {
|
|
|
|
// Decodes a Tables segment, i.e., a custom Huffman table.
|
|
|
|
// Annex B.2 Code table structure.
|
2020-01-24 17:48:21 +09:00
|
|
|
const flags = data[start];
|
|
|
|
const lowestValue = readUint32(data, start + 1) & 0xffffffff;
|
|
|
|
const highestValue = readUint32(data, start + 5) & 0xffffffff;
|
|
|
|
const reader = new Reader(data, start + 9, end);
|
|
|
|
|
|
|
|
const prefixSizeBits = ((flags >> 1) & 7) + 1;
|
|
|
|
const rangeSizeBits = ((flags >> 4) & 7) + 1;
|
|
|
|
const lines = [];
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
let prefixLength,
|
|
|
|
rangeLength,
|
|
|
|
currentRangeLow = lowestValue;
|
2018-01-24 00:04:07 +09:00
|
|
|
|
|
|
|
// Normal table lines
|
|
|
|
do {
|
|
|
|
prefixLength = reader.readBits(prefixSizeBits);
|
|
|
|
rangeLength = reader.readBits(rangeSizeBits);
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
lines.push(
|
|
|
|
new HuffmanLine([currentRangeLow, prefixLength, rangeLength, 0])
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
currentRangeLow += 1 << rangeLength;
|
|
|
|
} while (currentRangeLow < highestValue);
|
|
|
|
|
|
|
|
// Lower range table line
|
|
|
|
prefixLength = reader.readBits(prefixSizeBits);
|
|
|
|
lines.push(
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
new HuffmanLine([lowestValue - 1, prefixLength, 32, 0, "lower"])
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
|
|
|
|
// Upper range table line
|
|
|
|
prefixLength = reader.readBits(prefixSizeBits);
|
|
|
|
lines.push(new HuffmanLine([highestValue, prefixLength, 32, 0]));
|
|
|
|
|
|
|
|
if (flags & 1) {
|
|
|
|
// Out-of-band table line
|
|
|
|
prefixLength = reader.readBits(prefixSizeBits);
|
|
|
|
lines.push(new HuffmanLine([prefixLength, 0]));
|
|
|
|
}
|
|
|
|
|
|
|
|
return new HuffmanTable(lines, false);
|
|
|
|
}
|
|
|
|
|
2020-01-24 17:48:21 +09:00
|
|
|
const standardTablesCache = {};
|
2018-01-24 00:04:07 +09:00
|
|
|
|
|
|
|
function getStandardTable(number) {
|
|
|
|
// Annex B.5 Standard Huffman tables.
|
|
|
|
let table = standardTablesCache[number];
|
|
|
|
if (table) {
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
let lines;
|
|
|
|
switch (number) {
|
|
|
|
case 1:
|
|
|
|
lines = [
|
|
|
|
[0, 1, 4, 0x0],
|
|
|
|
[16, 2, 8, 0x2],
|
|
|
|
[272, 3, 16, 0x6],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[65808, 3, 32, 0x7], // upper
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
lines = [
|
|
|
|
[0, 1, 0, 0x0],
|
|
|
|
[1, 2, 0, 0x2],
|
|
|
|
[2, 3, 0, 0x6],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[3, 4, 3, 0xe],
|
|
|
|
[11, 5, 6, 0x1e],
|
|
|
|
[75, 6, 32, 0x3e], // upper
|
|
|
|
[6, 0x3f], // OOB
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
lines = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[-256, 8, 8, 0xfe],
|
2018-01-24 00:04:07 +09:00
|
|
|
[0, 1, 0, 0x0],
|
|
|
|
[1, 2, 0, 0x2],
|
|
|
|
[2, 3, 0, 0x6],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[3, 4, 3, 0xe],
|
|
|
|
[11, 5, 6, 0x1e],
|
|
|
|
[-257, 8, 32, 0xff, "lower"],
|
|
|
|
[75, 7, 32, 0x7e], // upper
|
|
|
|
[6, 0x3e], // OOB
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
lines = [
|
|
|
|
[1, 1, 0, 0x0],
|
|
|
|
[2, 2, 0, 0x2],
|
|
|
|
[3, 3, 0, 0x6],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[4, 4, 3, 0xe],
|
|
|
|
[12, 5, 6, 0x1e],
|
|
|
|
[76, 5, 32, 0x1f], // upper
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
lines = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[-255, 7, 8, 0x7e],
|
2018-01-24 00:04:07 +09:00
|
|
|
[1, 1, 0, 0x0],
|
|
|
|
[2, 2, 0, 0x2],
|
|
|
|
[3, 3, 0, 0x6],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[4, 4, 3, 0xe],
|
|
|
|
[12, 5, 6, 0x1e],
|
|
|
|
[-256, 7, 32, 0x7f, "lower"],
|
|
|
|
[76, 6, 32, 0x3e], // upper
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
lines = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[-2048, 5, 10, 0x1c],
|
2018-01-24 00:04:07 +09:00
|
|
|
[-1024, 4, 9, 0x8],
|
|
|
|
[-512, 4, 8, 0x9],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[-256, 4, 7, 0xa],
|
|
|
|
[-128, 5, 6, 0x1d],
|
|
|
|
[-64, 5, 5, 0x1e],
|
|
|
|
[-32, 4, 5, 0xb],
|
2018-01-24 00:04:07 +09:00
|
|
|
[0, 2, 7, 0x0],
|
|
|
|
[128, 3, 7, 0x2],
|
|
|
|
[256, 3, 8, 0x3],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[512, 4, 9, 0xc],
|
|
|
|
[1024, 4, 10, 0xd],
|
|
|
|
[-2049, 6, 32, 0x3e, "lower"],
|
|
|
|
[2048, 6, 32, 0x3f], // upper
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
lines = [
|
|
|
|
[-1024, 4, 9, 0x8],
|
|
|
|
[-512, 3, 8, 0x0],
|
|
|
|
[-256, 4, 7, 0x9],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[-128, 5, 6, 0x1a],
|
|
|
|
[-64, 5, 5, 0x1b],
|
|
|
|
[-32, 4, 5, 0xa],
|
|
|
|
[0, 4, 5, 0xb],
|
|
|
|
[32, 5, 5, 0x1c],
|
|
|
|
[64, 5, 6, 0x1d],
|
|
|
|
[128, 4, 7, 0xc],
|
2018-01-24 00:04:07 +09:00
|
|
|
[256, 3, 8, 0x1],
|
|
|
|
[512, 3, 9, 0x2],
|
|
|
|
[1024, 3, 10, 0x3],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[-1025, 5, 32, 0x1e, "lower"],
|
|
|
|
[2048, 5, 32, 0x1f], // upper
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
lines = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[-15, 8, 3, 0xfc],
|
|
|
|
[-7, 9, 1, 0x1fc],
|
|
|
|
[-5, 8, 1, 0xfd],
|
|
|
|
[-3, 9, 0, 0x1fd],
|
|
|
|
[-2, 7, 0, 0x7c],
|
|
|
|
[-1, 4, 0, 0xa],
|
2018-01-24 00:04:07 +09:00
|
|
|
[0, 2, 1, 0x0],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[2, 5, 0, 0x1a],
|
|
|
|
[3, 6, 0, 0x3a],
|
2018-01-24 00:04:07 +09:00
|
|
|
[4, 3, 4, 0x4],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[20, 6, 1, 0x3b],
|
|
|
|
[22, 4, 4, 0xb],
|
|
|
|
[38, 4, 5, 0xc],
|
|
|
|
[70, 5, 6, 0x1b],
|
|
|
|
[134, 5, 7, 0x1c],
|
|
|
|
[262, 6, 7, 0x3c],
|
|
|
|
[390, 7, 8, 0x7d],
|
|
|
|
[646, 6, 10, 0x3d],
|
|
|
|
[-16, 9, 32, 0x1fe, "lower"],
|
|
|
|
[1670, 9, 32, 0x1ff], // upper
|
|
|
|
[2, 0x1], // OOB
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
lines = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[-31, 8, 4, 0xfc],
|
|
|
|
[-15, 9, 2, 0x1fc],
|
|
|
|
[-11, 8, 2, 0xfd],
|
|
|
|
[-7, 9, 1, 0x1fd],
|
|
|
|
[-5, 7, 1, 0x7c],
|
|
|
|
[-3, 4, 1, 0xa],
|
2018-01-24 00:04:07 +09:00
|
|
|
[-1, 3, 1, 0x2],
|
|
|
|
[1, 3, 1, 0x3],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[3, 5, 1, 0x1a],
|
|
|
|
[5, 6, 1, 0x3a],
|
2018-01-24 00:04:07 +09:00
|
|
|
[7, 3, 5, 0x4],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[39, 6, 2, 0x3b],
|
|
|
|
[43, 4, 5, 0xb],
|
|
|
|
[75, 4, 6, 0xc],
|
|
|
|
[139, 5, 7, 0x1b],
|
|
|
|
[267, 5, 8, 0x1c],
|
|
|
|
[523, 6, 8, 0x3c],
|
|
|
|
[779, 7, 9, 0x7d],
|
|
|
|
[1291, 6, 11, 0x3d],
|
|
|
|
[-32, 9, 32, 0x1fe, "lower"],
|
|
|
|
[3339, 9, 32, 0x1ff], // upper
|
|
|
|
[2, 0x0], // OOB
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
lines = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[-21, 7, 4, 0x7a],
|
|
|
|
[-5, 8, 0, 0xfc],
|
|
|
|
[-4, 7, 0, 0x7b],
|
2018-01-24 00:04:07 +09:00
|
|
|
[-3, 5, 0, 0x18],
|
|
|
|
[-2, 2, 2, 0x0],
|
|
|
|
[2, 5, 0, 0x19],
|
|
|
|
[3, 6, 0, 0x36],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[4, 7, 0, 0x7c],
|
|
|
|
[5, 8, 0, 0xfd],
|
2018-01-24 00:04:07 +09:00
|
|
|
[6, 2, 6, 0x1],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[70, 5, 5, 0x1a],
|
2018-01-24 00:04:07 +09:00
|
|
|
[102, 6, 5, 0x37],
|
|
|
|
[134, 6, 6, 0x38],
|
|
|
|
[198, 6, 7, 0x39],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[326, 6, 8, 0x3a],
|
|
|
|
[582, 6, 9, 0x3b],
|
|
|
|
[1094, 6, 10, 0x3c],
|
|
|
|
[2118, 7, 11, 0x7d],
|
|
|
|
[-22, 8, 32, 0xfe, "lower"],
|
|
|
|
[4166, 8, 32, 0xff], // upper
|
|
|
|
[2, 0x2], // OOB
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
lines = [
|
|
|
|
[1, 1, 0, 0x0],
|
|
|
|
[2, 2, 1, 0x2],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[4, 4, 0, 0xc],
|
|
|
|
[5, 4, 1, 0xd],
|
|
|
|
[7, 5, 1, 0x1c],
|
|
|
|
[9, 5, 2, 0x1d],
|
|
|
|
[13, 6, 2, 0x3c],
|
|
|
|
[17, 7, 2, 0x7a],
|
|
|
|
[21, 7, 3, 0x7b],
|
|
|
|
[29, 7, 4, 0x7c],
|
|
|
|
[45, 7, 5, 0x7d],
|
|
|
|
[77, 7, 6, 0x7e],
|
|
|
|
[141, 7, 32, 0x7f], // upper
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
lines = [
|
|
|
|
[1, 1, 0, 0x0],
|
|
|
|
[2, 2, 0, 0x2],
|
|
|
|
[3, 3, 1, 0x6],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[5, 5, 0, 0x1c],
|
|
|
|
[6, 5, 1, 0x1d],
|
|
|
|
[8, 6, 1, 0x3c],
|
|
|
|
[10, 7, 0, 0x7a],
|
|
|
|
[11, 7, 1, 0x7b],
|
|
|
|
[13, 7, 2, 0x7c],
|
|
|
|
[17, 7, 3, 0x7d],
|
|
|
|
[25, 7, 4, 0x7e],
|
|
|
|
[41, 8, 5, 0xfe],
|
|
|
|
[73, 8, 32, 0xff], // upper
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
lines = [
|
|
|
|
[1, 1, 0, 0x0],
|
|
|
|
[2, 3, 0, 0x4],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[3, 4, 0, 0xc],
|
|
|
|
[4, 5, 0, 0x1c],
|
|
|
|
[5, 4, 1, 0xd],
|
2018-01-24 00:04:07 +09:00
|
|
|
[7, 3, 3, 0x5],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[15, 6, 1, 0x3a],
|
|
|
|
[17, 6, 2, 0x3b],
|
|
|
|
[21, 6, 3, 0x3c],
|
|
|
|
[29, 6, 4, 0x3d],
|
|
|
|
[45, 6, 5, 0x3e],
|
|
|
|
[77, 7, 6, 0x7e],
|
|
|
|
[141, 7, 32, 0x7f], // upper
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case 14:
|
|
|
|
lines = [
|
|
|
|
[-2, 3, 0, 0x4],
|
|
|
|
[-1, 3, 0, 0x5],
|
|
|
|
[0, 1, 0, 0x0],
|
|
|
|
[1, 3, 0, 0x6],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[2, 3, 0, 0x7],
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
lines = [
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[-24, 7, 4, 0x7c],
|
|
|
|
[-8, 6, 2, 0x3c],
|
|
|
|
[-4, 5, 1, 0x1c],
|
|
|
|
[-2, 4, 0, 0xc],
|
2018-01-24 00:04:07 +09:00
|
|
|
[-1, 3, 0, 0x4],
|
|
|
|
[0, 1, 0, 0x0],
|
|
|
|
[1, 3, 0, 0x5],
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
[2, 4, 0, 0xd],
|
|
|
|
[3, 5, 1, 0x1d],
|
|
|
|
[5, 6, 2, 0x3d],
|
|
|
|
[9, 7, 4, 0x7d],
|
|
|
|
[-25, 7, 32, 0x7e, "lower"],
|
|
|
|
[25, 7, 32, 0x7f], // upper
|
2018-01-24 00:04:07 +09:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw new Jbig2Error(`standard table B.${number} does not exist`);
|
|
|
|
}
|
|
|
|
|
2020-01-24 21:21:16 +09:00
|
|
|
for (let i = 0, ii = lines.length; i < ii; i++) {
|
2018-01-24 00:04:07 +09:00
|
|
|
lines[i] = new HuffmanLine(lines[i]);
|
|
|
|
}
|
|
|
|
table = new HuffmanTable(lines, true);
|
|
|
|
standardTablesCache[number] = table;
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
|
|
|
|
function Reader(data, start, end) {
|
|
|
|
this.data = data;
|
|
|
|
this.start = start;
|
|
|
|
this.end = end;
|
|
|
|
this.position = start;
|
|
|
|
this.shift = -1;
|
|
|
|
this.currentByte = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Reader.prototype = {
|
|
|
|
readBit() {
|
|
|
|
if (this.shift < 0) {
|
|
|
|
if (this.position >= this.end) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("end of data while reading bit");
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
|
|
|
this.currentByte = this.data[this.position++];
|
|
|
|
this.shift = 7;
|
|
|
|
}
|
2020-01-24 17:48:21 +09:00
|
|
|
const bit = (this.currentByte >> this.shift) & 1;
|
2018-01-24 00:04:07 +09:00
|
|
|
this.shift--;
|
|
|
|
return bit;
|
|
|
|
},
|
|
|
|
|
|
|
|
readBits(numBits) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
let result = 0,
|
|
|
|
i;
|
2018-01-24 00:04:07 +09:00
|
|
|
for (i = numBits - 1; i >= 0; i--) {
|
|
|
|
result |= this.readBit() << i;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
|
|
|
|
byteAlign() {
|
|
|
|
this.shift = -1;
|
|
|
|
},
|
|
|
|
|
|
|
|
next() {
|
|
|
|
if (this.position >= this.end) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return this.data[this.position++];
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
function getCustomHuffmanTable(index, referredTo, customTables) {
|
|
|
|
// Returns a Tables segment that has been earlier decoded.
|
|
|
|
// See 7.4.2.1.6 (symbol dictionary) or 7.4.3.1.6 (text region).
|
2020-01-24 21:21:16 +09:00
|
|
|
let currentIndex = 0;
|
|
|
|
for (let i = 0, ii = referredTo.length; i < ii; i++) {
|
|
|
|
const table = customTables[referredTo[i]];
|
2018-01-24 00:04:07 +09:00
|
|
|
if (table) {
|
|
|
|
if (index === currentIndex) {
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
currentIndex++;
|
|
|
|
}
|
|
|
|
}
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("can't find custom Huffman table");
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
function getTextRegionHuffmanTables(
|
|
|
|
textRegion,
|
|
|
|
referredTo,
|
|
|
|
customTables,
|
|
|
|
numberOfSymbols,
|
|
|
|
reader
|
|
|
|
) {
|
2018-01-24 00:04:07 +09:00
|
|
|
// 7.4.3.1.7 Symbol ID Huffman table decoding
|
|
|
|
|
|
|
|
// Read code lengths for RUNCODEs 0...34.
|
2020-01-24 21:21:16 +09:00
|
|
|
const codes = [];
|
|
|
|
for (let i = 0; i <= 34; i++) {
|
|
|
|
const codeLength = reader.readBits(4);
|
2018-01-24 00:04:07 +09:00
|
|
|
codes.push(new HuffmanLine([i, codeLength, 0, 0]));
|
|
|
|
}
|
|
|
|
// Assign Huffman codes for RUNCODEs.
|
2020-01-24 17:48:21 +09:00
|
|
|
const runCodesTable = new HuffmanTable(codes, false);
|
2018-01-24 00:04:07 +09:00
|
|
|
|
|
|
|
// Read a Huffman code using the assignment above.
|
|
|
|
// Interpret the RUNCODE codes and the additional bits (if any).
|
|
|
|
codes.length = 0;
|
2020-01-24 21:21:16 +09:00
|
|
|
for (let i = 0; i < numberOfSymbols; ) {
|
|
|
|
const codeLength = runCodesTable.decode(reader);
|
2018-01-24 00:04:07 +09:00
|
|
|
if (codeLength >= 32) {
|
|
|
|
let repeatedLength, numberOfRepeats, j;
|
|
|
|
switch (codeLength) {
|
|
|
|
case 32:
|
|
|
|
if (i === 0) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("no previous value in symbol ID table");
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
|
|
|
numberOfRepeats = reader.readBits(2) + 3;
|
|
|
|
repeatedLength = codes[i - 1].prefixLength;
|
|
|
|
break;
|
|
|
|
case 33:
|
|
|
|
numberOfRepeats = reader.readBits(3) + 3;
|
|
|
|
repeatedLength = 0;
|
|
|
|
break;
|
|
|
|
case 34:
|
|
|
|
numberOfRepeats = reader.readBits(7) + 11;
|
|
|
|
repeatedLength = 0;
|
|
|
|
break;
|
|
|
|
default:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("invalid code length in symbol ID table");
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
|
|
|
for (j = 0; j < numberOfRepeats; j++) {
|
|
|
|
codes.push(new HuffmanLine([i, repeatedLength, 0, 0]));
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
codes.push(new HuffmanLine([i, codeLength, 0, 0]));
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reader.byteAlign();
|
2020-01-24 17:48:21 +09:00
|
|
|
const symbolIDTable = new HuffmanTable(codes, false);
|
2018-01-24 00:04:07 +09:00
|
|
|
|
|
|
|
// 7.4.3.1.6 Text region segment Huffman table selection
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
let customIndex = 0,
|
|
|
|
tableFirstS,
|
|
|
|
tableDeltaS,
|
|
|
|
tableDeltaT;
|
2018-01-24 00:04:07 +09:00
|
|
|
|
|
|
|
switch (textRegion.huffmanFS) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
tableFirstS = getStandardTable(textRegion.huffmanFS + 6);
|
|
|
|
break;
|
|
|
|
case 3:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
tableFirstS = getCustomHuffmanTable(
|
|
|
|
customIndex,
|
|
|
|
referredTo,
|
|
|
|
customTables
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
customIndex++;
|
|
|
|
break;
|
|
|
|
default:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("invalid Huffman FS selector");
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (textRegion.huffmanDS) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
tableDeltaS = getStandardTable(textRegion.huffmanDS + 8);
|
|
|
|
break;
|
|
|
|
case 3:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
tableDeltaS = getCustomHuffmanTable(
|
|
|
|
customIndex,
|
|
|
|
referredTo,
|
|
|
|
customTables
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
customIndex++;
|
|
|
|
break;
|
|
|
|
default:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("invalid Huffman DS selector");
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (textRegion.huffmanDT) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
tableDeltaT = getStandardTable(textRegion.huffmanDT + 11);
|
|
|
|
break;
|
|
|
|
case 3:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
tableDeltaT = getCustomHuffmanTable(
|
|
|
|
customIndex,
|
|
|
|
referredTo,
|
|
|
|
customTables
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
customIndex++;
|
|
|
|
break;
|
|
|
|
default:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("invalid Huffman DT selector");
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
if (textRegion.refinement) {
|
|
|
|
// Load tables RDW, RDH, RDX and RDY.
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("refinement with Huffman is not supported");
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
symbolIDTable,
|
|
|
|
tableFirstS,
|
|
|
|
tableDeltaS,
|
|
|
|
tableDeltaT,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
function getSymbolDictionaryHuffmanTables(
|
|
|
|
dictionary,
|
|
|
|
referredTo,
|
|
|
|
customTables
|
|
|
|
) {
|
2018-01-24 00:04:07 +09:00
|
|
|
// 7.4.2.1.6 Symbol dictionary segment Huffman table selection
|
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
let customIndex = 0,
|
|
|
|
tableDeltaHeight,
|
|
|
|
tableDeltaWidth;
|
2018-01-24 00:04:07 +09:00
|
|
|
switch (dictionary.huffmanDHSelector) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
tableDeltaHeight = getStandardTable(dictionary.huffmanDHSelector + 4);
|
|
|
|
break;
|
|
|
|
case 3:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
tableDeltaHeight = getCustomHuffmanTable(
|
|
|
|
customIndex,
|
|
|
|
referredTo,
|
|
|
|
customTables
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
customIndex++;
|
|
|
|
break;
|
|
|
|
default:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("invalid Huffman DH selector");
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (dictionary.huffmanDWSelector) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
tableDeltaWidth = getStandardTable(dictionary.huffmanDWSelector + 2);
|
|
|
|
break;
|
|
|
|
case 3:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
tableDeltaWidth = getCustomHuffmanTable(
|
|
|
|
customIndex,
|
|
|
|
referredTo,
|
|
|
|
customTables
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
customIndex++;
|
|
|
|
break;
|
|
|
|
default:
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
throw new Jbig2Error("invalid Huffman DW selector");
|
2018-01-24 00:04:07 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
let tableBitmapSize, tableAggregateInstances;
|
|
|
|
if (dictionary.bitmapSizeSelector) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
tableBitmapSize = getCustomHuffmanTable(
|
|
|
|
customIndex,
|
|
|
|
referredTo,
|
|
|
|
customTables
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
customIndex++;
|
|
|
|
} else {
|
|
|
|
tableBitmapSize = getStandardTable(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dictionary.aggregationInstancesSelector) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
tableAggregateInstances = getCustomHuffmanTable(
|
|
|
|
customIndex,
|
|
|
|
referredTo,
|
|
|
|
customTables
|
|
|
|
);
|
2018-01-24 00:04:07 +09:00
|
|
|
} else {
|
|
|
|
tableAggregateInstances = getStandardTable(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
tableDeltaHeight,
|
|
|
|
tableDeltaWidth,
|
|
|
|
tableBitmapSize,
|
|
|
|
tableAggregateInstances,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function readUncompressedBitmap(reader, width, height) {
|
2020-01-24 21:21:16 +09:00
|
|
|
const bitmap = [];
|
|
|
|
for (let y = 0; y < height; y++) {
|
|
|
|
const row = new Uint8Array(width);
|
2018-01-24 00:04:07 +09:00
|
|
|
bitmap.push(row);
|
2020-01-24 21:21:16 +09:00
|
|
|
for (let x = 0; x < width; x++) {
|
2018-01-24 00:04:07 +09:00
|
|
|
row[x] = reader.readBit();
|
|
|
|
}
|
|
|
|
reader.byteAlign();
|
|
|
|
}
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
function decodeMMRBitmap(input, width, height, endOfBlock) {
|
|
|
|
// MMR is the same compression algorithm as the PDF filter
|
|
|
|
// CCITTFaxDecode with /K -1.
|
2020-01-24 17:48:21 +09:00
|
|
|
const params = {
|
2018-01-24 00:04:07 +09:00
|
|
|
K: -1,
|
|
|
|
Columns: width,
|
|
|
|
Rows: height,
|
|
|
|
BlackIs1: true,
|
|
|
|
EndOfBlock: endOfBlock,
|
|
|
|
};
|
2020-01-24 17:48:21 +09:00
|
|
|
const decoder = new CCITTFaxDecoder(input, params);
|
2020-01-24 21:21:16 +09:00
|
|
|
const bitmap = [];
|
|
|
|
let currentByte,
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
eof = false;
|
2018-01-24 00:04:07 +09:00
|
|
|
|
2020-01-24 21:21:16 +09:00
|
|
|
for (let y = 0; y < height; y++) {
|
|
|
|
const row = new Uint8Array(width);
|
2018-01-24 00:04:07 +09:00
|
|
|
bitmap.push(row);
|
2020-01-24 21:21:16 +09:00
|
|
|
let shift = -1;
|
|
|
|
for (let x = 0; x < width; x++) {
|
2018-01-24 00:04:07 +09:00
|
|
|
if (shift < 0) {
|
|
|
|
currentByte = decoder.readNextChar();
|
|
|
|
if (currentByte === -1) {
|
|
|
|
// Set the rest of the bits to zero.
|
|
|
|
currentByte = 0;
|
|
|
|
eof = true;
|
|
|
|
}
|
|
|
|
shift = 7;
|
|
|
|
}
|
|
|
|
row[x] = (currentByte >> shift) & 1;
|
|
|
|
shift--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (endOfBlock && !eof) {
|
|
|
|
// Read until EOFB has been consumed.
|
|
|
|
const lookForEOFLimit = 5;
|
|
|
|
for (let i = 0; i < lookForEOFLimit; i++) {
|
|
|
|
if (decoder.readNextChar() === -1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bitmap;
|
|
|
|
}
|
|
|
|
|
2020-03-25 18:15:50 +09:00
|
|
|
// eslint-disable-next-line no-shadow
|
2012-06-17 05:15:42 +09:00
|
|
|
function Jbig2Image() {}
|
|
|
|
|
|
|
|
Jbig2Image.prototype = {
|
2018-05-16 20:49:12 +09:00
|
|
|
parseChunks(chunks) {
|
2012-06-19 05:03:20 +09:00
|
|
|
return parseJbig2Chunks(chunks);
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 18:16:24 +09:00
|
|
|
},
|
2018-05-16 20:49:12 +09:00
|
|
|
|
|
|
|
parse(data) {
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
const { imgData, width, height } = parseJbig2(data);
|
2018-05-16 20:49:12 +09:00
|
|
|
this.width = width;
|
|
|
|
this.height = height;
|
|
|
|
return imgData;
|
|
|
|
},
|
2012-06-17 05:15:42 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
return Jbig2Image;
|
|
|
|
})();
|
2015-11-22 01:32:47 +09:00
|
|
|
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 23:59:37 +09:00
|
|
|
export { Jbig2Image };
|