added fastlz support in record device
authorMatthias Kramm <kramm@quiss.org>
Wed, 31 Mar 2010 02:58:44 +0000 (19:58 -0700)
committerMatthias Kramm <kramm@quiss.org>
Wed, 31 Mar 2010 02:58:44 +0000 (19:58 -0700)
lib/devices/record.c
lib/devices/render.c

index f79d32c..4365230 100644 (file)
@@ -39,6 +39,9 @@
 #include "../log.h"
 #include "../os.h"
 #include "../png.h"
 #include "../log.h"
 #include "../os.h"
 #include "../png.h"
+#ifdef HAVE_FASTLZ
+#include "../fastlz.h"
+#endif
 #include "record.h"
 
 //#define STATS
 #include "record.h"
 
 //#define STATS
@@ -176,6 +179,8 @@ static void dumpImage(writer_t*w, state_t*state, gfximage_t*img)
     //45.2% images (3055340 bytes) (without filter)
     //39.9% images (2458904 bytes) (with filter, Z_BEST_SPEED)
     //35.3% images (2027305 bytes) (with filter, Z_BEST_COMPRESSION)
     //45.2% images (3055340 bytes) (without filter)
     //39.9% images (2458904 bytes) (with filter, Z_BEST_SPEED)
     //35.3% images (2027305 bytes) (with filter, Z_BEST_COMPRESSION)
+    //48.0% images (3480495 bytes) (with filter, fastlz)
+
     unsigned char*filter = malloc(img->height);
     int y;
     gfxcolor_t*image = malloc(img->width*img->height*sizeof(gfxcolor_t));
     unsigned char*filter = malloc(img->height);
     int y;
     gfxcolor_t*image = malloc(img->width*img->height*sizeof(gfxcolor_t));
@@ -187,7 +192,13 @@ static void dumpImage(writer_t*w, state_t*state, gfximage_t*img)
     int size = img->width*img->height;
     uLongf compressdata_size = compressBound(size*sizeof(gfxcolor_t));
     void*compressdata = malloc(compressdata_size);
     int size = img->width*img->height;
     uLongf compressdata_size = compressBound(size*sizeof(gfxcolor_t));
     void*compressdata = malloc(compressdata_size);
+
+#ifdef HAVE_FASTLZ
+    compressdata_size = fastlz_compress_level(1, (void*)image, size*sizeof(gfxcolor_t), compressdata);
+#else
     compress2(compressdata, &compressdata_size, (void*)image, sizeof(gfxcolor_t)*size, Z_BEST_SPEED);
     compress2(compressdata, &compressdata_size, (void*)image, sizeof(gfxcolor_t)*size, Z_BEST_SPEED);
+#endif
+
     writer_writeU32(w, compressdata_size);
     w->write(w, filter, img->height);
     w->write(w, compressdata, compressdata_size);
     writer_writeU32(w, compressdata_size);
     w->write(w, filter, img->height);
     w->write(w, compressdata, compressdata_size);
@@ -213,7 +224,13 @@ static gfximage_t readImage(reader_t*r, state_t*state)
     unsigned char*filter = malloc(img.height);
     r->read(r, filter, img.height);
     r->read(r, compressdata, compressdata_size);
     unsigned char*filter = malloc(img.height);
     r->read(r, filter, img.height);
     r->read(r, compressdata, compressdata_size);
+   
+#ifdef HAVE_FASTLZ
+    fastlz_decompress(compressdata, compressdata_size, (void*)img.data, size);
+#else
     uncompress((void*)img.data, &size, compressdata, compressdata_size);
     uncompress((void*)img.data, &size, compressdata, compressdata_size);
+#endif
+
     int y;
     unsigned char*line = malloc(img.width*sizeof(gfxcolor_t));
     for(y=0;y<img.height;y++) {
     int y;
     unsigned char*line = malloc(img.width*sizeof(gfxcolor_t));
     for(y=0;y<img.height;y++) {
index ae7528a..250356a 100644 (file)
@@ -25,9 +25,8 @@
 #include "../gfxdevice.h"
 #include "../gfxtools.h"
 #include "../mem.h"
 #include "../gfxdevice.h"
 #include "../gfxtools.h"
 #include "../mem.h"
-#define PNG_INLINE_EXPORTS
 #include "../types.h"
 #include "../types.h"
-#include "../png.c"
+#include "../png.h"
 #include "../log.h"
 #include "render.h"
 
 #include "../log.h"
 #include "render.h"