This commit is contained in:
parent
86b44ca567
commit
aacad4200d
7 changed files with 28 additions and 21 deletions
|
@ -8,7 +8,9 @@ libeyd_la_SOURCES = eyd_bitreader.cpp \
|
||||||
eyd_bitwriter.cpp \
|
eyd_bitwriter.cpp \
|
||||||
eyd_bitgroup.cpp \
|
eyd_bitgroup.cpp \
|
||||||
eyd_compressor_rle1.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
|
libeyd_la_CFLAGS = -DTRACE
|
||||||
#-static
|
#-static
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef _EYD_BITCOMPRESSOR_HH
|
#ifndef _EYD_BITCOMPRESSOR_RLE1_HH
|
||||||
#define _EYD_BITCOMPRESSOR_HH
|
#define _EYD_BITCOMPRESSOR_RLE1_HH
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
#include "eyd_bitwriter.hh"
|
#include "eyd_bitwriter.hh"
|
||||||
#include "eyd_compressor_rle1.hh"
|
#include "eyd_compressor_rle1.hh"
|
||||||
#include "eyd_uncompressor_rle1.hh"
|
#include "eyd_uncompressor_rle1.hh"
|
||||||
|
#include "eyd_compressor_rle2.hh"
|
||||||
|
#include "eyd_uncompressor_rle2.hh"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace EydLib {
|
||||||
BitUncompressorRle1::BitUncompressorRle1(int size) : _rle(size) {
|
BitUncompressorRle1::BitUncompressorRle1(int size) : _rle(size) {
|
||||||
_group_size = size;
|
_group_size = size;
|
||||||
_last_count = 0;
|
_last_count = 0;
|
||||||
_status = UNCOMPRESSOR_STATUS_NORMAL;
|
_status = UNCOMPRESSOR_RLE1_STATUS_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitUncompressorRle1::clear(){
|
void BitUncompressorRle1::clear(){
|
||||||
|
@ -34,38 +34,38 @@ namespace EydLib {
|
||||||
|
|
||||||
void BitUncompressorRle1::append(BitGroup data){
|
void BitUncompressorRle1::append(BitGroup data){
|
||||||
switch (_status){
|
switch (_status){
|
||||||
case UNCOMPRESSOR_STATUS_NORMAL:
|
case UNCOMPRESSOR_RLE1_STATUS_NORMAL:
|
||||||
printf("STATUS NORMAL : %s\n", data.toString().c_str());
|
printf("STATUS NORMAL : %s\n", data.toString().c_str());
|
||||||
if (data == _rle){
|
if (data == _rle){
|
||||||
// on change le status et on n'écrit rien
|
// on change le status et on n'écrit rien
|
||||||
_status = UNCOMPRESSOR_STATUS_GOTRLE;
|
_status = UNCOMPRESSOR_RLE1_STATUS_GOTRLE;
|
||||||
} else {
|
} else {
|
||||||
// on écrit directement le resultat non décompressé
|
// on écrit directement le resultat non décompressé
|
||||||
_uncompressed.push_back(data);
|
_uncompressed.push_back(data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case UNCOMPRESSOR_STATUS_GOTRLE:
|
case UNCOMPRESSOR_RLE1_STATUS_GOTRLE:
|
||||||
printf("STATUS GOT RLE : %s\n", data.toString().c_str() );
|
printf("STATUS GOT RLE : %s\n", data.toString().c_str() );
|
||||||
if (data == _rle){
|
if (data == _rle){
|
||||||
// deux RLE c'est 1 RLE
|
// deux RLE c'est 1 RLE
|
||||||
// on écrit juste un RLE
|
// on écrit juste un RLE
|
||||||
_uncompressed.push_back(data);
|
_uncompressed.push_back(data);
|
||||||
_status = UNCOMPRESSOR_STATUS_NORMAL;
|
_status = UNCOMPRESSOR_RLE1_STATUS_NORMAL;
|
||||||
} else {
|
} else {
|
||||||
// un RLE et un différent c'est une longueur
|
// un RLE et un différent c'est une longueur
|
||||||
// sauf si égal à 1 ou 2
|
// 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
|
_last_count = data.getValue(); // on stocke la value
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case UNCOMPRESSOR_STATUS_GOTLEN:
|
case UNCOMPRESSOR_RLE1_STATUS_GOTLEN:
|
||||||
printf("STATUS GOT LEN : %s\n", data.toString().c_str() );
|
printf("STATUS GOT LEN : %s\n", data.toString().c_str() );
|
||||||
// ce qu'on lit est la valeur
|
// ce qu'on lit est la valeur
|
||||||
// on écrit donc _last_count fois data
|
// on écrit donc _last_count fois data
|
||||||
for (int i=0; i<_last_count; i++){
|
for (int i=0; i<_last_count; i++){
|
||||||
_uncompressed.push_back(data);
|
_uncompressed.push_back(data);
|
||||||
}
|
}
|
||||||
_status = UNCOMPRESSOR_STATUS_NORMAL;
|
_status = UNCOMPRESSOR_RLE1_STATUS_NORMAL;
|
||||||
_last_count = 0;
|
_last_count = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef _EYD_BITUNCOMPRESSOR_HH
|
#ifndef _EYD_BITUNCOMPRESSOR_RLE1_HH
|
||||||
#define _EYD_BITUNCOMPRESSOR_HH
|
#define _EYD_BITUNCOMPRESSOR_RLE1_HH
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -14,7 +14,11 @@
|
||||||
|
|
||||||
|
|
||||||
namespace EydLib {
|
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 {
|
class BitUncompressorRle1 {
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "eydrle.hh"
|
#include "eydrle2.hh"
|
||||||
|
|
||||||
namespace EydTools {
|
namespace EydTools {
|
||||||
void EydRle::compress(){
|
void EydRle2::compress(){
|
||||||
EydLib::BitGroup data;
|
EydLib::BitGroup data;
|
||||||
|
|
||||||
EydLib::BitReader bitread(_cellsize, 256);
|
EydLib::BitReader bitread(_cellsize, 256);
|
||||||
|
@ -12,7 +12,7 @@ namespace EydTools {
|
||||||
unsigned char c = (unsigned char)_cellsize;
|
unsigned char c = (unsigned char)_cellsize;
|
||||||
bitwrite.writeDirect(&c, 1);
|
bitwrite.writeDirect(&c, 1);
|
||||||
|
|
||||||
EydLib::BitCompressor compressor(_cellsize);
|
EydLib::BitCompressorRle2 compressor;
|
||||||
|
|
||||||
printf("File opened\n");
|
printf("File opened\n");
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ namespace EydTools {
|
||||||
} catch (EydLib::eBitReaderEndOfFile& e) {
|
} catch (EydLib::eBitReaderEndOfFile& e) {
|
||||||
done = true;
|
done = true;
|
||||||
// on flushe le contenu de record
|
// on flushe le contenu de record
|
||||||
compressor.flushRleData();
|
|
||||||
std::list<EydLib::BitGroup> compressedData = compressor.flush();
|
std::list<EydLib::BitGroup> compressedData = compressor.flush();
|
||||||
std::list<EydLib::BitGroup>::iterator cmpDataIt;
|
std::list<EydLib::BitGroup>::iterator cmpDataIt;
|
||||||
for(cmpDataIt = compressedData.begin();
|
for(cmpDataIt = compressedData.begin();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "eydrle.hh"
|
#include "eydrle2.hh"
|
||||||
|
|
||||||
namespace EydTools {
|
namespace EydTools {
|
||||||
void EydRle::uncompress(){
|
void EydRle2::uncompress(){
|
||||||
EydLib::BitGroup data;
|
EydLib::BitGroup data;
|
||||||
|
|
||||||
EydLib::BitReader bitread(_cellsize, 256);
|
EydLib::BitReader bitread(_cellsize, 256);
|
||||||
|
@ -18,7 +18,7 @@ namespace EydTools {
|
||||||
EydLib::BitWriter bitwrite(_cellsize,256);
|
EydLib::BitWriter bitwrite(_cellsize,256);
|
||||||
bitwrite.open(_output_file);
|
bitwrite.open(_output_file);
|
||||||
|
|
||||||
EydLib::BitUncompressor uncompressor(_cellsize);
|
EydLib::BitUncompressorRle2 uncompressor;
|
||||||
|
|
||||||
printf("File opened\n");
|
printf("File opened\n");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue