[poppler] 3 commits - goo/JpegWriter.cc goo/JpegWriter.h poppler/JBIG2Stream.cc poppler/XRef.cc poppler/XRef.h splash/SplashBitmap.cc splash/SplashBitmap.h

Albert Astals Cid aacid at kemper.freedesktop.org
Thu May 27 12:39:15 PDT 2010


 goo/JpegWriter.cc      |   15 +++++++++++++--
 goo/JpegWriter.h       |    4 ++++
 poppler/JBIG2Stream.cc |    2 +-
 poppler/XRef.cc        |   21 +++++++++++++++------
 poppler/XRef.h         |    7 ++++---
 splash/SplashBitmap.cc |   18 +++++++++---------
 splash/SplashBitmap.h  |    4 ++++
 7 files changed, 50 insertions(+), 21 deletions(-)

New commits:
commit 241c338facb45641ef1a271c904355a014bbf28d
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu May 27 20:37:55 2010 +0100

    Allow quality & progressive mode to be utilised in JpegWriter

diff --git a/goo/JpegWriter.cc b/goo/JpegWriter.cc
index 64df68a..c9b7052 100644
--- a/goo/JpegWriter.cc
+++ b/goo/JpegWriter.cc
@@ -6,6 +6,7 @@
 //
 // Copyright (C) 2009 Stefan Thomas <thomas at eload24.com>
 // Copyright (C) 2010 Adrian Johnson <ajohnson at redneon.com>
+// Copyright (C) 2010 Harry Roberts <harry.roberts at midnight-labs.org>
 //
 //========================================================================
 
@@ -26,7 +27,13 @@ void outputMessage(j_common_ptr cinfo)
 	error(-1, "%s", buffer);
 }
 
+JpegWriter::JpegWriter(int q, bool p)
+: progressive(p), quality(q)
+{
+}
+
 JpegWriter::JpegWriter()
+: progressive(false), quality(-1)
 {
 }
 
@@ -59,10 +66,14 @@ bool JpegWriter::init(FILE *f, int width, int height, int hDPI, int vDPI)
 	jpeg_set_defaults(&cinfo);
 	
 	// Set quality
-	//jpeg_set_quality(&cinfo, 80, true);
+	if( quality >= 0 && quality <= 100 ) { 
+		jpeg_set_quality(&cinfo, quality, true);
+	}
 	
 	// Use progressive mode
-	//jpeg_simple_progression(&cinfo);
+	if( progressive) {
+		jpeg_simple_progression(&cinfo);
+	}
 	
 	// Get ready for data
 	jpeg_start_compress(&cinfo, TRUE);
diff --git a/goo/JpegWriter.h b/goo/JpegWriter.h
index 36049b5..3b98da2 100644
--- a/goo/JpegWriter.h
+++ b/goo/JpegWriter.h
@@ -7,6 +7,7 @@
 // Copyright (C) 2009 Stefan Thomas <thomas at eload24.com>
 // Copyright (C) 2010 Adrian Johnson <ajohnson at redneon.com>
 // Copyright (C) 2010 Jürg Billeter <j at bitron.ch>
+// Copyright (C) 2010 Harry Roberts <harry.roberts at midnight-labs.org>
 //
 //========================================================================
 
