diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 13b62a5..deed4c5 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -8,7 +8,9 @@ libeyd_la_SOURCES = eyd_bitreader.cpp \ eyd_bitwriter.cpp \ eyd_bitgroup.cpp \ eyd_compressor_rle1.cpp \ - eyd_uncompressor_rle1.cpp + eyd_uncompressor_rle1.cpp \ + eyd_compressor_rle2.cpp \ + eyd_uncompressor_rle2.cpp libeyd_la_CFLAGS = -DTRACE #-static diff --git a/src/lib/eyd_compressor_rle1.hh b/src/lib/eyd_compressor_rle1.hh index f3842f1..209fae8 100644 --- a/src/lib/eyd_compressor_rle1.hh +++ b/src/lib/eyd_compressor_rle1.hh @@ -1,5 +1,5 @@ -#ifndef _EYD_BITCOMPRESSOR_HH -#define _EYD_BITCOMPRESSOR_HH +#ifndef _EYD_BITCOMPRESSOR_RLE1_HH +#define _EYD_BITCOMPRESSOR_RLE1_HH #include #include diff --git a/src/lib/eyd_proto.hh b/src/lib/eyd_proto.hh index 0a32304..5a7d4ae 100644 --- a/src/lib/eyd_proto.hh +++ b/src/lib/eyd_proto.hh @@ -13,6 +13,8 @@ #include "eyd_bitwriter.hh" #include "eyd_compressor_rle1.hh" #include "eyd_uncompressor_rle1.hh" +#include "eyd_compressor_rle2.hh" +#include "eyd_uncompressor_rle2.hh" #endif diff --git a/src/lib/eyd_uncompressor_rle1.cpp b/src/lib/eyd_uncompressor_rle1.cpp index cbbba13..80e9302 100644 --- a/src/lib/eyd_uncompressor_rle1.cpp +++ b/src/lib/eyd_uncompressor_rle1.cpp @@ -23,7 +23,7 @@ namespace EydLib { BitUncompressorRle1::BitUncompressorRle1(int size) : _rle(size) { _group_size = size; _last_count = 0; - _status = UNCOMPRESSOR_STATUS_NORMAL; + _status = UNCOMPRESSOR_RLE1_STATUS_NORMAL; } void BitUncompressorRle1::clear(){ @@ -34,38 +34,38 @@ namespace EydLib { void BitUncompressorRle1::append(BitGroup data){ switch (_status){ - case UNCOMPRESSOR_STATUS_NORMAL: + case UNCOMPRESSOR_RLE1_STATUS_NORMAL: printf("STATUS NORMAL : %s\n", data.toString().c_str()); if (data == _rle){ // on change le status et on n'écrit rien - _status = UNCOMPRESSOR_STATUS_GOTRLE; + _status = UNCOMPRESSOR_RLE1_STATUS_GOTRLE; } else { // on écrit directement le resultat non décompressé _uncompressed.push_back(data); } break; - case UNCOMPRESSOR_STATUS_GOTRLE: + case UNCOMPRESSOR_RLE1_STATUS_GOTRLE: printf("STATUS GOT RLE : %s\n", data.toString().c_str() ); if (data == _rle){ // deux RLE c'est 1 RLE // on écrit juste un RLE _uncompressed.push_back(data); - _status = UNCOMPRESSOR_STATUS_NORMAL; + _status = UNCOMPRESSOR_RLE1_STATUS_NORMAL; } else { // un RLE et un différent c'est une longueur // sauf si égal à 1 ou 2 - _status = UNCOMPRESSOR_STATUS_GOTLEN; // sauf si égal à RLE + _status = UNCOMPRESSOR_RLE1_STATUS_GOTLEN; // sauf si égal à RLE _last_count = data.getValue(); // on stocke la value } break; - case UNCOMPRESSOR_STATUS_GOTLEN: + case UNCOMPRESSOR_RLE1_STATUS_GOTLEN: printf("STATUS GOT LEN : %s\n", data.toString().c_str() ); // ce qu'on lit est la valeur // on écrit donc _last_count fois data for (int i=0; i<_last_count; i++){ _uncompressed.push_back(data); } - _status = UNCOMPRESSOR_STATUS_NORMAL; + _status = UNCOMPRESSOR_RLE1_STATUS_NORMAL; _last_count = 0; break; diff --git a/src/lib/eyd_uncompressor_rle1.hh b/src/lib/eyd_uncompressor_rle1.hh index c6250d9..482c91d 100644 --- a/src/lib/eyd_uncompressor_rle1.hh +++ b/src/lib/eyd_uncompressor_rle1.hh @@ -1,5 +1,5 @@ -#ifndef _EYD_BITUNCOMPRESSOR_HH -#define _EYD_BITUNCOMPRESSOR_HH +#ifndef _EYD_BITUNCOMPRESSOR_RLE1_HH +#define _EYD_BITUNCOMPRESSOR_RLE1_HH #include #include @@ -14,7 +14,11 @@ namespace EydLib { - typedef enum {UNCOMPRESSOR_STATUS_NORMAL, UNCOMPRESSOR_STATUS_GOTLEN, UNCOMPRESSOR_STATUS_GOTRLE} uncompressorRle1_status_t; + typedef enum { + UNCOMPRESSOR_RLE1_STATUS_NORMAL, + UNCOMPRESSOR_RLE1_STATUS_GOTLEN, + UNCOMPRESSOR_RLE1_STATUS_GOTRLE + } uncompressorRle1_status_t; class BitUncompressorRle1 { private: diff --git a/src/rle2/eydrle2_compress.cpp b/src/rle2/eydrle2_compress.cpp index 6b11cfd..8e69f03 100644 --- a/src/rle2/eydrle2_compress.cpp +++ b/src/rle2/eydrle2_compress.cpp @@ -1,7 +1,7 @@ -#include "eydrle.hh" +#include "eydrle2.hh" namespace EydTools { - void EydRle::compress(){ + void EydRle2::compress(){ EydLib::BitGroup data; EydLib::BitReader bitread(_cellsize, 256); @@ -12,7 +12,7 @@ namespace EydTools { unsigned char c = (unsigned char)_cellsize; bitwrite.writeDirect(&c, 1); - EydLib::BitCompressor compressor(_cellsize); + EydLib::BitCompressorRle2 compressor; printf("File opened\n"); @@ -35,7 +35,6 @@ namespace EydTools { } catch (EydLib::eBitReaderEndOfFile& e) { done = true; // on flushe le contenu de record - compressor.flushRleData(); std::list compressedData = compressor.flush(); std::list::iterator cmpDataIt; for(cmpDataIt = compressedData.begin(); diff --git a/src/rle2/eydrle2_uncompress.cpp b/src/rle2/eydrle2_uncompress.cpp index cd73346..8044e20 100644 --- a/src/rle2/eydrle2_uncompress.cpp +++ b/src/rle2/eydrle2_uncompress.cpp @@ -1,7 +1,7 @@ -#include "eydrle.hh" +#include "eydrle2.hh" namespace EydTools { - void EydRle::uncompress(){ + void EydRle2::uncompress(){ EydLib::BitGroup data; EydLib::BitReader bitread(_cellsize, 256); @@ -18,7 +18,7 @@ namespace EydTools { EydLib::BitWriter bitwrite(_cellsize,256); bitwrite.open(_output_file); - EydLib::BitUncompressor uncompressor(_cellsize); + EydLib::BitUncompressorRle2 uncompressor; printf("File opened\n");