]> git.llucax.com Git - z.facultad/75.06/jacu.git/commitdiff
Another safe upload..
authorAlan Kennedy <kennedya@3dgames.com.ar>
Wed, 23 Jun 2004 07:36:16 +0000 (07:36 +0000)
committerAlan Kennedy <kennedya@3dgames.com.ar>
Wed, 23 Jun 2004 07:36:16 +0000 (07:36 +0000)
src/statichuff/main_bychunk.c
src/statichuff/statichuff.c
src/statichuff/statichuff.h

index 5ce80160b846f29270499c37cb50606a57220430..eafe694df01b5682177f52625c9b894406dc42e8 100644 (file)
@@ -39,7 +39,7 @@ int main(int argc, char* argv[])
                
        if (cflag == 1) {
                /* Inicio un compresor huffman estatico por chunks */
                
        if (cflag == 1) {
                /* Inicio un compresor huffman estatico por chunks */
-               if ((shuff = shuff_init_static_bychunk(argv[optind+1],volumesize*1024)) == NULL) return 0;
+               if ((shuff = shuff_init_encoder_bychunk(argv[optind+1],volumesize*1024)) == NULL) return 0;
                
                /* Comprimo por chunks */               
                if ((fp = fopen(argv[optind],"rb")) == NULL) return 1;          
                
                /* Comprimo por chunks */               
                if ((fp = fopen(argv[optind],"rb")) == NULL) return 1;          
@@ -59,7 +59,7 @@ int main(int argc, char* argv[])
                shuff_encode_file(shuff);
                
                /* De init shuffman by chunks */
                shuff_encode_file(shuff);
                
                /* De init shuffman by chunks */
-               shuff_deinit_static_bychunk(shuff);
+               shuff_deinit_encoder(shuff);
                
                /* Free mem allocated by main */
                free(shuff);
                
                /* Free mem allocated by main */
                free(shuff);
@@ -71,7 +71,7 @@ int main(int argc, char* argv[])
        
        if (dflag == 1) { 
                /* Descomprimo */
        
        if (dflag == 1) { 
                /* Descomprimo */
-               return shuff_decode_file(argv[optind],argv[optind+1]);
+               /*return shuff_decode_file(argv[optind],argv[optind+1]);*/              
        }
                
        return 0;
        }
                
        return 0;
index 28b932d35edba9adcd7ec2ff47dedf25cece68bb..a2f6265c91b667f7ddeddfef255cbee571dfc8fd 100644 (file)
@@ -78,7 +78,10 @@ int shuff_scanfreq_chunk(HUFF_STATE *chunkshuff, char* chunk, int chunksize)
                /* Si llegue al tope de freq acumulada, halve em */
                if (chunkshuff->sumfreq == 14930352) 
                        chunkshuff->sumfreq = shuff_rescalefreq(chunkshuff->freqtable);
                /* Si llegue al tope de freq acumulada, halve em */
                if (chunkshuff->sumfreq == 14930352) 
                        chunkshuff->sumfreq = shuff_rescalefreq(chunkshuff->freqtable);
-       }               
+       }
+       
+       /* Dumpeamos el chunk en el temporal homero */
+       fwrite(chunk,chunksize,1,chunkshuff->coderfp);
                
        return 1;
 }
                
        return 1;
 }
@@ -230,7 +233,8 @@ int shuff_encode_symbols(HUFF_STATE *shuff, SHUFFCODE *ctable)
        char bit;
        SHUFFCODE symbolcode;
                
        char bit;
        SHUFFCODE symbolcode;
                
-       /* Abrimos el file */
+       /* Abrimos el source y el destino */
+       if (shuff->coderfp != NULL) fclose(shuff->coderfp); /* close bychunk temp file */
        if ((fpsource = fopen(shuff->sourcefile,"r")) == NULL) return 0;
        if ((fpdest = vfopen(shuff->targetfile,"w",shuff->volsize)) == NULL) return 0;
                
        if ((fpsource = fopen(shuff->sourcefile,"r")) == NULL) return 0;
        if ((fpdest = vfopen(shuff->targetfile,"w",shuff->volsize)) == NULL) return 0;
                
@@ -418,11 +422,11 @@ HUFF_STATE *shuff_init_encoder_bychunk(char *outputfile, long volsize)
 void shuff_deinit_encoder(HUFF_STATE *shuff)
 {
        /* Libero mallocs y cierro archivos */
 void shuff_deinit_encoder(HUFF_STATE *shuff)
 {
        /* Libero mallocs y cierro archivos */
-       free(shuff->freqtable);
-       free(shuff->sourcefile);
-       free(shuff->targetfile);        
+       free(shuff->freqtable); 
        if (shuff->coderfp != NULL) fclose(shuff->coderfp);
        if (shuff->coderfp != NULL) fclose(shuff->coderfp);
-       if (shuff->decoderfp != NULL) vfclose(shuff->decoderfp);
+       if (shuff->preloadfreq == 1) unlink(shuff->sourcefile);
+       free(shuff->sourcefile);
+       free(shuff->targetfile);                        
        
        /* Destruyo recursivamente el arbol de codigos */
 }
        
        /* Destruyo recursivamente el arbol de codigos */
 }
index 5bc16452e8a832908b18dc1740b6be572beb22a5..d892aea107b3a01939bd8545c2c9c62c08fc5248 100644 (file)
@@ -33,10 +33,12 @@ typedef struct t_huff {
        unsigned long int bytesleft; /* cuanto falta descomprimir en un bychunk */      
 } HUFF_STATE;
 
        unsigned long int bytesleft; /* cuanto falta descomprimir en un bychunk */      
 } HUFF_STATE;
 
+
 HUFF_STATE *shuff_init_encoder_byfile(char *inputfile, char *outputfile, long volsize);
 HUFF_STATE *shuff_init_encoder_bychunk(char *outputfile, long volsize);
 HUFF_STATE *shuff_init_decoder(char *inputfile, char *outputfile);
 void shuff_deinit_encoder(HUFF_STATE *shuff);
 HUFF_STATE *shuff_init_encoder_byfile(char *inputfile, char *outputfile, long volsize);
 HUFF_STATE *shuff_init_encoder_bychunk(char *outputfile, long volsize);
 HUFF_STATE *shuff_init_decoder(char *inputfile, char *outputfile);
 void shuff_deinit_encoder(HUFF_STATE *shuff);
+int shuff_encode_file(HUFF_STATE *shuff);
 int shuff_decode_file(HUFF_STATE *shuff);
 
 #endif /* _STATICHUFF_H_ */
 int shuff_decode_file(HUFF_STATE *shuff);
 
 #endif /* _STATICHUFF_H_ */