This commit is contained in:
glenux 2005-10-31 07:34:44 +00:00
parent 86b44ca567
commit aacad4200d
7 changed files with 28 additions and 21 deletions

View file

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

View file

@ -1,5 +1,5 @@
#ifndef _EYD_BITCOMPRESSOR_HH
#define _EYD_BITCOMPRESSOR_HH
#ifndef _EYD_BITCOMPRESSOR_RLE1_HH
#define _EYD_BITCOMPRESSOR_RLE1_HH
#include <string>
#include <sys/types.h>

View file

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

View file

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

View file

@ -1,5 +1,5 @@
#ifndef _EYD_BITUNCOMPRESSOR_HH
#define _EYD_BITUNCOMPRESSOR_HH
#ifndef _EYD_BITUNCOMPRESSOR_RLE1_HH
#define _EYD_BITUNCOMPRESSOR_RLE1_HH
#include <string>
#include <sys/types.h>
@ -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:

View file

@ -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<EydLib::BitGroup> compressedData = compressor.flush();
std::list<EydLib::BitGroup>::iterator cmpDataIt;
for(cmpDataIt = compressedData.begin();

View file

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