]> git.llucax.com Git - z.facultad/75.06/jacu.git/commitdiff
VIOLA !!!! ... ahora si anda !!!
authorRicardo Markiewicz <gazer.arg@gmail.com>
Fri, 25 Jun 2004 04:02:39 +0000 (04:02 +0000)
committerRicardo Markiewicz <gazer.arg@gmail.com>
Fri, 25 Jun 2004 04:02:39 +0000 (04:02 +0000)
 Eran los putos bits nomas !!

src/jacu.c
src/mtf/mtf.c
src/mtf/mtf.h

index 5add536bdca619bef27d773bc85a548264341a05..089bc7930fcd5aec94425a45d257448af371c607 100644 (file)
@@ -99,9 +99,9 @@ int main(int argc, char* argv[])
                /* Comprimo */          
                FILE *fp;
                Uint32 i, j, total, k;
-               char *mtf;
-               char *salida, *data;
-               char *z;
+               unsigned char *mtf;
+               unsigned char *salida, *data;
+               unsigned char *z;
                int z_len;
                
                /* Preparo el compresor huffman */
@@ -109,8 +109,8 @@ int main(int argc, char* argv[])
                if (mflag == 1) shuff_loadmodel(shuff,staticmodel);
                
                /* Preparo el BS alocando mem para el K, el Block y su Size */
-               data = malloc(sizeof(char)*pagesize);
-               salida = malloc(sizeof(char)*pagesize+sizeof(Uint32)*2);
+               data = malloc(sizeof(unsigned char)*pagesize);
+               salida = malloc(sizeof(unsigned char)*pagesize+sizeof(Uint32)*2);
                bs = bs_create(pagesize);
 
                /* Abrimos el archivo a comprimir y encodeamos bloques */
@@ -195,10 +195,10 @@ int main(int argc, char* argv[])
        if (dflag == 1) { 
                /* Descomprimo */
                FILE *fp_out;
-               FILE *fp_in;
+               /*FILE *fp_in;*/
                Uint32 block_size, k;
-               char *block, *mtf, *orig;
-               char *z;
+               unsigned char *block, *mtf, *orig;
+               unsigned char *z;
                int z_len,moredata = 0,decoded = 0;
 
                /* Inicializo el descompresor */
@@ -213,7 +213,7 @@ int main(int argc, char* argv[])
                        moredata = shuff_decode_chunk(shuff,(char*)&block_size,sizeof(Uint32),&decoded);
                        if (block_size > 0) {
                                moredata = shuff_decode_chunk(shuff,(char*)&z_len,sizeof(int),&decoded);                                
-                               z = malloc(sizeof(char)*z_len);
+                               z = malloc(sizeof(unsigned char)*z_len);
                                moredata = shuff_decode_chunk(shuff,z,z_len,&decoded);                          
 
                                /*printf("MTF Z (len=%d) = [", z_len);
@@ -225,8 +225,8 @@ int main(int argc, char* argv[])
        
                                }*/
                                
-                               block = malloc(block_size*sizeof(char)+sizeof(Uint32));
-                               orig = malloc(block_size*sizeof(char));
+                               block = malloc(block_size*sizeof(unsigned char)+sizeof(Uint32));
+                               orig = malloc(block_size*sizeof(unsigned char));
                                moredata = shuff_decode_chunk(shuff,block,block_size+sizeof(Uint32),&decoded);                          
 
                                /*printf("Antes MTF_inv = [");
@@ -237,7 +237,7 @@ int main(int argc, char* argv[])
                                        printf("]\n");
                                }*/
                                /* Hago el MTF inverso */
-                               mtf = jacu_mtf_inv(z, block, block_size*sizeof(char)+sizeof(Uint32));
+                               mtf = jacu_mtf_inv(z, block, block_size*sizeof(unsigned char)+sizeof(Uint32));
 
                                /*printf("Luego de MTF Inv= [");
                                {
@@ -253,7 +253,7 @@ int main(int argc, char* argv[])
                                /*printf("Restored : k=%ld\n", k);*/
                                bs_restore(orig, mtf+sizeof(Uint32), k, block_size);
 
-                               fwrite(orig, block_size, sizeof(char), fp_out);
+                               fwrite(orig, block_size, sizeof(unsigned char), fp_out);
                                free(block);
                                free(orig);
                                free(mtf);
index 92088c06e7530d02e73ae1d450290e50001a5d37..9f394e31ae0d6749c7f4b2147a9713729f72c223 100644 (file)
@@ -16,16 +16,16 @@ void print_z(char *z, int len)
        fprintf(stderr, "\n");
 }
 
-char *jacu_mtf(char *datos, int len, char **_z, int *z_len)
+unsigned char *jacu_mtf(unsigned char *datos, int len, unsigned char **_z, int *z_len)
 {
-       char *z;
-       char *pos;
+       unsigned char *z;
+       unsigned char *pos;
        int i, size;
        
-       pos = (char *)malloc(len*sizeof(char));
+       pos = (unsigned char *)malloc(len*sizeof(unsigned char));
        z = jacu_buscar_z(datos, len, &size);
-       *_z = (char*)malloc(len*sizeof(char));
-       memcpy(*_z, z, len*sizeof(char));
+       *_z = (unsigned char*)malloc(len*sizeof(unsigned char));
+       memcpy(*_z, z, len*sizeof(unsigned char));
        for(i=0; i<len; i++){
                pos[i] = get_pos(z, size, datos[i]);
                if (pos[i] != 0) 
@@ -35,7 +35,7 @@ char *jacu_mtf(char *datos, int len, char **_z, int *z_len)
        return pos;
 }
 
-char *jacu_mtf_inv(char *z, unsigned char *pos, int len)
+unsigned char *jacu_mtf_inv(unsigned char *z, unsigned char *pos, int len)
 {
        char *datos;
        int i;
@@ -49,7 +49,7 @@ char *jacu_mtf_inv(char *z, unsigned char *pos, int len)
        return datos;
 }
 
-char *jacu_buscar_z(char* datos, int len, int *size)
+unsigned char *jacu_buscar_z(unsigned char* datos, int len, int *size)
 {
        char *z;
        int i, j=0;
index c6f46ceab34eaff782ccc2353cc3d3cd5a360d3c..5d09eb9762067729f4896c05ca966af945d3f747 100644 (file)
@@ -4,10 +4,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-char *jacu_mtf(char *datos, int len, char **_z, int *z_len);
+unsigned char *jacu_mtf(unsigned char *datos, int len, unsigned char **_z, int *z_len);
 
-char *jacu_mtf_inv(char *z, unsigned char *pos, int len);
+unsigned char *jacu_mtf_inv(unsigned char *z, unsigned char *pos, int len);
 
-char *jacu_buscar_z(char* datos, int len, int *size);
+unsigned char *jacu_buscar_z(unsigned char* datos, int len, int *size);
 
 #endif