/* Le aplico el MTF a salida */
mtf = jacu_mtf(salida, i+sizeof(Uint32), &z, &z_len);
-
+
/* Guardo el z_len y el Z */
shuff_scanfreq_chunk(shuff,(char*)&z_len,sizeof(int));
shuff_scanfreq_chunk(shuff,z,z_len);
/* Si me lo piden, aplico ZG. */
if (zflag) {
- Uint32 len,total_len = 0;
- char buff[2];
+ Uint32 len;
+ unsigned char buff[2];
Uint32 total_size = i + sizeof(Uint32);
ZG zg;
/* Guardo la salida del MTF con ceros agrupados (ZG) */
zg_init(&zg);
for (j = 0; j < total_size; ++j)
- if ((len = zg_group(&zg, buff, mtf[j]))) {
+ if ((len = zg_group(&zg, buff, mtf[j])))
shuff_scanfreq_chunk(shuff, buff, len);
- total_len += len;
- }
+
/* Flusheo ultimo zgrouping */
- if ((len = zg_group_finish(&zg,buff))) {
- shuff_scanfreq_chunk(shuff, buff, len);
- total_len += len;
- }
- printf ("Saved %ld zgbytes\n",total_len);
+ if ((len = zg_group_finish(&zg,buff)))
+ shuff_scanfreq_chunk(shuff, buff, len);
} else {
/* Comprimo la salida del MTF */
shuff_scanfreq_chunk(shuff,mtf,i+sizeof(Uint32));
if (dflag == 1) {
/* Descomprimo */
FILE *fp_out;
- Uint32 block_size = 0,zgungrouped = 0, zgread = 0,k;
+ Uint32 block_size = 0,zgungrouped = 0, k;
unsigned char *block, *mtf, *orig;
unsigned char *z, *zgbuffer;
int zgmoved = 0,z_len=0,moredata = 0,decoded = 0;
/* Veo si se uso Zero Grouping para comprimir */
if (use_zg) {
- zgungrouped = 0;
- zgread = 0;
- /* Me fijo si tengo que copiar leftovers del zgbuffer anterior DEPRECATED? */
- while (zgmoved < retbytes) block[zgungrouped++] = zgbuffer[zgmoved++];
/* Desagrupo bytes hasta completar la pagina or End of Source File */
+ zgungrouped = 0;
do {
/* Levanto un byte zerogrouped y lo paso por el zg_ungroup */
- zgmoved = 0;
- moredata = shuff_decode_chunk(shuff,&zgbyte,1,&decoded);
- ++zgread;
+ zgmoved = 0;
+ moredata = shuff_decode_chunk(shuff,&zgbyte,1,&decoded);
retbytes = zg_ungroup(&zg,zgbuffer,zgbyte);
/* Muevo del zgbuffer a mi bloque lo que corresponda */
while ((zgmoved < retbytes) && (zgungrouped < block_size+sizeof(Uint32))) {
- block[zgungrouped++] = zgbuffer[zgmoved++];
- /*if ((zgungrouped % 500) == 0) printf("At source byte %ld we have processed %ld zgbytes\n",zgungrouped,zgread);*/
+ block[zgungrouped++] = zgbuffer[zgmoved++];
}
- /*if ((zgungrouped % 500) == 0) printf("At source byte %ld we have processed %ld zgbytes\n",zgungrouped,zgread);*/
} while ((moredata) && (zgungrouped < block_size+sizeof(Uint32)));
-
- /* Normalizo variables para continuar en common code */
- printf("At source byte %ld we have processed %ld zgbytes\n",zgungrouped,zgread);
+
+ /* Me fijo si el ultimo byte procesado que me completo la pagina fue un 0 */
+ if (zgbyte == 0) {
+ /* Leo un byte mas (un 0 seguro) y zg_ungroup cambiara su estado */
+ moredata = shuff_decode_chunk(shuff,&zgbyte,1,&decoded);
+ zg_ungroup(&zg,zgbuffer,zgbyte);
+ }
+
+ /* Normalizo variables para continuar en common code */
decoded = zgungrouped;
}
else {