}
if ( (argc == 1) || (cflag & dflag) || !(cflag | dflag) || ((argc - optind) < 2) || (mflag & sflag)) {
- fprintf(stderr, "Usage: %s [-cdzs][-q blksize][-t volsize][-m modeldumpfile] source target\n", argv[0]);
+ fprintf(stderr, "Usage: %s [-cdzs][-q compressionquality][-t volsize][-m modeldumpfile] source target\n", argv[0]);
return (3);
}
if ((tflag) && (volumesize <= 0l)) {
/* Guardamos el pagesize como header (huffencoded) */
shuff_scanfreq_chunk(shuff,(char*)&pagesize,sizeof(size_t));
+ /* Guardamos cabecera para indicar si usamos ZG (huffencoded) */
+ if (zflag) shuff_scanfreq_chunk(shuff, "\001", 1);
+ else shuff_scanfreq_chunk(shuff, "\000", 1);
+
total = 0;
while (!feof(fp)) {
i = 0;
/* Le aplico el MTF a salida */
mtf = jacu_mtf(salida, i+sizeof(Uint32), &z, &z_len);
+
+ /* Guardo el z_len y el Z */
+ shuff_scanfreq_chunk(shuff,(char*)&z_len,sizeof(int));
+ shuff_scanfreq_chunk(shuff,z,z_len);
/* Si me lo piden, aplico ZG. */
if (zflag) {
size_t len;
char buff[2];
+ Uint32 total_size = i + sizeof(Uint32);
ZG zg;
zg_init(&zg);
- /* TODO HACER LO MISMO QUE EN EL ELSE XXX */
- for (j = 0; j < i; ++j)
- if ((len = zg_group(&zg, buff, mtf[j]))) shuff_scanfreq_chunk(shuff,buff,len);
- } else {
- /* Comprimo el Z len y el Z */
- shuff_scanfreq_chunk(shuff,(char*)&z_len,sizeof(int));
- shuff_scanfreq_chunk(shuff,z,z_len);
-
+ /* Guardo la salida del MTF con ceros agrupados (ZG) */
+ for (j = 0; j < total_size; ++j)
+ if ((len = zg_group(&zg, buff, mtf[j])))
+ shuff_scanfreq_chunk(shuff, buff, len);
+ } else {
/* Comprimo la salida del MTF */
- shuff_scanfreq_chunk(shuff,mtf,i+sizeof(Uint32));
+ shuff_scanfreq_chunk(shuff,mtf,i+sizeof(Uint32));
}
free(mtf);
free(z);
unsigned char *block, *mtf, *orig;
unsigned char *z;
int z_len,moredata = 0,decoded = 0;
+ char use_zg;
/* Inicializo el descompresor */
if ((shuff = shuff_init_decoder(argv[optind],NULL)) == NULL) return 1;
/* Descomprimo primero que nada el pagesize utilizado para comprimir */
if (!(moredata = shuff_decode_chunk(shuff,(char*)&block_size,sizeof(Uint32),&decoded))) return 1;
+
+ /* Descomprimo byte que indica si se usa ZG */
+ if (!(moredata = shuff_decode_chunk(shuff, &use_zg, 1, &decoded))) return 1;
+
+ /* Creo buffers */
block = malloc(block_size*sizeof(unsigned char)+sizeof(Uint32));
orig = malloc(block_size*sizeof(unsigned char));