- block = malloc(block_size*sizeof(char)+sizeof(Uint32));
- orig = malloc(block_size*sizeof(char));
- fread(block, block_size, sizeof(char), fp_in);
-
- mtf = jacu_mtf_inv(z, block, block_size);
-
- memcpy(&k, block, sizeof(Uint32));
-
- bs_restore(orig, block+sizeof(Uint32), k, block_size);
-
- fwrite(orig, block_size, sizeof(char), fp_out);
- free(block);
- free(orig);
+ /* Descomprimo el Zlen y el Z del MTF */
+ moredata = shuff_decode_chunk(shuff,(char*)&z_len,sizeof(int),&decoded);
+ z = malloc(sizeof(unsigned char)*z_len);
+ moredata = shuff_decode_chunk(shuff,z,z_len,&decoded);
+
+ /* Levanto una salida de MTF y le aplico MTF Inverso */
+ moredata = shuff_decode_chunk(shuff,block,block_size+sizeof(Uint32),&decoded);
+ mtf = jacu_mtf_inv(z, block, decoded);
+
+ /* Ya tengo la salida del BS, tonces levanto su K */
+ memcpy(&k, mtf, sizeof(Uint32));
+
+ /* Obtengo el chunk original aplicando BS Inverso */
+ bs_restore(orig, mtf+sizeof(Uint32), k, decoded - sizeof(Uint32));
+
+ fwrite(orig, decoded - sizeof(Uint32), sizeof(unsigned char), fp_out);