From: Alan Kennedy Date: Sat, 26 Jun 2004 22:31:25 +0000 (+0000) Subject: Bufix PUTO PUTO PUTO X2 de ZG descubierto por allmighty luca. Killed the god damn... X-Git-Tag: svn_import~51 X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/commitdiff_plain/f6ac885f3bdb32a3dd9bbc4df6981a8efc04180c?hp=827a184ea907acf9b2b2d72d89ab67572728e11e Bufix PUTO PUTO PUTO X2 de ZG descubierto por allmighty luca. Killed the god damn thing. Rich ya podes darle tranca --- diff --git a/src/jacu.c b/src/jacu.c index ccd68ae..8a18603 100644 --- a/src/jacu.c +++ b/src/jacu.c @@ -140,30 +140,26 @@ int main(int argc, char* argv[]) /* 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)); @@ -191,7 +187,7 @@ int main(int argc, char* argv[]) 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; @@ -226,27 +222,27 @@ int main(int argc, char* argv[]) /* 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 {