@@ -27,6 +28,7 @@ extern "C" {
 class JpegWriter : public ImgWriter
 {
 	public:
+		JpegWriter(int quality, bool progressive);
 		JpegWriter();
 		~JpegWriter();
 		
@@ -38,6 +40,8 @@ class JpegWriter : public ImgWriter
 		bool close();
 	
 	private:
+		bool progressive;
+		int quality;
 		struct jpeg_compress_struct cinfo;
 		struct jpeg_error_mgr jerr;
 };
diff --git a/splash/SplashBitmap.cc b/splash/SplashBitmap.cc
index 7e99fc8..f983439 100644
--- a/splash/SplashBitmap.cc
+++ b/splash/SplashBitmap.cc
@@ -16,6 +16,7 @@
 // Copyright (C) 2009 Shen Liang <shenzhuxi at gmail.com>
 // Copyright (C) 2009 Stefan Thomas <thomas at eload24.com>
 // Copyright (C) 2010 Adrian Johnson <ajohnson at redneon.com>
+// Copyright (C) 2010 Harry Roberts <harry.roberts at midnight-labs.org>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -287,6 +288,7 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, char *fileN
 
 SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI) {
   ImgWriter *writer;
+	SplashError e;
   
   switch (format) {
     #ifdef ENABLE_LIBPNG
@@ -307,14 +309,19 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, in
       error(-1, "Support for this image type not compiled in");
       return splashErrGeneric;
   }
-  
+
+	e = writeImgFile(writer, f, hDPI, vDPI);
+	delete writer;
+	return e;
+}
+
+SplashError SplashBitmap::writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int vDPI) {
   if (mode != splashModeRGB8 && mode != splashModeMono8 && mode != splashModeMono1 && mode != splashModeXBGR8) {
     error(-1, "unsupported SplashBitmap mode");
     return splashErrGeneric;
   }
 
   if (!writer->init(f, width, height, hDPI, vDPI)) {
-    delete writer;
     return splashErrGeneric;
   }
 
@@ -331,7 +338,6 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, in
       }
       if (!writer->writePointers(row_pointers, height)) {
         delete[] row_pointers;
-        delete writer;
         return splashErrGeneric;
       }
       delete[] row_pointers;
@@ -351,7 +357,6 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, in
 
         if (!writer->writeRow(&row)) {
           delete[] row;
-          delete writer;
           return splashErrGeneric;
         }
       }
@@ -372,7 +377,6 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, in
 
         if (!writer->writeRow(&row)) {
           delete[] row;
-          delete writer;
           return splashErrGeneric;
         }
       }
@@ -393,7 +397,6 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, in
 
         if (!writer->writeRow(&row)) {
           delete[] row;
-          delete writer;
           return splashErrGeneric;
         }
       }
@@ -407,11 +410,8 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, in
   }
   
   if (writer->close()) {
-    delete writer;
     return splashErrGeneric;
   }
 
-  delete writer;
-
   return splashOk;
 }
diff --git a/splash/SplashBitmap.h b/splash/SplashBitmap.h
index c25e325..e741a91 100644
--- a/splash/SplashBitmap.h
+++ b/splash/SplashBitmap.h
@@ -16,6 +16,7 @@
 // Copyright (C) 2009 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2009 Stefan Thomas <thomas at eload24.com>
 // Copyright (C) 2010 Adrian Johnson <ajohnson at redneon.com>
+// Copyright (C) 2010 Harry Roberts <harry.roberts at midnight-labs.org>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -32,6 +33,8 @@
 #include "SplashTypes.h"
 #include <stdio.h>
 
+class ImgWriter;
+
 //------------------------------------------------------------------------
 // SplashBitmap
 //------------------------------------------------------------------------
@@ -62,6 +65,7 @@ public:
   
   SplashError writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI);
   SplashError writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI);
+  SplashError writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int vDPI);
 
   void getPixel(int x, int y, SplashColorPtr pixel);
   Guchar getAlpha(int x, int y);
commit 9eda6e8aaae412a9882141d1b5b8c7bf0c823c68
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue May 25 23:44:30 2010 +0100

    Do not follow loops blindly
    
    Fixes crash in pdf in bug 28172

diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index 3ab23d9..a4e3941 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -15,7 +15,7 @@
 //
 // Copyright (C) 2005 Dan Sheridan <dan.sheridan at postman.org.uk>
 // Copyright (C) 2005 Brad Hards <bradh at frogmouth.net>
-// Copyright (C) 2006, 2008 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006, 2008, 2010 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2007-2008 Julien Rebetez <julienr at svn.gnome.org>
 // Copyright (C) 2007 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2009 Ilya Gorenbein <igorenbein at finjan.com>
