home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR2 / DVPG30FS.ZIP / DITHER.C < prev    next >
Internet Message Format  |  1993-11-22  |  5KB

  1. From rossi@cs.unibo.it Mon Nov 22 12:14 EST 1993
  2. Received: from leporello.cs.unibo.it by maxwell.uwaterloo.ca with SMTP
  3.     (1.37.109.8/15.6) id AA20291; Mon, 22 Nov 1993 12:14:36 -0500
  4. Return-Path: <rossi@cs.unibo.it>
  5. Received: from desdemona.cs.unibo.it (radames.cs.unibo.it) by leporello.cs.unibo.it (5.65c/1.34)
  6.     id AA01968; Mon, 22 Nov 1993 18:14:26 +0100
  7. Received: by desdemona.cs.unibo.it (5.65c/SMI-4.1)
  8.     id AA02099; Mon, 22 Nov 1993 18:14:24 +0100
  9. From: rossi@cs.unibo.it (Davide Rossi)
  10. Message-Id: <199311221714.AA02099@desdemona.cs.unibo.it>
  11. Subject: Re: The new JPEG code...
  12. To: praetzel@maxwell.uwaterloo.ca (Eric Praetzel)
  13. Date: Mon, 22 Nov 93 18:14:22 MET
  14. In-Reply-To: <199311221655.AA01938@leporello.cs.unibo.it>; from "Eric Praetzel" at Nov 22, 93 11:55:24 am
  15. X-Mailer: ELM [version 2.4dev PL32]
  16. Status: RO
  17.  
  18. Hello again,
  19.  
  20. >I tried speeding up the Huffman decoding but had no measurable luck.  I
  21. >can speed it up a bit by playing with the assembler; but what is needed
  22. >is probably another method.
  23. Sure... I'll start to play with Huffman decoding when I'll be able to 
  24. print some docs I have about it...
  25.  
  26. >The grayscale viewing on mine is about as fast as the hi-color viewing
  27. >on QPEG.  That is not bad and I can't help but wonder where the speed
  28. >difference is.  He saves time in his colorspace conversion but I really
  29. >wonder how far behind we are on the IDCT and Huffman.  I can only see
  30. >the LUTs being used for the Huffman.  They would certainly not be usefull
  31. >for the IDCT.
  32. >I think that I will move the colorspace conversion into the IDCT.  That
  33. >will mean that storing of the components is not required.  It will be
  34. >interesting to see what it does.
  35. This was why I was talking about "write brand new code..." :)
  36.  
  37. >I have an interesting JPEG.  It is 2100 * 1500 (aprox) and was made from a
  38. >slide I took on my bike trip.  I believe that it was Cortina d'ampezo (?)
  39. Close but not right: is Cortina d'Ampezzo... 2 z's ;>
  40.  
  41. >The original Targa was 10M and the JPEG is only 350k.  It was first 
  42. >compressed to JPEG with Image Alchemy (a 2.2M JPEG) and then recompressed 
  43. >at Q = 75. I have been having some fun comparing that slide and computer 
  44. >image to a slide made from the JPEG file.
  45. I have not such a big image... for testing purpose I use some 1670x1700... 
  46. there is a way for having such image (I mean get it with ftp) ?
  47. Well I know: I can use any, say, 320x200 and change it to, say, 3200x2000 
  48. but it is not as fanny as having such a big image :)
  49.  
  50.  
  51. BTW: this is the code... let me know what you think about it!
  52.  
  53. Davide.
  54. _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  55.  
  56. uword far *ord[4][4];
  57.  
  58. #define MK_HI(R,G,B) \
  59. (((R)&0xf8)<<7|((G)&0xf8)<<2|(((B)&0xf8)>>3))
  60.  
  61. static void
  62. init_ord(decompress_info_ptr cinfo)
  63. {
  64.   for(int i=0; i<4; i++) {
  65.     for(int j=0; j<4; j++) {
  66.       ord[i][j]=(uword far *)(*cinfo->emethods->alloc_medium)(512);
  67.     }
  68.   }
  69.   static int err[4][4]=
  70.   { { 4, -1,  3, -2},
  71.     {-3,  2, -4,  1},
  72.     { 2, -2,  3, -1},
  73.     {-4,  0, -3,  1},};
  74.   int x,j,idx;
  75.   for(i=0; i<4; i++) {
  76.     for(j=0; j<4; j++) {
  77.       for(idx=0; idx<256; idx++) {
  78.         x=idx+err[i][j];
  79.         if(x<0) x=0;
  80.         if(x>255) x=255;
  81.         ord[i][j][idx]=MK_HI(x, x, x);
  82.       }
  83.     }
  84.   }
  85. }
  86.  
  87. METHODDEF void
  88. put_hi_ord_pixel_rows (decompress_info_ptr cinfo, int num_rows, JSAMPIMAGE pixel_data)
  89. /* Write some rows of output data */
  90. {
  91.   JSAMPROW ptr0, ptr1, ptr2;
  92.   uword far *ord_ptr0, far *ord_ptr1, far *ord_ptr2, far *ord_ptr3;
  93.   register int row, col;
  94.   register boolean cont=true;
  95.  
  96.   for (row=0; row<num_rows; row++, line++) {
  97.     uword *ptr=line_ptr;
  98.     ptr0 = pixel_data[0][row];
  99.     ptr1 = pixel_data[1][row];
  100.     ptr2 = pixel_data[2][row];
  101.     ord_ptr0=ord[line%4][0];
  102.     ord_ptr1=ord[line%4][1];
  103.     ord_ptr2=ord[line%4][2];
  104.     ord_ptr3=ord[line%4][3];
  105. //be careful: this code wants 8byte aligned image, else you have to add
  106. //some control
  107.     for(col=0; col<cinfo->image_width; col+=4) {
  108.       *ptr++=(ord_ptr0[*ptr0++]&0x7c00) |
  109.              (ord_ptr0[*ptr1++]&0x03e0) |
  110.              (ord_ptr0[*ptr2++]&0x001f);
  111.       *ptr++=(ord_ptr1[*ptr0++]&0x7c00) |
  112.              (ord_ptr1[*ptr1++]&0x03e0) |
  113.              (ord_ptr1[*ptr2++]&0x001f);
  114.       *ptr++=(ord_ptr2[*ptr0++]&0x7c00) |
  115.              (ord_ptr2[*ptr1++]&0x03e0) |
  116.              (ord_ptr2[*ptr2++]&0x001f);
  117.       *ptr++=(ord_ptr3[*ptr0++]&0x7c00) |
  118.              (ord_ptr3[*ptr1++]&0x03e0) |
  119.              (ord_ptr3[*ptr2++]&0x001f);
  120.     } //instead of 000111222333 you can also try 012301230123... is nice...
  121.     cont&=cinfo->picture->OutLine(global_props, line, (ubyte far *)line_ptr);
  122.   }
  123.   if(!cont) {
  124.     (*emethods->free_all) (); /* clean up memory allocation & temp files */
  125.     longjmp(setjmp_buffer, 1);
  126.   }
  127. }
  128.  
  129. PS:
  130. uword=unsigned
  131.  
  132.