This commit is contained in:
glenux 2005-10-30 23:34:21 +00:00
parent 4432a41a53
commit 869eac01a9
8 changed files with 64 additions and 33 deletions

View file

@ -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

View file

@ -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

View file

@ -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<EydLib::BitGroup> compressedData = compressor.flush();
if (compressorRle1.hasContent()){
std::list<EydLib::BitGroup> compressedData = compressorRle1.flush();
std::list<EydLib::BitGroup>::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<EydLib::BitGroup> compressedData = compressor.flush();
compressorRle1.flushRleData();
std::list<EydLib::BitGroup> compressedData = compressorRle1.flush();
std::list<EydLib::BitGroup>::iterator cmpDataIt;
for(cmpDataIt = compressedData.begin();
cmpDataIt != compressedData.end();

View file

@ -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<EydLib::BitGroup> uncompressedData = uncompressor.flush();
if (uncompressorRle1.hasContent()){
std::list<EydLib::BitGroup> uncompressedData = uncompressorRle1.flush();
std::list<EydLib::BitGroup>::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<EydLib::BitGroup> uncompressedData = uncompressor.flush();
// uncompressorRle1.flushRleData();
std::list<EydLib::BitGroup> uncompressedData = uncompressorRle1.flush();
std::list<EydLib::BitGroup>::iterator uncmpDataIt;
for(uncmpDataIt = uncompressedData.begin();
uncmpDataIt != uncompressedData.end();

View file

@ -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();

View file

@ -0,0 +1,31 @@
#ifndef _EYDRLE2_HH
#define _EYDRLE2_HH
#include <stdio.h>
#include <stdlib.h>
#include <eyd.hh>
#include <exception>
#include <vector>
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

View file

@ -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 <options>\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";

View file

@ -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;