jacu.o: statichuff/statichuff.h /usr/include/stdio.h /usr/include/features.h
jacu.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
-jacu.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stddef.h
jacu.o: /usr/include/bits/types.h /usr/include/bits/wordsize.h
jacu.o: /usr/include/bits/typesizes.h /usr/include/libio.h
jacu.o: /usr/include/_G_config.h /usr/include/wchar.h
jacu.o: /usr/include/bits/wchar.h /usr/include/gconv.h
-jacu.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stdarg.h
jacu.o: /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h
jacu.o: /usr/include/unistd.h /usr/include/bits/posix_opt.h
jacu.o: /usr/include/bits/confname.h blocksorting/bs.h /usr/include/string.h
-jacu.o: /usr/include/stdlib.h mtf/mtf.h
+jacu.o: /usr/include/stdlib.h mtf/mtf.h vfile/vfile.h
(*k) = generar_salida(in, bs, out);
/* Guardo el k y el tamaño en el array */
- memcpy(out, k, sizeof(unsigned long int));
- memcpy(out+sizeof(unsigned long int), &leido, sizeof(unsigned long int));
+ memcpy(out, &leido, sizeof(unsigned long int));
+ memcpy(out+sizeof(unsigned long int), k, sizeof(unsigned long int));
bs->len = l;
}
/* No me gusta el tmpfile ... es para probar como anda todo junto */
FILE *fp, *fp_out;
unsigned long int i, j, total, k;
- int *mtf;
+ char *mtf;
char *salida, *data, c;
data = malloc(sizeof(char)*pagesize);
- /* Reservo lugar tambien para guardar el k */
+ /* Reservo lugar tambien para guardar el k y el tamaño */
salida = malloc(sizeof(char)*(pagesize)+sizeof(unsigned long int)*2);
bs = bs_create(pagesize);
+
fp = fopen(argv[optind], "rb");
fp_out = fopen("tmp.comp", "wb");
+
c = fgetc(fp);
total = 0;
while (!feof(fp)) {
c = fgetc(fp);
total++;
}
+
/* Hago el BS */
bs_solve(data, salida, bs, &k, i);
- /* Le aplico el MTF */
- mtf = jacu_mtf(salida, i+sizeof(unsigned long int)*2);
+
+ /* Le aplico el MTF, salteo el tamaño del bloque para que no se pierda. */
+ mtf = jacu_mtf(salida+sizeof(unsigned long int), i+sizeof(unsigned long int));
for(j=0; j<i; j++)
fputc(mtf[j], fp_out);
+ free(mtf);
}
+
+ /* Limpiando */
fclose(fp);
fclose(fp_out);
bs_destroy(bs);
+
+ /* Comprimo con huffman */
i = shuff_encode_file("tmp.comp",argv[optind+1], volumesize);
+
/* borro el temporal */
unlink("tmp.comp");
return i;
fprintf(stderr, "\n");
}
-int *jacu_mtf(char *datos, int len)
+char *jacu_mtf(char *datos, int len)
{
char *z;
int *pos;
int i, size;
- pos = (int*)malloc(len*sizeof(int));
+ pos = (char *)malloc(len*sizeof(char));
z = jacu_buscar_z(datos, len, &size);
for(i=0; i<len; i++){
pos[i] = get_pos(z, size, datos[i]);
#include <stdio.h>
#include <stdlib.h>
-int *jacu_mtf(char *datos, int len);
+char *jacu_mtf(char *datos, int len);
char *jacu_mtf_inv(char *z, int *pos, int len);