pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1784581 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxDecoderStream.java
Date Mon, 27 Feb 2017 15:10:14 GMT
Author: tilman
Date: Mon Feb 27 15:10:14 2017
New Revision: 1784581

URL: http://svn.apache.org/viewvc?rev=1784581&view=rev
Log:
PDFBOX-3704: update twelvemonkeys changes made after May 7, 2016 up to commit ceb2c82

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxDecoderStream.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxDecoderStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxDecoderStream.java?rev=1784581&r1=1784580&r2=1784581&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxDecoderStream.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxDecoderStream.java
Mon Feb 27 15:10:14 2017
@@ -67,6 +67,7 @@ final class CCITTFaxDecoderStream extend
     private int[] changesCurrentRow;
     private int changesReferenceRowCount;
     private int changesCurrentRowCount;
+    private int lastChangingElement = 0;
 
     private boolean optionG32D = false;
 
@@ -194,7 +195,7 @@ final class CCITTFaxDecoderStream extend
                         case VALUE_PASSMODE:
                             int pChangingElement = getNextChangingElement(index, white) +
1;
 
-                            if (pChangingElement >= changesReferenceRowCount || pChangingElement
== -1) {
+                            if (pChangingElement >= changesReferenceRowCount) {
                                 index = columns;
                             }
                             else {
@@ -228,10 +229,18 @@ final class CCITTFaxDecoderStream extend
     }
 
     private int getNextChangingElement(final int a0, final boolean white) {
-        int start = white ? 0 : 1;
+        int start = (lastChangingElement & 0xFFFFFFFE) + (white ? 0 : 1);
+        if (start > 2) {
+            start -= 2;
+        }
+
+        if (a0 == 0) {
+            return start;
+        }
 
         for (int i = start; i < changesReferenceRowCount; i += 2) {
-            if (a0 < changesReferenceRow[i] || (a0 == 0 && changesReferenceRow[i]
== 0)) {
+            if (a0 < changesReferenceRow[i]) {
+                lastChangingElement = i;
                 return i;
             }
         }
@@ -299,7 +308,8 @@ final class CCITTFaxDecoderStream extend
         int index = 0;
         boolean white = true;
 
-        for (int i = 0; i <= changesCurrentRowCount; i++) {
+            lastChangingElement = 0;
+            for (int i = 0; i <= changesCurrentRowCount; i++) {
             int nextChange = columns;
 
             if (i != changesCurrentRowCount) {



Mime
View raw message