diff -rcN -x winvnc___Win32_Http -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt -x buildtime.h ../UltraVNC-102-Src\UltraVNC/rfb/rfbproto.h UltraVNC/rfb/rfbproto.h *** ../UltraVNC-102-Src\UltraVNC/rfb/rfbproto.h Wed Aug 02 11:53:58 2006 --- UltraVNC/rfb/rfbproto.h Wed Aug 02 12:53:47 2006 *************** *** 322,327 **** --- 322,329 ---- #define rfbEncodingZlibHex 8 #define rfbEncodingUltra 9 #define rfbEncodingZRLE 16 + // nyama/2006/08/02:new YUV-Wavlet lossy codec based on ZRLE + #define rfbEncodingZYWRLE 17 // Cache & XOR-Zlib - rdv@2002 #define rfbEncodingCache 0xFFFF0000 diff -rcN -x winvnc___Win32_Http -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt -x buildtime.h ../UltraVNC-102-Src\UltraVNC/rfb/zrleDecode.h UltraVNC/rfb/zrleDecode.h *** ../UltraVNC-102-Src\UltraVNC/rfb/zrleDecode.h Wed Aug 02 11:53:59 2006 --- UltraVNC/rfb/zrleDecode.h Tue Jul 25 10:53:00 2006 *************** *** 39,54 **** #define __RFB_CONCAT2E(a,b) __RFB_CONCAT2(a,b) #endif #ifdef CPIXEL #define PIXEL_T __RFB_CONCAT2E(rdr::U,BPP) #define READ_PIXEL __RFB_CONCAT2E(readOpaque,CPIXEL) ! #define ZRLE_DECODE_BPP __RFB_CONCAT2E(zrleDecode,CPIXEL) #else #define PIXEL_T __RFB_CONCAT2E(rdr::U,BPP) #define READ_PIXEL __RFB_CONCAT2E(readOpaque,BPP) ! #define ZRLE_DECODE_BPP __RFB_CONCAT2E(zrleDecode,BPP) #endif void ZRLE_DECODE_BPP (int x, int y, int w, int h, rdr::InStream* is, rdr::ZlibInStream* zis, PIXEL_T* buf) { --- 39,80 ---- #define __RFB_CONCAT2E(a,b) __RFB_CONCAT2(a,b) #endif + #ifndef __RFB_CONCAT3E + #define __RFB_CONCAT3(a,b,c) a##b##c + #define __RFB_CONCAT3E(a,b,c) __RFB_CONCAT3(a,b,c) + #endif + + #undef END_FIX + #if ZYWRLE_ENDIAN == ENDIAN_LITTLE + # define END_FIX LE + #elif ZYWRLE_ENDIAN == ENDIAN_BIG + # define END_FIX BE + #else + # define END_FIX NE + #endif + #ifdef CPIXEL #define PIXEL_T __RFB_CONCAT2E(rdr::U,BPP) #define READ_PIXEL __RFB_CONCAT2E(readOpaque,CPIXEL) ! #define ZRLE_DECODE_BPP __RFB_CONCAT3E(zrleDecode,CPIXEL,END_FIX) ! #define BPPOUT BPP ! #elif BPP==15 ! #define PIXEL_T __RFB_CONCAT2E(rdr::U,16) ! #define READ_PIXEL __RFB_CONCAT2E(readOpaque,16) ! #define ZRLE_DECODE_BPP __RFB_CONCAT3E(zrleDecode,BPP,END_FIX) ! #define BPPOUT 16 #else #define PIXEL_T __RFB_CONCAT2E(rdr::U,BPP) #define READ_PIXEL __RFB_CONCAT2E(readOpaque,BPP) ! #define ZRLE_DECODE_BPP __RFB_CONCAT3E(zrleDecode,BPP,END_FIX) ! #define BPPOUT BPP #endif + #if BPP!=8 + #define ZYWRLE_DECODE + #include + #endif + void ZRLE_DECODE_BPP (int x, int y, int w, int h, rdr::InStream* is, rdr::ZlibInStream* zis, PIXEL_T* buf) { *************** *** 62,67 **** --- 88,96 ---- int tw = rfbZRLETileWidth; if (tw > x+w-tx) tw = x+w-tx; + #if BPP!=8 + top: + #endif int mode = zis->readU8(); BOOL rle = mode & 128; int palSize = mode & 127; *************** *** 74,82 **** } if (palSize == 1) { ! PIXEL_T pix = palette[0]; ! FILL_RECT(tx,ty,tw,th,pix); ! continue; } if (!rle) { --- 103,113 ---- } if (palSize == 1) { ! PIXEL_T* ptr = buf; ! for (int i = 0; i < tw*th; i++) { ! *ptr++ = palette[0]; ! } ! goto draw; } if (!rle) { *************** *** 84,95 **** // raw #ifdef CPIXEL for (PIXEL_T* ptr = buf; ptr < buf+tw*th; ptr++) { *ptr = zis->READ_PIXEL(); } #else ! zis->readBytes(buf, tw * th * (BPP / 8)); #endif } else { --- 115,132 ---- // raw + #if BPP!=8 + if( (zywrle_level>0)&& !(zywrle_level & 0x80) ){ + zywrle_level |= 0x80; + goto top; + }else + #endif #ifdef CPIXEL for (PIXEL_T* ptr = buf; ptr < buf+tw*th; ptr++) { *ptr = zis->READ_PIXEL(); } #else ! zis->readBytes(buf, tw * th * (BPPOUT / 8)); #endif } else { *************** *** 228,233 **** --- 265,277 ---- #ifndef FAVOUR_FILL_RECT //fprintf(stderr,"copying data to screen %dx%d at %d,%d\n",tw,th,tx,ty); + draw: + #if BPP!=8 + if( zywrle_level & 0x80 ){ + zywrle_level &= 0x7F; + ZYWRLE_SYNTHESIZE( buf, buf, tw, th, tw, zywrle_level, zywrleBuf ); + } + #endif IMAGE_RECT(tx,ty,tw,th,buf); #endif } *************** *** 239,241 **** --- 283,286 ---- #undef ZRLE_DECODE_BPP #undef READ_PIXEL #undef PIXEL_T + #undef BPPOUT diff -rcN -x winvnc___Win32_Http -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt -x buildtime.h ../UltraVNC-102-Src\UltraVNC/rfb/zrleEncode.h UltraVNC/rfb/zrleEncode.h *** ../UltraVNC-102-Src\UltraVNC/rfb/zrleEncode.h Wed Aug 02 11:53:59 2006 --- UltraVNC/rfb/zrleEncode.h Thu Aug 31 16:17:28 2006 *************** *** 44,60 **** #define __RFB_CONCAT2E(a,b) __RFB_CONCAT2(a,b) #endif #ifdef CPIXEL #define PIXEL_T __RFB_CONCAT2E(rdr::U,BPP) #define WRITE_PIXEL __RFB_CONCAT2E(writeOpaque,CPIXEL) ! #define ZRLE_ENCODE __RFB_CONCAT2E(zrleEncode,CPIXEL) ! #define ZRLE_ENCODE_TILE __RFB_CONCAT2E(zrleEncodeTile,CPIXEL) #define BPPOUT 24 #else #define PIXEL_T __RFB_CONCAT2E(rdr::U,BPP) #define WRITE_PIXEL __RFB_CONCAT2E(writeOpaque,BPP) ! #define ZRLE_ENCODE __RFB_CONCAT2E(zrleEncode,BPP) ! #define ZRLE_ENCODE_TILE __RFB_CONCAT2E(zrleEncodeTile,BPP) #define BPPOUT BPP #endif --- 44,80 ---- #define __RFB_CONCAT2E(a,b) __RFB_CONCAT2(a,b) #endif + #ifndef __RFB_CONCAT3E + #define __RFB_CONCAT3(a,b,c) a##b##c + #define __RFB_CONCAT3E(a,b,c) __RFB_CONCAT3(a,b,c) + #endif + + #undef END_FIX + #if ZYWRLE_ENDIAN == ENDIAN_LITTLE + # define END_FIX LE + #elif ZYWRLE_ENDIAN == ENDIAN_BIG + # define END_FIX BE + #else + # define END_FIX NE + #endif + #ifdef CPIXEL #define PIXEL_T __RFB_CONCAT2E(rdr::U,BPP) #define WRITE_PIXEL __RFB_CONCAT2E(writeOpaque,CPIXEL) ! #define ZRLE_ENCODE __RFB_CONCAT3E(zrleEncode,CPIXEL,END_FIX) ! #define ZRLE_ENCODE_TILE __RFB_CONCAT3E(zrleEncodeTile,CPIXEL,END_FIX) #define BPPOUT 24 + #elif BPP==15 + #define PIXEL_T __RFB_CONCAT2E(rdr::U,16) + #define WRITE_PIXEL __RFB_CONCAT2E(writeOpaque,16) + #define ZRLE_ENCODE __RFB_CONCAT3E(zrleEncode,BPP,END_FIX) + #define ZRLE_ENCODE_TILE __RFB_CONCAT3E(zrleEncodeTile,BPP,END_FIX) + #define BPPOUT 16 #else #define PIXEL_T __RFB_CONCAT2E(rdr::U,BPP) #define WRITE_PIXEL __RFB_CONCAT2E(writeOpaque,BPP) ! #define ZRLE_ENCODE __RFB_CONCAT3E(zrleEncode,BPP,END_FIX) ! #define ZRLE_ENCODE_TILE __RFB_CONCAT3E(zrleEncodeTile,BPP,END_FIX) #define BPPOUT BPP #endif *************** *** 64,69 **** --- 84,92 ---- 0, 1, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }; + int zywrle_level = 1; + int zywrleBuf[rfbZRLETileWidth*rfbZRLETileHeight]; + // The PaletteHelper class helps us build up the palette from pixel data by // storing a reverse index using a simple hash-table *************** *** 116,121 **** --- 139,149 ---- void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, rdr::OutStream* os); + #if BPP!=8 + #define ZYWRLE_ENCODE + #include + #endif + void ZRLE_ENCODE (int x, int y, int w, int h, rdr::OutStream* os, rdr::ZlibOutStream* zos, void* buf EXTRA_ARGS *************** *** 184,189 **** --- 212,223 ---- int estimatedBytes = w * h * (BPPOUT/8); // start assuming raw + #if BPP!=8 + if( (zywrle_level>0)&& !(zywrle_level & 0x80) ){ + estimatedBytes >>= zywrle_level; + } + #endif + int plainRleBytes = ((BPPOUT/8)+1) * (runs + singlePixels); if (plainRleBytes < estimatedBytes) { *************** *** 292,303 **** // raw #ifdef CPIXEL for (PIXEL_T* ptr = data; ptr < data+w*h; ptr++) { os->WRITE_PIXEL(*ptr); } #else ! os->writeBytes(data, w*h*(BPP/8)); #endif } } --- 326,345 ---- // raw + #if BPP!=8 + if( (zywrle_level>0)&& !(zywrle_level & 0x80) ){ + ZYWRLE_ANALYZE( data, data, w, h, w, zywrle_level, zywrleBuf ); + zywrle_level |= 0x80; + ZRLE_ENCODE_TILE( data, w, h, os ); + zywrle_level &= 0x7F; + }else + #endif #ifdef CPIXEL for (PIXEL_T* ptr = data; ptr < data+w*h; ptr++) { os->WRITE_PIXEL(*ptr); } #else ! os->writeBytes(data, w*h*(BPPOUT/8)); #endif } } diff -rcN -x winvnc___Win32_Http -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt -x buildtime.h ../UltraVNC-102-Src\UltraVNC/rfb/zywrletemplate.c UltraVNC/rfb/zywrletemplate.c *** ../UltraVNC-102-Src\UltraVNC/rfb/zywrletemplate.c Thu Jan 01 09:00:00 1970 --- UltraVNC/rfb/zywrletemplate.c Thu Aug 31 16:14:44 2006 *************** *** 0 **** --- 1,804 ---- + + /******************************************************************** + * * + * THIS FILE IS PART OF THE 'ZYWRLE' VNC CODEC SOURCE CODE. * + * * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A FOLLOWING BSD-STYLE SOURCE LICENSE. * + * PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE 'ZYWRLE' VNC CODEC SOURCE CODE IS (C) COPYRIGHT 2006 * + * BY Hitachi Systems & Services, Ltd. * + * (Noriaki Yamazaki, Research & Developement Center) * * + * * + ******************************************************************** + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + - Neither the name of the Hitachi Systems & Services, Ltd. nor + the names of its contributors may be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ********************************************************************/ + + //#define ZYWRLE_ENCODE + //#define ZYWRLE_DECODE + #define ZYWRLE_QUANTIZE + + //[References] + // PLHarr: + // Senecal, J. G., P. Lindstrom, M. A. Duchaineau, and K. I. Joy, "An Improved N-Bit to N-Bit Reversible Haar-Like Transform," Pacific Graphics 2004, October 2004, pp. 371-380. + // EZW: + // Shapiro, JM: Embedded Image Coding Using Zerotrees of Wavelet Coefficients, IEEE Trans. Signal. Process., Vol.41, pp.3445-3462 (1993). + + + // Template Macro stuffs. + #undef ZYWRLE_ANALYZE + #undef ZYWRLE_SYNTHESIZE + #define ZYWRLE_ANALYZE __RFB_CONCAT3E(zywrleAnalyze,BPP,END_FIX) + #define ZYWRLE_SYNTHESIZE __RFB_CONCAT3E(zywrleSynthesize,BPP,END_FIX) + + #define ZYWRLE_RGBYUV __RFB_CONCAT3E(zywrleRGBYUV,BPP,END_FIX) + #define ZYWRLE_YUVRGB __RFB_CONCAT3E(zywrleYUVRGB,BPP,END_FIX) + #define ZYWRLE_YMASK __RFB_CONCAT2E(ZYWRLE_YMASK,BPP) + #define ZYWRLE_UVMASK __RFB_CONCAT2E(ZYWRLE_UVMASK,BPP) + #define ZYWRLE_LOAD_PIXEL __RFB_CONCAT2E(ZYWRLE_LOAD_PIXEL,BPP) + #define ZYWRLE_SAVE_PIXEL __RFB_CONCAT2E(ZYWRLE_SAVE_PIXEL,BPP) + + // Packing/Unpacking pixel stuffs. + // Endian conversion stuffs. + #undef S_0 + #undef S_1 + #undef L_0 + #undef L_1 + #undef L_2 + #if ZYWRLE_ENDIAN == ENDIAN_BIG + # define S_0 1 + # define S_1 0 + # define L_0 3 + # define L_1 2 + # define L_2 1 + #else + # define S_0 0 + # define S_1 1 + # define L_0 0 + # define L_1 1 + # define L_2 2 + #endif + + // Load/Save pixel stuffs. + #define ZYWRLE_YMASK15 0xFFFFFFF8 + #define ZYWRLE_UVMASK15 0xFFFFFFF8 + #define ZYWRLE_LOAD_PIXEL15(pSrc,R,G,B) { \ + R = (((unsigned char*)pSrc)[S_1]<< 1)& 0xF8; \ + G = ((((unsigned char*)pSrc)[S_1]<< 6)|(((unsigned char*)pSrc)[S_0]>> 2))& 0xF8; \ + B = (((unsigned char*)pSrc)[S_0]<< 3)& 0xF8; \ + } + #define ZYWRLE_SAVE_PIXEL15(pDst,R,G,B) { \ + R &= 0xF8; \ + G &= 0xF8; \ + B &= 0xF8; \ + ((unsigned char*)pDst)[S_1] = (unsigned char)( (R>>1)|(G>>6) ); \ + ((unsigned char*)pDst)[S_0] = (unsigned char)(((B>>3)|(G<<2))& 0xFF); \ + } + #define ZYWRLE_YMASK16 0xFFFFFFFC + #define ZYWRLE_UVMASK16 0xFFFFFFF8 + #define ZYWRLE_LOAD_PIXEL16(pSrc,R,G,B) { \ + R = ((unsigned char*)pSrc)[S_1] & 0xF8; \ + G = ((((unsigned char*)pSrc)[S_1]<< 5)|(((unsigned char*)pSrc)[S_0]>> 3))& 0xFC; \ + B = (((unsigned char*)pSrc)[S_0]<< 3)& 0xF8; \ + } + #define ZYWRLE_SAVE_PIXEL16(pDst,R,G,B) { \ + R &= 0xF8; \ + G &= 0xFC; \ + B &= 0xF8; \ + ((unsigned char*)pDst)[S_1] = (unsigned char)( R |(G>>5) ); \ + ((unsigned char*)pDst)[S_0] = (unsigned char)(((B>>3)|(G<<3))& 0xFF); \ + } + #define ZYWRLE_YMASK32 0xFFFFFFFF + #define ZYWRLE_UVMASK32 0xFFFFFFFF + #define ZYWRLE_LOAD_PIXEL32(pSrc,R,G,B) { \ + R = ((unsigned char*)pSrc)[L_2]; \ + G = ((unsigned char*)pSrc)[L_1]; \ + B = ((unsigned char*)pSrc)[L_0]; \ + } + #define ZYWRLE_SAVE_PIXEL32(pDst,R,G,B) { \ + ((unsigned char*)pDst)[L_2] = (unsigned char)R; \ + ((unsigned char*)pDst)[L_1] = (unsigned char)G; \ + ((unsigned char*)pDst)[L_0] = (unsigned char)B; \ + } + + #ifndef ZYWRLE_ONCE + #define ZYWRLE_ONCE + + #ifdef WIN32 + #define InlineX __inline + #else + #define InlineX inline + #endif + + #ifdef ZYWRLE_ENCODE + // Tables for Coefficients filtering. + # ifndef ZYWRLE_QUANTIZE + // Type A:lower bit omitting of EZW style. + const static unsigned int zywrleParam[3][3]={ + {0x0000F000,0x00000000,0x00000000}, + {0x0000C000,0x00F0F0F0,0x00000000}, + {0x0000C000,0x00C0C0C0,0x00F0F0F0}, + // {0x0000FF00,0x00000000,0x00000000}, + // {0x0000FF00,0x00FFFFFF,0x00000000}, + // {0x0000FF00,0x00FFFFFF,0x00FFFFFF}, + }; + # else + // Type B:Non liner quantization filter. + static const signed char zywrleConv[4][256]={ + { // bi=5, bo=5 r=0.0:PSNR=24.849 + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }, + { // bi=5, bo=5 r=2.0:PSNR=74.031 + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 64, 64, 64, 64, + 64, 64, 64, 64, 72, 72, 72, 72, + 72, 72, 72, 72, 80, 80, 80, 80, + 80, 80, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 96, 96, + 96, 96, 96, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 104, 112, 112, 112, + 112, 112, 112, 112, 112, 112, 120, 120, + 120, 120, 120, 120, 120, 120, 120, 120, + 0, -120, -120, -120, -120, -120, -120, -120, + -120, -120, -120, -112, -112, -112, -112, -112, + -112, -112, -112, -112, -104, -104, -104, -104, + -104, -104, -104, -104, -104, -104, -96, -96, + -96, -96, -96, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -80, + -80, -80, -80, -80, -80, -72, -72, -72, + -72, -72, -72, -72, -72, -64, -64, -64, + -64, -64, -64, -64, -64, -56, -56, -56, + -56, -56, -56, -56, -56, -56, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, + -48, -32, -32, -32, -32, -32, -32, -32, + -32, -32, -32, -32, -32, -32, -32, -32, + -32, -32, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }, + { // bi=5, bo=4 r=2.0:PSNR=64.441 + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 80, 80, 80, 80, 80, 80, 80, 80, + 80, 80, 80, 80, 80, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, + 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 112, 112, 112, 112, 112, + 112, 112, 112, 112, 120, 120, 120, 120, + 120, 120, 120, 120, 120, 120, 120, 120, + 0, -120, -120, -120, -120, -120, -120, -120, + -120, -120, -120, -120, -120, -112, -112, -112, + -112, -112, -112, -112, -112, -112, -104, -104, + -104, -104, -104, -104, -104, -104, -104, -104, + -104, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -80, -80, -80, -80, + -80, -80, -80, -80, -80, -80, -80, -80, + -80, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, + -64, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, + -48, -48, -48, -48, -48, -48, -48, -48, + -48, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }, + { // bi=5, bo=2 r=2.0:PSNR=43.175 + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, + 0, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -88, + -88, -88, -88, -88, -88, -88, -88, -88, + -88, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + } + }; + const static signed char* zywrleParam[3][3][3]={ + {{zywrleConv[0],zywrleConv[2],zywrleConv[0]},{zywrleConv[0],zywrleConv[0],zywrleConv[0]},{zywrleConv[0],zywrleConv[0],zywrleConv[0]}}, + {{zywrleConv[0],zywrleConv[3],zywrleConv[0]},{zywrleConv[1],zywrleConv[1],zywrleConv[1]},{zywrleConv[0],zywrleConv[0],zywrleConv[0]}}, + {{zywrleConv[0],zywrleConv[3],zywrleConv[0]},{zywrleConv[2],zywrleConv[2],zywrleConv[2]},{zywrleConv[1],zywrleConv[1],zywrleConv[1]}}, + }; + # endif + #endif + + static InlineX void Harr( signed char* pX0, signed char* pX1 ){ + // Piecewise-Linear Harr(PLHarr) + int X0=(int)*pX0, X1=(int)*pX1; + int orgX0=X0, orgX1=X1; + if( (X0^X1)&0x80 ){ + // differ sign + X1 += X0; + if( ((X1^orgX1)&0x80)==0 ){ + // |X1| > |X0| + X0 -= X1; // H = -B + } + }else{ + // same sign + X0 -= X1; + if( ((X0^orgX0)&0x80)==0 ){ + // |X0| > |X1| + X1 += X0; // L = A + } + } + *pX0 = (signed char)X1; + *pX1 = (signed char)X0; + } + // 1D-Wavelet transform. + // + // In coefficients array, the famous 'pyramid' decomposition is well used. + // + // 1D Model: + // |L0L0L0L0|L0L0L0L0|H0H0H0H0|H0H0H0H0| : level 0 + // |L1L1L1L1|H1H1H1H1|H0H0H0H0|H0H0H0H0| : level 1 + // + // But this method needs line buffer because H/L is different position from X0/X1. + // So, I used 'interleave' decomposition instead of it. + // + // 1D Model: + // |L0H0L0H0|L0H0L0H0|L0H0L0H0|L0H0L0H0| : level 0 + // |L1H0H1H0|L1H0H1H0|L1H0H1H0|L1H0H1H0| : level 1 + // + // In this method, H/L and X0/X1 is always same position. + // This lead us to more speed and less memory. + // Of cause, the result of both method is quite same + // because it's only difference that coefficient position. + + static InlineX void WaveletLevel( int* data, int size, int l, int SkipPixel ){ + int s, ofs; + signed char* pX0; + signed char* end; + + pX0 = (signed char*)data; + s = (8<>(l+1))*s; + s -= 2; + ofs = (4<>1; + } + if( r & 0x02 ){ + pH += (s>>1)*width; + } + for( y=0; y 1.0 : Larger value is more important than smaller value. + // r = 1.0 : Liner quantization which is same with EZW style. + // + // r = 0.75 is famous non liner quantization used in MP3 audio codec. + // In contrast to audio data, larger value is important in wavelet coefficients. + // So, I select r = 2.0 table( quantize is x^2, dequantize sqrt(x) ). + // + // As compared with EZW style liner quantization, this filter tended to be + // more sharp edge and be more compression rate but be more blocking noise and be less quality. + // Especially, the surface of graphic objects has distinguishable noise in middle quality mode. + // + // We need only quantized-dequantized(filtered) value rather than quantized value itself + // because all values are packed or palette-lized in later ZRLE section. + // This lead us not to need to modify client decoder when we change + // the filtering procedure in future. + // Client only decodes coefficients given by encoder. + static InlineX void FilterWaveletSquare( int* pBuf, int width, int height, int level, int l ){ + int r, s; + int x, y; + int* pH; + const signed char** pM; + + pM = zywrleParam[level-1][l]; + s = 2<>1; + } + if( r & 0x02 ){ + pH += (s>>1)*width; + } + for( y=0; y=0; l-- ){ + pTop = pBuf; + pEnd = pBuf+width; + s = 1< YUV conversion stuffs. + // YUV coversion is explained as following formula in strict meaning: + // Y = 0.299R + 0.587G + 0.114B ( 0<=Y<=255) + // U = -0.169R - 0.331G + 0.500B (-128<=U<=127) + // V = 0.500R - 0.419G - 0.081B (-128<=V<=127) + // + // I use simple conversion RCT(reversible color transform) which is described + // in JPEG-2000 specification. + // Y = (R + 2G + B)/4 ( 0<=Y<=255) + // U = B-G (-256<=U<=255) + // V = R-G (-256<=V<=255) + + #define ROUND(x) (((x)<0)?0:(((x)>255)?255:(x))) + // RCT is N-bit RGB to N-bit Y and N+1-bit UV. + // For make Same N-bit, UV is lossy. + // More exact PLHarr, we reduce to odd range(-127<=x<=127). + #define ZYWRLE_RGBYUV1(R,G,B,Y,U,V,ymask,uvmask) { \ + Y = (R+(G<<1)+B)>>2; \ + U = B-G; \ + V = R-G; \ + Y -= 128; \ + U >>= 1; \ + V >>= 1; \ + Y &= ymask; \ + U &= uvmask; \ + V &= uvmask; \ + if( Y == -128 ){ \ + Y += (0xFFFFFFFF-ymask+1); \ + } \ + if( U == -128 ){ \ + U += (0xFFFFFFFF-uvmask+1); \ + } \ + if( V == -128 ){ \ + V += (0xFFFFFFFF-uvmask+1); \ + } \ + } + #define ZYWRLE_YUVRGB1(R,G,B,Y,U,V) { \ + Y += 128; \ + U <<= 1; \ + V <<= 1; \ + G = Y-((U+V)>>2); \ + B = U+G; \ + R = V+G; \ + G = ROUND(G); \ + B = ROUND(B); \ + R = ROUND(R); \ + } + + // coefficient packing/unpacking stuffs. + // Wavelet transform makes 4 sub coefficient image from 1 original image. + // + // model with pyramid decomposition: + // +------+------+ + // | | | + // | L | Hx | + // | | | + // +------+------+ + // | | | + // | H | Hxy | + // | | | + // +------+------+ + // + // So, we must transfer each sub images individually in strict meaning. + // But at least ZRLE meaning, following one decompositon image is same as + // avobe individual sub image. I use this format. + // (Strictly saying, transfer order is reverse(Hxy->Hy->Hx->L) + // for simplified procedure for any wavelet level.) + // + // +------+------+ + // | L | + // +------+------+ + // | Hx | + // +------+------+ + // | Hy | + // +------+------+ + // | Hxy | + // +------+------+ + + #define ZYWRLE_TRANSFER_COEFF(pBuf,data,r,width,height,level,TRANS) \ + pH = pBuf; \ + s = 2<>1; \ + } \ + if( r & 0x02 ){ \ + pH += (s>>1)*width; \ + } \ + pEnd = pH+height*width; \ + while( pH < pEnd ){ \ + pLine = pH+width; \ + while( pH < pLine ){ \ + TRANS \ + data++; \ + pH += s; \ + } \ + pH += (s-1)*width; \ + } + + #define ZYWRLE_PACK_COEFF(pBuf,data,r,width,height,level) \ + ZYWRLE_TRANSFER_COEFF(pBuf,data,r,width,height,level,ZYWRLE_LOAD_COEFF(pH,R,G,B);ZYWRLE_SAVE_PIXEL(data,R,G,B);) + + #define ZYWRLE_UNPACK_COEFF(pBuf,data,r,width,height,level) \ + ZYWRLE_TRANSFER_COEFF(pBuf,data,r,width,height,level,ZYWRLE_LOAD_PIXEL(data,R,G,B);ZYWRLE_SAVE_COEFF(pH,R,G,B);) + + #define ZYWRLE_SAVE_UNALIGN(data,TRANS) \ + pTop = pBuf+w*h; \ + pEnd = pTop + (w+uw)*(h+uh)-w*h; \ + while( pTop < pEnd ){ \ + TRANS \ + data++; \ + pTop++; \ + } + + #define ZYWRLE_LOAD_UNALIGN(data,pData,TRANS) \ + pTop = pBuf+w*h; \ + if( uw ){ \ + pData= data + w; \ + pEnd = (int*)(pData+ h*scanline); \ + while( pData < (PIXEL_T*)pEnd ){ \ + pLine = (int*)(pData + uw); \ + while( pData < (PIXEL_T*)pLine ){ \ + TRANS \ + pData++; \ + pTop++; \ + } \ + pData += scanline-uw; \ + } \ + } \ + if( uh ){ \ + pData= data + h*scanline; \ + pEnd = (int*)(pData+ uh*scanline); \ + while( pData < (PIXEL_T*)pEnd ){ \ + pLine = (int*)(pData + w); \ + while( pData < (PIXEL_T*)pLine ){ \ + TRANS \ + pData++; \ + pTop++; \ + } \ + pData += scanline-w; \ + } \ + } \ + if( uw && uh ){ \ + pData= data + w+ h*scanline; \ + pEnd = (int*)(pData+ uh*scanline); \ + while( pData < (PIXEL_T*)pEnd ){ \ + pLine = (int*)(pData + uw); \ + while( pData < (PIXEL_T*)pLine ){ \ + TRANS \ + pData++; \ + pTop++; \ + } \ + pData += scanline-uw; \ + } \ + } + + static InlineX void zywrleCalcSize( int* pW, int* pH, int level ){ + *pW &= ~((1<GetReadFromMemoryBuffer()) { ! if (surh.encoding == rfbEncodingZRLE) { // Get the size of the rectangle data buffer ReadExact((char*)&(m_nZRLEReadSize), sizeof(CARD32)); --- 3555,3561 ---- // ZRLE special case if (!fis->GetReadFromMemoryBuffer()) { ! if ((surh.encoding == rfbEncodingZYWRLE)||(surh.encoding == rfbEncodingZRLE)) { // Get the size of the rectangle data buffer ReadExact((char*)&(m_nZRLEReadSize), sizeof(CARD32)); *************** *** 3676,3681 **** --- 3684,3691 ---- ReadSolidRect(&surh); break; case rfbEncodingZRLE: + zywrle = 0; + case rfbEncodingZYWRLE: SaveArea(cacherect); zrleDecode(surh.r.x, surh.r.y, surh.r.w, surh.r.h); EncodingStatusWindow=rfbEncodingZRLE; *************** *** 4427,4432 **** --- 4437,4445 ---- break; case rfbEncodingZRLE: if (m_hwndStatus)SetDlgItemText(m_hwndStatus, IDC_ENCODER, m_opts.m_fEnableCache ? "ZRLE, Cache" :"ZRLE"); + break; + case rfbEncodingZYWRLE: + if (m_hwndStatus)SetDlgItemText(m_hwndStatus, IDC_ENCODER, m_opts.m_fEnableCache ? "ZYWRLE, Cache" :"ZYWRLE"); break; case rfbEncodingTight: if (m_hwndStatus)SetDlgItemText(m_hwndStatus, IDC_ENCODER, m_opts.m_fEnableCache ? "Tight, Cache" : "Tight"); diff -rcN -x winvnc___Win32_Http -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt -x buildtime.h ../UltraVNC-102-Src\UltraVNC/vncviewer/ClientConnection.h UltraVNC/vncviewer/ClientConnection.h *** ../UltraVNC-102-Src\UltraVNC/vncviewer/ClientConnection.h Wed Aug 02 11:54:02 2006 --- UltraVNC/vncviewer/ClientConnection.h Wed Aug 02 12:57:22 2006 *************** *** 546,561 **** rdr::FdInStream* fis; rdr::ZlibInStream* zis; void zrleDecode(int x, int y, int w, int h); ! void zrleDecode8(int x, int y, int w, int h, rdr::InStream* is, rdr::ZlibInStream* zis, rdr::U8* buf); ! void zrleDecode16(int x, int y, int w, int h, rdr::InStream* is, rdr::ZlibInStream* zis, rdr::U16* buf); ! void zrleDecode24A(int x, int y, int w, int h, rdr::InStream* is, rdr::ZlibInStream* zis, rdr::U32* buf); ! void zrleDecode24B(int x, int y, int w, int h, rdr::InStream* is, rdr::ZlibInStream* zis, rdr::U32* buf); ! void zrleDecode32(int x, int y, int w, int h, rdr::InStream* is, rdr::ZlibInStream* zis, rdr::U32* buf); //UltraFast void ConvertAll(int width, int height, int xx, int yy,int bytes_per_pixel,BYTE* source,BYTE* dest,int framebufferWidth); void SolidColor(int width, int height, int xx, int yy,int bytes_per_pixel,BYTE* source,BYTE* dest,int framebufferWidth); --- 546,566 ---- rdr::FdInStream* fis; rdr::ZlibInStream* zis; void zrleDecode(int x, int y, int w, int h); ! void zrleDecode8NE(int x, int y, int w, int h, rdr::InStream* is, rdr::ZlibInStream* zis, rdr::U8* buf); ! void zrleDecode15LE(int x, int y, int w, int h, rdr::InStream* is, rdr::ZlibInStream* zis, rdr::U16* buf); ! void zrleDecode16LE(int x, int y, int w, int h, rdr::InStream* is, ! rdr::ZlibInStream* zis, rdr::U16* buf); ! void zrleDecode24ALE(int x, int y, int w, int h, rdr::InStream* is, rdr::ZlibInStream* zis, rdr::U32* buf); ! void zrleDecode24BLE(int x, int y, int w, int h, rdr::InStream* is, rdr::ZlibInStream* zis, rdr::U32* buf); ! void zrleDecode32LE(int x, int y, int w, int h, rdr::InStream* is, rdr::ZlibInStream* zis, rdr::U32* buf); + long zywrle; + long zywrle_level; + long zywrleBuf[rfbZRLETileWidth*rfbZRLETileHeight]; //UltraFast void ConvertAll(int width, int height, int xx, int yy,int bytes_per_pixel,BYTE* source,BYTE* dest,int framebufferWidth); void SolidColor(int width, int height, int xx, int yy,int bytes_per_pixel,BYTE* source,BYTE* dest,int framebufferWidth); diff -rcN -x winvnc___Win32_Http -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt -x buildtime.h ../UltraVNC-102-Src\UltraVNC/vncviewer/VNCOptions.cpp UltraVNC/vncviewer/VNCOptions.cpp *** ../UltraVNC-102-Src\UltraVNC/vncviewer/VNCOptions.cpp Wed Aug 02 11:54:20 2006 --- UltraVNC/vncviewer/VNCOptions.cpp Wed Aug 02 13:03:30 2006 *************** *** 79,84 **** --- 79,85 ---- m_UseEnc[rfbEncodingTight] = true; m_UseEnc[rfbEncodingZlibHex] = true; m_UseEnc[rfbEncodingZRLE] = true; + m_UseEnc[rfbEncodingZYWRLE] = true; m_UseEnc[rfbEncodingUltra] = true; m_ViewOnly = false; diff -rcN -x winvnc___Win32_Http -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt -x buildtime.h ../UltraVNC-102-Src\UltraVNC/vncviewer/VNCOptions.h UltraVNC/vncviewer/VNCOptions.h *** ../UltraVNC-102-Src\UltraVNC/vncviewer/VNCOptions.h Wed Aug 02 11:54:20 2006 --- UltraVNC/vncviewer/VNCOptions.h Wed Aug 02 13:03:11 2006 *************** *** 32,38 **** #pragma once ! #define LASTENCODING rfbEncodingZRLE #define NOCURSOR 0 #define DOTCURSOR 1 --- 32,38 ---- #pragma once ! #define LASTENCODING rfbEncodingZYWRLE #define NOCURSOR 0 #define DOTCURSOR 1 diff -rcN -x winvnc___Win32_Http -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt -x buildtime.h ../UltraVNC-102-Src\UltraVNC/vncviewer/res/resource.h UltraVNC/vncviewer/res/resource.h *** ../UltraVNC-102-Src\UltraVNC/vncviewer/res/resource.h Wed Aug 02 11:54:17 2006 --- UltraVNC/vncviewer/res/resource.h Wed Aug 02 13:06:18 2006 *************** *** 202,208 **** #define IDC_ZLIBHEXRADIO 2008 #define IDC_ULTRA 2009 #define IDC_ZRLERADIO 2016 ! #define IDC_LAST_ENCODING 2017 #define ID_SESSION_SET_CRECT 32777 #define ID_SESSION_SWAPMOUSE 32785 #define ID_CLOSEDAEMON 50001 --- 202,209 ---- #define IDC_ZLIBHEXRADIO 2008 #define IDC_ULTRA 2009 #define IDC_ZRLERADIO 2016 ! #define IDC_ZYWRLERADIO 2017 ! #define IDC_LAST_ENCODING 2018 #define ID_SESSION_SET_CRECT 32777 #define ID_SESSION_SWAPMOUSE 32785 #define ID_CLOSEDAEMON 50001 diff -rcN -x winvnc___Win32_Http -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt -x buildtime.h ../UltraVNC-102-Src\UltraVNC/vncviewer/res/vncviewer.rc UltraVNC/vncviewer/res/vncviewer.rc *** ../UltraVNC-102-Src\UltraVNC/vncviewer/res/vncviewer.rc Wed Aug 02 11:54:18 2006 --- UltraVNC/vncviewer/res/vncviewer.rc Wed Aug 02 13:08:12 2006 *************** *** 123,135 **** 12,52,55,10 CONTROL "Hextile",IDC_HEXTILERADIO,"Button",BS_AUTORADIOBUTTON, 12,62,37,10 ! CONTROL "RRE",IDC_RRERADIO,"Button",BS_AUTORADIOBUTTON,12,73,31, 10 ! CONTROL "CoRRE",IDC_CORRERADIO,"Button",BS_AUTORADIOBUTTON,12,83, ! 40,10 ! CONTROL "Raw",IDC_RAWRADIO,"Button",BS_AUTORADIOBUTTON,12,94,29, 10 ! CONTROL "Ultra",IDC_ULTRA,"Button",BS_AUTORADIOBUTTON,47,94,29, 10 GROUPBOX "",IDC_STATIC,84,22,65,86,WS_GROUP CONTROL "Full Colors",IDC_FULLCOLORS_RADIO,"Button", --- 123,135 ---- 12,52,55,10 CONTROL "Hextile",IDC_HEXTILERADIO,"Button",BS_AUTORADIOBUTTON, 12,62,37,10 ! CONTROL "RRE",IDC_RRERADIO,"Button",BS_AUTORADIOBUTTON,12,73,29, 10 ! CONTROL "CoRRE",IDC_CORRERADIO,"Button",BS_AUTORADIOBUTTON,41,73, ! 38,10 ! CONTROL "Raw",IDC_RAWRADIO,"Button",BS_AUTORADIOBUTTON,12,83,29, 10 ! CONTROL "Ultra",IDC_ULTRA,"Button",BS_AUTORADIOBUTTON,41,83,29, 10 GROUPBOX "",IDC_STATIC,84,22,65,86,WS_GROUP CONTROL "Full Colors",IDC_FULLCOLORS_RADIO,"Button", *************** *** 204,209 **** --- 204,211 ---- NOT WS_VISIBLE LTEXT "1 /",IDC_STATIC,253,153,12,8 LTEXT "by",IDC_STATIC,259,139,10,8 + CONTROL "ZYWRLE",IDC_ZYWRLERADIO,"Button",BS_AUTORADIOBUTTON,12, + 94,47,10 END IDD_FILETRANSFER_DLG DIALOGEX 0, 0, 555, 414 diff -rcN -x winvnc___Win32_Http -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt -x buildtime.h ../UltraVNC-102-Src\UltraVNC/vncviewer/zrle.cpp UltraVNC/vncviewer/zrle.cpp *** ../UltraVNC-102-Src\UltraVNC/vncviewer/zrle.cpp Wed Aug 02 11:54:24 2006 --- UltraVNC/vncviewer/zrle.cpp Tue Jul 25 10:54:35 2006 *************** *** 11,21 **** // Instantiate the decoding function for 8, 16 and 32 BPP ! #define FAVOUR_FILL_RECT #define zrleDecode ClientConnection::zrleDecode #define BPP 8 #define IMAGE_RECT(x,y,w,h,data) \ SETUP_COLOR_SHORTCUTS; \ SETPIXELS(m_netbuf,8,x,y,w,h) --- 11,25 ---- // Instantiate the decoding function for 8, 16 and 32 BPP ! //#define FAVOUR_FILL_RECT #define zrleDecode ClientConnection::zrleDecode + #define ENDIAN_LITTLE 0 + #define ENDIAN_BIG 1 + #define ENDIAN_NO 2 #define BPP 8 + #define ZYWRLE_ENDIAN ENDIAN_NO #define IMAGE_RECT(x,y,w,h,data) \ SETUP_COLOR_SHORTCUTS; \ SETPIXELS(m_netbuf,8,x,y,w,h) *************** *** 25,34 **** --- 29,40 ---- FillSolidRect(x,y,w,h,color) #include #undef BPP + #undef ZYWRLE_ENDIAN #undef IMAGE_RECT #undef FILL_RECT #define BPP 16 + #define ZYWRLE_ENDIAN ENDIAN_LITTLE #define IMAGE_RECT(x,y,w,h,data) \ SETUP_COLOR_SHORTCUTS; \ SETPIXELS(m_netbuf,16,x,y,w,h) *************** *** 38,43 **** --- 44,55 ---- FillSolidRect(x,y,w,h,color) #include #undef BPP + #undef ZYWRLE_ENDIAN + #define BPP 15 + #define ZYWRLE_ENDIAN ENDIAN_LITTLE + #include + #undef BPP + #undef ZYWRLE_ENDIAN #undef IMAGE_RECT #undef FILL_RECT *************** *** 50,55 **** --- 62,68 ---- FillSolidRect(x,y,w,h,color) #define BPP 32 + #define ZYWRLE_ENDIAN ENDIAN_LITTLE #include #define CPIXEL 24A #include *************** *** 58,63 **** --- 71,77 ---- #include #undef CPIXEL #undef BPP + #undef ZYWRLE_ENDIAN #undef IMAGE_RECT #undef FILL_RECT *************** *** 71,84 **** ObjectSelector b(m_hBitmapDC, m_hBitmap); PaletteSelector p(m_hBitmapDC, m_hPalette); switch (m_myFormat.bitsPerPixel) { case 8: ! zrleDecode8(x,y,w,h,fis,zis,(rdr::U8*)m_netbuf); break; case 16: ! zrleDecode16(x,y,w,h,fis,zis,(rdr::U16*)m_netbuf); break; case 32: --- 85,116 ---- ObjectSelector b(m_hBitmapDC, m_hBitmap); PaletteSelector p(m_hBitmapDC, m_hPalette); + if( zywrle ){ + if( !m_opts.m_enableJpegCompression ){ + zywrle_level = 1; + }else if( m_opts.m_jpegQualityLevel < 3 ){ + zywrle_level = 3; + }else if( m_opts.m_jpegQualityLevel < 6 ){ + zywrle_level = 2; + }else{ + zywrle_level = 1; + } + }else{ + zywrle_level = 0; + } + switch (m_myFormat.bitsPerPixel) { case 8: ! zrleDecode8NE(x,y,w,h,fis,zis,(rdr::U8*)m_netbuf); break; case 16: ! if( m_myFormat.greenMax > 0x1F ){ ! zrleDecode16LE(x,y,w,h,fis,zis,(rdr::U16*)m_netbuf); ! }else{ ! zrleDecode15LE(x,y,w,h,fis,zis,(rdr::U16*)m_netbuf); ! } break; case 32: *************** *** 94,109 **** if ((fitsInLS3Bytes && !m_myFormat.bigEndian) || (fitsInMS3Bytes && m_myFormat.bigEndian)) { ! zrleDecode24A(x,y,w,h,fis,zis,(rdr::U32*)m_netbuf); } else if ((fitsInLS3Bytes && m_myFormat.bigEndian) || (fitsInMS3Bytes && !m_myFormat.bigEndian)) { ! zrleDecode24B(x,y,w,h,fis,zis,(rdr::U32*)m_netbuf); } else { ! zrleDecode32(x,y,w,h,fis,zis,(rdr::U32*)m_netbuf); } break; } --- 126,141 ---- if ((fitsInLS3Bytes && !m_myFormat.bigEndian) || (fitsInMS3Bytes && m_myFormat.bigEndian)) { ! zrleDecode24ALE(x,y,w,h,fis,zis,(rdr::U32*)m_netbuf); } else if ((fitsInLS3Bytes && m_myFormat.bigEndian) || (fitsInMS3Bytes && !m_myFormat.bigEndian)) { ! zrleDecode24BLE(x,y,w,h,fis,zis,(rdr::U32*)m_netbuf); } else { ! zrleDecode32LE(x,y,w,h,fis,zis,(rdr::U32*)m_netbuf); } break; } diff -rcN -x winvnc___Win32_Http -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt -x buildtime.h ../UltraVNC-102-Src\UltraVNC/winvnc/winvnc/vncencodemgr.h UltraVNC/winvnc/winvnc/vncencodemgr.h *** ../UltraVNC-102-Src\UltraVNC/winvnc/winvnc/vncencodemgr.h Wed Aug 02 11:55:04 2006 --- UltraVNC/winvnc/winvnc/vncencodemgr.h Wed Aug 02 13:12:27 2006 *************** *** 116,122 **** inline BOOL ResetZRLEEncoding(void); #endif ! inline bool IsSlowEncoding() {return (m_encoding == rfbEncodingZRLE || m_encoding == rfbEncodingTight || m_encoding == rfbEncodingZlib);}; inline bool IsUltraEncoding() {return (m_encoding == rfbEncodingUltra);}; --- 116,122 ---- inline BOOL ResetZRLEEncoding(void); #endif ! inline bool IsSlowEncoding() {return (m_encoding == rfbEncodingZYWRLE || m_encoding == rfbEncodingZRLE || m_encoding == rfbEncodingTight || m_encoding == rfbEncodingZlib);}; inline bool IsUltraEncoding() {return (m_encoding == rfbEncodingUltra);}; *************** *** 480,485 **** --- 480,494 ---- if (!zrleEncoder) zrleEncoder = new vncEncodeZRLE; m_encoder = zrleEncoder; + ((vncEncodeZRLE*)zrleEncoder)->m_use_zywrle = FALSE; + break; + + case rfbEncodingZYWRLE: + vnclog.Print(LL_INTINFO, VNCLOG("ZYWRLE encoder requested\n")); + if (!zrleEncoder) + zrleEncoder = new vncEncodeZRLE; + m_encoder = zrleEncoder; + ((vncEncodeZRLE*)zrleEncoder)->m_use_zywrle = TRUE; break; case rfbEncodingZlib: diff -rcN -x winvnc___Win32_Http -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt -x buildtime.h ../UltraVNC-102-Src\UltraVNC/winvnc/winvnc/vncencodezrle.cpp UltraVNC/winvnc/winvnc/vncencodezrle.cpp *** ../UltraVNC-102-Src\UltraVNC/winvnc/winvnc/vncencodezrle.cpp Wed Aug 02 11:55:07 2006 --- UltraVNC/winvnc/winvnc/vncencodezrle.cpp Tue Jul 25 10:50:34 2006 *************** *** 37,54 **** --- 37,86 ---- #define EXTRA_ARGS , BYTE* source, vncEncoder* encoder + #define ENDIAN_LITTLE 0 + #define ENDIAN_BIG 1 + #define ENDIAN_NO 2 #define BPP 8 + #define ZYWRLE_ENDIAN ENDIAN_NO #include #undef BPP + #define BPP 15 + #undef ZYWRLE_ENDIAN + #define ZYWRLE_ENDIAN ENDIAN_LITTLE + #include + #undef ZYWRLE_ENDIAN + #define ZYWRLE_ENDIAN ENDIAN_BIG + #include + #undef BPP #define BPP 16 + #undef ZYWRLE_ENDIAN + #define ZYWRLE_ENDIAN ENDIAN_LITTLE #include + #undef ZYWRLE_ENDIAN + #define ZYWRLE_ENDIAN ENDIAN_BIG + #include #undef BPP #define BPP 32 + #undef ZYWRLE_ENDIAN + #define ZYWRLE_ENDIAN ENDIAN_LITTLE + #include + #undef ZYWRLE_ENDIAN + #define ZYWRLE_ENDIAN ENDIAN_BIG #include #define CPIXEL 24A + #undef ZYWRLE_ENDIAN + #define ZYWRLE_ENDIAN ENDIAN_LITTLE #include + #undef ZYWRLE_ENDIAN + #define ZYWRLE_ENDIAN ENDIAN_BIG + #include #undef CPIXEL #define CPIXEL 24B + #undef ZYWRLE_ENDIAN + #define ZYWRLE_ENDIAN ENDIAN_LITTLE + #include + #undef ZYWRLE_ENDIAN + #define ZYWRLE_ENDIAN ENDIAN_BIG #include #undef CPIXEL #undef BPP *************** *** 58,63 **** --- 90,96 ---- mos = new rdr::MemOutStream; zos = new rdr::ZlibOutStream; beforeBuf = new rdr::U32[rfbZRLETileWidth * rfbZRLETileHeight + 1]; + m_use_zywrle = FALSE; } vncEncodeZRLE::~vncEncodeZRLE() *************** *** 90,103 **** mos->clear(); switch (m_remoteformat.bitsPerPixel) { case 8: ! zrleEncode8( x, y, w, h, mos, zos, beforeBuf, source, this); break; case 16: ! zrleEncode16(x, y, w, h, mos, zos, beforeBuf, source, this); break; case 32: --- 123,162 ---- mos->clear(); + if( m_use_zywrle ){ + if( m_qualitylevel < 0 ){ + zywrle_level = 1; + }else if( m_qualitylevel < 3 ){ + zywrle_level = 3; + }else if( m_qualitylevel < 6 ){ + zywrle_level = 2; + }else{ + zywrle_level = 1; + } + }else{ + zywrle_level = 0; + } + switch (m_remoteformat.bitsPerPixel) { case 8: ! zrleEncode8NE( x, y, w, h, mos, zos, beforeBuf, source, this); break; case 16: ! if( m_remoteformat.greenMax > 0x1F ){ ! if( m_remoteformat.bigEndian ){ ! zrleEncode16BE(x, y, w, h, mos, zos, beforeBuf, source, this); ! }else{ ! zrleEncode16LE(x, y, w, h, mos, zos, beforeBuf, source, this); ! } ! }else{ ! if( m_remoteformat.bigEndian ){ ! zrleEncode15BE(x, y, w, h, mos, zos, beforeBuf, source, this); ! }else{ ! zrleEncode15LE(x, y, w, h, mos, zos, beforeBuf, source, this); ! } ! } break; case 32: *************** *** 113,128 **** if ((fitsInLS3Bytes && !m_remoteformat.bigEndian) || (fitsInMS3Bytes && m_remoteformat.bigEndian)) { ! zrleEncode24A(x, y, w, h, mos, zos, beforeBuf, source, this); } else if ((fitsInLS3Bytes && m_remoteformat.bigEndian) || (fitsInMS3Bytes && !m_remoteformat.bigEndian)) { ! zrleEncode24B(x, y, w, h, mos, zos, beforeBuf, source, this); } else { ! zrleEncode32(x, y, w, h, mos, zos, beforeBuf, source, this); } break; } --- 172,199 ---- if ((fitsInLS3Bytes && !m_remoteformat.bigEndian) || (fitsInMS3Bytes && m_remoteformat.bigEndian)) { ! if( m_remoteformat.bigEndian ){ ! zrleEncode24ABE(x, y, w, h, mos, zos, beforeBuf, source, this); ! }else{ ! zrleEncode24ALE(x, y, w, h, mos, zos, beforeBuf, source, this); ! } } else if ((fitsInLS3Bytes && m_remoteformat.bigEndian) || (fitsInMS3Bytes && !m_remoteformat.bigEndian)) { ! if( m_remoteformat.bigEndian ){ ! zrleEncode24BBE(x, y, w, h, mos, zos, beforeBuf, source, this); ! }else{ ! zrleEncode24BLE(x, y, w, h, mos, zos, beforeBuf, source, this); ! } } else { ! if( m_remoteformat.bigEndian ){ ! zrleEncode32BE(x, y, w, h, mos, zos, beforeBuf, source, this); ! }else{ ! zrleEncode32LE(x, y, w, h, mos, zos, beforeBuf, source, this); ! } } break; } *************** *** 132,138 **** surh->r.y = Swap16IfLE(y-m_SWOffsety); surh->r.w = Swap16IfLE(w); surh->r.h = Swap16IfLE(h); ! surh->encoding = Swap32IfLE(rfbEncodingZRLE); rfbZRLEHeader* hdr = (rfbZRLEHeader*)(dest + sz_rfbFramebufferUpdateRectHeader); --- 203,213 ---- surh->r.y = Swap16IfLE(y-m_SWOffsety); surh->r.w = Swap16IfLE(w); surh->r.h = Swap16IfLE(h); ! if( m_use_zywrle ){ ! surh->encoding = Swap32IfLE(rfbEncodingZYWRLE); ! }else{ ! surh->encoding = Swap32IfLE(rfbEncodingZRLE); ! } rfbZRLEHeader* hdr = (rfbZRLEHeader*)(dest + sz_rfbFramebufferUpdateRectHeader); diff -rcN -x winvnc___Win32_Http -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt -x buildtime.h ../UltraVNC-102-Src\UltraVNC/winvnc/winvnc/vncencodezrle.h UltraVNC/winvnc/winvnc/vncencodezrle.h *** ../UltraVNC-102-Src\UltraVNC/winvnc/winvnc/vncencodezrle.h Wed Aug 02 11:55:07 2006 --- UltraVNC/winvnc/winvnc/vncencodezrle.h Thu Jul 06 10:37:19 2006 *************** *** 38,43 **** --- 38,45 ---- virtual UINT EncodeRect(BYTE *source, BYTE *dest, const rfb::Rect &rect); + BOOL m_use_zywrle; + private: rdr::ZlibOutStream* zos; rdr::MemOutStream* mos;