From e321a0df2c56ff61602b13c1440465911b231f89 Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Tue, 30 Mar 2010 19:58:44 -0700 Subject: [PATCH] added fastlz support in record device --- lib/devices/record.c | 17 +++++++++++++++++ lib/devices/render.c | 3 +-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/devices/record.c b/lib/devices/record.c index f79d32c..4365230 100644 --- a/lib/devices/record.c +++ b/lib/devices/record.c @@ -39,6 +39,9 @@ #include "../log.h" #include "../os.h" #include "../png.h" +#ifdef HAVE_FASTLZ +#include "../fastlz.h" +#endif #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) + //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)); @@ -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); + +#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); +#endif + 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); + +#ifdef HAVE_FASTLZ + fastlz_decompress(compressdata, compressdata_size, (void*)img.data, size); +#else uncompress((void*)img.data, &size, compressdata, compressdata_size); +#endif + int y; unsigned char*line = malloc(img.width*sizeof(gfxcolor_t)); for(y=0;y