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.
|
|
|
|
*/
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2020-01-08 03:59:16 +09:00
|
|
|
import { BaseException, info, warn } from "../shared/util.js";
|
|
|
|
import { log2, readUint16, readUint32 } from "./core_utils.js";
|
2020-01-02 20:00:16 +09:00
|
|
|
import { ArithmeticDecoder } from "./arithmetic_decoder.js";
|
2015-11-22 01:32:47 +09:00
|
|
|
|
2019-10-01 20:10:14 +09:00
|
|
|
class JpxError extends BaseException {
|
|
|
|
constructor(msg) {
|
|
|
|
super(`JPX 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
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const JpxImage = (function JpxImageClosure() {
|
2012-04-05 05:43:26 +09:00
|
|
|
// Table E.1
|
2021-05-05 19:46:08 +09:00
|
|
|
const SubbandsGainLog2 = {
|
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
|
|
|
LL: 0,
|
|
|
|
LH: 1,
|
|
|
|
HL: 1,
|
|
|
|
HH: 2,
|
2012-04-05 05:43:26 +09:00
|
|
|
};
|
2020-03-25 18:15:50 +09:00
|
|
|
|
|
|
|
// eslint-disable-next-line no-shadow
|
2012-04-05 05:43:26 +09:00
|
|
|
function JpxImage() {
|
|
|
|
this.failOnCorruptedImage = false;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
JpxImage.prototype = {
|
|
|
|
parse: function JpxImage_parse(data) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const head = readUint16(data, 0);
|
2014-03-03 05:12:26 +09:00
|
|
|
// No box header, immediate start of codestream (SOC)
|
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 (head === 0xff4f) {
|
2014-03-03 05:12:26 +09:00
|
|
|
this.parseCodestream(data, 0, data.length);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-05-05 19:47:01 +09:00
|
|
|
const length = data.length;
|
|
|
|
let position = 0;
|
2012-04-05 05:43:26 +09:00
|
|
|
while (position < length) {
|
2021-05-05 19:46:08 +09:00
|
|
|
let headerSize = 8;
|
|
|
|
let lbox = readUint32(data, position);
|
|
|
|
const tbox = readUint32(data, position + 4);
|
2012-04-05 05:43:26 +09:00
|
|
|
position += headerSize;
|
2014-04-17 04:31:16 +09:00
|
|
|
if (lbox === 1) {
|
|
|
|
// XLBox: read UInt64 according to spec.
|
|
|
|
// JavaScript's int precision of 53 bit should be sufficient here.
|
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
|
|
|
lbox =
|
|
|
|
readUint32(data, position) * 4294967296 +
|
|
|
|
readUint32(data, position + 4);
|
2012-04-05 05:43:26 +09:00
|
|
|
position += 8;
|
|
|
|
headerSize += 8;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2014-03-10 06:31:55 +09:00
|
|
|
if (lbox === 0) {
|
2012-04-05 05:43:26 +09:00
|
|
|
lbox = length - position + headerSize;
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
|
|
|
if (lbox < headerSize) {
|
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 JpxError("Invalid box field size");
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2021-05-05 19:46:08 +09:00
|
|
|
const dataLength = lbox - headerSize;
|
|
|
|
let jumpDataLength = true;
|
2012-04-05 05:43:26 +09:00
|
|
|
switch (tbox) {
|
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
|
|
|
case 0x6a703268: // 'jp2h'
|
2012-04-05 05:43:26 +09:00
|
|
|
jumpDataLength = false; // parsing child boxes
|
|
|
|
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
|
|
|
case 0x636f6c72: // 'colr'
|
2014-09-27 06:38:37 +09:00
|
|
|
// Colorspaces are not used, the CS from the PDF is used.
|
2021-05-05 19:47:01 +09:00
|
|
|
const method = data[position];
|
2014-09-27 06:38:37 +09:00
|
|
|
if (method === 1) {
|
|
|
|
// enumerated colorspace
|
2021-05-05 19:46:08 +09:00
|
|
|
const colorspace = readUint32(data, position + 3);
|
2014-09-27 06:38:37 +09:00
|
|
|
switch (colorspace) {
|
|
|
|
case 16: // this indicates a sRGB colorspace
|
|
|
|
case 17: // this indicates a grayscale colorspace
|
|
|
|
case 18: // this indicates a YUV colorspace
|
|
|
|
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
|
|
|
warn("Unknown colorspace " + colorspace);
|
2014-09-27 06:38:37 +09:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (method === 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
|
|
|
info("ICC profile not supported");
|
2014-09-27 06:38:37 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
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
|
|
|
case 0x6a703263: // 'jp2c'
|
2012-04-05 05:43:26 +09:00
|
|
|
this.parseCodestream(data, position, position + dataLength);
|
2012-01-15 04:15:16 +09:00
|
|
|
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
|
|
|
case 0x6a502020: // 'jP\024\024'
|
2017-03-07 00:50:22 +09:00
|
|
|
if (readUint32(data, position) !== 0x0d0a870a) {
|
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
|
|
|
warn("Invalid JP2 signature");
|
2014-09-27 06:38:37 +09:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
// The following header types are valid but currently not used:
|
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
|
|
|
case 0x6a501a1a: // 'jP\032\032'
|
2014-09-27 06:38:37 +09:00
|
|
|
case 0x66747970: // 'ftyp'
|
|
|
|
case 0x72726571: // 'rreq'
|
|
|
|
case 0x72657320: // 'res '
|
|
|
|
case 0x69686472: // 'ihdr'
|
|
|
|
break;
|
|
|
|
default:
|
2021-05-05 19:47:01 +09:00
|
|
|
const headerType = String.fromCharCode(
|
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
|
|
|
(tbox >> 24) & 0xff,
|
|
|
|
(tbox >> 16) & 0xff,
|
|
|
|
(tbox >> 8) & 0xff,
|
|
|
|
tbox & 0xff
|
|
|
|
);
|
|
|
|
warn("Unsupported header type " + tbox + " (" + headerType + ")");
|
2014-09-27 06:38:37 +09:00
|
|
|
break;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2014-03-10 06:31:55 +09:00
|
|
|
if (jumpDataLength) {
|
2012-04-05 05:43:26 +09:00
|
|
|
position += dataLength;
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
},
|
2014-04-06 19:08:04 +09:00
|
|
|
parseImageProperties: function JpxImage_parseImageProperties(stream) {
|
2021-05-05 19:46:08 +09:00
|
|
|
let newByte = stream.getByte();
|
2014-04-30 16:00:17 +09:00
|
|
|
while (newByte >= 0) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const oldByte = newByte;
|
2014-04-30 16:00:17 +09:00
|
|
|
newByte = stream.getByte();
|
2021-05-05 19:46:08 +09:00
|
|
|
const code = (oldByte << 8) | newByte;
|
2014-04-30 16:00:17 +09:00
|
|
|
// Image and tile size (SIZ)
|
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 (code === 0xff51) {
|
2014-04-30 16:00:17 +09:00
|
|
|
stream.skip(4);
|
2021-05-05 19:46:08 +09:00
|
|
|
const Xsiz = stream.getInt32() >>> 0; // Byte 4
|
|
|
|
const Ysiz = stream.getInt32() >>> 0; // Byte 8
|
|
|
|
const XOsiz = stream.getInt32() >>> 0; // Byte 12
|
|
|
|
const YOsiz = stream.getInt32() >>> 0; // Byte 16
|
2014-04-30 16:00:17 +09:00
|
|
|
stream.skip(16);
|
2021-05-05 19:46:08 +09:00
|
|
|
const Csiz = stream.getUint16(); // Byte 36
|
2014-04-30 16:00:17 +09:00
|
|
|
this.width = Xsiz - XOsiz;
|
|
|
|
this.height = Ysiz - YOsiz;
|
|
|
|
this.componentsCount = Csiz;
|
2018-07-16 01:32:05 +09:00
|
|
|
// Results are always returned as `Uint8ClampedArray`s.
|
2014-04-30 16:00:17 +09:00
|
|
|
this.bitsPerComponent = 8;
|
|
|
|
return;
|
2014-04-06 00:27:18 +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
|
|
|
throw new JpxError("No size marker found in JPX stream");
|
2014-04-06 00:27:18 +09:00
|
|
|
},
|
2012-04-05 05:43:26 +09:00
|
|
|
parseCodestream: function JpxImage_parseCodestream(data, start, end) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const context = {};
|
|
|
|
let doNotRecover = false;
|
2012-04-05 05:43:26 +09:00
|
|
|
try {
|
2021-05-05 19:46:08 +09:00
|
|
|
let position = start;
|
2014-04-17 04:40:37 +09:00
|
|
|
while (position + 1 < end) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const code = readUint16(data, position);
|
2012-04-05 05:43:26 +09:00
|
|
|
position += 2;
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:47:01 +09:00
|
|
|
let length = 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
|
|
|
j,
|
|
|
|
sqcd,
|
|
|
|
spqcds,
|
|
|
|
spqcdSize,
|
|
|
|
scalarExpounded,
|
|
|
|
tile;
|
2012-04-05 05:43:26 +09:00
|
|
|
switch (code) {
|
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
|
|
|
case 0xff4f: // Start of codestream (SOC)
|
2012-04-05 05:43:26 +09:00
|
|
|
context.mainHeader = true;
|
|
|
|
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
|
|
|
case 0xffd9: // End of codestream (EOC)
|
2012-04-05 05:43:26 +09:00
|
|
|
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
|
|
|
case 0xff51: // Image and tile size (SIZ)
|
2012-04-05 05:43:26 +09:00
|
|
|
length = readUint16(data, position);
|
2021-05-05 19:47:01 +09:00
|
|
|
const siz = {};
|
2012-04-05 05:43:26 +09:00
|
|
|
siz.Xsiz = readUint32(data, position + 4);
|
|
|
|
siz.Ysiz = readUint32(data, position + 8);
|
|
|
|
siz.XOsiz = readUint32(data, position + 12);
|
|
|
|
siz.YOsiz = readUint32(data, position + 16);
|
|
|
|
siz.XTsiz = readUint32(data, position + 20);
|
|
|
|
siz.YTsiz = readUint32(data, position + 24);
|
|
|
|
siz.XTOsiz = readUint32(data, position + 28);
|
|
|
|
siz.YTOsiz = readUint32(data, position + 32);
|
2021-05-05 19:47:01 +09:00
|
|
|
const componentsCount = readUint16(data, position + 36);
|
2012-04-05 05:43:26 +09:00
|
|
|
siz.Csiz = componentsCount;
|
2021-05-05 19:47:01 +09:00
|
|
|
const components = [];
|
2012-04-05 05:43:26 +09:00
|
|
|
j = position + 38;
|
2021-05-05 19:46:08 +09:00
|
|
|
for (let i = 0; i < componentsCount; i++) {
|
|
|
|
const component = {
|
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
|
|
|
precision: (data[j] & 0x7f) + 1,
|
2012-04-05 05:43:26 +09:00
|
|
|
isSigned: !!(data[j] & 0x80),
|
|
|
|
XRsiz: data[j + 1],
|
2018-01-04 00:10:56 +09:00
|
|
|
YRsiz: data[j + 2],
|
2012-04-05 05:43:26 +09:00
|
|
|
};
|
2018-01-04 00:10:56 +09:00
|
|
|
j += 3;
|
2012-04-05 05:43:26 +09:00
|
|
|
calculateComponentDimensions(component, siz);
|
|
|
|
components.push(component);
|
|
|
|
}
|
|
|
|
context.SIZ = siz;
|
|
|
|
context.components = components;
|
|
|
|
calculateTileGrids(context, components);
|
|
|
|
context.QCC = [];
|
|
|
|
context.COC = [];
|
|
|
|
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
|
|
|
case 0xff5c: // Quantization default (QCD)
|
2012-04-05 05:43:26 +09:00
|
|
|
length = readUint16(data, position);
|
2021-05-05 19:47:01 +09:00
|
|
|
const qcd = {};
|
2012-04-05 05:43:26 +09:00
|
|
|
j = position + 2;
|
2014-04-08 06:42:54 +09:00
|
|
|
sqcd = data[j++];
|
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
|
|
|
switch (sqcd & 0x1f) {
|
2012-04-05 05:43:26 +09:00
|
|
|
case 0:
|
|
|
|
spqcdSize = 8;
|
|
|
|
scalarExpounded = true;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
spqcdSize = 16;
|
|
|
|
scalarExpounded = false;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
spqcdSize = 16;
|
|
|
|
scalarExpounded = true;
|
|
|
|
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 Error("Invalid SQcd value " + sqcd);
|
2012-04-05 05:43:26 +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
|
|
|
qcd.noQuantization = spqcdSize === 8;
|
2012-04-05 05:43:26 +09:00
|
|
|
qcd.scalarExpounded = scalarExpounded;
|
|
|
|
qcd.guardBits = sqcd >> 5;
|
2014-04-08 06:42:54 +09:00
|
|
|
spqcds = [];
|
2012-04-05 05:43:26 +09:00
|
|
|
while (j < length + position) {
|
2021-05-05 19:47:01 +09:00
|
|
|
const spqcd = {};
|
2014-08-02 05:56:11 +09:00
|
|
|
if (spqcdSize === 8) {
|
2012-04-05 05:43:26 +09:00
|
|
|
spqcd.epsilon = data[j++] >> 3;
|
|
|
|
spqcd.mu = 0;
|
|
|
|
} else {
|
|
|
|
spqcd.epsilon = data[j] >> 3;
|
|
|
|
spqcd.mu = ((data[j] & 0x7) << 8) | data[j + 1];
|
|
|
|
j += 2;
|
|
|
|
}
|
|
|
|
spqcds.push(spqcd);
|
|
|
|
}
|
|
|
|
qcd.SPqcds = spqcds;
|
2014-03-10 06:31:55 +09:00
|
|
|
if (context.mainHeader) {
|
2012-04-05 05:43:26 +09:00
|
|
|
context.QCD = qcd;
|
2014-03-10 06:31:55 +09:00
|
|
|
} else {
|
2012-04-05 05:43:26 +09:00
|
|
|
context.currentTile.QCD = qcd;
|
|
|
|
context.currentTile.QCC = [];
|
|
|
|
}
|
|
|
|
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
|
|
|
case 0xff5d: // Quantization component (QCC)
|
2012-04-05 05:43:26 +09:00
|
|
|
length = readUint16(data, position);
|
2021-05-05 19:47:01 +09:00
|
|
|
const qcc = {};
|
2012-04-05 05:43:26 +09:00
|
|
|
j = position + 2;
|
2021-05-05 19:47:01 +09:00
|
|
|
let cqcc;
|
2014-03-10 06:31:55 +09:00
|
|
|
if (context.SIZ.Csiz < 257) {
|
2012-04-05 05:43:26 +09:00
|
|
|
cqcc = data[j++];
|
2014-03-10 06:31:55 +09:00
|
|
|
} else {
|
2012-04-05 05:43:26 +09:00
|
|
|
cqcc = readUint16(data, j);
|
|
|
|
j += 2;
|
|
|
|
}
|
2014-04-08 06:42:54 +09:00
|
|
|
sqcd = data[j++];
|
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
|
|
|
switch (sqcd & 0x1f) {
|
2012-04-05 05:43:26 +09:00
|
|
|
case 0:
|
|
|
|
spqcdSize = 8;
|
|
|
|
scalarExpounded = true;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
spqcdSize = 16;
|
|
|
|
scalarExpounded = false;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
spqcdSize = 16;
|
|
|
|
scalarExpounded = true;
|
|
|
|
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 Error("Invalid SQcd value " + sqcd);
|
2012-04-05 05:43:26 +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
|
|
|
qcc.noQuantization = spqcdSize === 8;
|
2012-04-05 05:43:26 +09:00
|
|
|
qcc.scalarExpounded = scalarExpounded;
|
|
|
|
qcc.guardBits = sqcd >> 5;
|
2014-04-08 06:42:54 +09:00
|
|
|
spqcds = [];
|
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
|
|
|
while (j < length + position) {
|
2021-05-05 19:47:01 +09:00
|
|
|
const spqcd = {};
|
2014-08-02 05:56:11 +09:00
|
|
|
if (spqcdSize === 8) {
|
2012-04-05 05:43:26 +09:00
|
|
|
spqcd.epsilon = data[j++] >> 3;
|
|
|
|
spqcd.mu = 0;
|
|
|
|
} else {
|
|
|
|
spqcd.epsilon = data[j] >> 3;
|
|
|
|
spqcd.mu = ((data[j] & 0x7) << 8) | data[j + 1];
|
|
|
|
j += 2;
|
|
|
|
}
|
|
|
|
spqcds.push(spqcd);
|
|
|
|
}
|
|
|
|
qcc.SPqcds = spqcds;
|
2014-03-10 06:31:55 +09:00
|
|
|
if (context.mainHeader) {
|
2012-04-05 05:43:26 +09:00
|
|
|
context.QCC[cqcc] = qcc;
|
2014-03-10 06:31:55 +09:00
|
|
|
} else {
|
2012-04-05 05:43:26 +09:00
|
|
|
context.currentTile.QCC[cqcc] = qcc;
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
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
|
|
|
case 0xff52: // Coding style default (COD)
|
2012-04-05 05:43:26 +09:00
|
|
|
length = readUint16(data, position);
|
2021-05-05 19:47:01 +09:00
|
|
|
const cod = {};
|
2012-04-05 05:43:26 +09:00
|
|
|
j = position + 2;
|
2021-05-05 19:47:01 +09:00
|
|
|
const scod = data[j++];
|
2012-04-05 05:43:26 +09:00
|
|
|
cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
|
|
|
|
cod.sopMarkerUsed = !!(scod & 2);
|
|
|
|
cod.ephMarkerUsed = !!(scod & 4);
|
|
|
|
cod.progressionOrder = data[j++];
|
|
|
|
cod.layersCount = readUint16(data, j);
|
|
|
|
j += 2;
|
|
|
|
cod.multipleComponentTransform = data[j++];
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
cod.decompositionLevelsCount = data[j++];
|
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
|
|
|
cod.xcb = (data[j++] & 0xf) + 2;
|
|
|
|
cod.ycb = (data[j++] & 0xf) + 2;
|
2021-05-05 19:47:01 +09:00
|
|
|
const blockStyle = data[j++];
|
2012-04-05 05:43:26 +09:00
|
|
|
cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
|
|
|
|
cod.resetContextProbabilities = !!(blockStyle & 2);
|
|
|
|
cod.terminationOnEachCodingPass = !!(blockStyle & 4);
|
2018-04-02 06:20:41 +09:00
|
|
|
cod.verticallyStripe = !!(blockStyle & 8);
|
2012-04-05 05:43:26 +09:00
|
|
|
cod.predictableTermination = !!(blockStyle & 16);
|
|
|
|
cod.segmentationSymbolUsed = !!(blockStyle & 32);
|
2014-04-06 00:27:18 +09:00
|
|
|
cod.reversibleTransformation = data[j++];
|
2012-04-05 05:43:26 +09:00
|
|
|
if (cod.entropyCoderWithCustomPrecincts) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const precinctsSizes = [];
|
2012-04-05 05:43:26 +09:00
|
|
|
while (j < length + position) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const precinctsSize = data[j++];
|
2012-04-05 05:43:26 +09:00
|
|
|
precinctsSizes.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
|
|
|
PPx: precinctsSize & 0xf,
|
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
|
|
|
PPy: precinctsSize >> 4,
|
2012-04-05 05:43:26 +09:00
|
|
|
});
|
|
|
|
}
|
|
|
|
cod.precinctsSizes = precinctsSizes;
|
|
|
|
}
|
2021-05-05 19:47:01 +09:00
|
|
|
const unsupported = [];
|
2014-04-30 16:00:17 +09:00
|
|
|
if (cod.selectiveArithmeticCodingBypass) {
|
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
|
|
|
unsupported.push("selectiveArithmeticCodingBypass");
|
2014-04-30 16:00:17 +09:00
|
|
|
}
|
|
|
|
if (cod.resetContextProbabilities) {
|
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
|
|
|
unsupported.push("resetContextProbabilities");
|
2014-04-30 16:00:17 +09:00
|
|
|
}
|
|
|
|
if (cod.terminationOnEachCodingPass) {
|
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
|
|
|
unsupported.push("terminationOnEachCodingPass");
|
2014-04-30 16:00:17 +09:00
|
|
|
}
|
2018-04-02 06:20:41 +09:00
|
|
|
if (cod.verticallyStripe) {
|
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
|
|
|
unsupported.push("verticallyStripe");
|
2014-04-30 16:00:17 +09:00
|
|
|
}
|
|
|
|
if (cod.predictableTermination) {
|
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
|
|
|
unsupported.push("predictableTermination");
|
2014-04-30 16:00:17 +09:00
|
|
|
}
|
|
|
|
if (unsupported.length > 0) {
|
|
|
|
doNotRecover = true;
|
2020-12-22 04:24:13 +09:00
|
|
|
warn(
|
|
|
|
`JPX: Unsupported COD options (${unsupported.join(", ")}).`
|
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
|
|
|
);
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
|
|
|
if (context.mainHeader) {
|
2012-04-05 05:43:26 +09:00
|
|
|
context.COD = cod;
|
2014-03-10 06:31:55 +09:00
|
|
|
} else {
|
2012-04-05 05:43:26 +09:00
|
|
|
context.currentTile.COD = cod;
|
|
|
|
context.currentTile.COC = [];
|
|
|
|
}
|
|
|
|
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
|
|
|
case 0xff90: // Start of tile-part (SOT)
|
2012-04-05 05:43:26 +09:00
|
|
|
length = readUint16(data, position);
|
2014-04-08 06:42:54 +09:00
|
|
|
tile = {};
|
2012-04-05 05:43:26 +09:00
|
|
|
tile.index = readUint16(data, position + 2);
|
|
|
|
tile.length = readUint32(data, position + 4);
|
|
|
|
tile.dataEnd = tile.length + position - 2;
|
|
|
|
tile.partIndex = data[position + 8];
|
|
|
|
tile.partsCount = data[position + 9];
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
context.mainHeader = false;
|
2013-02-01 08:32:40 +09:00
|
|
|
if (tile.partIndex === 0) {
|
2012-04-05 05:43:26 +09:00
|
|
|
// reset component specific settings
|
|
|
|
tile.COD = context.COD;
|
|
|
|
tile.COC = context.COC.slice(0); // clone of the global COC
|
|
|
|
tile.QCD = context.QCD;
|
|
|
|
tile.QCC = context.QCC.slice(0); // clone of the global COC
|
|
|
|
}
|
|
|
|
context.currentTile = tile;
|
|
|
|
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
|
|
|
case 0xff93: // Start of data (SOD)
|
2014-04-08 06:42:54 +09:00
|
|
|
tile = context.currentTile;
|
2013-02-01 08:32:40 +09:00
|
|
|
if (tile.partIndex === 0) {
|
2012-04-05 05:43:26 +09:00
|
|
|
initializeTile(context, tile.index);
|
|
|
|
buildPackets(context);
|
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
// moving to the end of the data
|
|
|
|
length = tile.dataEnd - position;
|
|
|
|
parseTilePackets(context, data, position, length);
|
|
|
|
break;
|
2020-12-18 23:42:28 +09:00
|
|
|
case 0xff53: // Coding style component (COC)
|
|
|
|
warn("JPX: Codestream code 0xFF53 (COC) is not implemented.");
|
|
|
|
/* falls through */
|
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
|
|
|
case 0xff55: // Tile-part lengths, main header (TLM)
|
|
|
|
case 0xff57: // Packet length, main header (PLM)
|
|
|
|
case 0xff58: // Packet length, tile-part header (PLT)
|
|
|
|
case 0xff64: // Comment (COM)
|
2012-04-05 05:43:26 +09:00
|
|
|
length = readUint16(data, position);
|
|
|
|
// skipping content
|
|
|
|
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 Error("Unknown codestream code: " + code.toString(16));
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
|
|
|
position += length;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
} catch (e) {
|
2014-04-30 16:00:17 +09:00
|
|
|
if (doNotRecover || this.failOnCorruptedImage) {
|
2017-06-29 05:51:31 +09:00
|
|
|
throw new JpxError(e.message);
|
2014-03-10 06:31:55 +09:00
|
|
|
} else {
|
2020-12-22 04:24:13 +09:00
|
|
|
warn(`JPX: Trying to recover from: "${e.message}".`);
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
|
|
|
this.tiles = transformComponents(context);
|
|
|
|
this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
|
|
|
|
this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
|
|
|
|
this.componentsCount = context.SIZ.Csiz;
|
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-04-05 05:43:26 +09:00
|
|
|
};
|
|
|
|
function calculateComponentDimensions(component, siz) {
|
|
|
|
// Section B.2 Component mapping
|
|
|
|
component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
|
|
|
|
component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
|
|
|
|
component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
|
|
|
|
component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
|
|
|
|
component.width = component.x1 - component.x0;
|
|
|
|
component.height = component.y1 - component.y0;
|
|
|
|
}
|
|
|
|
function calculateTileGrids(context, components) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const siz = context.SIZ;
|
2012-04-05 05:43:26 +09:00
|
|
|
// Section B.3 Division into tile and tile-components
|
2021-05-05 19:47:01 +09:00
|
|
|
const tiles = [];
|
|
|
|
let tile;
|
2021-05-05 19:46:08 +09:00
|
|
|
const numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
|
|
|
|
const numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
|
|
|
|
for (let q = 0; q < numYtiles; q++) {
|
|
|
|
for (let p = 0; p < numXtiles; p++) {
|
2014-04-08 06:42:54 +09:00
|
|
|
tile = {};
|
2012-04-05 05:43:26 +09:00
|
|
|
tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
|
|
|
|
tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
|
|
|
|
tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
|
|
|
|
tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
|
|
|
|
tile.width = tile.tx1 - tile.tx0;
|
|
|
|
tile.height = tile.ty1 - tile.ty0;
|
|
|
|
tile.components = [];
|
|
|
|
tiles.push(tile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
context.tiles = tiles;
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const componentsCount = siz.Csiz;
|
|
|
|
for (let i = 0, ii = componentsCount; i < ii; i++) {
|
|
|
|
const component = components[i];
|
|
|
|
for (let j = 0, jj = tiles.length; j < jj; j++) {
|
|
|
|
const tileComponent = {};
|
2014-04-08 06:42:54 +09:00
|
|
|
tile = tiles[j];
|
2012-04-05 05:43:26 +09:00
|
|
|
tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
|
|
|
|
tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
|
|
|
|
tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
|
|
|
|
tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
|
|
|
|
tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
|
|
|
|
tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
|
|
|
|
tile.components[i] = tileComponent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function getBlocksDimensions(context, component, r) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const codOrCoc = component.codingStyleParameters;
|
|
|
|
const result = {};
|
2012-04-05 05:43:26 +09:00
|
|
|
if (!codOrCoc.entropyCoderWithCustomPrecincts) {
|
|
|
|
result.PPx = 15;
|
|
|
|
result.PPy = 15;
|
|
|
|
} else {
|
|
|
|
result.PPx = codOrCoc.precinctsSizes[r].PPx;
|
|
|
|
result.PPy = codOrCoc.precinctsSizes[r].PPy;
|
|
|
|
}
|
|
|
|
// calculate codeblock size as described in section B.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
|
|
|
result.xcb_ =
|
|
|
|
r > 0
|
|
|
|
? Math.min(codOrCoc.xcb, result.PPx - 1)
|
|
|
|
: Math.min(codOrCoc.xcb, result.PPx);
|
|
|
|
result.ycb_ =
|
|
|
|
r > 0
|
|
|
|
? Math.min(codOrCoc.ycb, result.PPy - 1)
|
|
|
|
: Math.min(codOrCoc.ycb, result.PPy);
|
2012-04-05 05:43:26 +09:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
function buildPrecincts(context, resolution, dimensions) {
|
|
|
|
// Section B.6 Division resolution to precincts
|
2021-05-05 19:46:08 +09:00
|
|
|
const precinctWidth = 1 << dimensions.PPx;
|
|
|
|
const precinctHeight = 1 << dimensions.PPy;
|
2014-11-13 17:06:41 +09:00
|
|
|
// Jasper introduces codeblock groups for mapping each subband codeblocks
|
|
|
|
// to precincts. Precinct partition divides a resolution according to width
|
|
|
|
// and height parameters. The subband that belongs to the resolution level
|
|
|
|
// has a different size than the level, unless it is the zero resolution.
|
|
|
|
|
|
|
|
// From Jasper documentation: jpeg2000.pdf, section K: Tier-2 coding:
|
|
|
|
// The precinct partitioning for a particular subband is derived from a
|
|
|
|
// partitioning of its parent LL band (i.e., the LL band at the next higher
|
|
|
|
// resolution level)... The LL band associated with each resolution level is
|
|
|
|
// divided into precincts... Each of the resulting precinct regions is then
|
|
|
|
// mapped into its child subbands (if any) at the next lower resolution
|
|
|
|
// level. This is accomplished by using the coordinate transformation
|
|
|
|
// (u, v) = (ceil(x/2), ceil(y/2)) where (x, y) and (u, v) are the
|
|
|
|
// coordinates of a point in the LL band and child subband, respectively.
|
2021-05-05 19:46:08 +09:00
|
|
|
const isZeroRes = resolution.resLevel === 0;
|
|
|
|
const precinctWidthInSubband = 1 << (dimensions.PPx + (isZeroRes ? 0 : -1));
|
|
|
|
const precinctHeightInSubband =
|
|
|
|
1 << (dimensions.PPy + (isZeroRes ? 0 : -1));
|
|
|
|
const numprecinctswide =
|
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
|
|
|
resolution.trx1 > resolution.trx0
|
|
|
|
? Math.ceil(resolution.trx1 / precinctWidth) -
|
|
|
|
Math.floor(resolution.trx0 / precinctWidth)
|
|
|
|
: 0;
|
2021-05-05 19:46:08 +09:00
|
|
|
const numprecinctshigh =
|
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
|
|
|
resolution.try1 > resolution.try0
|
|
|
|
? Math.ceil(resolution.try1 / precinctHeight) -
|
|
|
|
Math.floor(resolution.try0 / precinctHeight)
|
|
|
|
: 0;
|
2021-05-05 19:46:08 +09:00
|
|
|
const numprecincts = numprecinctswide * numprecinctshigh;
|
2014-11-13 17:06:41 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
resolution.precinctParameters = {
|
2017-04-27 19:58:44 +09:00
|
|
|
precinctWidth,
|
|
|
|
precinctHeight,
|
|
|
|
numprecinctswide,
|
|
|
|
numprecinctshigh,
|
|
|
|
numprecincts,
|
|
|
|
precinctWidthInSubband,
|
|
|
|
precinctHeightInSubband,
|
2012-04-05 05:43:26 +09:00
|
|
|
};
|
|
|
|
}
|
|
|
|
function buildCodeblocks(context, subband, dimensions) {
|
|
|
|
// Section B.7 Division sub-band into code-blocks
|
2021-05-05 19:46:08 +09:00
|
|
|
const xcb_ = dimensions.xcb_;
|
|
|
|
const ycb_ = dimensions.ycb_;
|
|
|
|
const codeblockWidth = 1 << xcb_;
|
|
|
|
const codeblockHeight = 1 << ycb_;
|
|
|
|
const cbx0 = subband.tbx0 >> xcb_;
|
|
|
|
const cby0 = subband.tby0 >> ycb_;
|
|
|
|
const cbx1 = (subband.tbx1 + codeblockWidth - 1) >> xcb_;
|
|
|
|
const cby1 = (subband.tby1 + codeblockHeight - 1) >> ycb_;
|
|
|
|
const precinctParameters = subband.resolution.precinctParameters;
|
|
|
|
const codeblocks = [];
|
|
|
|
const precincts = [];
|
|
|
|
let i, j, codeblock, precinctNumber;
|
2014-04-08 06:42:54 +09:00
|
|
|
for (j = cby0; j < cby1; j++) {
|
|
|
|
for (i = cbx0; i < cbx1; i++) {
|
|
|
|
codeblock = {
|
2012-04-05 05:43:26 +09:00
|
|
|
cbx: i,
|
|
|
|
cby: j,
|
|
|
|
tbx0: codeblockWidth * i,
|
|
|
|
tby0: codeblockHeight * j,
|
|
|
|
tbx1: codeblockWidth * (i + 1),
|
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
|
|
|
tby1: codeblockHeight * (j + 1),
|
2012-04-05 05:43:26 +09:00
|
|
|
};
|
2014-11-13 17:06:41 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
|
|
|
|
codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
|
|
|
|
codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
|
|
|
|
codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
|
2014-11-13 17:06:41 +09:00
|
|
|
|
|
|
|
// Calculate precinct number for this codeblock, codeblock position
|
|
|
|
// should be relative to its subband, use actual dimension and position
|
|
|
|
// See comment about codeblock group width and height
|
2021-05-05 19:46:08 +09:00
|
|
|
const pi = Math.floor(
|
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
|
|
|
(codeblock.tbx0_ - subband.tbx0) /
|
|
|
|
precinctParameters.precinctWidthInSubband
|
|
|
|
);
|
2021-05-05 19:46:08 +09:00
|
|
|
const pj = Math.floor(
|
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
|
|
|
(codeblock.tby0_ - subband.tby0) /
|
|
|
|
precinctParameters.precinctHeightInSubband
|
|
|
|
);
|
|
|
|
precinctNumber = pi + pj * precinctParameters.numprecinctswide;
|
2014-11-13 17:06:41 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
codeblock.precinctNumber = precinctNumber;
|
|
|
|
codeblock.subbandType = subband.type;
|
|
|
|
codeblock.Lblock = 3;
|
2014-10-21 06:53:40 +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 (
|
|
|
|
codeblock.tbx1_ <= codeblock.tbx0_ ||
|
|
|
|
codeblock.tby1_ <= codeblock.tby0_
|
|
|
|
) {
|
2014-10-21 06:53:40 +09:00
|
|
|
continue;
|
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
codeblocks.push(codeblock);
|
|
|
|
// building precinct for the sub-band
|
2021-05-05 19:46:08 +09:00
|
|
|
let precinct = precincts[precinctNumber];
|
2014-04-04 22:19:41 +09:00
|
|
|
if (precinct !== undefined) {
|
|
|
|
if (i < precinct.cbxMin) {
|
|
|
|
precinct.cbxMin = i;
|
|
|
|
} else if (i > precinct.cbxMax) {
|
|
|
|
precinct.cbxMax = i;
|
|
|
|
}
|
|
|
|
if (j < precinct.cbyMin) {
|
|
|
|
precinct.cbxMin = j;
|
|
|
|
} else if (j > precinct.cbyMax) {
|
|
|
|
precinct.cbyMax = j;
|
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
} else {
|
|
|
|
precincts[precinctNumber] = precinct = {
|
|
|
|
cbxMin: i,
|
|
|
|
cbyMin: j,
|
|
|
|
cbxMax: i,
|
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
|
|
|
cbyMax: j,
|
2012-04-05 05:43:26 +09:00
|
|
|
};
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
codeblock.precinct = precinct;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
subband.codeblockParameters = {
|
|
|
|
codeblockWidth: xcb_,
|
|
|
|
codeblockHeight: ycb_,
|
|
|
|
numcodeblockwide: cbx1 - cbx0 + 1,
|
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
|
|
|
numcodeblockhigh: cby1 - cby0 + 1,
|
2012-04-05 05:43:26 +09:00
|
|
|
};
|
|
|
|
subband.codeblocks = codeblocks;
|
|
|
|
subband.precincts = precincts;
|
|
|
|
}
|
|
|
|
function createPacket(resolution, precinctNumber, layerNumber) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const precinctCodeblocks = [];
|
2012-04-05 05:43:26 +09:00
|
|
|
// Section B.10.8 Order of info in packet
|
2021-05-05 19:46:08 +09:00
|
|
|
const subbands = resolution.subbands;
|
2012-04-05 05:43:26 +09:00
|
|
|
// sub-bands already ordered in 'LL', 'HL', 'LH', and 'HH' sequence
|
2021-05-05 19:46:08 +09:00
|
|
|
for (let i = 0, ii = subbands.length; i < ii; i++) {
|
|
|
|
const subband = subbands[i];
|
|
|
|
const codeblocks = subband.codeblocks;
|
|
|
|
for (let j = 0, jj = codeblocks.length; j < jj; j++) {
|
|
|
|
const codeblock = codeblocks[j];
|
2014-08-02 05:56:11 +09:00
|
|
|
if (codeblock.precinctNumber !== precinctNumber) {
|
2012-04-05 05:43:26 +09:00
|
|
|
continue;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
precinctCodeblocks.push(codeblock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return {
|
2017-04-27 19:58:44 +09:00
|
|
|
layerNumber,
|
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
|
|
|
codeblocks: precinctCodeblocks,
|
2012-04-05 05:43:26 +09:00
|
|
|
};
|
|
|
|
}
|
|
|
|
function LayerResolutionComponentPositionIterator(context) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const siz = context.SIZ;
|
|
|
|
const tileIndex = context.currentTile.index;
|
|
|
|
const tile = context.tiles[tileIndex];
|
|
|
|
const layersCount = tile.codingStyleDefaultParameters.layersCount;
|
|
|
|
const componentsCount = siz.Csiz;
|
|
|
|
let maxDecompositionLevelsCount = 0;
|
|
|
|
for (let q = 0; q < componentsCount; q++) {
|
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
|
|
|
maxDecompositionLevelsCount = Math.max(
|
|
|
|
maxDecompositionLevelsCount,
|
|
|
|
tile.components[q].codingStyleParameters.decompositionLevelsCount
|
|
|
|
);
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
let l = 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
|
|
|
r = 0,
|
|
|
|
i = 0,
|
|
|
|
k = 0;
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
this.nextPacket = function JpxImage_nextPacket() {
|
|
|
|
// Section B.12.1.1 Layer-resolution-component-position
|
|
|
|
for (; l < layersCount; l++) {
|
|
|
|
for (; r <= maxDecompositionLevelsCount; r++) {
|
|
|
|
for (; i < componentsCount; i++) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const component = tile.components[i];
|
2014-03-10 06:31:55 +09:00
|
|
|
if (r > component.codingStyleParameters.decompositionLevelsCount) {
|
2012-04-05 05:43:26 +09:00
|
|
|
continue;
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const resolution = component.resolutions[r];
|
|
|
|
const numprecincts = resolution.precinctParameters.numprecincts;
|
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
|
|
|
for (; k < numprecincts; ) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const packet = createPacket(resolution, k, l);
|
2012-04-05 05:43:26 +09:00
|
|
|
k++;
|
|
|
|
return packet;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
k = 0;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
i = 0;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
r = 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 JpxError("Out of packets");
|
2012-04-05 05:43:26 +09:00
|
|
|
};
|
|
|
|
}
|
|
|
|
function ResolutionLayerComponentPositionIterator(context) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const siz = context.SIZ;
|
|
|
|
const tileIndex = context.currentTile.index;
|
|
|
|
const tile = context.tiles[tileIndex];
|
|
|
|
const layersCount = tile.codingStyleDefaultParameters.layersCount;
|
|
|
|
const componentsCount = siz.Csiz;
|
|
|
|
let maxDecompositionLevelsCount = 0;
|
|
|
|
for (let q = 0; q < componentsCount; q++) {
|
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
|
|
|
maxDecompositionLevelsCount = Math.max(
|
|
|
|
maxDecompositionLevelsCount,
|
|
|
|
tile.components[q].codingStyleParameters.decompositionLevelsCount
|
|
|
|
);
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
let r = 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
|
|
|
l = 0,
|
|
|
|
i = 0,
|
|
|
|
k = 0;
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
this.nextPacket = function JpxImage_nextPacket() {
|
|
|
|
// Section B.12.1.2 Resolution-layer-component-position
|
|
|
|
for (; r <= maxDecompositionLevelsCount; r++) {
|
|
|
|
for (; l < layersCount; l++) {
|
|
|
|
for (; i < componentsCount; i++) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const component = tile.components[i];
|
2014-03-10 06:31:55 +09:00
|
|
|
if (r > component.codingStyleParameters.decompositionLevelsCount) {
|
2012-04-05 05:43:26 +09:00
|
|
|
continue;
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const resolution = component.resolutions[r];
|
|
|
|
const numprecincts = resolution.precinctParameters.numprecincts;
|
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
|
|
|
for (; k < numprecincts; ) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const packet = createPacket(resolution, k, l);
|
2012-04-05 05:43:26 +09:00
|
|
|
k++;
|
|
|
|
return packet;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
k = 0;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
i = 0;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
l = 0;
|
2012-01-12 11:08:46 +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
|
|
|
throw new JpxError("Out of packets");
|
2012-01-12 11:08:46 +09:00
|
|
|
};
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
2014-12-17 04:45:51 +09:00
|
|
|
function ResolutionPositionComponentLayerIterator(context) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const siz = context.SIZ;
|
|
|
|
const tileIndex = context.currentTile.index;
|
|
|
|
const tile = context.tiles[tileIndex];
|
|
|
|
const layersCount = tile.codingStyleDefaultParameters.layersCount;
|
|
|
|
const componentsCount = siz.Csiz;
|
|
|
|
let l, r, c, p;
|
|
|
|
let maxDecompositionLevelsCount = 0;
|
2014-12-17 04:45:51 +09:00
|
|
|
for (c = 0; c < componentsCount; c++) {
|
2020-03-24 01:04:47 +09:00
|
|
|
const component = tile.components[c];
|
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
|
|
|
maxDecompositionLevelsCount = Math.max(
|
|
|
|
maxDecompositionLevelsCount,
|
|
|
|
component.codingStyleParameters.decompositionLevelsCount
|
|
|
|
);
|
2014-12-17 04:45:51 +09:00
|
|
|
}
|
2021-05-05 19:46:08 +09:00
|
|
|
const maxNumPrecinctsInLevel = new Int32Array(
|
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
|
|
|
maxDecompositionLevelsCount + 1
|
|
|
|
);
|
2014-12-17 04:45:51 +09:00
|
|
|
for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
|
2021-05-05 19:46:08 +09:00
|
|
|
let maxNumPrecincts = 0;
|
2014-12-17 04:45:51 +09:00
|
|
|
for (c = 0; c < componentsCount; ++c) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const resolutions = tile.components[c].resolutions;
|
2014-12-17 04:45:51 +09:00
|
|
|
if (r < resolutions.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
|
|
|
maxNumPrecincts = Math.max(
|
|
|
|
maxNumPrecincts,
|
|
|
|
resolutions[r].precinctParameters.numprecincts
|
|
|
|
);
|
2014-12-17 04:45:51 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
maxNumPrecinctsInLevel[r] = maxNumPrecincts;
|
|
|
|
}
|
|
|
|
l = 0;
|
|
|
|
r = 0;
|
|
|
|
c = 0;
|
|
|
|
p = 0;
|
2014-12-21 07:19:21 +09:00
|
|
|
|
2014-12-17 04:45:51 +09:00
|
|
|
this.nextPacket = function JpxImage_nextPacket() {
|
|
|
|
// Section B.12.1.3 Resolution-position-component-layer
|
|
|
|
for (; r <= maxDecompositionLevelsCount; r++) {
|
|
|
|
for (; p < maxNumPrecinctsInLevel[r]; p++) {
|
|
|
|
for (; c < componentsCount; c++) {
|
2020-03-24 01:04:47 +09:00
|
|
|
const component = tile.components[c];
|
2014-12-17 04:45:51 +09:00
|
|
|
if (r > component.codingStyleParameters.decompositionLevelsCount) {
|
|
|
|
continue;
|
|
|
|
}
|
2021-05-05 19:46:08 +09:00
|
|
|
const resolution = component.resolutions[r];
|
|
|
|
const numprecincts = resolution.precinctParameters.numprecincts;
|
2014-12-17 04:45:51 +09:00
|
|
|
if (p >= numprecincts) {
|
|
|
|
continue;
|
|
|
|
}
|
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
|
|
|
for (; l < layersCount; ) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const packet = createPacket(resolution, p, l);
|
2014-12-17 04:45:51 +09:00
|
|
|
l++;
|
|
|
|
return packet;
|
|
|
|
}
|
|
|
|
l = 0;
|
|
|
|
}
|
|
|
|
c = 0;
|
|
|
|
}
|
|
|
|
p = 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 JpxError("Out of packets");
|
2014-12-17 04:45:51 +09:00
|
|
|
};
|
|
|
|
}
|
|
|
|
function PositionComponentResolutionLayerIterator(context) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const siz = context.SIZ;
|
|
|
|
const tileIndex = context.currentTile.index;
|
|
|
|
const tile = context.tiles[tileIndex];
|
|
|
|
const layersCount = tile.codingStyleDefaultParameters.layersCount;
|
|
|
|
const componentsCount = siz.Csiz;
|
|
|
|
const precinctsSizes = getPrecinctSizesInImageScale(tile);
|
|
|
|
const precinctsIterationSizes = precinctsSizes;
|
|
|
|
let l = 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
|
|
|
r = 0,
|
|
|
|
c = 0,
|
|
|
|
px = 0,
|
|
|
|
py = 0;
|
2014-12-17 04:45:51 +09:00
|
|
|
|
|
|
|
this.nextPacket = function JpxImage_nextPacket() {
|
|
|
|
// Section B.12.1.4 Position-component-resolution-layer
|
|
|
|
for (; py < precinctsIterationSizes.maxNumHigh; py++) {
|
|
|
|
for (; px < precinctsIterationSizes.maxNumWide; px++) {
|
|
|
|
for (; c < componentsCount; c++) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const component = tile.components[c];
|
|
|
|
const decompositionLevelsCount =
|
2014-12-17 04:45:51 +09:00
|
|
|
component.codingStyleParameters.decompositionLevelsCount;
|
|
|
|
for (; r <= decompositionLevelsCount; r++) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const resolution = component.resolutions[r];
|
|
|
|
const sizeInImageScale =
|
2014-12-17 04:45:51 +09:00
|
|
|
precinctsSizes.components[c].resolutions[r];
|
2021-05-05 19:46:08 +09:00
|
|
|
const k = getPrecinctIndexIfExist(
|
2014-12-17 04:45:51 +09:00
|
|
|
px,
|
|
|
|
py,
|
|
|
|
sizeInImageScale,
|
|
|
|
precinctsIterationSizes,
|
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
|
|
|
resolution
|
|
|
|
);
|
2014-12-17 04:45:51 +09:00
|
|
|
if (k === null) {
|
|
|
|
continue;
|
|
|
|
}
|
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
|
|
|
for (; l < layersCount; ) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const packet = createPacket(resolution, k, l);
|
2014-12-17 04:45:51 +09:00
|
|
|
l++;
|
|
|
|
return packet;
|
|
|
|
}
|
|
|
|
l = 0;
|
|
|
|
}
|
|
|
|
r = 0;
|
|
|
|
}
|
|
|
|
c = 0;
|
|
|
|
}
|
|
|
|
px = 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 JpxError("Out of packets");
|
2014-12-17 04:45:51 +09:00
|
|
|
};
|
|
|
|
}
|
|
|
|
function ComponentPositionResolutionLayerIterator(context) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const siz = context.SIZ;
|
|
|
|
const tileIndex = context.currentTile.index;
|
|
|
|
const tile = context.tiles[tileIndex];
|
|
|
|
const layersCount = tile.codingStyleDefaultParameters.layersCount;
|
|
|
|
const componentsCount = siz.Csiz;
|
|
|
|
const precinctsSizes = getPrecinctSizesInImageScale(tile);
|
|
|
|
let l = 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
|
|
|
r = 0,
|
|
|
|
c = 0,
|
|
|
|
px = 0,
|
|
|
|
py = 0;
|
2014-12-21 07:19:21 +09:00
|
|
|
|
2014-12-17 04:45:51 +09:00
|
|
|
this.nextPacket = function JpxImage_nextPacket() {
|
|
|
|
// Section B.12.1.5 Component-position-resolution-layer
|
|
|
|
for (; c < componentsCount; ++c) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const component = tile.components[c];
|
|
|
|
const precinctsIterationSizes = precinctsSizes.components[c];
|
|
|
|
const decompositionLevelsCount =
|
2014-12-17 04:45:51 +09:00
|
|
|
component.codingStyleParameters.decompositionLevelsCount;
|
|
|
|
for (; py < precinctsIterationSizes.maxNumHigh; py++) {
|
|
|
|
for (; px < precinctsIterationSizes.maxNumWide; px++) {
|
|
|
|
for (; r <= decompositionLevelsCount; r++) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const resolution = component.resolutions[r];
|
|
|
|
const sizeInImageScale = precinctsIterationSizes.resolutions[r];
|
|
|
|
const k = getPrecinctIndexIfExist(
|
2014-12-17 04:45:51 +09:00
|
|
|
px,
|
|
|
|
py,
|
|
|
|
sizeInImageScale,
|
|
|
|
precinctsIterationSizes,
|
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
|
|
|
resolution
|
|
|
|
);
|
2014-12-17 04:45:51 +09:00
|
|
|
if (k === null) {
|
|
|
|
continue;
|
|
|
|
}
|
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
|
|
|
for (; l < layersCount; ) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const packet = createPacket(resolution, k, l);
|
2014-12-17 04:45:51 +09:00
|
|
|
l++;
|
|
|
|
return packet;
|
|
|
|
}
|
|
|
|
l = 0;
|
|
|
|
}
|
|
|
|
r = 0;
|
|
|
|
}
|
|
|
|
px = 0;
|
|
|
|
}
|
|
|
|
py = 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 JpxError("Out of packets");
|
2014-12-17 04:45:51 +09:00
|
|
|
};
|
|
|
|
}
|
|
|
|
function getPrecinctIndexIfExist(
|
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
|
|
|
pxIndex,
|
|
|
|
pyIndex,
|
|
|
|
sizeInImageScale,
|
|
|
|
precinctIterationSizes,
|
|
|
|
resolution
|
|
|
|
) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const posX = pxIndex * precinctIterationSizes.minWidth;
|
|
|
|
const posY = pyIndex * precinctIterationSizes.minHeight;
|
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 (
|
|
|
|
posX % sizeInImageScale.width !== 0 ||
|
|
|
|
posY % sizeInImageScale.height !== 0
|
|
|
|
) {
|
2014-12-17 04:45:51 +09:00
|
|
|
return null;
|
|
|
|
}
|
2021-05-05 19:46:08 +09:00
|
|
|
const startPrecinctRowIndex =
|
2014-12-17 04:45:51 +09:00
|
|
|
(posY / sizeInImageScale.width) *
|
|
|
|
resolution.precinctParameters.numprecinctswide;
|
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 posX / sizeInImageScale.height + startPrecinctRowIndex;
|
2014-12-17 04:45:51 +09:00
|
|
|
}
|
|
|
|
function getPrecinctSizesInImageScale(tile) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const componentsCount = tile.components.length;
|
|
|
|
let minWidth = Number.MAX_VALUE;
|
|
|
|
let minHeight = Number.MAX_VALUE;
|
|
|
|
let maxNumWide = 0;
|
|
|
|
let maxNumHigh = 0;
|
|
|
|
const sizePerComponent = new Array(componentsCount);
|
|
|
|
for (let c = 0; c < componentsCount; c++) {
|
|
|
|
const component = tile.components[c];
|
|
|
|
const decompositionLevelsCount =
|
2014-12-17 04:45:51 +09:00
|
|
|
component.codingStyleParameters.decompositionLevelsCount;
|
2021-05-05 19:46:08 +09:00
|
|
|
const sizePerResolution = new Array(decompositionLevelsCount + 1);
|
|
|
|
let minWidthCurrentComponent = Number.MAX_VALUE;
|
|
|
|
let minHeightCurrentComponent = Number.MAX_VALUE;
|
|
|
|
let maxNumWideCurrentComponent = 0;
|
|
|
|
let maxNumHighCurrentComponent = 0;
|
|
|
|
let scale = 1;
|
|
|
|
for (let r = decompositionLevelsCount; r >= 0; --r) {
|
|
|
|
const resolution = component.resolutions[r];
|
|
|
|
const widthCurrentResolution =
|
2014-12-17 04:45:51 +09:00
|
|
|
scale * resolution.precinctParameters.precinctWidth;
|
2021-05-05 19:46:08 +09:00
|
|
|
const heightCurrentResolution =
|
2014-12-17 04:45:51 +09:00
|
|
|
scale * resolution.precinctParameters.precinctHeight;
|
|
|
|
minWidthCurrentComponent = Math.min(
|
|
|
|
minWidthCurrentComponent,
|
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
|
|
|
widthCurrentResolution
|
|
|
|
);
|
2014-12-17 04:45:51 +09:00
|
|
|
minHeightCurrentComponent = Math.min(
|
|
|
|
minHeightCurrentComponent,
|
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
|
|
|
heightCurrentResolution
|
|
|
|
);
|
|
|
|
maxNumWideCurrentComponent = Math.max(
|
|
|
|
maxNumWideCurrentComponent,
|
|
|
|
resolution.precinctParameters.numprecinctswide
|
|
|
|
);
|
|
|
|
maxNumHighCurrentComponent = Math.max(
|
|
|
|
maxNumHighCurrentComponent,
|
|
|
|
resolution.precinctParameters.numprecinctshigh
|
|
|
|
);
|
2014-12-17 04:45:51 +09:00
|
|
|
sizePerResolution[r] = {
|
|
|
|
width: widthCurrentResolution,
|
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
|
|
|
height: heightCurrentResolution,
|
2014-12-17 04:45:51 +09:00
|
|
|
};
|
|
|
|
scale <<= 1;
|
|
|
|
}
|
|
|
|
minWidth = Math.min(minWidth, minWidthCurrentComponent);
|
|
|
|
minHeight = Math.min(minHeight, minHeightCurrentComponent);
|
|
|
|
maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
|
|
|
|
maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
|
|
|
|
sizePerComponent[c] = {
|
|
|
|
resolutions: sizePerResolution,
|
|
|
|
minWidth: minWidthCurrentComponent,
|
|
|
|
minHeight: minHeightCurrentComponent,
|
|
|
|
maxNumWide: maxNumWideCurrentComponent,
|
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
|
|
|
maxNumHigh: maxNumHighCurrentComponent,
|
2014-12-17 04:45:51 +09:00
|
|
|
};
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
components: sizePerComponent,
|
2017-04-27 19:58:44 +09:00
|
|
|
minWidth,
|
|
|
|
minHeight,
|
|
|
|
maxNumWide,
|
|
|
|
maxNumHigh,
|
2014-12-17 04:45:51 +09:00
|
|
|
};
|
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
function buildPackets(context) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const siz = context.SIZ;
|
|
|
|
const tileIndex = context.currentTile.index;
|
|
|
|
const tile = context.tiles[tileIndex];
|
|
|
|
const componentsCount = siz.Csiz;
|
2012-04-05 05:43:26 +09:00
|
|
|
// Creating resolutions and sub-bands for each component
|
2021-05-05 19:46:08 +09:00
|
|
|
for (let c = 0; c < componentsCount; c++) {
|
|
|
|
const component = tile.components[c];
|
|
|
|
const decompositionLevelsCount =
|
2012-04-05 05:43:26 +09:00
|
|
|
component.codingStyleParameters.decompositionLevelsCount;
|
|
|
|
// Section B.5 Resolution levels and sub-bands
|
2021-05-05 19:46:08 +09:00
|
|
|
const resolutions = [];
|
|
|
|
const subbands = [];
|
|
|
|
for (let r = 0; r <= decompositionLevelsCount; r++) {
|
|
|
|
const blocksDimensions = getBlocksDimensions(context, component, r);
|
|
|
|
const resolution = {};
|
|
|
|
const scale = 1 << (decompositionLevelsCount - r);
|
2012-04-05 05:43:26 +09:00
|
|
|
resolution.trx0 = Math.ceil(component.tcx0 / scale);
|
|
|
|
resolution.try0 = Math.ceil(component.tcy0 / scale);
|
|
|
|
resolution.trx1 = Math.ceil(component.tcx1 / scale);
|
|
|
|
resolution.try1 = Math.ceil(component.tcy1 / scale);
|
2014-11-13 17:06:41 +09:00
|
|
|
resolution.resLevel = r;
|
2012-04-05 05:43:26 +09:00
|
|
|
buildPrecincts(context, resolution, blocksDimensions);
|
|
|
|
resolutions.push(resolution);
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:47:01 +09:00
|
|
|
let subband;
|
2013-02-01 08:32:40 +09:00
|
|
|
if (r === 0) {
|
2012-04-05 05:43:26 +09:00
|
|
|
// one sub-band (LL) with last decomposition
|
|
|
|
subband = {};
|
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
|
|
|
subband.type = "LL";
|
2012-04-05 05:43:26 +09:00
|
|
|
subband.tbx0 = Math.ceil(component.tcx0 / scale);
|
|
|
|
subband.tby0 = Math.ceil(component.tcy0 / scale);
|
|
|
|
subband.tbx1 = Math.ceil(component.tcx1 / scale);
|
|
|
|
subband.tby1 = Math.ceil(component.tcy1 / scale);
|
|
|
|
subband.resolution = resolution;
|
|
|
|
buildCodeblocks(context, subband, blocksDimensions);
|
|
|
|
subbands.push(subband);
|
|
|
|
resolution.subbands = [subband];
|
|
|
|
} else {
|
2021-05-05 19:46:08 +09:00
|
|
|
const bscale = 1 << (decompositionLevelsCount - r + 1);
|
|
|
|
const resolutionSubbands = [];
|
2012-04-05 05:43:26 +09:00
|
|
|
// three sub-bands (HL, LH and HH) with rest of decompositions
|
|
|
|
subband = {};
|
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
|
|
|
subband.type = "HL";
|
2012-04-05 05:43:26 +09:00
|
|
|
subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
|
|
|
|
subband.tby0 = Math.ceil(component.tcy0 / bscale);
|
|
|
|
subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
|
|
|
|
subband.tby1 = Math.ceil(component.tcy1 / bscale);
|
|
|
|
subband.resolution = resolution;
|
|
|
|
buildCodeblocks(context, subband, blocksDimensions);
|
|
|
|
subbands.push(subband);
|
|
|
|
resolutionSubbands.push(subband);
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
subband = {};
|
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
|
|
|
subband.type = "LH";
|
2012-04-05 05:43:26 +09:00
|
|
|
subband.tbx0 = Math.ceil(component.tcx0 / bscale);
|
|
|
|
subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
|
|
|
|
subband.tbx1 = Math.ceil(component.tcx1 / bscale);
|
|
|
|
subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
|
|
|
|
subband.resolution = resolution;
|
|
|
|
buildCodeblocks(context, subband, blocksDimensions);
|
|
|
|
subbands.push(subband);
|
|
|
|
resolutionSubbands.push(subband);
|
2012-01-14 09:45:19 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
subband = {};
|
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
|
|
|
subband.type = "HH";
|
2012-04-05 05:43:26 +09:00
|
|
|
subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
|
|
|
|
subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
|
|
|
|
subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
|
|
|
|
subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
|
|
|
|
subband.resolution = resolution;
|
|
|
|
buildCodeblocks(context, subband, blocksDimensions);
|
|
|
|
subbands.push(subband);
|
|
|
|
resolutionSubbands.push(subband);
|
|
|
|
|
|
|
|
resolution.subbands = resolutionSubbands;
|
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
component.resolutions = resolutions;
|
|
|
|
component.subbands = subbands;
|
|
|
|
}
|
|
|
|
// Generate the packets sequence
|
2021-05-05 19:46:08 +09:00
|
|
|
const progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
|
2012-04-05 05:43:26 +09:00
|
|
|
switch (progressionOrder) {
|
|
|
|
case 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
|
|
|
tile.packetsIterator = new LayerResolutionComponentPositionIterator(
|
|
|
|
context
|
|
|
|
);
|
2012-04-05 05:43:26 +09:00
|
|
|
break;
|
|
|
|
case 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
|
|
|
tile.packetsIterator = new ResolutionLayerComponentPositionIterator(
|
|
|
|
context
|
|
|
|
);
|
2012-04-05 05:43:26 +09:00
|
|
|
break;
|
2014-12-17 04:45:51 +09:00
|
|
|
case 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
|
|
|
tile.packetsIterator = new ResolutionPositionComponentLayerIterator(
|
|
|
|
context
|
|
|
|
);
|
2014-12-17 04:45:51 +09:00
|
|
|
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
|
|
|
tile.packetsIterator = new PositionComponentResolutionLayerIterator(
|
|
|
|
context
|
|
|
|
);
|
2014-12-17 04:45:51 +09:00
|
|
|
break;
|
|
|
|
case 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
|
|
|
tile.packetsIterator = new ComponentPositionResolutionLayerIterator(
|
|
|
|
context
|
|
|
|
);
|
2014-12-17 04:45:51 +09:00
|
|
|
break;
|
2012-04-05 05:43:26 +09:00
|
|
|
default:
|
2017-06-29 05:51:31 +09:00
|
|
|
throw new JpxError(`Unsupported progression order ${progressionOrder}`);
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
function parseTilePackets(context, data, offset, dataLength) {
|
2021-05-05 19:46:08 +09:00
|
|
|
let position = 0;
|
|
|
|
let buffer,
|
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
|
|
|
bufferSize = 0,
|
|
|
|
skipNextBit = false;
|
2012-04-05 05:43:26 +09:00
|
|
|
function readBits(count) {
|
|
|
|
while (bufferSize < count) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const b = data[offset + position];
|
2012-04-05 05:43:26 +09:00
|
|
|
position++;
|
|
|
|
if (skipNextBit) {
|
|
|
|
buffer = (buffer << 7) | b;
|
|
|
|
bufferSize += 7;
|
|
|
|
skipNextBit = false;
|
|
|
|
} else {
|
|
|
|
buffer = (buffer << 8) | b;
|
|
|
|
bufferSize += 8;
|
|
|
|
}
|
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 (b === 0xff) {
|
2012-04-05 05:43:26 +09:00
|
|
|
skipNextBit = true;
|
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
bufferSize -= count;
|
|
|
|
return (buffer >>> bufferSize) & ((1 << count) - 1);
|
|
|
|
}
|
2014-12-17 19:55:52 +09:00
|
|
|
function skipMarkerIfEqual(value) {
|
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[offset + position - 1] === 0xff &&
|
|
|
|
data[offset + position] === value
|
|
|
|
) {
|
2014-12-17 19:55:52 +09:00
|
|
|
skipBytes(1);
|
|
|
|
return 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
|
|
|
} else if (
|
|
|
|
data[offset + position] === 0xff &&
|
|
|
|
data[offset + position + 1] === value
|
|
|
|
) {
|
2014-12-17 19:55:52 +09:00
|
|
|
skipBytes(2);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
function skipBytes(count) {
|
|
|
|
position += count;
|
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
function alignToByte() {
|
|
|
|
bufferSize = 0;
|
|
|
|
if (skipNextBit) {
|
|
|
|
position++;
|
|
|
|
skipNextBit = false;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
|
|
|
function readCodingpasses() {
|
2014-04-17 04:40:37 +09:00
|
|
|
if (readBits(1) === 0) {
|
2012-04-05 05:43:26 +09:00
|
|
|
return 1;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2014-04-17 04:40:37 +09:00
|
|
|
if (readBits(1) === 0) {
|
2012-04-05 05:43:26 +09:00
|
|
|
return 2;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2021-05-05 19:46:08 +09:00
|
|
|
let value = readBits(2);
|
2014-04-17 04:40:37 +09:00
|
|
|
if (value < 3) {
|
|
|
|
return value + 3;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2014-04-17 04:40:37 +09:00
|
|
|
value = readBits(5);
|
|
|
|
if (value < 31) {
|
|
|
|
return value + 6;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2014-04-17 04:40:37 +09:00
|
|
|
value = readBits(7);
|
|
|
|
return value + 37;
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
2021-05-05 19:46:08 +09:00
|
|
|
const tileIndex = context.currentTile.index;
|
|
|
|
const tile = context.tiles[tileIndex];
|
|
|
|
const sopMarkerUsed = context.COD.sopMarkerUsed;
|
|
|
|
const ephMarkerUsed = context.COD.ephMarkerUsed;
|
|
|
|
const packetsIterator = tile.packetsIterator;
|
2012-04-05 05:43:26 +09:00
|
|
|
while (position < dataLength) {
|
2014-09-27 06:38:37 +09:00
|
|
|
alignToByte();
|
2014-12-17 19:55:52 +09:00
|
|
|
if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
|
|
|
|
// Skip also marker segment length and packet sequence ID
|
|
|
|
skipBytes(4);
|
|
|
|
}
|
2021-05-05 19:46:08 +09:00
|
|
|
const packet = packetsIterator.nextPacket();
|
2012-04-05 05:43:26 +09:00
|
|
|
if (!readBits(1)) {
|
|
|
|
continue;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2021-05-05 19:47:01 +09:00
|
|
|
const layerNumber = packet.layerNumber,
|
|
|
|
queue = [];
|
|
|
|
let codeblock;
|
2021-05-05 19:46:08 +09:00
|
|
|
for (let i = 0, ii = packet.codeblocks.length; i < ii; i++) {
|
2014-04-08 06:42:54 +09:00
|
|
|
codeblock = packet.codeblocks[i];
|
2021-05-05 19:46:08 +09:00
|
|
|
let precinct = codeblock.precinct;
|
|
|
|
const codeblockColumn = codeblock.cbx - precinct.cbxMin;
|
|
|
|
const codeblockRow = codeblock.cby - precinct.cbyMin;
|
|
|
|
let codeblockIncluded = false;
|
|
|
|
let firstTimeInclusion = false;
|
2021-05-05 19:47:01 +09:00
|
|
|
let valueReady, zeroBitPlanesTree;
|
2020-04-17 19:06:27 +09:00
|
|
|
if (codeblock.included !== undefined) {
|
2012-04-05 05:43:26 +09:00
|
|
|
codeblockIncluded = !!readBits(1);
|
|
|
|
} else {
|
|
|
|
// reading inclusion tree
|
2014-04-08 06:42:54 +09:00
|
|
|
precinct = codeblock.precinct;
|
2021-05-05 19:47:01 +09:00
|
|
|
let inclusionTree;
|
2020-04-17 19:06:27 +09:00
|
|
|
if (precinct.inclusionTree !== undefined) {
|
2012-04-05 05:43:26 +09:00
|
|
|
inclusionTree = precinct.inclusionTree;
|
|
|
|
} else {
|
|
|
|
// building inclusion and zero bit-planes trees
|
2021-05-05 19:46:08 +09:00
|
|
|
const width = precinct.cbxMax - precinct.cbxMin + 1;
|
|
|
|
const height = precinct.cbyMax - precinct.cbyMin + 1;
|
2012-04-05 05:43:26 +09:00
|
|
|
inclusionTree = new InclusionTree(width, height, layerNumber);
|
|
|
|
zeroBitPlanesTree = new TagTree(width, height);
|
|
|
|
precinct.inclusionTree = inclusionTree;
|
|
|
|
precinct.zeroBitPlanesTree = zeroBitPlanesTree;
|
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
|
|
|
|
while (true) {
|
|
|
|
if (readBits(1)) {
|
2014-04-08 06:42:54 +09:00
|
|
|
valueReady = !inclusionTree.nextLevel();
|
2012-04-05 05:43:26 +09:00
|
|
|
if (valueReady) {
|
|
|
|
codeblock.included = true;
|
|
|
|
codeblockIncluded = firstTimeInclusion = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
inclusionTree.incrementValue(layerNumber);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
2014-03-03 05:12:26 +09:00
|
|
|
if (!codeblockIncluded) {
|
2012-01-12 11:08:46 +09:00
|
|
|
continue;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
if (firstTimeInclusion) {
|
|
|
|
zeroBitPlanesTree = precinct.zeroBitPlanesTree;
|
|
|
|
zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
|
|
|
|
while (true) {
|
|
|
|
if (readBits(1)) {
|
2014-04-08 06:42:54 +09:00
|
|
|
valueReady = !zeroBitPlanesTree.nextLevel();
|
2014-03-03 05:12:26 +09:00
|
|
|
if (valueReady) {
|
2012-04-05 05:43:26 +09:00
|
|
|
break;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
|
|
|
} else {
|
2012-04-05 05:43:26 +09:00
|
|
|
zeroBitPlanesTree.incrementValue();
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
|
|
|
codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2021-05-05 19:46:08 +09:00
|
|
|
const codingpasses = readCodingpasses();
|
2014-03-03 05:12:26 +09:00
|
|
|
while (readBits(1)) {
|
2012-04-05 05:43:26 +09:00
|
|
|
codeblock.Lblock++;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2021-05-05 19:46:08 +09:00
|
|
|
const codingpassesLog2 = log2(codingpasses);
|
2012-04-05 05:43:26 +09:00
|
|
|
// rounding down log2
|
2021-05-05 19:46:08 +09:00
|
|
|
const bits =
|
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
|
|
|
(codingpasses < 1 << codingpassesLog2
|
|
|
|
? codingpassesLog2 - 1
|
|
|
|
: codingpassesLog2) + codeblock.Lblock;
|
2021-05-05 19:46:08 +09:00
|
|
|
const codedDataLength = readBits(bits);
|
2012-04-05 05:43:26 +09:00
|
|
|
queue.push({
|
2017-04-27 19:58:44 +09:00
|
|
|
codeblock,
|
|
|
|
codingpasses,
|
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
|
|
|
dataLength: codedDataLength,
|
2012-04-05 05:43:26 +09:00
|
|
|
});
|
|
|
|
}
|
|
|
|
alignToByte();
|
2014-12-17 19:55:52 +09:00
|
|
|
if (ephMarkerUsed) {
|
|
|
|
skipMarkerIfEqual(0x92);
|
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
while (queue.length > 0) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const packetItem = queue.shift();
|
2014-04-08 06:42:54 +09:00
|
|
|
codeblock = packetItem.codeblock;
|
2020-04-17 19:06:27 +09:00
|
|
|
if (codeblock.data === undefined) {
|
2012-04-05 05:43:26 +09:00
|
|
|
codeblock.data = [];
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
codeblock.data.push({
|
2017-04-27 19:58:44 +09:00
|
|
|
data,
|
2012-04-05 05:43:26 +09:00
|
|
|
start: offset + position,
|
|
|
|
end: offset + position + packetItem.dataLength,
|
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
|
|
|
codingpasses: packetItem.codingpasses,
|
2012-04-05 05:43:26 +09:00
|
|
|
});
|
|
|
|
position += packetItem.dataLength;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
return 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
|
|
|
function copyCoefficients(
|
|
|
|
coefficients,
|
|
|
|
levelWidth,
|
|
|
|
levelHeight,
|
|
|
|
subband,
|
|
|
|
delta,
|
|
|
|
mb,
|
|
|
|
reversible,
|
|
|
|
segmentationSymbolUsed
|
|
|
|
) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const x0 = subband.tbx0;
|
|
|
|
const y0 = subband.tby0;
|
|
|
|
const width = subband.tbx1 - subband.tbx0;
|
|
|
|
const codeblocks = subband.codeblocks;
|
|
|
|
const right = subband.type.charAt(0) === "H" ? 1 : 0;
|
|
|
|
const bottom = subband.type.charAt(1) === "H" ? levelWidth : 0;
|
|
|
|
|
|
|
|
for (let i = 0, ii = codeblocks.length; i < ii; ++i) {
|
|
|
|
const codeblock = codeblocks[i];
|
|
|
|
const blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
|
|
|
|
const blockHeight = codeblock.tby1_ - codeblock.tby0_;
|
2014-03-03 05:12:26 +09:00
|
|
|
if (blockWidth === 0 || blockHeight === 0) {
|
2012-04-05 05:43:26 +09:00
|
|
|
continue;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2020-04-17 19:06:27 +09:00
|
|
|
if (codeblock.data === undefined) {
|
2012-04-05 05:43:26 +09:00
|
|
|
continue;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:47:01 +09:00
|
|
|
const bitModel = new BitModel(
|
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
|
|
|
blockWidth,
|
|
|
|
blockHeight,
|
|
|
|
codeblock.subbandType,
|
|
|
|
codeblock.zeroBitPlanes,
|
|
|
|
mb
|
|
|
|
);
|
2021-05-05 19:47:01 +09:00
|
|
|
let currentCodingpassType = 2; // first bit plane starts from cleanup
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
// collect data
|
2021-05-05 19:47:01 +09:00
|
|
|
const data = codeblock.data;
|
|
|
|
let totalLength = 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
|
|
|
codingpasses = 0;
|
2021-05-05 19:47:01 +09:00
|
|
|
let j, jj, dataItem;
|
2014-04-16 17:40:04 +09:00
|
|
|
for (j = 0, jj = data.length; j < jj; j++) {
|
|
|
|
dataItem = data[j];
|
2012-04-05 05:43:26 +09:00
|
|
|
totalLength += dataItem.end - dataItem.start;
|
|
|
|
codingpasses += dataItem.codingpasses;
|
|
|
|
}
|
2021-05-05 19:46:08 +09:00
|
|
|
const encodedData = new Uint8Array(totalLength);
|
|
|
|
let position = 0;
|
2014-04-16 17:40:04 +09:00
|
|
|
for (j = 0, jj = data.length; j < jj; j++) {
|
|
|
|
dataItem = data[j];
|
2021-05-05 19:46:08 +09:00
|
|
|
const chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
|
2014-04-16 17:40:04 +09:00
|
|
|
encodedData.set(chunk, position);
|
|
|
|
position += chunk.length;
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
|
|
|
// decoding the item
|
2021-05-05 19:46:08 +09:00
|
|
|
const decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
|
2012-04-05 05:43:26 +09:00
|
|
|
bitModel.setDecoder(decoder);
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2014-04-16 17:40:04 +09:00
|
|
|
for (j = 0; j < codingpasses; j++) {
|
2012-04-05 05:43:26 +09:00
|
|
|
switch (currentCodingpassType) {
|
|
|
|
case 0:
|
2016-05-03 07:34:58 +09:00
|
|
|
bitModel.runSignificancePropagationPass();
|
2012-04-05 05:43:26 +09:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
bitModel.runMagnitudeRefinementPass();
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
bitModel.runCleanupPass();
|
2014-03-03 05:12:26 +09:00
|
|
|
if (segmentationSymbolUsed) {
|
2012-07-10 03:59:50 +09:00
|
|
|
bitModel.checkSegmentationSymbol();
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
currentCodingpassType = (currentCodingpassType + 1) % 3;
|
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
let offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
|
|
|
|
const sign = bitModel.coefficentsSign;
|
|
|
|
const magnitude = bitModel.coefficentsMagnitude;
|
|
|
|
const bitsDecoded = bitModel.bitsDecoded;
|
|
|
|
const magnitudeCorrection = reversible ? 0 : 0.5;
|
2021-05-05 19:47:01 +09:00
|
|
|
let k, n, nb;
|
2014-04-16 17:40:04 +09:00
|
|
|
position = 0;
|
2014-04-10 22:07:50 +09:00
|
|
|
// Do the interleaving of Section F.3.3 here, so we do not need
|
2014-04-16 17:40:04 +09:00
|
|
|
// to copy later. LL level is not interleaved, just copied.
|
2021-05-05 19:46:08 +09:00
|
|
|
const interleave = subband.type !== "LL";
|
2014-04-16 17:40:04 +09:00
|
|
|
for (j = 0; j < blockHeight; j++) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const row = (offset / width) | 0; // row in the non-interleaved subband
|
|
|
|
const levelOffset = 2 * row * (levelWidth - width) + right + bottom;
|
2014-04-08 06:42:54 +09:00
|
|
|
for (k = 0; k < blockWidth; k++) {
|
2014-04-04 22:19:41 +09:00
|
|
|
n = magnitude[position];
|
|
|
|
if (n !== 0) {
|
|
|
|
n = (n + magnitudeCorrection) * delta;
|
|
|
|
if (sign[position] !== 0) {
|
|
|
|
n = -n;
|
|
|
|
}
|
2014-04-06 00:27:18 +09:00
|
|
|
nb = bitsDecoded[position];
|
2021-05-05 19:46:08 +09:00
|
|
|
const pos = interleave ? levelOffset + (offset << 1) : offset;
|
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 (reversible && nb >= mb) {
|
2014-04-16 17:40:04 +09:00
|
|
|
coefficients[pos] = n;
|
2014-04-04 22:19:41 +09:00
|
|
|
} else {
|
2014-04-16 17:40:04 +09:00
|
|
|
coefficients[pos] = n * (1 << (mb - nb));
|
2014-04-04 22:19:41 +09:00
|
|
|
}
|
2014-04-06 00:27:18 +09:00
|
|
|
}
|
|
|
|
offset++;
|
2012-04-05 05:43:26 +09:00
|
|
|
position++;
|
|
|
|
}
|
|
|
|
offset += width - blockWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function transformTile(context, tile, c) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const component = tile.components[c];
|
|
|
|
const codingStyleParameters = component.codingStyleParameters;
|
|
|
|
const quantizationParameters = component.quantizationParameters;
|
|
|
|
const decompositionLevelsCount =
|
2012-04-05 05:43:26 +09:00
|
|
|
codingStyleParameters.decompositionLevelsCount;
|
2021-05-05 19:46:08 +09:00
|
|
|
const spqcds = quantizationParameters.SPqcds;
|
|
|
|
const scalarExpounded = quantizationParameters.scalarExpounded;
|
|
|
|
const guardBits = quantizationParameters.guardBits;
|
|
|
|
const segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
|
|
|
|
const precision = context.components[c].precision;
|
|
|
|
|
|
|
|
const reversible = codingStyleParameters.reversibleTransformation;
|
|
|
|
const transform = reversible
|
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 ReversibleTransform()
|
|
|
|
: new IrreversibleTransform();
|
2014-03-06 17:05:24 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const subbandCoefficients = [];
|
|
|
|
let b = 0;
|
|
|
|
for (let i = 0; i <= decompositionLevelsCount; i++) {
|
|
|
|
const resolution = component.resolutions[i];
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const width = resolution.trx1 - resolution.trx0;
|
|
|
|
const height = resolution.try1 - resolution.try0;
|
2014-04-16 17:40:04 +09:00
|
|
|
// Allocate space for the whole sublevel.
|
2021-05-05 19:46:08 +09:00
|
|
|
const coefficients = new Float32Array(width * height);
|
2014-04-16 17:40:04 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
for (let j = 0, jj = resolution.subbands.length; j < jj; j++) {
|
2021-05-05 19:47:01 +09:00
|
|
|
let mu, epsilon;
|
2012-04-05 05:43:26 +09:00
|
|
|
if (!scalarExpounded) {
|
|
|
|
// formula E-5
|
|
|
|
mu = spqcds[0].mu;
|
|
|
|
epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
|
|
|
|
} else {
|
|
|
|
mu = spqcds[b].mu;
|
|
|
|
epsilon = spqcds[b].epsilon;
|
2014-04-16 17:40:04 +09:00
|
|
|
b++;
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const subband = resolution.subbands[j];
|
|
|
|
const gainLog2 = SubbandsGainLog2[subband.type];
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2016-07-17 21:33:41 +09:00
|
|
|
// calculate quantization coefficient (Section E.1.1.1)
|
2021-05-05 19:46:08 +09:00
|
|
|
const delta = reversible
|
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
|
|
|
? 1
|
2020-03-19 20:36:25 +09:00
|
|
|
: 2 ** (precision + gainLog2 - epsilon) * (1 + mu / 2048);
|
2021-05-05 19:46:08 +09:00
|
|
|
const mb = guardBits + epsilon - 1;
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2014-04-16 17:40:04 +09:00
|
|
|
// In the first resolution level, copyCoefficients will fill the
|
2016-07-17 21:33:41 +09:00
|
|
|
// whole array with coefficients. In the succeeding passes,
|
2014-04-16 17:40:04 +09:00
|
|
|
// copyCoefficients will consecutively fill in the values that belong
|
|
|
|
// to the interleaved positions of the HL, LH, and HH coefficients.
|
|
|
|
// The LL coefficients will then be interleaved in Transform.iterate().
|
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
|
|
|
copyCoefficients(
|
|
|
|
coefficients,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
subband,
|
|
|
|
delta,
|
|
|
|
mb,
|
|
|
|
reversible,
|
|
|
|
segmentationSymbolUsed
|
|
|
|
);
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2014-04-16 17:40:04 +09:00
|
|
|
subbandCoefficients.push({
|
2017-04-27 19:58:44 +09:00
|
|
|
width,
|
|
|
|
height,
|
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
|
|
|
items: coefficients,
|
2014-04-16 17:40:04 +09:00
|
|
|
});
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const result = transform.calculate(
|
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
|
|
|
subbandCoefficients,
|
|
|
|
component.tcx0,
|
|
|
|
component.tcy0
|
|
|
|
);
|
2012-04-05 05:43:26 +09:00
|
|
|
return {
|
|
|
|
left: component.tcx0,
|
|
|
|
top: component.tcy0,
|
|
|
|
width: result.width,
|
|
|
|
height: result.height,
|
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
|
|
|
items: result.items,
|
2012-01-12 11:08:46 +09:00
|
|
|
};
|
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
function transformComponents(context) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const siz = context.SIZ;
|
|
|
|
const components = context.components;
|
|
|
|
const componentsCount = siz.Csiz;
|
|
|
|
const resultImages = [];
|
|
|
|
for (let i = 0, ii = context.tiles.length; i < ii; i++) {
|
|
|
|
const tile = context.tiles[i];
|
|
|
|
const transformedTiles = [];
|
2021-05-05 19:47:01 +09:00
|
|
|
for (let c = 0; c < componentsCount; c++) {
|
2014-04-16 17:40:04 +09:00
|
|
|
transformedTiles[c] = transformTile(context, tile, c);
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
2021-05-05 19:46:08 +09:00
|
|
|
const tile0 = transformedTiles[0];
|
|
|
|
const out = new Uint8ClampedArray(tile0.items.length * componentsCount);
|
|
|
|
const result = {
|
2014-04-16 17:40:04 +09:00
|
|
|
left: tile0.left,
|
|
|
|
top: tile0.top,
|
|
|
|
width: tile0.width,
|
|
|
|
height: tile0.height,
|
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
|
|
|
items: out,
|
2014-04-16 17:40:04 +09:00
|
|
|
};
|
2012-04-05 05:43:26 +09:00
|
|
|
|
|
|
|
// Section G.2.2 Inverse multi component transform
|
2021-05-05 19:47:01 +09:00
|
|
|
let shift, offset;
|
|
|
|
let pos = 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
|
|
|
j,
|
|
|
|
jj,
|
|
|
|
y0,
|
|
|
|
y1,
|
|
|
|
y2;
|
2012-04-05 05:43:26 +09:00
|
|
|
if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const fourComponents = componentsCount === 4;
|
|
|
|
const y0items = transformedTiles[0].items;
|
|
|
|
const y1items = transformedTiles[1].items;
|
|
|
|
const y2items = transformedTiles[2].items;
|
|
|
|
const y3items = fourComponents ? transformedTiles[3].items : null;
|
2014-04-16 17:40:04 +09:00
|
|
|
|
|
|
|
// HACK: The multiple component transform formulas below assume that
|
|
|
|
// all components have the same precision. With this in mind, we
|
|
|
|
// compute shift and offset only once.
|
|
|
|
shift = components[0].precision - 8;
|
|
|
|
offset = (128 << shift) + 0.5;
|
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const component0 = tile.components[0];
|
|
|
|
const alpha01 = componentsCount - 3;
|
2014-04-29 00:24:22 +09:00
|
|
|
jj = y0items.length;
|
2014-04-06 00:27:18 +09:00
|
|
|
if (!component0.codingStyleParameters.reversibleTransformation) {
|
2014-03-06 17:05:24 +09:00
|
|
|
// inverse irreversible multiple component transform
|
2014-04-29 00:24:22 +09:00
|
|
|
for (j = 0; j < jj; j++, pos += alpha01) {
|
|
|
|
y0 = y0items[j] + offset;
|
2014-04-16 17:40:04 +09:00
|
|
|
y1 = y1items[j];
|
|
|
|
y2 = y2items[j];
|
2017-08-15 23:45:33 +09:00
|
|
|
out[pos++] = (y0 + 1.402 * y2) >> shift;
|
|
|
|
out[pos++] = (y0 - 0.34413 * y1 - 0.71414 * y2) >> shift;
|
|
|
|
out[pos++] = (y0 + 1.772 * y1) >> shift;
|
2014-03-06 17:05:24 +09:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// inverse reversible multiple component transform
|
2014-04-29 00:24:22 +09:00
|
|
|
for (j = 0; j < jj; j++, pos += alpha01) {
|
|
|
|
y0 = y0items[j] + offset;
|
2014-04-16 17:40:04 +09:00
|
|
|
y1 = y1items[j];
|
|
|
|
y2 = y2items[j];
|
2020-01-24 17:48:21 +09:00
|
|
|
const g = y0 - ((y2 + y1) >> 2);
|
2017-08-15 23:45:33 +09:00
|
|
|
|
|
|
|
out[pos++] = (g + y2) >> shift;
|
|
|
|
out[pos++] = g >> shift;
|
|
|
|
out[pos++] = (g + y1) >> shift;
|
2014-04-29 00:24:22 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fourComponents) {
|
|
|
|
for (j = 0, pos = 3; j < jj; j++, pos += 4) {
|
2017-08-15 23:45:33 +09:00
|
|
|
out[pos] = (y3items[j] + offset) >> shift;
|
2014-03-06 17:05:24 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +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
|
|
|
} else {
|
|
|
|
// no multi-component transform
|
2021-05-05 19:47:01 +09:00
|
|
|
for (let c = 0; c < componentsCount; c++) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const items = transformedTiles[c].items;
|
2014-04-16 17:40:04 +09:00
|
|
|
shift = components[c].precision - 8;
|
|
|
|
offset = (128 << shift) + 0.5;
|
|
|
|
for (pos = c, j = 0, jj = items.length; j < jj; j++) {
|
2017-08-15 23:45:33 +09:00
|
|
|
out[pos] = (items[j] + offset) >> shift;
|
2014-04-16 17:40:04 +09:00
|
|
|
pos += componentsCount;
|
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
resultImages.push(result);
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
return resultImages;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
function initializeTile(context, tileIndex) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const siz = context.SIZ;
|
|
|
|
const componentsCount = siz.Csiz;
|
|
|
|
const tile = context.tiles[tileIndex];
|
|
|
|
for (let c = 0; c < componentsCount; c++) {
|
|
|
|
const component = tile.components[c];
|
|
|
|
const qcdOrQcc =
|
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
|
|
|
context.currentTile.QCC[c] !== undefined
|
|
|
|
? context.currentTile.QCC[c]
|
|
|
|
: context.currentTile.QCD;
|
2012-04-05 05:43:26 +09:00
|
|
|
component.quantizationParameters = qcdOrQcc;
|
2021-05-05 19:46:08 +09:00
|
|
|
const codOrCoc =
|
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
|
|
|
context.currentTile.COC[c] !== undefined
|
|
|
|
? context.currentTile.COC[c]
|
|
|
|
: context.currentTile.COD;
|
2012-04-05 05:43:26 +09:00
|
|
|
component.codingStyleParameters = codOrCoc;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
tile.codingStyleDefaultParameters = context.currentTile.COD;
|
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
// Section B.10.2 Tag trees
|
2021-05-05 19:47:01 +09:00
|
|
|
const TagTree = (function TagTreeClosure() {
|
2020-03-25 18:15:50 +09:00
|
|
|
// eslint-disable-next-line no-shadow
|
2012-04-05 05:43:26 +09:00
|
|
|
function TagTree(width, height) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const levelsLength = log2(Math.max(width, height)) + 1;
|
2012-04-05 05:43:26 +09:00
|
|
|
this.levels = [];
|
2021-05-05 19:46:08 +09:00
|
|
|
for (let i = 0; i < levelsLength; i++) {
|
|
|
|
const level = {
|
2017-04-27 19:58:44 +09:00
|
|
|
width,
|
|
|
|
height,
|
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
|
|
|
items: [],
|
2012-04-05 05:43:26 +09:00
|
|
|
};
|
|
|
|
this.levels.push(level);
|
|
|
|
width = Math.ceil(width / 2);
|
|
|
|
height = Math.ceil(height / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TagTree.prototype = {
|
|
|
|
reset: function TagTree_reset(i, j) {
|
2021-05-05 19:46:08 +09:00
|
|
|
let currentLevel = 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
|
|
|
value = 0,
|
|
|
|
level;
|
2012-04-05 05:43:26 +09:00
|
|
|
while (currentLevel < this.levels.length) {
|
2014-04-08 06:42:54 +09:00
|
|
|
level = this.levels[currentLevel];
|
2021-05-05 19:46:08 +09:00
|
|
|
const index = i + j * level.width;
|
2014-09-27 06:38:37 +09:00
|
|
|
if (level.items[index] !== undefined) {
|
2012-04-05 05:43:26 +09:00
|
|
|
value = level.items[index];
|
|
|
|
break;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
level.index = index;
|
|
|
|
i >>= 1;
|
|
|
|
j >>= 1;
|
|
|
|
currentLevel++;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
currentLevel--;
|
2014-04-08 06:42:54 +09:00
|
|
|
level = this.levels[currentLevel];
|
2012-04-05 05:43:26 +09:00
|
|
|
level.items[level.index] = value;
|
|
|
|
this.currentLevel = currentLevel;
|
|
|
|
delete this.value;
|
|
|
|
},
|
|
|
|
incrementValue: function TagTree_incrementValue() {
|
2021-05-05 19:46:08 +09:00
|
|
|
const level = this.levels[this.currentLevel];
|
2012-04-05 05:43:26 +09:00
|
|
|
level.items[level.index]++;
|
|
|
|
},
|
|
|
|
nextLevel: function TagTree_nextLevel() {
|
2021-05-05 19:46:08 +09:00
|
|
|
let currentLevel = this.currentLevel;
|
|
|
|
let level = this.levels[currentLevel];
|
|
|
|
const value = level.items[level.index];
|
2012-04-05 05:43:26 +09:00
|
|
|
currentLevel--;
|
|
|
|
if (currentLevel < 0) {
|
|
|
|
this.value = value;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.currentLevel = currentLevel;
|
2014-04-08 06:42:54 +09:00
|
|
|
level = this.levels[currentLevel];
|
2012-04-05 05:43:26 +09:00
|
|
|
level.items[level.index] = value;
|
|
|
|
return true;
|
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-01-12 11:08:46 +09:00
|
|
|
};
|
2012-04-05 05:43:26 +09:00
|
|
|
return TagTree;
|
|
|
|
})();
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:47:01 +09:00
|
|
|
const InclusionTree = (function InclusionTreeClosure() {
|
2020-03-25 18:15:50 +09:00
|
|
|
// eslint-disable-next-line no-shadow
|
2016-12-10 22:28:27 +09:00
|
|
|
function InclusionTree(width, height, defaultValue) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const levelsLength = log2(Math.max(width, height)) + 1;
|
2012-04-05 05:43:26 +09:00
|
|
|
this.levels = [];
|
2021-05-05 19:46:08 +09:00
|
|
|
for (let i = 0; i < levelsLength; i++) {
|
|
|
|
const items = new Uint8Array(width * height);
|
|
|
|
for (let j = 0, jj = items.length; j < jj; j++) {
|
2012-04-05 05:43:26 +09:00
|
|
|
items[j] = defaultValue;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const level = {
|
2017-04-27 19:58:44 +09:00
|
|
|
width,
|
|
|
|
height,
|
|
|
|
items,
|
2012-04-05 05:43:26 +09:00
|
|
|
};
|
|
|
|
this.levels.push(level);
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
width = Math.ceil(width / 2);
|
|
|
|
height = Math.ceil(height / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
InclusionTree.prototype = {
|
|
|
|
reset: function InclusionTree_reset(i, j, stopValue) {
|
2021-05-05 19:46:08 +09:00
|
|
|
let currentLevel = 0;
|
2012-04-05 05:43:26 +09:00
|
|
|
while (currentLevel < this.levels.length) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const level = this.levels[currentLevel];
|
|
|
|
const index = i + j * level.width;
|
2012-04-05 05:43:26 +09:00
|
|
|
level.index = index;
|
2021-05-05 19:46:08 +09:00
|
|
|
const value = level.items[index];
|
2012-04-05 05:43:26 +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 (value === 0xff) {
|
2012-04-05 05:43:26 +09:00
|
|
|
break;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
|
|
|
|
if (value > stopValue) {
|
|
|
|
this.currentLevel = currentLevel;
|
|
|
|
// already know about this one, propagating the value to top levels
|
|
|
|
this.propagateValues();
|
|
|
|
return false;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
|
|
|
|
i >>= 1;
|
|
|
|
j >>= 1;
|
|
|
|
currentLevel++;
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
this.currentLevel = currentLevel - 1;
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
incrementValue: function InclusionTree_incrementValue(stopValue) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const level = this.levels[this.currentLevel];
|
2012-04-05 05:43:26 +09:00
|
|
|
level.items[level.index] = stopValue + 1;
|
|
|
|
this.propagateValues();
|
|
|
|
},
|
|
|
|
propagateValues: function InclusionTree_propagateValues() {
|
2021-05-05 19:46:08 +09:00
|
|
|
let levelIndex = this.currentLevel;
|
|
|
|
let level = this.levels[levelIndex];
|
|
|
|
const currentValue = level.items[level.index];
|
2012-04-05 05:43:26 +09:00
|
|
|
while (--levelIndex >= 0) {
|
2014-04-08 06:42:54 +09:00
|
|
|
level = this.levels[levelIndex];
|
2012-04-05 05:43:26 +09:00
|
|
|
level.items[level.index] = currentValue;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
nextLevel: function InclusionTree_nextLevel() {
|
2021-05-05 19:46:08 +09:00
|
|
|
let currentLevel = this.currentLevel;
|
|
|
|
let level = this.levels[currentLevel];
|
|
|
|
const value = level.items[level.index];
|
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
|
|
|
level.items[level.index] = 0xff;
|
2012-04-05 05:43:26 +09:00
|
|
|
currentLevel--;
|
2014-03-03 05:12:26 +09:00
|
|
|
if (currentLevel < 0) {
|
2012-04-05 05:43:26 +09:00
|
|
|
return false;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
|
|
|
|
this.currentLevel = currentLevel;
|
2014-04-08 06:42:54 +09:00
|
|
|
level = this.levels[currentLevel];
|
2012-04-05 05:43:26 +09:00
|
|
|
level.items[level.index] = value;
|
|
|
|
return true;
|
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-01-12 11:08:46 +09:00
|
|
|
};
|
2012-04-05 05:43:26 +09:00
|
|
|
return InclusionTree;
|
|
|
|
})();
|
|
|
|
|
|
|
|
// Section D. Coefficient bit modeling
|
2021-05-05 19:47:01 +09:00
|
|
|
const BitModel = (function BitModelClosure() {
|
2021-05-05 19:46:08 +09:00
|
|
|
const UNIFORM_CONTEXT = 17;
|
|
|
|
const RUNLENGTH_CONTEXT = 18;
|
2012-04-05 05:43:26 +09:00
|
|
|
// Table D-1
|
|
|
|
// The index is binary presentation: 0dddvvhh, ddd - sum of Di (0..4),
|
|
|
|
// vv - sum of Vi (0..2), and hh - sum of Hi (0..2)
|
2019-12-25 23:54:34 +09:00
|
|
|
// prettier-ignore
|
2021-05-05 19:46:08 +09:00
|
|
|
const LLAndLHContextsLabel = new Uint8Array([
|
2012-04-05 05:43:26 +09:00
|
|
|
0, 5, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 1, 6, 8, 0, 3, 7, 8, 0, 4,
|
|
|
|
7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6,
|
|
|
|
8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8
|
|
|
|
]);
|
2019-12-25 23:54:34 +09:00
|
|
|
// prettier-ignore
|
2021-05-05 19:46:08 +09:00
|
|
|
const HLContextLabel = new Uint8Array([
|
2012-04-05 05:43:26 +09:00
|
|
|
0, 3, 4, 0, 5, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 1, 3, 4, 0, 6, 7, 7, 0, 8,
|
|
|
|
8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3,
|
|
|
|
4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8
|
|
|
|
]);
|
2019-12-25 23:54:34 +09:00
|
|
|
// prettier-ignore
|
2021-05-05 19:46:08 +09:00
|
|
|
const HHContextLabel = new Uint8Array([
|
2012-04-05 05:43:26 +09:00
|
|
|
0, 1, 2, 0, 1, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, 0, 3, 4, 5, 0, 4, 5, 5, 0, 5,
|
|
|
|
5, 5, 0, 0, 0, 0, 0, 6, 7, 7, 0, 7, 7, 7, 0, 7, 7, 7, 0, 0, 0, 0, 0, 8, 8,
|
|
|
|
8, 0, 8, 8, 8, 0, 8, 8, 8, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8
|
|
|
|
]);
|
|
|
|
|
2020-03-25 18:15:50 +09:00
|
|
|
// eslint-disable-next-line no-shadow
|
2014-04-16 17:40:04 +09:00
|
|
|
function BitModel(width, height, subband, zeroBitPlanes, mb) {
|
2012-04-05 05:43:26 +09:00
|
|
|
this.width = width;
|
|
|
|
this.height = height;
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2020-01-13 03:47:13 +09:00
|
|
|
let contextLabelTable;
|
|
|
|
if (subband === "HH") {
|
|
|
|
contextLabelTable = HHContextLabel;
|
|
|
|
} else if (subband === "HL") {
|
|
|
|
contextLabelTable = HLContextLabel;
|
|
|
|
} else {
|
|
|
|
contextLabelTable = LLAndLHContextsLabel;
|
|
|
|
}
|
|
|
|
this.contextLabelTable = contextLabelTable;
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const coefficientCount = width * height;
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
// coefficients outside the encoding region treated as insignificant
|
|
|
|
// add border state cells for significanceState
|
|
|
|
this.neighborsSignificance = new Uint8Array(coefficientCount);
|
|
|
|
this.coefficentsSign = new Uint8Array(coefficientCount);
|
2020-01-13 03:47:13 +09:00
|
|
|
let coefficentsMagnitude;
|
|
|
|
if (mb > 14) {
|
|
|
|
coefficentsMagnitude = new Uint32Array(coefficientCount);
|
|
|
|
} else if (mb > 6) {
|
|
|
|
coefficentsMagnitude = new Uint16Array(coefficientCount);
|
|
|
|
} else {
|
|
|
|
coefficentsMagnitude = new Uint8Array(coefficientCount);
|
|
|
|
}
|
|
|
|
this.coefficentsMagnitude = coefficentsMagnitude;
|
2012-04-05 05:43:26 +09:00
|
|
|
this.processingFlags = new Uint8Array(coefficientCount);
|
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const bitsDecoded = new Uint8Array(coefficientCount);
|
2014-04-04 22:19:41 +09:00
|
|
|
if (zeroBitPlanes !== 0) {
|
2021-05-05 19:46:08 +09:00
|
|
|
for (let i = 0; i < coefficientCount; i++) {
|
2014-04-04 22:19:41 +09:00
|
|
|
bitsDecoded[i] = zeroBitPlanes;
|
|
|
|
}
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
this.bitsDecoded = bitsDecoded;
|
|
|
|
|
|
|
|
this.reset();
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
BitModel.prototype = {
|
|
|
|
setDecoder: function BitModel_setDecoder(decoder) {
|
|
|
|
this.decoder = decoder;
|
|
|
|
},
|
|
|
|
reset: function BitModel_reset() {
|
2014-04-04 22:19:41 +09:00
|
|
|
// We have 17 contexts that are accessed via context labels,
|
2014-03-11 00:56:00 +09:00
|
|
|
// plus the uniform and runlength context.
|
|
|
|
this.contexts = new Int8Array(19);
|
|
|
|
|
|
|
|
// Contexts are packed into 1 byte:
|
|
|
|
// highest 7 bits carry the index, lowest bit carries mps
|
|
|
|
this.contexts[0] = (4 << 1) | 0;
|
|
|
|
this.contexts[UNIFORM_CONTEXT] = (46 << 1) | 0;
|
|
|
|
this.contexts[RUNLENGTH_CONTEXT] = (3 << 1) | 0;
|
2012-04-05 05:43:26 +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
|
|
|
setNeighborsSignificance: function BitModel_setNeighborsSignificance(
|
|
|
|
row,
|
|
|
|
column,
|
|
|
|
index
|
|
|
|
) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const neighborsSignificance = this.neighborsSignificance;
|
|
|
|
const width = this.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
|
|
|
height = this.height;
|
2021-05-05 19:46:08 +09:00
|
|
|
const left = column > 0;
|
|
|
|
const right = column + 1 < width;
|
|
|
|
let i;
|
2014-04-04 22:19:41 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
if (row > 0) {
|
2014-04-08 06:42:54 +09:00
|
|
|
i = index - width;
|
2014-04-04 22:19:41 +09:00
|
|
|
if (left) {
|
|
|
|
neighborsSignificance[i - 1] += 0x10;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2014-04-04 22:19:41 +09:00
|
|
|
if (right) {
|
|
|
|
neighborsSignificance[i + 1] += 0x10;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2014-04-04 22:19:41 +09:00
|
|
|
neighborsSignificance[i] += 0x04;
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
2014-04-04 22:19:41 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
if (row + 1 < height) {
|
2014-04-08 06:42:54 +09:00
|
|
|
i = index + width;
|
2014-04-04 22:19:41 +09:00
|
|
|
if (left) {
|
|
|
|
neighborsSignificance[i - 1] += 0x10;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2014-04-04 22:19:41 +09:00
|
|
|
if (right) {
|
|
|
|
neighborsSignificance[i + 1] += 0x10;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2014-04-04 22:19:41 +09:00
|
|
|
neighborsSignificance[i] += 0x04;
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
2014-04-04 22:19:41 +09:00
|
|
|
|
|
|
|
if (left) {
|
2012-04-05 05:43:26 +09:00
|
|
|
neighborsSignificance[index - 1] += 0x01;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2014-04-04 22:19:41 +09:00
|
|
|
if (right) {
|
2012-04-05 05:43:26 +09:00
|
|
|
neighborsSignificance[index + 1] += 0x01;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
neighborsSignificance[index] |= 0x80;
|
|
|
|
},
|
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
|
|
|
runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
|
2021-05-05 19:46:08 +09:00
|
|
|
const decoder = this.decoder;
|
|
|
|
const width = this.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
|
|
|
height = this.height;
|
2021-05-05 19:46:08 +09:00
|
|
|
const coefficentsMagnitude = this.coefficentsMagnitude;
|
|
|
|
const coefficentsSign = this.coefficentsSign;
|
|
|
|
const neighborsSignificance = this.neighborsSignificance;
|
|
|
|
const processingFlags = this.processingFlags;
|
|
|
|
const contexts = this.contexts;
|
|
|
|
const labels = this.contextLabelTable;
|
|
|
|
const bitsDecoded = this.bitsDecoded;
|
|
|
|
const processedInverseMask = ~1;
|
|
|
|
const processedMask = 1;
|
|
|
|
const firstMagnitudeBitMask = 2;
|
|
|
|
|
|
|
|
for (let i0 = 0; i0 < height; i0 += 4) {
|
|
|
|
for (let j = 0; j < width; j++) {
|
|
|
|
let index = i0 * width + j;
|
|
|
|
for (let i1 = 0; i1 < 4; i1++, index += width) {
|
|
|
|
const i = i0 + i1;
|
2014-03-03 05:12:26 +09:00
|
|
|
if (i >= height) {
|
2012-04-05 05:43:26 +09:00
|
|
|
break;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2014-04-04 22:19:41 +09:00
|
|
|
// clear processed flag first
|
|
|
|
processingFlags[index] &= processedInverseMask;
|
2012-01-12 11:08:46 +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 (
|
|
|
|
coefficentsMagnitude[index] ||
|
|
|
|
!neighborsSignificance[index]
|
|
|
|
) {
|
2012-04-05 05:43:26 +09:00
|
|
|
continue;
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const contextLabel = labels[neighborsSignificance[index]];
|
|
|
|
const decision = decoder.readBit(contexts, contextLabel);
|
2012-04-05 05:43:26 +09:00
|
|
|
if (decision) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const sign = this.decodeSignBit(i, j, index);
|
2012-04-05 05:43:26 +09:00
|
|
|
coefficentsSign[index] = sign;
|
|
|
|
coefficentsMagnitude[index] = 1;
|
2014-04-04 22:19:41 +09:00
|
|
|
this.setNeighborsSignificance(i, j, index);
|
2012-04-05 05:43:26 +09:00
|
|
|
processingFlags[index] |= firstMagnitudeBitMask;
|
|
|
|
}
|
|
|
|
bitsDecoded[index]++;
|
|
|
|
processingFlags[index] |= processedMask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-04-04 22:19:41 +09:00
|
|
|
decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const width = this.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
|
|
|
height = this.height;
|
2021-05-05 19:46:08 +09:00
|
|
|
const coefficentsMagnitude = this.coefficentsMagnitude;
|
|
|
|
const coefficentsSign = this.coefficentsSign;
|
|
|
|
let contribution, sign0, sign1, significance1;
|
|
|
|
let contextLabel, decoded;
|
2014-04-04 22:19:41 +09:00
|
|
|
|
|
|
|
// calculate horizontal contribution
|
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
|
|
|
significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
|
2014-04-04 22:19:41 +09:00
|
|
|
if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
|
|
|
|
sign1 = coefficentsSign[index + 1];
|
|
|
|
if (significance1) {
|
|
|
|
sign0 = coefficentsSign[index - 1];
|
|
|
|
contribution = 1 - sign1 - sign0;
|
|
|
|
} else {
|
|
|
|
contribution = 1 - sign1 - sign1;
|
|
|
|
}
|
|
|
|
} else if (significance1) {
|
|
|
|
sign0 = coefficentsSign[index - 1];
|
|
|
|
contribution = 1 - sign0 - sign0;
|
|
|
|
} else {
|
|
|
|
contribution = 0;
|
|
|
|
}
|
2021-05-05 19:46:08 +09:00
|
|
|
const horizontalContribution = 3 * contribution;
|
2014-04-04 22:19:41 +09:00
|
|
|
|
|
|
|
// calculate vertical contribution and combine with the horizontal
|
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
|
|
|
significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
|
2014-04-04 22:19:41 +09:00
|
|
|
if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
|
|
|
|
sign1 = coefficentsSign[index + width];
|
|
|
|
if (significance1) {
|
|
|
|
sign0 = coefficentsSign[index - width];
|
|
|
|
contribution = 1 - sign1 - sign0 + horizontalContribution;
|
|
|
|
} else {
|
|
|
|
contribution = 1 - sign1 - sign1 + horizontalContribution;
|
|
|
|
}
|
|
|
|
} else if (significance1) {
|
|
|
|
sign0 = coefficentsSign[index - width];
|
|
|
|
contribution = 1 - sign0 - sign0 + horizontalContribution;
|
|
|
|
} else {
|
|
|
|
contribution = horizontalContribution;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (contribution >= 0) {
|
2014-04-08 06:42:54 +09:00
|
|
|
contextLabel = 9 + contribution;
|
|
|
|
decoded = this.decoder.readBit(this.contexts, contextLabel);
|
2014-04-04 22:19:41 +09:00
|
|
|
} else {
|
2014-04-08 06:42:54 +09:00
|
|
|
contextLabel = 9 - contribution;
|
|
|
|
decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
|
2014-04-04 22:19:41 +09:00
|
|
|
}
|
|
|
|
return decoded;
|
2012-04-05 05:43:26 +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
|
|
|
runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
|
2021-05-05 19:46:08 +09:00
|
|
|
const decoder = this.decoder;
|
|
|
|
const width = this.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
|
|
|
height = this.height;
|
2021-05-05 19:46:08 +09:00
|
|
|
const coefficentsMagnitude = this.coefficentsMagnitude;
|
|
|
|
const neighborsSignificance = this.neighborsSignificance;
|
|
|
|
const contexts = this.contexts;
|
|
|
|
const bitsDecoded = this.bitsDecoded;
|
|
|
|
const processingFlags = this.processingFlags;
|
|
|
|
const processedMask = 1;
|
|
|
|
const firstMagnitudeBitMask = 2;
|
|
|
|
const length = width * height;
|
|
|
|
const width4 = width * 4;
|
2014-04-04 22:19:41 +09:00
|
|
|
|
2021-05-05 19:47:01 +09:00
|
|
|
for (let index0 = 0, indexNext; index0 < length; index0 = indexNext) {
|
2014-04-04 22:19:41 +09:00
|
|
|
indexNext = Math.min(length, index0 + width4);
|
2021-05-05 19:46:08 +09:00
|
|
|
for (let j = 0; j < width; j++) {
|
|
|
|
for (let index = index0 + j; index < indexNext; index += width) {
|
2012-04-05 05:43:26 +09:00
|
|
|
// significant but not those that have just become
|
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 (
|
|
|
|
!coefficentsMagnitude[index] ||
|
|
|
|
(processingFlags[index] & processedMask) !== 0
|
|
|
|
) {
|
2012-04-05 05:43:26 +09:00
|
|
|
continue;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
let contextLabel = 16;
|
2014-03-10 06:31:55 +09:00
|
|
|
if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
|
2014-04-04 22:19:41 +09:00
|
|
|
processingFlags[index] ^= firstMagnitudeBitMask;
|
2012-04-05 05:43:26 +09:00
|
|
|
// first refinement
|
2021-05-05 19:46:08 +09:00
|
|
|
const significance = neighborsSignificance[index] & 127;
|
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 = significance === 0 ? 15 : 14;
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const bit = decoder.readBit(contexts, contextLabel);
|
2012-04-05 05:43:26 +09:00
|
|
|
coefficentsMagnitude[index] =
|
|
|
|
(coefficentsMagnitude[index] << 1) | bit;
|
|
|
|
bitsDecoded[index]++;
|
|
|
|
processingFlags[index] |= processedMask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
runCleanupPass: function BitModel_runCleanupPass() {
|
2021-05-05 19:46:08 +09:00
|
|
|
const decoder = this.decoder;
|
|
|
|
const width = this.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
|
|
|
height = this.height;
|
2021-05-05 19:46:08 +09:00
|
|
|
const neighborsSignificance = this.neighborsSignificance;
|
|
|
|
const coefficentsMagnitude = this.coefficentsMagnitude;
|
|
|
|
const coefficentsSign = this.coefficentsSign;
|
|
|
|
const contexts = this.contexts;
|
|
|
|
const labels = this.contextLabelTable;
|
|
|
|
const bitsDecoded = this.bitsDecoded;
|
|
|
|
const processingFlags = this.processingFlags;
|
|
|
|
const processedMask = 1;
|
|
|
|
const firstMagnitudeBitMask = 2;
|
|
|
|
const oneRowDown = width;
|
|
|
|
const twoRowsDown = width * 2;
|
|
|
|
const threeRowsDown = width * 3;
|
|
|
|
let iNext;
|
|
|
|
for (let i0 = 0; i0 < height; i0 = iNext) {
|
2014-04-10 22:07:50 +09:00
|
|
|
iNext = Math.min(i0 + 4, height);
|
2021-05-05 19:46:08 +09:00
|
|
|
const indexBase = i0 * width;
|
|
|
|
const checkAllEmpty = i0 + 3 < height;
|
|
|
|
for (let j = 0; j < width; j++) {
|
|
|
|
const index0 = indexBase + j;
|
2014-08-02 05:56:11 +09:00
|
|
|
// using the property: labels[neighborsSignificance[index]] === 0
|
|
|
|
// when neighborsSignificance[index] === 0
|
2021-05-05 19:46:08 +09:00
|
|
|
const allEmpty =
|
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
|
|
|
checkAllEmpty &&
|
2013-02-01 08:32:40 +09:00
|
|
|
processingFlags[index0] === 0 &&
|
|
|
|
processingFlags[index0 + oneRowDown] === 0 &&
|
|
|
|
processingFlags[index0 + twoRowsDown] === 0 &&
|
|
|
|
processingFlags[index0 + threeRowsDown] === 0 &&
|
|
|
|
neighborsSignificance[index0] === 0 &&
|
|
|
|
neighborsSignificance[index0 + oneRowDown] === 0 &&
|
|
|
|
neighborsSignificance[index0 + twoRowsDown] === 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
|
|
|
neighborsSignificance[index0 + threeRowsDown] === 0;
|
2021-05-05 19:46:08 +09:00
|
|
|
let i1 = 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
|
|
|
index = index0;
|
2021-05-05 19:47:01 +09:00
|
|
|
let i = i0,
|
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
|
|
|
sign;
|
2012-04-05 05:43:26 +09:00
|
|
|
if (allEmpty) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const hasSignificantCoefficent = decoder.readBit(
|
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
|
|
|
contexts,
|
|
|
|
RUNLENGTH_CONTEXT
|
|
|
|
);
|
2012-04-05 05:43:26 +09:00
|
|
|
if (!hasSignificantCoefficent) {
|
|
|
|
bitsDecoded[index0]++;
|
|
|
|
bitsDecoded[index0 + oneRowDown]++;
|
|
|
|
bitsDecoded[index0 + twoRowsDown]++;
|
|
|
|
bitsDecoded[index0 + threeRowsDown]++;
|
|
|
|
continue; // next column
|
|
|
|
}
|
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
|
|
|
i1 =
|
|
|
|
(decoder.readBit(contexts, UNIFORM_CONTEXT) << 1) |
|
|
|
|
decoder.readBit(contexts, UNIFORM_CONTEXT);
|
2014-04-10 22:07:50 +09:00
|
|
|
if (i1 !== 0) {
|
|
|
|
i = i0 + i1;
|
|
|
|
index += i1 * width;
|
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2014-04-08 06:42:54 +09:00
|
|
|
sign = this.decodeSignBit(i, j, index);
|
2012-04-05 05:43:26 +09:00
|
|
|
coefficentsSign[index] = sign;
|
|
|
|
coefficentsMagnitude[index] = 1;
|
2014-04-04 22:19:41 +09:00
|
|
|
this.setNeighborsSignificance(i, j, index);
|
2012-04-05 05:43:26 +09:00
|
|
|
processingFlags[index] |= firstMagnitudeBitMask;
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
index = index0;
|
2021-05-05 19:46:08 +09:00
|
|
|
for (let i2 = i0; i2 <= i; i2++, index += width) {
|
2012-04-05 05:43:26 +09:00
|
|
|
bitsDecoded[index]++;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
i1++;
|
|
|
|
}
|
2014-04-10 22:07:50 +09:00
|
|
|
for (i = i0 + i1; i < iNext; i++, index += 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
|
|
|
if (
|
|
|
|
coefficentsMagnitude[index] ||
|
|
|
|
(processingFlags[index] & processedMask) !== 0
|
|
|
|
) {
|
2012-04-05 05:43:26 +09:00
|
|
|
continue;
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const contextLabel = labels[neighborsSignificance[index]];
|
|
|
|
const decision = decoder.readBit(contexts, contextLabel);
|
2014-04-10 22:07:50 +09:00
|
|
|
if (decision === 1) {
|
2014-04-08 06:42:54 +09:00
|
|
|
sign = this.decodeSignBit(i, j, index);
|
2012-04-05 05:43:26 +09:00
|
|
|
coefficentsSign[index] = sign;
|
|
|
|
coefficentsMagnitude[index] = 1;
|
2014-04-04 22:19:41 +09:00
|
|
|
this.setNeighborsSignificance(i, j, index);
|
2012-04-05 05:43:26 +09:00
|
|
|
processingFlags[index] |= firstMagnitudeBitMask;
|
|
|
|
}
|
|
|
|
bitsDecoded[index]++;
|
|
|
|
}
|
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-07-10 03:59:50 +09:00
|
|
|
},
|
|
|
|
checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
|
2021-05-05 19:46:08 +09:00
|
|
|
const decoder = this.decoder;
|
|
|
|
const contexts = this.contexts;
|
|
|
|
const symbol =
|
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
|
|
|
(decoder.readBit(contexts, UNIFORM_CONTEXT) << 3) |
|
|
|
|
(decoder.readBit(contexts, UNIFORM_CONTEXT) << 2) |
|
|
|
|
(decoder.readBit(contexts, UNIFORM_CONTEXT) << 1) |
|
|
|
|
decoder.readBit(contexts, UNIFORM_CONTEXT);
|
|
|
|
if (symbol !== 0xa) {
|
|
|
|
throw new JpxError("Invalid segmentation symbol");
|
2014-03-03 05:12:26 +09:00
|
|
|
}
|
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-04-05 05:43:26 +09:00
|
|
|
};
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
return BitModel;
|
|
|
|
})();
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2014-03-10 06:31:55 +09:00
|
|
|
// Section F, Discrete wavelet transformation
|
2021-05-05 19:46:08 +09:00
|
|
|
const Transform = (function TransformClosure() {
|
2020-03-25 18:15:50 +09:00
|
|
|
// eslint-disable-next-line no-shadow
|
2014-03-10 06:31:55 +09:00
|
|
|
function Transform() {}
|
|
|
|
|
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
|
|
|
Transform.prototype.calculate = function transformCalculate(
|
|
|
|
subbands,
|
|
|
|
u0,
|
|
|
|
v0
|
|
|
|
) {
|
2021-05-05 19:46:08 +09:00
|
|
|
let ll = subbands[0];
|
|
|
|
for (let i = 1, ii = subbands.length; i < ii; i++) {
|
2014-04-16 17:40:04 +09:00
|
|
|
ll = this.iterate(ll, subbands[i], u0, v0);
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
return ll;
|
|
|
|
};
|
2014-02-25 02:43:12 +09:00
|
|
|
Transform.prototype.extend = function extend(buffer, offset, size) {
|
2014-03-10 06:31:55 +09:00
|
|
|
// Section F.3.7 extending... using max extension of 4
|
2021-05-05 19:46:08 +09:00
|
|
|
let i1 = offset - 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
|
|
|
j1 = offset + 1;
|
2021-05-05 19:46:08 +09:00
|
|
|
let i2 = offset + size - 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
|
|
|
j2 = offset + size;
|
2014-03-10 06:31:55 +09:00
|
|
|
buffer[i1--] = buffer[j1++];
|
|
|
|
buffer[j2++] = buffer[i2--];
|
|
|
|
buffer[i1--] = buffer[j1++];
|
|
|
|
buffer[j2++] = buffer[i2--];
|
|
|
|
buffer[i1--] = buffer[j1++];
|
|
|
|
buffer[j2++] = buffer[i2--];
|
|
|
|
buffer[i1] = buffer[j1];
|
|
|
|
buffer[j2] = buffer[i2];
|
2013-10-16 16:47: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
|
|
|
Transform.prototype.iterate = function Transform_iterate(
|
|
|
|
ll,
|
|
|
|
hl_lh_hh,
|
|
|
|
u0,
|
|
|
|
v0
|
|
|
|
) {
|
2021-05-05 19:47:01 +09:00
|
|
|
const llWidth = ll.width,
|
|
|
|
llHeight = ll.height;
|
|
|
|
let llItems = ll.items;
|
2021-05-05 19:46:08 +09:00
|
|
|
const width = hl_lh_hh.width;
|
|
|
|
const height = hl_lh_hh.height;
|
|
|
|
const items = hl_lh_hh.items;
|
|
|
|
let i, j, k, l, u, v;
|
2014-02-25 02:43:12 +09:00
|
|
|
|
2014-04-16 17:40:04 +09:00
|
|
|
// Interleave LL according to Section F.3.3
|
|
|
|
for (k = 0, i = 0; i < llHeight; i++) {
|
2014-04-06 00:27:18 +09:00
|
|
|
l = i * 2 * width;
|
2014-04-08 06:42:54 +09:00
|
|
|
for (j = 0; j < llWidth; j++, k++, l += 2) {
|
2012-04-05 05:43:26 +09:00
|
|
|
items[l] = llItems[k];
|
2014-02-25 02:43:12 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
2014-04-16 17:40:04 +09:00
|
|
|
// The LL band is not needed anymore.
|
|
|
|
llItems = ll.items = null;
|
2012-02-19 01:50:02 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const bufferPadding = 4;
|
|
|
|
const rowBuffer = new Float32Array(width + 2 * bufferPadding);
|
2012-01-12 11:08:46 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
// Section F.3.4 HOR_SR
|
2014-04-04 22:19:41 +09:00
|
|
|
if (width === 1) {
|
|
|
|
// if width = 1, when u0 even keep items as is, when odd divide by 2
|
|
|
|
if ((u0 & 1) !== 0) {
|
2014-04-08 06:42:54 +09:00
|
|
|
for (v = 0, k = 0; v < height; v++, k += width) {
|
2014-04-04 22:19:41 +09:00
|
|
|
items[k] *= 0.5;
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
|
|
|
}
|
2014-04-04 22:19:41 +09:00
|
|
|
} else {
|
2014-04-08 06:42:54 +09:00
|
|
|
for (v = 0, k = 0; v < height; v++, k += width) {
|
2014-04-04 22:19:41 +09:00
|
|
|
rowBuffer.set(items.subarray(k, k + width), bufferPadding);
|
2012-02-19 01:50:02 +09:00
|
|
|
|
2014-04-04 22:19:41 +09:00
|
|
|
this.extend(rowBuffer, bufferPadding, width);
|
2014-04-10 22:07:50 +09:00
|
|
|
this.filter(rowBuffer, bufferPadding, width);
|
2012-02-19 01:50:02 +09:00
|
|
|
|
2014-04-04 22:19:41 +09:00
|
|
|
items.set(
|
|
|
|
rowBuffer.subarray(bufferPadding, bufferPadding + 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
|
|
|
k
|
|
|
|
);
|
2014-04-04 22:19:41 +09:00
|
|
|
}
|
2014-02-25 02:43:12 +09:00
|
|
|
}
|
2012-02-19 01:50:02 +09:00
|
|
|
|
2014-02-25 02:43:12 +09:00
|
|
|
// Accesses to the items array can take long, because it may not fit into
|
|
|
|
// CPU cache and has to be fetched from main memory. Since subsequent
|
|
|
|
// accesses to the items array are not local when reading columns, we
|
|
|
|
// have a cache miss every time. To reduce cache misses, get up to
|
|
|
|
// 'numBuffers' items at a time and store them into the individual
|
|
|
|
// buffers. The colBuffers should be small enough to fit into CPU cache.
|
2021-05-05 19:46:08 +09:00
|
|
|
let numBuffers = 16;
|
|
|
|
const colBuffers = [];
|
2014-02-25 02:43:12 +09:00
|
|
|
for (i = 0; i < numBuffers; i++) {
|
|
|
|
colBuffers.push(new Float32Array(height + 2 * bufferPadding));
|
2012-04-05 05:43:26 +09:00
|
|
|
}
|
2021-05-05 19:46:08 +09:00
|
|
|
let 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
|
|
|
currentBuffer = 0;
|
2014-04-08 06:42:54 +09:00
|
|
|
ll = bufferPadding + height;
|
2012-04-05 05:43:26 +09:00
|
|
|
|
|
|
|
// Section F.3.5 VER_SR
|
2014-04-04 22:19:41 +09:00
|
|
|
if (height === 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
|
|
|
// if height = 1, when v0 even keep items as is, when odd divide by 2
|
2014-04-04 22:19:41 +09:00
|
|
|
if ((v0 & 1) !== 0) {
|
2014-04-08 06:42:54 +09:00
|
|
|
for (u = 0; u < width; u++) {
|
2014-04-04 22:19:41 +09:00
|
|
|
items[u] *= 0.5;
|
2012-02-19 01:50:02 +09:00
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2014-04-04 22:19:41 +09:00
|
|
|
} else {
|
2014-04-08 06:42:54 +09:00
|
|
|
for (u = 0; u < width; u++) {
|
2014-04-04 22:19:41 +09:00
|
|
|
// if we ran out of buffers, copy several image columns at once
|
|
|
|
if (currentBuffer === 0) {
|
|
|
|
numBuffers = Math.min(width - u, numBuffers);
|
|
|
|
for (k = u, l = bufferPadding; l < ll; k += width, l++) {
|
|
|
|
for (b = 0; b < numBuffers; b++) {
|
|
|
|
colBuffers[b][l] = items[k + b];
|
|
|
|
}
|
2014-02-25 02:43:12 +09:00
|
|
|
}
|
2014-04-04 22:19:41 +09:00
|
|
|
currentBuffer = numBuffers;
|
2014-02-25 02:43:12 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
|
2014-04-04 22:19:41 +09:00
|
|
|
currentBuffer--;
|
2021-05-05 19:46:08 +09:00
|
|
|
const buffer = colBuffers[currentBuffer];
|
2014-04-04 22:19:41 +09:00
|
|
|
this.extend(buffer, bufferPadding, height);
|
2014-04-10 22:07:50 +09:00
|
|
|
this.filter(buffer, bufferPadding, height);
|
2014-04-04 22:19:41 +09:00
|
|
|
|
|
|
|
// If this is last buffer in this group of buffers, flush all buffers.
|
|
|
|
if (currentBuffer === 0) {
|
|
|
|
k = u - numBuffers + 1;
|
|
|
|
for (l = bufferPadding; l < ll; k += width, l++) {
|
|
|
|
for (b = 0; b < numBuffers; b++) {
|
|
|
|
items[k + b] = colBuffers[b][l];
|
|
|
|
}
|
2014-02-25 02:43:12 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2014-02-25 02:43:12 +09:00
|
|
|
|
2012-04-05 05:43:26 +09:00
|
|
|
return {
|
2017-04-27 19:58:44 +09:00
|
|
|
width,
|
|
|
|
height,
|
|
|
|
items,
|
2012-04-05 05:43:26 +09:00
|
|
|
};
|
|
|
|
};
|
|
|
|
return Transform;
|
|
|
|
})();
|
|
|
|
|
|
|
|
// Section 3.8.2 Irreversible 9-7 filter
|
2021-05-05 19:47:01 +09:00
|
|
|
const IrreversibleTransform = (function IrreversibleTransformClosure() {
|
2020-03-25 18:15:50 +09:00
|
|
|
// eslint-disable-next-line no-shadow
|
2012-04-05 05:43:26 +09:00
|
|
|
function IrreversibleTransform() {
|
|
|
|
Transform.call(this);
|
2012-01-12 11:08:46 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
|
|
|
|
IrreversibleTransform.prototype = Object.create(Transform.prototype);
|
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
|
|
|
IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(
|
|
|
|
x,
|
|
|
|
offset,
|
|
|
|
length
|
|
|
|
) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const len = length >> 1;
|
2014-04-08 06:42:54 +09:00
|
|
|
offset = offset | 0;
|
2021-05-05 19:46:08 +09:00
|
|
|
let j, n, current, next;
|
2012-04-05 05:43:26 +09:00
|
|
|
|
2021-05-05 19:46:08 +09:00
|
|
|
const alpha = -1.586134342059924;
|
|
|
|
const beta = -0.052980118572961;
|
|
|
|
const gamma = 0.882911075530934;
|
|
|
|
const delta = 0.443506852043971;
|
|
|
|
const K = 1.230174104914001;
|
|
|
|
const K_ = 1 / K;
|
2012-04-05 05:43:26 +09:00
|
|
|
|
2014-04-04 22:19:41 +09:00
|
|
|
// step 1 is combined with step 3
|
2012-04-05 05:43:26 +09:00
|
|
|
|
|
|
|
// step 2
|
2014-04-10 22:07:50 +09:00
|
|
|
j = offset - 3;
|
|
|
|
for (n = len + 4; n--; j += 2) {
|
|
|
|
x[j] *= K_;
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
|
2014-04-04 22:19:41 +09:00
|
|
|
// step 1 & 3
|
2014-04-10 22:07:50 +09:00
|
|
|
j = offset - 2;
|
2016-11-01 23:04:21 +09:00
|
|
|
current = delta * x[j - 1];
|
2014-04-10 22:07:50 +09:00
|
|
|
for (n = len + 3; n--; j += 2) {
|
|
|
|
next = delta * x[j + 1];
|
|
|
|
x[j] = K * x[j] - current - next;
|
|
|
|
if (n--) {
|
|
|
|
j += 2;
|
|
|
|
current = delta * x[j + 1];
|
|
|
|
x[j] = K * x[j] - current - next;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
|
|
|
|
// step 4
|
2014-04-10 22:07:50 +09:00
|
|
|
j = offset - 1;
|
|
|
|
current = gamma * x[j - 1];
|
|
|
|
for (n = len + 2; n--; j += 2) {
|
|
|
|
next = gamma * x[j + 1];
|
|
|
|
x[j] -= current + next;
|
|
|
|
if (n--) {
|
|
|
|
j += 2;
|
|
|
|
current = gamma * x[j + 1];
|
|
|
|
x[j] -= current + next;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
|
|
|
|
// step 5
|
2014-04-10 22:07:50 +09:00
|
|
|
j = offset;
|
|
|
|
current = beta * x[j - 1];
|
|
|
|
for (n = len + 1; n--; j += 2) {
|
|
|
|
next = beta * x[j + 1];
|
|
|
|
x[j] -= current + next;
|
|
|
|
if (n--) {
|
|
|
|
j += 2;
|
|
|
|
current = beta * x[j + 1];
|
|
|
|
x[j] -= current + next;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
|
|
|
|
// step 6
|
2014-04-10 22:07:50 +09:00
|
|
|
if (len !== 0) {
|
|
|
|
j = offset + 1;
|
|
|
|
current = alpha * x[j - 1];
|
|
|
|
for (n = len; n--; j += 2) {
|
|
|
|
next = alpha * x[j + 1];
|
|
|
|
x[j] -= current + next;
|
|
|
|
if (n--) {
|
|
|
|
j += 2;
|
|
|
|
current = alpha * x[j + 1];
|
|
|
|
x[j] -= current + next;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
return IrreversibleTransform;
|
|
|
|
})();
|
|
|
|
|
|
|
|
// Section 3.8.1 Reversible 5-3 filter
|
2021-05-05 19:47:01 +09:00
|
|
|
const ReversibleTransform = (function ReversibleTransformClosure() {
|
2020-03-25 18:15:50 +09:00
|
|
|
// eslint-disable-next-line no-shadow
|
2012-04-05 05:43:26 +09:00
|
|
|
function ReversibleTransform() {
|
|
|
|
Transform.call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
ReversibleTransform.prototype = Object.create(Transform.prototype);
|
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
|
|
|
ReversibleTransform.prototype.filter = function reversibleTransformFilter(
|
|
|
|
x,
|
|
|
|
offset,
|
|
|
|
length
|
|
|
|
) {
|
2021-05-05 19:46:08 +09:00
|
|
|
const len = length >> 1;
|
2014-04-08 06:42:54 +09:00
|
|
|
offset = offset | 0;
|
2021-05-05 19:46:08 +09:00
|
|
|
let j, n;
|
2012-04-05 05:43:26 +09:00
|
|
|
|
2014-04-08 06:42:54 +09:00
|
|
|
for (j = offset, n = len + 1; n--; j += 2) {
|
2014-04-10 22:07:50 +09:00
|
|
|
x[j] -= (x[j - 1] + x[j + 1] + 2) >> 2;
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
|
2014-04-08 06:42:54 +09:00
|
|
|
for (j = offset + 1, n = len; n--; j += 2) {
|
2014-04-10 22:07:50 +09:00
|
|
|
x[j] += (x[j - 1] + x[j + 1]) >> 1;
|
2014-03-10 06:31:55 +09:00
|
|
|
}
|
2012-04-05 05:43:26 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
return ReversibleTransform;
|
|
|
|
})();
|
|
|
|
|
2012-01-12 11:08:46 +09:00
|
|
|
return JpxImage;
|
|
|
|
})();
|
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 { JpxImage };
|