@@ -267,7 +267,8 @@ XRef::XRef(BaseStream *strA) {
 
   // read the xref table
   } else {
-    while (readXRef(&pos)) ;
+    GooVector<Guint> followedXRefStm;
+    while (readXRef(&pos, &followedXRefStm)) ;
 
     // if there was a problem with the xref table,
     // try to reconstruct it
@@ -346,7 +347,7 @@ Guint XRef::getStartXref() {
 
 // Read one xref table section.  Also reads the associated trailer
 // dictionary, and returns the prev pointer (if any).
-GBool XRef::readXRef(Guint *pos) {
+GBool XRef::readXRef(Guint *pos, GooVector<Guint> *followedXRefStm) {
   Parser *parser;
   Object obj;
   GBool more;
@@ -362,7 +363,7 @@ GBool XRef::readXRef(Guint *pos) {
   // parse an old-style xref table
   if (obj.isCmd("xref")) {
     obj.free();
-    more = readXRefTable(parser, pos);
+    more = readXRefTable(parser, pos, followedXRefStm);
 
   // parse an xref stream
   } else if (obj.isInt()) {
@@ -395,7 +396,7 @@ GBool XRef::readXRef(Guint *pos) {
   return gFalse;
 }
 
-GBool XRef::readXRefTable(Parser *parser, Guint *pos) {
+GBool XRef::readXRefTable(Parser *parser, Guint *pos, GooVector<Guint> *followedXRefStm) {
   XRefEntry entry;
   GBool more;
   Object obj, obj2;
@@ -509,7 +510,15 @@ GBool XRef::readXRefTable(Parser *parser, Guint *pos) {
   // check for an 'XRefStm' key
   if (obj.getDict()->lookup("XRefStm", &obj2)->isInt()) {
     pos2 = (Guint)obj2.getInt();
-    readXRef(&pos2);
+    for (uint i = 0; ok == gTrue && i < followedXRefStm->size(); ++i) {
+      if (followedXRefStm->at(i) == pos2) {
+        ok = gFalse;
+      }
+    }
+    if (ok) {
+      followedXRefStm->push_back(pos2);
+      readXRef(&pos2, followedXRefStm);
+    }
     if (!ok) {
       obj2.free();
       goto err1;
diff --git a/poppler/XRef.h b/poppler/XRef.h
index 2dbd469..36546fc 100644
--- a/poppler/XRef.h
+++ b/poppler/XRef.h
@@ -14,7 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2005 Brad Hards <bradh at frogmouth.net>
-// Copyright (C) 2006, 2008 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006, 2008, 2010 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2007-2008 Julien Rebetez <julienr at svn.gnome.org>
 // Copyright (C) 2007 Carlos Garcia Campos <carlosgc at gnome.org>
 //
@@ -31,6 +31,7 @@
 #endif
 
 #include "goo/gtypes.h"
+#include "goo/GooVector.h"
 #include "Object.h"
 
 class Dict;
@@ -156,8 +157,8 @@ private:
   GBool ownerPasswordOk;	// true if owner password is correct
 
   Guint getStartXref();
-  GBool readXRef(Guint *pos);
-  GBool readXRefTable(Parser *parser, Guint *pos);
+  GBool readXRef(Guint *pos, GooVector<Guint> *followedXRefStm);
+  GBool readXRefTable(Parser *parser, Guint *pos, GooVector<Guint> *followedXRefStm);
   GBool readXRefStreamSection(Stream *xrefStr, int *w, int first, int n);
   GBool readXRefStream(Stream *xrefStr, Guint *pos);
   GBool constructXRef();
commit bbee6e0c8c9b181f8d19c167c867d74a765685fb
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue May 25 23:13:38 2010 +0100

    update copyright

diff --git a/poppler/JBIG2Stream.cc b/poppler/JBIG2Stream.cc
index f16ad58..95123a6 100644
--- a/poppler/JBIG2Stream.cc
+++ b/poppler/JBIG2Stream.cc
@@ -15,7 +15,7 @@
 //
 // Copyright (C) 2006 Raj Kumar <rkumar at archive.org>
 // Copyright (C) 2006 Paul Walmsley <paul at booyaka.com>
-// Copyright (C) 2006-2009 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006-2010 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2009 David Benjamin <davidben at mit.edu>
 //
 // To see a description of the changes please see the Changelog file that


More information about the poppler mailing list