From 2ee6f95a8db79ede018e0f15124dd486451c4170 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Fri, 25 Jun 2004 21:59:31 +0000 Subject: [PATCH] Intento de poner a andar el ZG. --- src/Makefile | 78 ++++++++++++++++++++++++++++++++++++++++++++++------ src/jacu.c | 32 ++++++++++++++------- 2 files changed, 92 insertions(+), 18 deletions(-) diff --git a/src/Makefile b/src/Makefile index da939ef..4010113 100644 --- a/src/Makefile +++ b/src/Makefile @@ -27,10 +27,12 @@ TARGETS=jacu COMMON=zerogrouping/zerogrouping.o mtf/mtf.o blocksorting/bs.o \ statichuff/statichuff.o vfile/vfile.o vfile/common.o -SRCS=jacu.c +SRCS=jacu.c zerogrouping/zerogrouping.c mtf/mtf.c blocksorting/bs.c \ + statichuff/statichuff.c vfile/vfile.c vfile/common.c #CFLAGS=-O3 -Wall -DNDEBUG -CFLAGS=-ggdb -Wall -DDEBUG +CFLAGS=-ggdb -Wall +#CFLAGS=-ggdb -Wall -DDEBUG all: $(TARGETS) @@ -46,13 +48,73 @@ clean: # DO NOT DELETE -jacu.o: statichuff/statichuff.h /usr/include/stdio.h /usr/include/features.h +jacu.o: blocksorting/bs.h /usr/include/string.h /usr/include/features.h jacu.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.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/lib/gcc-lib/i486-linux/3.3.4/include/stddef.h +jacu.o: /usr/include/stdlib.h /usr/include/stdio.h /usr/include/bits/types.h +jacu.o: /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h +jacu.o: /usr/include/libio.h /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: mtf/mtf.h zerogrouping/zerogrouping.h statichuff/statichuff.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 vfile/vfile.h +jacu.o: /usr/include/bits/confname.h vfile/vfile.h vfile/vfile.h +jacu.o: vfile/common.h +zerogrouping/zerogrouping.o: zerogrouping/zerogrouping.h +zerogrouping/zerogrouping.o: /usr/include/stdlib.h /usr/include/features.h +zerogrouping/zerogrouping.o: /usr/include/sys/cdefs.h +zerogrouping/zerogrouping.o: /usr/include/gnu/stubs.h +zerogrouping/zerogrouping.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stddef.h +mtf/mtf.o: mtf/mtf.h /usr/include/stdio.h /usr/include/features.h +mtf/mtf.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h +mtf/mtf.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stddef.h +mtf/mtf.o: /usr/include/bits/types.h /usr/include/bits/wordsize.h +mtf/mtf.o: /usr/include/bits/typesizes.h /usr/include/libio.h +mtf/mtf.o: /usr/include/_G_config.h /usr/include/wchar.h +mtf/mtf.o: /usr/include/bits/wchar.h /usr/include/gconv.h +mtf/mtf.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stdarg.h +mtf/mtf.o: /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h +mtf/mtf.o: /usr/include/stdlib.h /usr/include/string.h +blocksorting/bs.o: blocksorting/bs.h /usr/include/string.h +blocksorting/bs.o: /usr/include/features.h /usr/include/sys/cdefs.h +blocksorting/bs.o: /usr/include/gnu/stubs.h +blocksorting/bs.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stddef.h +blocksorting/bs.o: /usr/include/stdlib.h /usr/include/stdio.h +blocksorting/bs.o: /usr/include/bits/types.h /usr/include/bits/wordsize.h +blocksorting/bs.o: /usr/include/bits/typesizes.h /usr/include/libio.h +blocksorting/bs.o: /usr/include/_G_config.h /usr/include/wchar.h +blocksorting/bs.o: /usr/include/bits/wchar.h /usr/include/gconv.h +blocksorting/bs.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stdarg.h +blocksorting/bs.o: /usr/include/bits/stdio_lim.h +blocksorting/bs.o: /usr/include/bits/sys_errlist.h +statichuff/statichuff.o: statichuff/statichuff.h /usr/include/stdio.h +statichuff/statichuff.o: /usr/include/features.h /usr/include/sys/cdefs.h +statichuff/statichuff.o: /usr/include/gnu/stubs.h +statichuff/statichuff.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stddef.h +statichuff/statichuff.o: /usr/include/bits/types.h +statichuff/statichuff.o: /usr/include/bits/wordsize.h +statichuff/statichuff.o: /usr/include/bits/typesizes.h /usr/include/libio.h +statichuff/statichuff.o: /usr/include/_G_config.h /usr/include/wchar.h +statichuff/statichuff.o: /usr/include/bits/wchar.h /usr/include/gconv.h +statichuff/statichuff.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stdarg.h +statichuff/statichuff.o: /usr/include/bits/stdio_lim.h +statichuff/statichuff.o: /usr/include/bits/sys_errlist.h +statichuff/statichuff.o: /usr/include/unistd.h /usr/include/bits/posix_opt.h +statichuff/statichuff.o: /usr/include/bits/confname.h vfile/vfile.h +statichuff/statichuff.o: /usr/include/stdlib.h /usr/include/string.h +vfile/vfile.o: vfile/common.h vfile/vfile.h /usr/include/stdio.h +vfile/vfile.o: /usr/include/features.h /usr/include/sys/cdefs.h +vfile/vfile.o: /usr/include/gnu/stubs.h +vfile/vfile.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stddef.h +vfile/vfile.o: /usr/include/bits/types.h /usr/include/bits/wordsize.h +vfile/vfile.o: /usr/include/bits/typesizes.h /usr/include/libio.h +vfile/vfile.o: /usr/include/_G_config.h /usr/include/wchar.h +vfile/vfile.o: /usr/include/bits/wchar.h /usr/include/gconv.h +vfile/vfile.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stdarg.h +vfile/vfile.o: /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h +vfile/vfile.o: /usr/include/malloc.h /usr/include/string.h +vfile/common.o: vfile/common.h /usr/include/malloc.h +vfile/common.o: /usr/lib/gcc-lib/i486-linux/3.3.4/include/stddef.h +vfile/common.o: /usr/include/string.h /usr/include/features.h +vfile/common.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h diff --git a/src/jacu.c b/src/jacu.c index ab4c79d..599d636 100644 --- a/src/jacu.c +++ b/src/jacu.c @@ -84,7 +84,7 @@ int main(int argc, char* argv[]) } 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)) { @@ -120,6 +120,10 @@ int main(int argc, char* argv[]) /* 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; @@ -136,23 +140,25 @@ int main(int argc, char* argv[]) /* 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); @@ -182,6 +188,7 @@ int main(int argc, char* argv[]) 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; @@ -191,6 +198,11 @@ int main(int argc, char* argv[]) /* 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)); -- 2.43.0