diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index d7d821a..13b62a5 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -7,8 +7,8 @@ lib_LTLIBRARIES = libeyd.la libeyd_la_SOURCES = eyd_bitreader.cpp \ eyd_bitwriter.cpp \ eyd_bitgroup.cpp \ - eyd_compressor.cpp \ - eyd_uncompressor.cpp + eyd_compressor_rle1.cpp \ + eyd_uncompressor_rle1.cpp libeyd_la_CFLAGS = -DTRACE #-static diff --git a/src/lib/eyd_proto.hh b/src/lib/eyd_proto.hh index a2e5868..0a32304 100644 --- a/src/lib/eyd_proto.hh +++ b/src/lib/eyd_proto.hh @@ -11,8 +11,8 @@ #include "eyd_bitgroup.hh" #include "eyd_bitreader.hh" #include "eyd_bitwriter.hh" -#include "eyd_compressor.hh" -#include "eyd_uncompressor.hh" +#include "eyd_compressor_rle1.hh" +#include "eyd_uncompressor_rle1.hh" #endif diff --git a/src/rle1/eydrle_compress.cpp b/src/rle1/eydrle_compress.cpp index 6b11cfd..0dcb63f 100644 --- a/src/rle1/eydrle_compress.cpp +++ b/src/rle1/eydrle_compress.cpp @@ -12,7 +12,7 @@ namespace EydTools { unsigned char c = (unsigned char)_cellsize; bitwrite.writeDirect(&c, 1); - EydLib::BitCompressor compressor(_cellsize); + EydLib::BitCompressorRle1 compressorRle1(_cellsize); printf("File opened\n"); @@ -21,10 +21,10 @@ namespace EydTools { while(!done){ try{ data = bitread.read(); - compressor.append(data); + compressorRle1.append(data); - if (compressor.hasContent()){ - std::list compressedData = compressor.flush(); + if (compressorRle1.hasContent()){ + std::list compressedData = compressorRle1.flush(); std::list::iterator cmpDataIt; for(cmpDataIt = compressedData.begin(); cmpDataIt != compressedData.end(); @@ -35,8 +35,8 @@ namespace EydTools { } catch (EydLib::eBitReaderEndOfFile& e) { done = true; // on flushe le contenu de record - compressor.flushRleData(); - std::list compressedData = compressor.flush(); + compressorRle1.flushRleData(); + std::list compressedData = compressorRle1.flush(); std::list::iterator cmpDataIt; for(cmpDataIt = compressedData.begin(); cmpDataIt != compressedData.end(); diff --git a/src/rle1/eydrle_uncompress.cpp b/src/rle1/eydrle_uncompress.cpp index cd73346..1ee08cb 100644 --- a/src/rle1/eydrle_uncompress.cpp +++ b/src/rle1/eydrle_uncompress.cpp @@ -18,7 +18,7 @@ namespace EydTools { EydLib::BitWriter bitwrite(_cellsize,256); bitwrite.open(_output_file); - EydLib::BitUncompressor uncompressor(_cellsize); + EydLib::BitUncompressorRle1 uncompressorRle1(_cellsize); printf("File opened\n"); @@ -27,10 +27,10 @@ namespace EydTools { while(!done){ try{ data = bitread.read(); - uncompressor.append(data); + uncompressorRle1.append(data); - if (uncompressor.hasContent()){ - std::list uncompressedData = uncompressor.flush(); + if (uncompressorRle1.hasContent()){ + std::list uncompressedData = uncompressorRle1.flush(); std::list::iterator uncmpDataIt; for(uncmpDataIt = uncompressedData.begin(); uncmpDataIt != uncompressedData.end(); @@ -41,8 +41,8 @@ namespace EydTools { } catch (EydLib::eBitReaderEndOfFile& e) { done = true; // on flushe le contenu de record - // uncompressor.flushRleData(); - std::list uncompressedData = uncompressor.flush(); + // uncompressorRle1.flushRleData(); + std::list uncompressedData = uncompressorRle1.flush(); std::list::iterator uncmpDataIt; for(uncmpDataIt = uncompressedData.begin(); uncmpDataIt != uncompressedData.end(); diff --git a/src/rle2/eydrle2.cpp b/src/rle2/eydrle2.cpp index f6cebc6..c4b2ef0 100644 --- a/src/rle2/eydrle2.cpp +++ b/src/rle2/eydrle2.cpp @@ -1,15 +1,15 @@ -#include "eydrle.hh" +#include "eydrle2.hh" namespace EydTools { - EydRle::EydRle(){ - _mode_compress = EYDRLE_MODE_UNDEF; + EydRle2::EydRle2(){ + _mode_compress = EYDRLE2_MODE_UNDEF; _input_file.clear(); _output_file.clear(); _cellsize = 8; // one octet each time (by default); } - void EydRle::run(){ - if (_mode_compress == EYDRLE_MODE_COMPRESS){ + void EydRle2::run(){ + if (_mode_compress == EYDRLE2_MODE_COMPRESS){ this->compress(); } else { this->uncompress(); diff --git a/src/rle2/eydrle2.hh b/src/rle2/eydrle2.hh index e69de29..264cc53 100644 --- a/src/rle2/eydrle2.hh +++ b/src/rle2/eydrle2.hh @@ -0,0 +1,31 @@ +#ifndef _EYDRLE2_HH +#define _EYDRLE2_HH + +#include +#include +#include +#include +#include + +namespace EydTools { + typedef enum { EYDRLE2_MODE_COMPRESS, EYDRLE2_MODE_UNCOMPRESS, EYDRLE2_MODE_UNDEF } eydrle2_mode_t; + + class EydRle2 { + private: + // la config + eydrle2_mode_t _mode_compress; + std::string _input_file; + std::string _output_file; + int _cellsize; + EydLib::BitGroup _rle; + + public: + EydRle2(); + bool init(int argc, char **argv); + void run(); + void compress(); + void uncompress(); + }; +} + +#endif diff --git a/src/rle2/eydrle2_init.cpp b/src/rle2/eydrle2_init.cpp index fab3347..588826f 100644 --- a/src/rle2/eydrle2_init.cpp +++ b/src/rle2/eydrle2_init.cpp @@ -1,9 +1,9 @@ -#include "eydrle.hh" +#include "eydrle2.hh" namespace EydTools { - bool EydRle::init(int argc, char ** argv){ - _mode_compress = EYDRLE_MODE_UNDEF; + bool EydRle2::init(int argc, char ** argv){ + _mode_compress = EYDRLE2_MODE_UNDEF; int i; for (i = 1; i + 1 < argc; i = i + 2){ @@ -13,14 +13,14 @@ namespace EydTools { switch(val[0]){ case 'c': case 'C': - _mode_compress = EYDRLE_MODE_COMPRESS; + _mode_compress = EYDRLE2_MODE_COMPRESS; break; case 'u': case 'U': - _mode_compress = EYDRLE_MODE_UNCOMPRESS; + _mode_compress = EYDRLE2_MODE_UNCOMPRESS; break; default: - _mode_compress = EYDRLE_MODE_UNDEF; + _mode_compress = EYDRLE2_MODE_UNDEF; break; } continue; @@ -42,7 +42,7 @@ namespace EydTools { // printf("value = %s\n",argv[i+1]); } - if ((_mode_compress == EYDRLE_MODE_UNDEF) || + if ((_mode_compress == EYDRLE2_MODE_UNDEF) || (_input_file.length() == 0)) { printf("\nUsage: %s \n", argv[0]); printf("\nWhere options could be:\n"); @@ -54,7 +54,7 @@ namespace EydTools { } if (_output_file.length() == 0){ - if (_mode_compress == EYDRLE_MODE_COMPRESS){ + if (_mode_compress == EYDRLE2_MODE_COMPRESS){ _output_file = _input_file + ".rl1"; } else { _output_file = _input_file + ".rl1_orig"; diff --git a/src/rle2/eydrle2_main.cpp b/src/rle2/eydrle2_main.cpp index c91b7ef..cc5ebf0 100644 --- a/src/rle2/eydrle2_main.cpp +++ b/src/rle2/eydrle2_main.cpp @@ -1,14 +1,14 @@ -#include "eydrle.hh" +#include "eydrle2.hh" using namespace std; using namespace EydTools; int main(int argc, char **argv){ bool ready; - EydRle eydrle; - ready = eydrle.init(argc, argv); + EydRle2 eydrle2; + ready = eydrle2.init(argc, argv); if (ready) { - eydrle.run(); + eydrle2.run(); } return 0;