- block = malloc((block_size+sizeof(unsigned long int))*sizeof(char));
- orig = malloc(block_size*sizeof(char));
- vfread(block, block_size, sizeof(char), fp_in);
-
- mtf = jacu_mtf_inv(block, /*XXX NO LO TENGO XXX */pos, block_size);
-
- memcpy(&k, block, sizeof(unsigned long int));
-
- bs_restore(orig, block+sizeof(unsigned long int), 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);