[poppler] Branch 'xpdf303merge' - 4 commits - poppler/JBIG2Stream.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Mon Sep 5 11:24:22 PDT 2011


 poppler/JBIG2Stream.cc |   45 +++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)

New commits:
commit 28adb3884dafcf1d36aae1ec05855b10b22aa4ae
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Sep 5 20:26:57 2011 +0200

    xpdf303: Change bpp calculation

diff --git a/poppler/JBIG2Stream.cc b/poppler/JBIG2Stream.cc
index 9f46706..e1ae481 100644
--- a/poppler/JBIG2Stream.cc
+++ b/poppler/JBIG2Stream.cc
@@ -2569,11 +2569,17 @@ void JBIG2Stream::readHalftoneRegionSeg(Guint segNum, GBool imm,
   }
 
   patternDict = (JBIG2PatternDict *)seg;
-  bpp = 0;
-  i = 1;
-  while (i < patternDict->getSize()) {
-    ++bpp;
-    i <<= 1;
+  i = patternDict->getSize();
+  if (i <= 1) {
+    bpp = 0;
+  } else {
+    --i;
+    bpp = 0;
+    // i = floor((size-1) / 2^bpp)
+    while (i > 0) {
+      ++bpp;
+      i >>= 1;
+    }
   }
   patW = patternDict->getBitmap(0)->getWidth();
   patH = patternDict->getBitmap(0)->getHeight();
commit c163a82f45d869b7c35a1a7141ab237507671f82
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Sep 5 20:25:04 2011 +0200

    xpdf303: Change symCodeLen calculation

diff --git a/poppler/JBIG2Stream.cc b/poppler/JBIG2Stream.cc
index 5807f51..9f46706 100644
--- a/poppler/JBIG2Stream.cc
+++ b/poppler/JBIG2Stream.cc
@@ -2018,11 +2018,17 @@ void JBIG2Stream::readTextRegionSeg(Guint segNum, GBool imm,
       return;
     }
   }
-  symCodeLen = 0;
-  i = 1;
-  while (i < numSyms) {
-    ++symCodeLen;
-    i <<= 1;
+  i = numSyms;
+  if (i <= 1) {
+    symCodeLen = huff ? 1 : 0;
+  } else {
+    --i;
+    symCodeLen = 0;
+    // i = floor((numSyms-1) / 2^symCodeLen)
+    while (i > 0) {
+      ++symCodeLen;
+      i >>= 1;
+    }
   }
 
   // get the symbol bitmaps
commit 1d1a985101c26f90bde8340dcfae3d6a1e0a08ba
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Sep 5 20:20:03 2011 +0200

    xpdf303: symCodeLen calculation fix

diff --git a/poppler/JBIG2Stream.cc b/poppler/JBIG2Stream.cc
index 1ae48e2..5807f51 100644
--- a/poppler/JBIG2Stream.cc
+++ b/poppler/JBIG2Stream.cc
@@ -1603,10 +1603,14 @@ GBool JBIG2Stream::readSymbolDictSeg(Guint segNum, Guint length,
 
   // compute symbol code length, per 6.5.8.2.3
   //  symCodeLen = ceil( log2( numInputSyms + numNewSyms ) )
-  symCodeLen = 1;
-  if (likely(numInputSyms + numNewSyms > 0)) { // don't fail too badly if the sum is 0
-    i = (numInputSyms + numNewSyms - 1) >> 1;
-    while (i) {
+  i = numInputSyms + numNewSyms;
+  if (i <= 1) {
+    symCodeLen = huff ? 1 : 0;
+  } else {
+    --i;
+    symCodeLen = 0;
+    // i = floor((numSyms-1) / 2^symCodeLen)
+    while (i > 0) {
       ++symCodeLen;
       i >>= 1;
     }
commit 5c0274572c65972434293a30f3ba5afd3905005f
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon Sep 5 20:07:54 2011 +0200

    xpdf303: add line accessor

diff --git a/poppler/JBIG2Stream.cc b/poppler/JBIG2Stream.cc
index 96c8ad3..1ae48e2 100644
--- a/poppler/JBIG2Stream.cc
+++ b/poppler/JBIG2Stream.cc
@@ -675,6 +675,7 @@ public:
   void clearToOne();
   int getWidth() { return w; }
   int getHeight() { return h; }
+  int getLineSize() { return line; }
   int getPixel(int x, int y)
     { return (x < 0 || x >= w || y < 0 || y >= h) ? 0 :
              (data[y * line + (x >> 3)] >> (7 - (x & 7))) & 1; }


More information about the poppler mailing list