[poppler] poppler/DCTStream.cc poppler/DCTStream.h poppler/Stream.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Thu Jan 15 13:18:18 PST 2009


 poppler/DCTStream.cc |   17 ++++++++---------
 poppler/DCTStream.h  |    3 ++-
 poppler/Stream.cc    |    3 ++-
 3 files changed, 12 insertions(+), 11 deletions(-)

New commits:
commit d65dd23752ec14635d0d224afa7dd605f98a10a4
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Jan 15 22:17:14 2009 +0100

    Minor optimizations

diff --git a/poppler/DCTStream.cc b/poppler/DCTStream.cc
index 2b4f9c1..906f3ca 100644
--- a/poppler/DCTStream.cc
+++ b/poppler/DCTStream.cc
@@ -89,7 +89,8 @@ void DCTStream::init()
   jpeg_std_error(&jerr);
   jerr.error_exit = &exitErrorHandler;
   cinfo.err = &jerr;
-  x = 0;
+  current = NULL;
+  limit = NULL;
   row_buffer = NULL;
 }
 
@@ -150,26 +151,24 @@ int DCTStream::getChar() {
   
   int c;
 
-  if (x == 0) {
+  if (current == limit) {
     if (cinfo.output_scanline < cinfo.output_height)
     {
       if (!jpeg_read_scanlines(&cinfo, row_buffer, 1)) return EOF;
+      current = &row_buffer[0][0];
+      limit = &row_buffer[0][cinfo.output_width * cinfo.output_components];
     }
     else return EOF;
   }
-  c = row_buffer[0][x];
-  x++;
-  if (x == cinfo.output_width * cinfo.output_components)
-    x = 0;
+  c = *current;
+  ++current;
   return c;
 }
 
 int DCTStream::lookChar() {
   if (src.abort) return EOF;
   
-  int c;
-  c = row_buffer[0][x];
-  return c;
+  return *current;
 }
 
 GooString *DCTStream::getPSFilter(int psLevel, char *indent) {
diff --git a/poppler/DCTStream.h b/poppler/DCTStream.h
index 772dda5..d04345b 100644
--- a/poppler/DCTStream.h
+++ b/poppler/DCTStream.h
@@ -68,7 +68,8 @@ public:
 private:
   void init();
 
-  unsigned int x;
+  JSAMPLE *current;
+  JSAMPLE *limit;
   struct jpeg_decompress_struct cinfo;
   struct jpeg_error_mgr jerr;
   struct str_src_mgr src;
diff --git a/poppler/Stream.cc b/poppler/Stream.cc
index 385e545..72fc0ab 100644
--- a/poppler/Stream.cc
+++ b/poppler/Stream.cc
@@ -447,8 +447,9 @@ Guchar *ImageStream::getLine() {
       imgLine[i+7] = (Guchar)(c & 1);
     }
   } else if (nBits == 8) {
+    Guchar *line = imgLine;
     for (i = 0; i < nVals; ++i) {
-      imgLine[i] = str->getChar();
+      *line++ = str->getChar();
     }
   } else if (nBits == 16) {
     // this is a hack to support 16 bits images, everywhere


More information about the poppler mailing list