diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/CMsgWriter.cxx ./common/rfb/CMsgWriter.cxx *** ..\vnc-4_1_2-winsrc/common/rfb/CMsgWriter.cxx Mon May 15 18:04:00 2006 --- ./common/rfb/CMsgWriter.cxx Mon Feb 05 16:48:40 2007 *************** *** 56,62 **** // Ask for encodings based on which decoders are supported. Assumes higher // encoding numbers are more desirable. ! void CMsgWriter::writeSetEncodings(int preferredEncoding, bool useCopyRect) { int nEncodings = 0; rdr::U32 encodings[encodingMax+2]; --- 56,62 ---- // Ask for encodings based on which decoders are supported. Assumes higher // encoding numbers are more desirable. ! void CMsgWriter::writeSetEncodings(int preferredEncoding, bool useCopyRect, int qualityLevel) { int nEncodings = 0; rdr::U32 encodings[encodingMax+2]; *************** *** 69,74 **** --- 69,77 ---- } if (useCopyRect) { encodings[nEncodings++] = encodingCopyRect; + } + if( preferredEncoding == encoding3rdPartyHitachiZYWRLE ){ + encodings[nEncodings++] = pseudoEncodingQualityLevel0+qualityLevel; } for (int i = encodingMax; i >= 0; i--) { if (i != preferredEncoding && Decoder::supported(i)) { diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/CMsgWriter.h ./common/rfb/CMsgWriter.h *** ..\vnc-4_1_2-winsrc/common/rfb/CMsgWriter.h Mon May 15 18:04:00 2006 --- ./common/rfb/CMsgWriter.h Mon Feb 05 15:41:46 2007 *************** *** 44,50 **** // CMsgWriter implemented methods virtual void writeSetPixelFormat(const PixelFormat& pf); virtual void writeSetEncodings(int nEncodings, rdr::U32* encodings); ! virtual void writeSetEncodings(int preferredEncoding, bool useCopyRect); virtual void writeFramebufferUpdateRequest(const Rect& r,bool incremental); // InputHandler implementation --- 44,50 ---- // CMsgWriter implemented methods virtual void writeSetPixelFormat(const PixelFormat& pf); virtual void writeSetEncodings(int nEncodings, rdr::U32* encodings); ! virtual void writeSetEncodings(int preferredEncoding, bool useCopyRect, int qualityLevel); virtual void writeFramebufferUpdateRequest(const Rect& r,bool incremental); // InputHandler implementation diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/ConnParams.cxx ./common/rfb/ConnParams.cxx *** ..\vnc-4_1_2-winsrc/common/rfb/ConnParams.cxx Mon May 15 18:04:00 2006 --- ./common/rfb/ConnParams.cxx Mon Feb 05 13:23:16 2007 *************** *** 88,93 **** --- 88,94 ---- useCopyRect = false; supportsLocalCursor = false; supportsDesktopResize = false; + qualityLevel = 6; currentEncoding_ = encodingRaw; for (int i = nEncodings-1; i >= 0; i--) { *************** *** 99,104 **** --- 100,107 ---- supportsLocalCursor = true; else if (encodings[i] == pseudoEncodingDesktopSize) supportsDesktopResize = true; + else if ((encodings[i] >= pseudoEncodingQualityLevel0)&&(encodings[i] <= pseudoEncodingQualityLevel9)) + qualityLevel = encodings[i] - pseudoEncodingQualityLevel0; else if (encodings[i] <= encodingMax && Encoder::supported(encodings[i])) currentEncoding_ = encodings[i]; } diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/ConnParams.h ./common/rfb/ConnParams.h *** ..\vnc-4_1_2-winsrc/common/rfb/ConnParams.h Mon May 15 18:04:00 2006 --- ./common/rfb/ConnParams.h Mon Feb 05 13:22:05 2007 *************** *** 72,77 **** --- 72,79 ---- bool supportsLocalCursor; bool supportsDesktopResize; + int qualityLevel; + private: PixelFormat pf_; diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/Decoder.cxx ./common/rfb/Decoder.cxx *** ..\vnc-4_1_2-winsrc/common/rfb/Decoder.cxx Mon May 15 18:04:00 2006 --- ./common/rfb/Decoder.cxx Mon Feb 05 12:08:51 2007 *************** *** 22,27 **** --- 22,28 ---- #include #include #include + #include using namespace rfb; *************** *** 65,68 **** --- 66,70 ---- Decoder::registerDecoder(encodingRRE, RREDecoder::create); Decoder::registerDecoder(encodingHextile, HextileDecoder::create); Decoder::registerDecoder(encodingZRLE, ZRLEDecoder::create); + Decoder::registerDecoder(encoding3rdPartyHitachiZYWRLE, ZYWRLEDecoder::create); } diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/Encoder.cxx ./common/rfb/Encoder.cxx *** ..\vnc-4_1_2-winsrc/common/rfb/Encoder.cxx Mon May 15 18:04:00 2006 --- ./common/rfb/Encoder.cxx Mon Feb 05 12:08:32 2007 *************** *** 22,27 **** --- 22,28 ---- #include #include #include + #include using namespace rfb; *************** *** 72,75 **** --- 73,77 ---- Encoder::registerEncoder(encodingRRE, RREEncoder::create); Encoder::registerEncoder(encodingHextile, HextileEncoder::create); Encoder::registerEncoder(encodingZRLE, ZRLEEncoder::create); + Encoder::registerEncoder(encoding3rdPartyHitachiZYWRLE, ZYWRLEEncoder::create); } diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/ZYWRLEDecoder.cxx ./common/rfb/ZYWRLEDecoder.cxx *** ..\vnc-4_1_2-winsrc/common/rfb/ZYWRLEDecoder.cxx Thu Jan 01 09:00:00 1970 --- ./common/rfb/ZYWRLEDecoder.cxx Thu Feb 08 10:14:38 2007 *************** *** 0 **** --- 1,212 ---- + /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + + /******************************************************************** + * * + * 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-2007 * + * BY Hitachi Systems & Services, Ltd. * + * (Noriaki Yamazaki, Research & Developement Center) * * + * * + * ZYWRLE VNC codec homepage: * + * http://mobile.hitachi-system.co.jp/publications/ZYWRLE/ * + * * + ******************************************************************** + 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. + ********************************************************************/ + #include + #include + #include + + using namespace rfb; + + #define EXTRA_ARGS CMsgHandler* handler, int zywrle_level, int* zywrleBuf + #define FILL_RECT(r, p) handler->fillRect(r, p) + #define IMAGE_RECT(r, p) handler->imageRect(r, p) + #define ENDIAN_LITTLE 0 + #define ENDIAN_BIG 1 + // BPP==8 ZYWRLE is complete same with ZRLE. + //#define BPP 8 + //#include + //#undef BPP + namespace rfb { + void zrleDecode8 (const Rect& r, rdr::InStream* is, + rdr::ZlibInStream* zis, rdr::U8* buf + , CMsgHandler* handler + ); + } + #define ZYWRLE_DECODE + #undef FAVOUR_FILL_RECT + #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 + + Decoder* ZYWRLEDecoder::create(CMsgReader* reader) + { + return new ZYWRLEDecoder(reader); + } + + ZYWRLEDecoder::ZYWRLEDecoder(CMsgReader* reader_) : reader(reader_) + { + } + + ZYWRLEDecoder::~ZYWRLEDecoder() + { + } + + void ZYWRLEDecoder::readRect(const Rect& r, CMsgHandler* handler) + { + rdr::InStream* is = reader->getInStream(); + rdr::U8* buf = reader->getImageBuf(64 * 64 * 4); + const rfb::PixelFormat& pf = handler->cp.pf(); + int zywrle_level; + + if( handler->cp.qualityLevel < 3 ){ + zywrle_level = 3; + }else if( handler->cp.qualityLevel < 6 ){ + zywrle_level = 2; + }else{ + zywrle_level = 1; + } + + switch (reader->bpp()) { + case 8: zrleDecode8 (r, is, &zis, (rdr::U8*) buf, handler); break; + case 16: + if( pf.greenMax > 0x1F ){ + if( pf.bigEndian ){ + zywrleDecode16BE(r, is, &zis, (rdr::U16*)buf, handler, zywrle_level, zywrleBuf); + }else{ + zywrleDecode16LE(r, is, &zis, (rdr::U16*)buf, handler, zywrle_level, zywrleBuf); + } + }else{ + if( pf.bigEndian ){ + zywrleDecode15BE(r, is, &zis, (rdr::U16*)buf, handler, zywrle_level, zywrleBuf); + }else{ + zywrleDecode15LE(r, is, &zis, (rdr::U16*)buf, handler, zywrle_level, zywrleBuf); + } + } + break; + case 32: + { + bool fitsInLS3Bytes = ((pf.redMax << pf.redShift) < (1<<24) && + (pf.greenMax << pf.greenShift) < (1<<24) && + (pf.blueMax << pf.blueShift) < (1<<24)); + + bool fitsInMS3Bytes = (pf.redShift > 7 && + pf.greenShift > 7 && + pf.blueShift > 7); + + if ((fitsInLS3Bytes && !pf.bigEndian) || + (fitsInMS3Bytes && pf.bigEndian)) + { + + if( pf.bigEndian ){ + zywrleDecode24ABE(r, is, &zis, (rdr::U32*)buf, handler, zywrle_level, zywrleBuf); + }else{ + zywrleDecode24ALE(r, is, &zis, (rdr::U32*)buf, handler, zywrle_level, zywrleBuf); + } + } + else if ((fitsInLS3Bytes && pf.bigEndian) || + (fitsInMS3Bytes && !pf.bigEndian)) + { + if( pf.bigEndian ){ + zywrleDecode24BBE(r, is, &zis, (rdr::U32*)buf, handler, zywrle_level, zywrleBuf); + }else{ + zywrleDecode24ALE(r, is, &zis, (rdr::U32*)buf, handler, zywrle_level, zywrleBuf); + } + } + else + { + if( pf.bigEndian ){ + zywrleDecode32BE(r, is, &zis, (rdr::U32*)buf, handler, zywrle_level, zywrleBuf); + }else{ + zywrleDecode32LE(r, is, &zis, (rdr::U32*)buf, handler, zywrle_level, zywrleBuf); + } + } + break; + } + } + } diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/ZYWRLEDecoder.h ./common/rfb/ZYWRLEDecoder.h *** ..\vnc-4_1_2-winsrc/common/rfb/ZYWRLEDecoder.h Thu Jan 01 09:00:00 1970 --- ./common/rfb/ZYWRLEDecoder.h Thu Feb 08 10:15:01 2007 *************** *** 0 **** --- 1,83 ---- + /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + + /******************************************************************** + * * + * 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-2007 * + * BY Hitachi Systems & Services, Ltd. * + * (Noriaki Yamazaki, Research & Developement Center) * * + * * + * ZYWRLE VNC codec homepage: * + * http://mobile.hitachi-system.co.jp/publications/ZYWRLE/ * + * * + ******************************************************************** + 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. + ********************************************************************/ + #ifndef __RFB_ZYWRLEDECODER_H__ + #define __RFB_ZYWRLEDECODER_H__ + + #include + #include + + namespace rfb { + + class ZYWRLEDecoder : public Decoder { + public: + static Decoder* create(CMsgReader* reader); + virtual void readRect(const Rect& r, CMsgHandler* handler); + virtual ~ZYWRLEDecoder(); + private: + ZYWRLEDecoder(CMsgReader* reader); + CMsgReader* reader; + rdr::ZlibInStream zis; + int zywrleBuf[64*64]; + }; + } + #endif diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/ZYWRLEEncoder.cxx ./common/rfb/ZYWRLEEncoder.cxx *** ..\vnc-4_1_2-winsrc/common/rfb/ZYWRLEEncoder.cxx Thu Jan 01 09:00:00 1970 --- ./common/rfb/ZYWRLEEncoder.cxx Thu Feb 08 10:14:50 2007 *************** *** 0 **** --- 1,237 ---- + /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + + /******************************************************************** + * * + * 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-2007 * + * BY Hitachi Systems & Services, Ltd. * + * (Noriaki Yamazaki, Research & Developement Center) * * + * * + * ZYWRLE VNC codec homepage: * + * http://mobile.hitachi-system.co.jp/publications/ZYWRLE/ * + * * + ******************************************************************** + 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. + ********************************************************************/ + #include + #include + #include + #include + #include + #include + #include + #include + + using namespace rfb; + + rdr::MemOutStream* ZYWRLEEncoder::sharedMos = 0; + int ZYWRLEEncoder::maxLen = 4097 * 1024; // enough for width 16384 32-bit pixels + + static IntParameter zlibLevel("ZlibLevel","Zlib compression level",-1); + + #define EXTRA_ARGS ImageGetter* ig, int zywrle_level, int* zywrleBuf + #define GET_IMAGE_INTO_BUF(r,buf) ig->getImage(buf, r); + #define ENDIAN_LITTLE 0 + #define ENDIAN_BIG 1 + // BPP==8 ZYWRLE is complete same with ZRLE. + //#define BPP 8 + //#include + //#undef BPP + namespace rfb { + bool zrleEncode8(const Rect& r, rdr::OutStream* os, + rdr::ZlibOutStream* zos, void* buf, int maxLen, Rect* actual + , ImageGetter* ig + ); + } + #define ZYWRLE_ENCODE + #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 + + Encoder* ZYWRLEEncoder::create(SMsgWriter* writer) + { + return new ZYWRLEEncoder(writer); + } + + ZYWRLEEncoder::ZYWRLEEncoder(SMsgWriter* writer_) + : writer(writer_), zos(0,0,zlibLevel) + { + if (sharedMos) + mos = sharedMos; + else + mos = new rdr::MemOutStream(129*1024); + } + + ZYWRLEEncoder::~ZYWRLEEncoder() + { + if (!sharedMos) + delete mos; + } + + bool ZYWRLEEncoder::writeRect(const Rect& r, ImageGetter* ig, Rect* actual) + { + rdr::U8* imageBuf = writer->getImageBuf(64 * 64 * 4 + 4); + mos->clear(); + bool wroteAll = true; + *actual = r; + const PixelFormat& pf = writer->getConnParams()->pf(); + int zywrle_level; + + if( writer->getConnParams()->qualityLevel < 3 ){ + zywrle_level = 3; + }else if( writer->getConnParams()->qualityLevel < 6 ){ + zywrle_level = 2; + }else{ + zywrle_level = 1; + } + + switch (writer->bpp()) { + case 8: + wroteAll = zrleEncode8(r, mos, &zos, imageBuf, maxLen, actual, ig); + break; + case 16: + if( pf.greenMax > 0x1F ){ + if( pf.bigEndian ){ + wroteAll = zywrleEncode16BE(r, mos, &zos, imageBuf, maxLen, actual, ig, zywrle_level, zywrleBuf); + }else{ + wroteAll = zywrleEncode16LE(r, mos, &zos, imageBuf, maxLen, actual, ig, zywrle_level, zywrleBuf); + } + }else{ + if( pf.bigEndian ){ + wroteAll = zywrleEncode15BE(r, mos, &zos, imageBuf, maxLen, actual, ig, zywrle_level, zywrleBuf); + }else{ + wroteAll = zywrleEncode15LE(r, mos, &zos, imageBuf, maxLen, actual, ig, zywrle_level, zywrleBuf); + } + } + break; + case 32: + { + bool fitsInLS3Bytes = ((pf.redMax << pf.redShift) < (1<<24) && + (pf.greenMax << pf.greenShift) < (1<<24) && + (pf.blueMax << pf.blueShift) < (1<<24)); + + bool fitsInMS3Bytes = (pf.redShift > 7 && + pf.greenShift > 7 && + pf.blueShift > 7); + + if ((fitsInLS3Bytes && !pf.bigEndian) || + (fitsInMS3Bytes && pf.bigEndian)) + { + if( pf.bigEndian ){ + wroteAll = zywrleEncode24ABE(r, mos, &zos, imageBuf, maxLen, actual, ig, zywrle_level, zywrleBuf); + }else{ + wroteAll = zywrleEncode24ALE(r, mos, &zos, imageBuf, maxLen, actual, ig, zywrle_level, zywrleBuf); + } + } + else if ((fitsInLS3Bytes && pf.bigEndian) || + (fitsInMS3Bytes && !pf.bigEndian)) + { + if( pf.bigEndian ){ + wroteAll = zywrleEncode24BBE(r, mos, &zos, imageBuf, maxLen, actual, ig, zywrle_level, zywrleBuf); + }else{ + wroteAll = zywrleEncode24BLE(r, mos, &zos, imageBuf, maxLen, actual, ig, zywrle_level, zywrleBuf); + } + } + else + { + if( pf.bigEndian ){ + wroteAll = zywrleEncode32BE(r, mos, &zos, imageBuf, maxLen, actual, ig, zywrle_level, zywrleBuf); + }else{ + wroteAll = zywrleEncode32LE(r, mos, &zos, imageBuf, maxLen, actual, ig, zywrle_level, zywrleBuf); + } + } + break; + } + } + + writer->startRect(*actual, encoding3rdPartyHitachiZYWRLE); + rdr::OutStream* os = writer->getOutStream(); + os->writeU32(mos->length()); + os->writeBytes(mos->data(), mos->length()); + writer->endRect(); + return wroteAll; + } diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/ZYWRLEEncoder.h ./common/rfb/ZYWRLEEncoder.h *** ..\vnc-4_1_2-winsrc/common/rfb/ZYWRLEEncoder.h Thu Jan 01 09:00:00 1970 --- ./common/rfb/ZYWRLEEncoder.h Thu Feb 08 10:15:23 2007 *************** *** 0 **** --- 1,100 ---- + /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + + /******************************************************************** + * * + * 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-2007 * + * BY Hitachi Systems & Services, Ltd. * + * (Noriaki Yamazaki, Research & Developement Center) * * + * * + * ZYWRLE VNC codec homepage: * + * http://mobile.hitachi-system.co.jp/publications/ZYWRLE/ * + * * + ******************************************************************** + 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. + ********************************************************************/ + #ifndef __RFB_ZYWRLEENCODER_H__ + #define __RFB_ZYWRLEENCODER_H__ + + #include + #include + #include + + namespace rfb { + + class ZYWRLEEncoder : public Encoder { + public: + static Encoder* create(SMsgWriter* writer); + virtual bool writeRect(const Rect& r, ImageGetter* ig, Rect* actual); + virtual ~ZYWRLEEncoder(); + + // setMaxLen() sets the maximum size in bytes of any ZRLE rectangle. This + // can be used to stop the MemOutStream from growing too large. The value + // must be large enough to allow for at least one row of ZRLE tiles. So + // for example for a screen width of 2048 32-bit pixels this is 2K*4*64 = + // 512Kbytes plus a bit of overhead (the overhead is about 1/16 of the + // width, in this example about 128 bytes). + static void setMaxLen(int m) { maxLen = m; } + + // setSharedMos() sets a MemOutStream to be shared amongst all + // ZYWRLEEncoders. Should be called before any ZYWRLEEncoders are created. + static void setSharedMos(rdr::MemOutStream* mos_) { sharedMos = mos_; } + + private: + ZYWRLEEncoder(SMsgWriter* writer); + SMsgWriter* writer; + rdr::ZlibOutStream zos; + rdr::MemOutStream* mos; + static rdr::MemOutStream* sharedMos; + static int maxLen; + int zywrleBuf[64*64]; + }; + } + #endif diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/encodings.h ./common/rfb/encodings.h *** ..\vnc-4_1_2-winsrc/common/rfb/encodings.h Mon May 15 18:04:00 2006 --- ./common/rfb/encodings.h Mon Feb 05 15:34:05 2007 *************** *** 27,36 **** --- 27,43 ---- const unsigned int encodingHextile = 5; const unsigned int encodingZRLE = 16; + const unsigned int encoding3rdPartyHitachiZYWRLE = 17; + const unsigned int encodingMax = 255; const unsigned int pseudoEncodingCursor = 0xffffff11; const unsigned int pseudoEncodingDesktopSize = 0xffffff21; + + const unsigned int pseudoEncodingQualityLevel0 = 0xffffffe0; + const unsigned int pseudoEncodingQualityLevel3 = 0xffffffe3; + const unsigned int pseudoEncodingQualityLevel6 = 0xffffffe6; + const unsigned int pseudoEncodingQualityLevel9 = 0xffffffe9; int encodingNum(const char* name); const char* encodingName(unsigned int num); diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/rfb.dsp ./common/rfb/rfb.dsp *** ..\vnc-4_1_2-winsrc/common/rfb/rfb.dsp Mon Feb 28 10:55:00 2005 --- ./common/rfb/rfb.dsp Mon Feb 05 17:36:25 2007 *************** *** 304,309 **** --- 304,317 ---- SOURCE=.\ZRLEEncoder.cxx # End Source File + # Begin Source File + + SOURCE=.\ZYWRLEDecoder.cxx + # End Source File + # Begin Source File + + SOURCE=.\ZYWRLEEncoder.cxx + # End Source File # End Group # Begin Group "Header Files" diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/zrleDecode.h ./common/rfb/zrleDecode.h *** ..\vnc-4_1_2-winsrc/common/rfb/zrleDecode.h Mon May 15 18:05:00 2006 --- ./common/rfb/zrleDecode.h Thu Feb 08 10:18:45 2007 *************** *** 1,4 **** ! /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by --- 1,6 ---- ! /* ! * Copyright (C) 2006-2007 Hitachi Systems & Services, Ltd. All Rights Reserved. ! * Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by *************** *** 14,19 **** --- 16,24 ---- * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. + * + * ZYWRLE VNC codec homepage: + * http://mobile.hitachi-system.co.jp/publications/ZYWRLE/ */ // *************** *** 38,43 **** --- 43,49 ---- #define CONCAT2E(a,b) CONCAT2(a,b) #endif + #ifndef ZYWRLE_DECODE #ifdef CPIXEL #define PIXEL_T rdr::CONCAT2E(U,BPP) #define READ_PIXEL CONCAT2E(readOpaque,CPIXEL) *************** *** 47,52 **** --- 53,88 ---- #define READ_PIXEL CONCAT2E(readOpaque,BPP) #define ZRLE_DECODE CONCAT2E(zrleDecode,BPP) #endif + #define BPPOUT BPP + #else + #ifndef CONCAT3E + #define CONCAT3(a,b,c) a##b##c + #define CONCAT3E(a,b,c) 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 + #endif + #ifdef CPIXEL + #define PIXEL_T rdr::CONCAT2E(U,BPP) + #define READ_PIXEL CONCAT2E(readOpaque,CPIXEL) + #define ZRLE_DECODE CONCAT3E(zywrleDecode,CPIXEL,END_FIX) + #define BPPOUT BPP + #elif BPP==15 + #define PIXEL_T rdr::CONCAT2E(U,16) + #define READ_PIXEL CONCAT2E(readOpaque,16) + #define ZRLE_DECODE CONCAT3E(zywrleDecode,BPP,END_FIX) + #define BPPOUT 16 + #else + #define PIXEL_T rdr::CONCAT2E(U,BPP) + #define READ_PIXEL CONCAT2E(readOpaque,BPP) + #define ZRLE_DECODE CONCAT3E(zywrleDecode,BPP,END_FIX) + #define BPPOUT BPP + #endif + #include + #endif void ZRLE_DECODE (const Rect& r, rdr::InStream* is, rdr::ZlibInStream* zis, PIXEL_T* buf *************** *** 67,72 **** --- 103,111 ---- t.br.x = __rfbmin(r.br.x, t.tl.x + 64); + #ifdef ZYWRLE_DECODE + top: + #endif int mode = zis->readU8(); bool rle = mode & 128; int palSize = mode & 127; *************** *** 77,85 **** --- 116,132 ---- } if (palSize == 1) { + #ifndef ZYWRLE_DECODE PIXEL_T pix = palette[0]; FILL_RECT(t,pix); continue; + #else + PIXEL_T* ptr = buf; + for (int i = 0; i < t.width()*t.height(); i++) { + *ptr++ = palette[0]; + } + goto draw; + #endif } if (!rle) { *************** *** 87,98 **** // raw #ifdef CPIXEL for (PIXEL_T* ptr = buf; ptr < buf+t.area(); ptr++) { *ptr = zis->READ_PIXEL(); } #else ! zis->readBytes(buf, t.area() * (BPP / 8)); #endif } else { --- 134,151 ---- // raw + #ifdef ZYWRLE_DECODE + if( !(zywrle_level & 0x80) ){ + zywrle_level |= 0x80; + goto top; + }else + #endif #ifdef CPIXEL for (PIXEL_T* ptr = buf; ptr < buf+t.area(); ptr++) { *ptr = zis->READ_PIXEL(); } #else ! zis->readBytes(buf, t.area() * (BPPOUT / 8)); #endif } else { *************** *** 237,242 **** --- 290,302 ---- #ifndef FAVOUR_FILL_RECT //fprintf(stderr,"copying data to screen %dx%d at %d,%d\n", //t.width(),t.height(),t.tl.x,t.tl.y); + #ifdef ZYWRLE_DECODE + draw: + if( zywrle_level & 0x80 ){ + zywrle_level &= 0x7F; + ZYWRLE_SYNTHESIZE( buf, buf, t.width(), t.height(), t.width(), zywrle_level, zywrleBuf ); + } + #endif IMAGE_RECT(t,buf); #endif } *************** *** 248,251 **** --- 308,312 ---- #undef ZRLE_DECODE #undef READ_PIXEL #undef PIXEL_T + #undef BPPOUT } diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/zrleEncode.h ./common/rfb/zrleEncode.h *** ..\vnc-4_1_2-winsrc/common/rfb/zrleEncode.h Mon May 15 18:05:00 2006 --- ./common/rfb/zrleEncode.h Thu Feb 08 10:18:48 2007 *************** *** 1,4 **** ! /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by --- 1,6 ---- ! /* ! * Copyright (C) 2006-2007 Hitachi Systems & Services, Ltd. All Rights Reserved. ! * Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by *************** *** 14,19 **** --- 16,24 ---- * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. + * + * ZYWRLE VNC codec homepage: + * http://mobile.hitachi-system.co.jp/publications/ZYWRLE/ */ // *************** *** 42,47 **** --- 47,53 ---- #define CONCAT2E(a,b) CONCAT2(a,b) #endif + #ifndef ZYWRLE_ENCODE #ifdef CPIXEL #define PIXEL_T rdr::CONCAT2E(U,BPP) #define WRITE_PIXEL CONCAT2E(writeOpaque,CPIXEL) *************** *** 55,60 **** --- 61,98 ---- #define ZRLE_ENCODE_TILE CONCAT2E(zrleEncodeTile,BPP) #define BPPOUT BPP #endif + #else + #ifndef CONCAT3E + #define CONCAT3(a,b,c) a##b##c + #define CONCAT3E(a,b,c) 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 + #endif + #ifdef CPIXEL + #define PIXEL_T rdr::CONCAT2E(U,BPP) + #define WRITE_PIXEL CONCAT2E(writeOpaque,CPIXEL) + #define ZRLE_ENCODE CONCAT3E(zywrleEncode,CPIXEL,END_FIX) + #define ZRLE_ENCODE_TILE CONCAT3E(zywrleEncodeTile,CPIXEL,END_FIX) + #define BPPOUT 24 + #elif BPP==15 + #define PIXEL_T rdr::CONCAT2E(U,16) + #define WRITE_PIXEL CONCAT2E(writeOpaque,16) + #define ZRLE_ENCODE CONCAT3E(zywrleEncode,BPP,END_FIX) + #define ZRLE_ENCODE_TILE CONCAT3E(zywrleEncodeTile,BPP,END_FIX) + #define BPPOUT 16 + #else + #define PIXEL_T rdr::CONCAT2E(U,BPP) + #define WRITE_PIXEL CONCAT2E(writeOpaque,BPP) + #define ZRLE_ENCODE CONCAT3E(zywrleEncode,BPP,END_FIX) + #define ZRLE_ENCODE_TILE CONCAT3E(zywrleEncodeTile,BPP,END_FIX) + #define BPPOUT BPP + #endif + #include + #endif #ifndef ZRLE_ONCE #define ZRLE_ONCE *************** *** 112,118 **** --- 150,160 ---- }; #endif + #ifndef ZYWRLE_ENCODE void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, rdr::OutStream* os); + #else + void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, rdr::OutStream* os, int zywrle_level, int* zywrleBuf); + #endif bool ZRLE_ENCODE (const Rect& r, rdr::OutStream* os, rdr::ZlibOutStream* zos, void* buf, int maxLen, Rect* actual *************** *** 147,153 **** --- 189,199 ---- GET_IMAGE_INTO_BUF(t,buf); + #ifndef ZYWRLE_ENCODE ZRLE_ENCODE_TILE((PIXEL_T*)buf, t.width(), t.height(), zos); + #else + ZRLE_ENCODE_TILE((PIXEL_T*)buf, t.width(), t.height(), zos, zywrle_level, zywrleBuf); + #endif } zos->flush(); *************** *** 156,162 **** --- 202,212 ---- } + #ifndef ZYWRLE_ENCODE void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, rdr::OutStream* os) + #else + void ZRLE_ENCODE_TILE (PIXEL_T* data, int w, int h, rdr::OutStream* os, int zywrle_level, int* zywrleBuf) + #endif { // First find the palette and the number of runs *************** *** 200,205 **** --- 250,260 ---- bool usePalette = false; int estimatedBytes = w * h * (BPPOUT/8); // start assuming raw + #ifdef ZYWRLE_ENCODE + if( (zywrle_level & 0x80)== 0 ){ + estimatedBytes >>= zywrle_level; + } + #endif int plainRleBytes = ((BPPOUT/8)+1) * (runs + singlePixels); *************** *** 309,314 **** --- 364,377 ---- // raw + #ifdef ZYWRLE_ENCODE + if( (zywrle_level & 0x80)== 0 ){ + ZYWRLE_ANALYZE( data, data, w, h, w, zywrle_level, zywrleBuf ); + zywrle_level |= 0x80; + ZRLE_ENCODE_TILE( data, w, h, os, zywrle_level, zywrleBuf ); + zywrle_level &= 0x7F; + }else + #endif #ifdef CPIXEL for (PIXEL_T* ptr = data; ptr < data+w*h; ptr++) { os->WRITE_PIXEL(*ptr); diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/common/rfb/zywrletemplate.c ./common/rfb/zywrletemplate.c *** ..\vnc-4_1_2-winsrc/common/rfb/zywrletemplate.c Thu Jan 01 09:00:00 1970 --- ./common/rfb/zywrletemplate.c Thu Feb 08 10:14:23 2007 *************** *** 0 **** --- 1,807 ---- + + /******************************************************************** + * * + * 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-2007 * + * BY Hitachi Systems & Services, Ltd. * + * (Noriaki Yamazaki, Research & Developement Center) * * + * * + * ZYWRLE VNC codec homepage: * + * http://mobile.hitachi-system.co.jp/publications/ZYWRLE/ * + * * + ******************************************************************** + 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 CONCAT3E(zywrleAnalyze,BPP,END_FIX) + #define ZYWRLE_SYNTHESIZE CONCAT3E(zywrleSynthesize,BPP,END_FIX) + + #define ZYWRLE_RGBYUV CONCAT3E(zywrleRGBYUV,BPP,END_FIX) + #define ZYWRLE_YUVRGB CONCAT3E(zywrleYUVRGB,BPP,END_FIX) + #define ZYWRLE_YMASK CONCAT2E(ZYWRLE_YMASK,BPP) + #define ZYWRLE_UVMASK CONCAT2E(ZYWRLE_UVMASK,BPP) + #define ZYWRLE_LOAD_PIXEL CONCAT2E(ZYWRLE_LOAD_PIXEL,BPP) + #define ZYWRLE_SAVE_PIXEL 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<writeSetEncodings(options.preferredEncoding, true); } writer()->writeFramebufferUpdateRequest(Rect(0, 0, cp.width, cp.height), --- 501,507 ---- if (encodingChange) { vlog.info("Using %s encoding",encodingName(options.preferredEncoding)); ! writer()->writeSetEncodings(options.preferredEncoding, true, options.qualityLevel); } writer()->writeFramebufferUpdateRequest(Rect(0, 0, cp.width, cp.height), diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/win/vncviewer/CConnOptions.cxx ./win/vncviewer/CConnOptions.cxx *** ..\vnc-4_1_2-winsrc/win/vncviewer/CConnOptions.cxx Mon May 15 18:05:00 2006 --- ./win/vncviewer/CConnOptions.cxx Mon Feb 05 16:01:58 2007 *************** *** 361,366 **** --- 361,367 ---- fullColour = o.fullColour; lowColourLevel = o.lowColourLevel; preferredEncoding = o.preferredEncoding; + qualityLevel = o.qualityLevel; autoSelect = o.autoSelect; shared = o.shared; sendPtrEvents = o.sendPtrEvents; diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/win/vncviewer/CConnOptions.h ./win/vncviewer/CConnOptions.h *** ..\vnc-4_1_2-winsrc/win/vncviewer/CConnOptions.h Mon May 15 18:05:00 2006 --- ./win/vncviewer/CConnOptions.h Mon Feb 05 15:32:53 2007 *************** *** 54,59 **** --- 54,60 ---- bool fullColour; int lowColourLevel; int preferredEncoding; + int qualityLevel; bool autoSelect; bool shared; bool sendPtrEvents; diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/win/vncviewer/OptionsDialog.cxx ./win/vncviewer/OptionsDialog.cxx *** ..\vnc-4_1_2-winsrc/win/vncviewer/OptionsDialog.cxx Mon May 15 18:05:00 2006 --- ./win/vncviewer/OptionsDialog.cxx Mon Feb 05 16:49:11 2007 *************** *** 87,92 **** --- 87,93 ---- case encodingZRLE: setItemChecked(IDC_ENCODING_ZRLE, true); break; case encodingHextile: setItemChecked(IDC_ENCODING_HEXTILE, true); break; case encodingRaw: setItemChecked(IDC_ENCODING_RAW, true); break; + case encoding3rdPartyHitachiZYWRLE: setItemChecked(IDC_ENCODING_ZYWRLE, true); break; } onCommand(IDC_ENCODING_AUTO, 0 /* ? */); // Force enableItem status to refresh } *************** *** 104,109 **** --- 105,118 ---- dlg->options.preferredEncoding = encodingHextile; if (isItemChecked(IDC_ENCODING_RAW)) dlg->options.preferredEncoding = encodingRaw; + if (isItemChecked(IDC_ENCODING_ZYWRLE)){ + dlg->options.preferredEncoding = encoding3rdPartyHitachiZYWRLE; + dlg->options.qualityLevel = 6; + } + if (isItemChecked(IDC_ENCODING_ZYWRLE2)){ + dlg->options.preferredEncoding = encoding3rdPartyHitachiZYWRLE; + dlg->options.qualityLevel = 3; + } ((ViewerOptions*)propSheet)->setChanged(); return true; } *************** *** 113,118 **** --- 122,129 ---- enableItem(IDC_ENCODING_ZRLE, ok); enableItem(IDC_ENCODING_HEXTILE, ok); enableItem(IDC_ENCODING_RAW, ok); + enableItem(IDC_ENCODING_ZYWRLE, ok); + enableItem(IDC_ENCODING_ZYWRLE2, ok); return true; } return false; diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/win/vncviewer/resource.h ./win/vncviewer/resource.h *** ..\vnc-4_1_2-winsrc/win/vncviewer/resource.h Fri Nov 19 11:48:00 2004 --- ./win/vncviewer/resource.h Mon Feb 05 15:21:31 2007 *************** *** 31,38 **** --- 31,40 ---- #define IDC_ENCODING_RAW 1014 #define IDC_FULL_SCREEN 1014 #define IDC_SEND_POINTER 1015 + #define IDC_ENCODING_ZYWRLE 1015 #define IDC_SEND_KEYS 1016 #define IDC_CLIENT_CUTTEXT 1017 + #define IDC_ENCODING_ZYWRLE2 1017 #define IDC_SERVER_CUTTEXT 1018 #define IDC_LOCAL_CURSOR 1019 #define IDC_DESKTOP_RESIZE 1020 diff -rcN -x Release -x Debug -x *.plg -x *.dsw -x *.ncb -x *.opt ..\vnc-4_1_2-winsrc/win/vncviewer/vncviewer.rc ./win/vncviewer/vncviewer.rc *** ..\vnc-4_1_2-winsrc/win/vncviewer/vncviewer.rc Fri May 12 14:58:00 2006 --- ./win/vncviewer/vncviewer.rc Mon Feb 05 17:40:44 2007 *************** *** 172,184 **** BEGIN CONTROL "&Auto select",IDC_ENCODING_AUTO,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,7,88,13 ! GROUPBOX "Preferred encoding",IDC_STATIC,7,25,83,60 CONTROL "ZRLE",IDC_ENCODING_ZRLE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,35,75,14 CONTROL "Hextile",IDC_ENCODING_HEXTILE,"Button", BS_AUTORADIOBUTTON,10,49,75,16 CONTROL "Raw",IDC_ENCODING_RAW,"Button",BS_AUTORADIOBUTTON,10,65, 75,15 GROUPBOX "Colour level",IDC_STATIC,95,10,99,75 CONTROL "&Full (all available colours)",IDC_FORMAT_FULLCOLOUR, "Button",BS_AUTORADIOBUTTON | WS_GROUP,100,20,90,15 --- 172,188 ---- BEGIN CONTROL "&Auto select",IDC_ENCODING_AUTO,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,7,88,13 ! GROUPBOX "Preferred encoding",IDC_STATIC,7,25,83,84 CONTROL "ZRLE",IDC_ENCODING_ZRLE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,35,75,14 CONTROL "Hextile",IDC_ENCODING_HEXTILE,"Button", BS_AUTORADIOBUTTON,10,49,75,16 CONTROL "Raw",IDC_ENCODING_RAW,"Button",BS_AUTORADIOBUTTON,10,65, 75,15 + CONTROL "ZYWRLE(High)",IDC_ENCODING_ZYWRLE,"Button", + BS_AUTORADIOBUTTON,10,80,55,14 + CONTROL "ZYWRLE(Mid)",IDC_ENCODING_ZYWRLE2,"Button", + BS_AUTORADIOBUTTON,10,94,55,14 GROUPBOX "Colour level",IDC_STATIC,95,10,99,75 CONTROL "&Full (all available colours)",IDC_FORMAT_FULLCOLOUR, "Button",BS_AUTORADIOBUTTON | WS_GROUP,100,20,90,15