--- psiconv/trunk/lib/psiconv/parse_image.c 2004/02/25 16:12:10 229 +++ psiconv/trunk/lib/psiconv/parse_image.c 2004/02/25 20:56:43 230 @@ -30,6 +30,9 @@ #include #endif +/* Extreme debugging info */ +#undef LOUD + static int psiconv_decode_rle8 (const psiconv_config config, int lev, psiconv_u32 off, const psiconv_pixel_bytes encoded, @@ -279,9 +282,11 @@ psiconv_progress(config,lev+2,off+len,"Going to read the pixel data"); for (i = 0; i < datasize; i++) { byte = psiconv_read_u8(config,buf,lev+2,off+len+i,&res); +#ifdef LOUD psiconv_debug(config,lev+2,off+len+i, "Pixel byte %04x of %04x has value %02x", i,datasize,byte); +#endif if (res) goto ERROR3; psiconv_list_add(bytes,&byte); @@ -652,32 +657,46 @@ goto ERROR1; for (i = 0; i < psiconv_list_length(encoded);) { +#ifdef LOUD psiconv_progress(config,lev+2,off,"Going to read marker byte at %04x",i); +#endif if (!(marker = psiconv_list_get(encoded,i))) goto ERROR2; +#ifdef LOUD psiconv_debug(config,lev+2,off,"Marker byte: %02x",*marker); +#endif if (*marker < 0x80) { +#ifdef LOUD psiconv_debug(config,lev+2,off,"Marker: repeat value byte %02x times", - *marker+1); + *marker+1); */ psiconv_progress(config,lev+2,off,"Going to read value byte at %04x",i+1); +#endif if (!(value = psiconv_list_get(encoded,i+1))) goto ERROR2; - psiconv_debug(config,lev+2,off,"Value byte: %02x",*value); +#ifdef LOUD + psiconv_debug(config,lev+2,off,"Value byte: %02x",*value); psiconv_progress(config,lev+2,off,"Adding %02x pixels %02x", *marker+1,*value); +#endif for (j = 0; j < *marker + 1; j++) if ((res = psiconv_list_add(*decoded,value))) goto ERROR2; i += 2; } else { +#ifdef LOUD psiconv_debug(config,lev+2,off,"Marker: %02x value bytes follow", 0x100 - *marker); +#endif for (j = 0; j < (0x100 - *marker); j++) { +#ifdef LOUD psiconv_progress(config,lev+2,off,"Going to read value byte at %04x", i+j+1); +#endif if (!(value = psiconv_list_get(encoded,i+j+1))) goto ERROR2; - psiconv_debug(config,lev+2,off,"Value: %02x",*value); +#ifdef LOUD + psiconv_debug(config,lev+2,off,"Value: %02x",*value); +#endif if ((res = psiconv_list_add(*decoded,value))) goto ERROR2; } @@ -901,17 +920,23 @@ input = 0; ibits = 0; for (x= 0; x < xsize; x++) { +#ifdef LOUD psiconv_progress(config,lev+2,off, "Processing pixel at (x,y) = (%04x,%04x)",x,y); +#endif output = 0; obits = 0; while (obits < colordepth) { if (ibits == 0) { +#ifdef LOUD psiconv_progress(config,lev+3,off, "Going to read byte %08x",nr); +#endif if (!(ientry = psiconv_list_get(bytes,nr))) goto ERROR2; +#ifdef LOUD psiconv_debug(config,lev+3,off,"Byte value: %02x",*ientry); +#endif input = *ientry; ibits = 8; nr ++; @@ -923,7 +948,9 @@ ibits -= bits; obits += bits; } +#ifdef LOUD psiconv_debug(config,lev+2,off,"Pixel value: %08x",output); +#endif if ((res = psiconv_list_add(*pixels,&output))) goto ERROR2; } @@ -971,7 +998,9 @@ for (i = 0; i < psiconv_list_length(pixels); i++) { if (!(pixel = psiconv_list_get(pixels,i))) goto ERROR4; +#ifdef LOUD psiconv_progress(config,lev+2,off, "Handling pixel %04x (%04x)",i,*pixel); +#endif if (!palet.length) { if (color) { (*floats).blue[i] = ((float) (*pixel & ((1 << bluebits) - 1))) / @@ -998,8 +1027,10 @@ (*floats).blue[i] = palet.blue[*pixel]; } } +#ifdef LOUD psiconv_debug(config,lev+2,off, "Pixel: Red (%f), green (%f), blue (%f)", (*floats).red[i],(*floats).green[i],(*floats).blue[i]); +#endif } psiconv_progress(config,lev+1,off,"Finished converting pixels to floats"); return 0;