/*************************************************************************************************************************************/
/* */
/* C O M P R E S S I O N / D E C O M P R E S S I O N " R U N - L E N G T H E N C O D I N G " */
/* ( G E N E R A L I T E S ) : */
/* */
/* */
/* Author of '$xrC/CompressionDeCompressionRunLengthEncodingGeneral.01$vv$I' : */
/* */
/* Jean-Francois Colonna (LACTAMME, 20130926144345). */
/* */
/*************************************************************************************************************************************/
#include "CompressionDeCompression.01.vv.I"
#define COMPRESSION_RUN_LENGTH_ENCODING_DU_FICHIER_R(facteur,TestCompteurRepetitions) \
{ \
TypeImage *ImageACompacter=malloc(1*longueur); \
TypeImage *ImageCompactee=malloc(facteur*longueur); \
/* Le '*facteur' est destine au cas le pire : celui ou il n'y a aucune repetition et ou */ \
/* donc chaque octet original {NN} est, par exemple de la cas de la longueur fixe, est */ \
/* double sous la forme {1,NN}... */ \
\
int JImageACompacter; \
int JImageCompactee=0; \
\
int CaracterePrecedent=INFINI; \
int CompteurRepetitions=INFINI; \
int AntiCumulCompteurRepetitions=longueur; \
\
LECTURE_FICHIER(ImageACompacter,longueur); \
\
for (JImageACompacter=0 ; JImageACompacter < NombreOctetsLus ; JImageACompacter++) \
{ \
TypeImage CaractereCourant=ImageACompacter[JImageACompacter]; \
\
if ((CaractereCourant == CaracterePrecedent) && (TestCompteurRepetitions)) \
{ \
CompteurRepetitions++; \
} \
else \
{ \
if (CaracterePrecedent == INFINI) \
{ \
} \
else \
{ \
ENREGISTREMENT_D_UNE_SUITE_DE_REPETITIONS(CompteurRepetitions,CaracterePrecedent); \
AntiCumulCompteurRepetitions=AntiCumulCompteurRepetitions-CompteurRepetitions; \
} \
\
CompteurRepetitions=1; \
CaracterePrecedent=CaractereCourant; \
} \
} \
\
if (AntiCumulCompteurRepetitions > 0) \
{ \
ENREGISTREMENT_D_UNE_SUITE_DE_REPETITIONS(CompteurRepetitions,CaracterePrecedent); \
AntiCumulCompteurRepetitions=AntiCumulCompteurRepetitions-CompteurRepetitions; \
/* Enregistrement d'un eventuel dernier caractere en attente... */ \
} \
else \
{ \
} \
\
ECRITURE_FICHIER(ImageCompactee,JImageCompactee); \
\
free(ImageCompactee); \
free(ImageACompacter); \
}
#define PROGRESSION_DES_COORDONNEES \
{ \
if (x < Xmax) \
{ \
x++; \
} \
else \
{ \
x=Xmin; \
\
if (y < Ymax) \
{ \
y++; \
} \
else \
{ \
} \
} \
}
#ifndef define_dimX_dimY
/* Introduit le 20141024150620 pour accelerer la decompression utilisant le programme */
/* 'v .xrC.EffectuerCompilations.01.vv.Z DeCompressionRunLengthEncoding.02$vv'... */
#else
# if (dimX == 1)
# undef PROGRESSION_DES_COORDONNEES
# define PROGRESSION_DES_COORDONNEES \
{ \
y++; \
}
# else
# if (dimY == 1)
# undef PROGRESSION_DES_COORDONNEES
# define PROGRESSION_DES_COORDONNEES \
{ \
x++; \
}
# else
# endif
# endif
#endif
#define GENERATION_D_UNE_SUITE_DE_REPETITIONS(CaractereARepeter) \
{ \
gSTORE_IMAGE_PLAN(ImageDecompactee,x,y,CaractereARepeter); \
\
DimensionImageEffective++; \
/* Et ce afin de pouvoir traiter aussi bien des images '$TypeOctet' que '$TypeBit__' */ \
/* auquel la matrice 'ImageDecompactee' n'est pas entierement remplie et surtout n'est */ \
/* remplie pas comme on le croit, suivant un carre... */ \
\
PROGRESSION_DES_COORDONNEES; \
}