Skip to content

Commit

Permalink
[JPEG 2000] Add support for resetContextProbabilities (bug 1731483)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmuizel authored and Snuffleupagus committed Feb 26, 2022
1 parent 4157d77 commit 4317e00
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/core/jpx.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,6 @@ class JpxImage {
if (cod.selectiveArithmeticCodingBypass) {
unsupported.push("selectiveArithmeticCodingBypass");
}
if (cod.resetContextProbabilities) {
unsupported.push("resetContextProbabilities");
}
if (cod.terminationOnEachCodingPass) {
unsupported.push("terminationOnEachCodingPass");
}
Expand Down Expand Up @@ -1290,7 +1287,8 @@ function copyCoefficients(
delta,
mb,
reversible,
segmentationSymbolUsed
segmentationSymbolUsed,
resetContextProbabilities
) {
const x0 = subband.tbx0;
const y0 = subband.tby0;
Expand Down Expand Up @@ -1356,6 +1354,11 @@ function copyCoefficients(
}
break;
}

if (resetContextProbabilities) {
bitModel.reset();
}

currentCodingpassType = (currentCodingpassType + 1) % 3;
}

Expand Down Expand Up @@ -1404,6 +1407,7 @@ function transformTile(context, tile, c) {
const scalarExpounded = quantizationParameters.scalarExpounded;
const guardBits = quantizationParameters.guardBits;
const segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
const resetContextProbabilities = codingStyleParameters.resetContextProbabilities;
const precision = context.components[c].precision;

const reversible = codingStyleParameters.reversibleTransformation;
Expand Down Expand Up @@ -1455,7 +1459,8 @@ function transformTile(context, tile, c) {
delta,
mb,
reversible,
segmentationSymbolUsed
segmentationSymbolUsed,
resetContextProbabilities
);
}
subbandCoefficients.push({
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@
!issue14117.pdf
!issue5070.pdf
!issue5238.pdf
!jp2k-resetprob.pdf
!issue5244.pdf
!issue5291.pdf
!issue4398.pdf
Expand Down
Binary file added test/pdfs/jp2k-resetprob.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4922,6 +4922,13 @@
"rounds": 1,
"type": "eq"
},
{ "id": "jpx-resetContextProbabilities",
"file": "pdfs/jp2k-resetprob.pdf",
"md5": "fc9fb23e0a08d985b70cfb32fa9e9ca1",
"rounds": 1,
"type": "eq",
"about": "Fixes one part of bug 1731483."
},
{ "id": "bug1140761",
"file": "pdfs/bug1140761.pdf",
"md5": "b74eced7634d4f248dc6265f8225d432",
Expand Down

0 comments on commit 4317e00

Please # to comment.