This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pdfbox-jbig2.git
The following commit(s) were added to refs/heads/master by this push:
new 08ecd9f PDFBOX-6155: split method to clarify 7.4.2.2 Steps 4 and 5
08ecd9f is described below
commit 08ecd9f5220e32a2b7eb8a41012dbdc05acc6816
Author: Maruan Sahyoun <[email protected]>
AuthorDate: Sun Apr 19 19:44:54 2026 +0200
PDFBOX-6155: split method to clarify 7.4.2.2 Steps 4 and 5
---
.../pdfbox/jbig2/segments/SymbolDictionary.java | 67 ++++++++--------------
1 file changed, 25 insertions(+), 42 deletions(-)
diff --git
a/src/main/java/org/apache/pdfbox/jbig2/segments/SymbolDictionary.java
b/src/main/java/org/apache/pdfbox/jbig2/segments/SymbolDictionary.java
index dd6cf1d..d2e1ff1 100644
--- a/src/main/java/org/apache/pdfbox/jbig2/segments/SymbolDictionary.java
+++ b/src/main/java/org/apache/pdfbox/jbig2/segments/SymbolDictionary.java
@@ -393,7 +393,8 @@ public class SymbolDictionary implements Dictionary
if (!isHuffmanEncoded)
{
- setCodingStatistics();
+ resetBitmapCodingStatistics();
+ resetIntegerCoderStatistics();
}
/* 6.5.5 1) */
@@ -505,55 +506,37 @@ public class SymbolDictionary implements Dictionary
return exportSymbols;
}
- private void setCodingStatistics() throws IOException
+ /**
+ * Step 4 (§7.4.2.2): Reset arithmetic coding statistics for the generic
+ * region and generic refinement region decoding procedures to zero.
+ * Only the bitmap CX is reset here; integer coder contexts are separate
(step 5).
+ */
+ private void resetBitmapCodingStatistics()
{
- if (cxIADT == null)
- {
- cxIADT = new CX(512, 1);
- }
-
- if (cxIADH == null)
- {
- cxIADH = new CX(512, 1);
- }
-
- if (cxIADW == null)
- {
- cxIADW = new CX(512, 1);
- }
-
- if (cxIAAI == null)
- {
- cxIAAI = new CX(512, 1);
- }
+ cx = new CX(65536, 1);
+ }
- if (cxIAEX == null)
- {
- cxIAEX = new CX(512, 1);
- }
+ /**
+ * Step 5 (§7.4.2.2): Reset arithmetic coding statistics for all contexts
+ * of all arithmetic integer coders to zero.
+ */
+ private void resetIntegerCoderStatistics() throws IOException
+ {
+ cxIADT = new CX(512, 1);
+ cxIADH = new CX(512, 1);
+ cxIADW = new CX(512, 1);
+ cxIAAI = new CX(512, 1);
+ cxIAEX = new CX(512, 1);
- if (useRefinementAggregation && cxIAID == null)
+ if (useRefinementAggregation)
{
- cxIAID = new CX(1 << sbSymCodeLen, 1);
+ cxIAID = new CX(1 << sbSymCodeLen, 1);
cxIARDX = new CX(512, 1);
cxIARDY = new CX(512, 1);
}
- if (cx == null)
- {
- cx = new CX(65536, 1);
- }
-
- if (arithmeticDecoder == null)
- {
- arithmeticDecoder = new ArithmeticDecoder(subInputStream);
- }
-
- if (iDecoder == null)
- {
- iDecoder = new ArithmeticIntegerDecoder(arithmeticDecoder);
- }
-
+ arithmeticDecoder = new ArithmeticDecoder(subInputStream);
+ iDecoder = new ArithmeticIntegerDecoder(arithmeticDecoder);
}
private void decodeHeightClassBitmap(final Bitmap
heightClassCollectiveBitmap,