From: Alan Kennedy Date: Thu, 24 Jun 2004 06:49:45 +0000 (+0000) Subject: Ahora si, me habia olvidado de hacer el Decoder de Jacu chunkeable y sin archivo... X-Git-Tag: svn_import~65 X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/commitdiff_plain/bfe6de10fe456e512b54d97dc54de7591c443875 Ahora si, me habia olvidado de hacer el Decoder de Jacu chunkeable y sin archivo temporal. Done and tested for good --- diff --git a/src/jacu.c b/src/jacu.c index f0c3444..5add536 100644 --- a/src/jacu.c +++ b/src/jacu.c @@ -199,23 +199,22 @@ int main(int argc, char* argv[]) Uint32 block_size, k; char *block, *mtf, *orig; char *z; - int z_len; + int z_len,moredata = 0,decoded = 0; - if ((shuff = shuff_init_decoder(argv[optind],"tmp.comp")) == NULL) return 1; - shuff_decode_file(shuff); - shuff_deinit_decoder(shuff); - free(shuff); - - fp_in = fopen("tmp.comp", "rb"); + /* Inicializo el descompresor */ + if ((shuff = shuff_init_decoder(argv[optind],NULL)) == NULL) return 1; + + /* Abrimos el archivo de salida */ fp_out = fopen(argv[optind+1], "wb"); - while (!feof(fp_in)) { - block_size = 0; - fread(&block_size, sizeof(Uint32), 1, fp_in); + /* Descomprimimos de a chunks segun convenga */ + do { + block_size = 0; + moredata = shuff_decode_chunk(shuff,(char*)&block_size,sizeof(Uint32),&decoded); if (block_size > 0) { - fread(&z_len, sizeof(int), 1, fp_in); + moredata = shuff_decode_chunk(shuff,(char*)&z_len,sizeof(int),&decoded); z = malloc(sizeof(char)*z_len); - fread(z, z_len, sizeof(char), fp_in); + moredata = shuff_decode_chunk(shuff,z,z_len,&decoded); /*printf("MTF Z (len=%d) = [", z_len); { @@ -228,7 +227,7 @@ int main(int argc, char* argv[]) block = malloc(block_size*sizeof(char)+sizeof(Uint32)); orig = malloc(block_size*sizeof(char)); - fread(block, block_size+sizeof(Uint32), sizeof(char), fp_in); + moredata = shuff_decode_chunk(shuff,block,block_size+sizeof(Uint32),&decoded); /*printf("Antes MTF_inv = ["); { @@ -260,9 +259,14 @@ int main(int argc, char* argv[]) free(mtf); free(z); } - } - fclose(fp_in); + } while (moredata); + + /* Close up files */ fclose(fp_out); + + /* Shutdown Huffman */ + shuff_deinit_decoder(shuff); + free(shuff); } return 0;