Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2000-2003 Constantin Kaplinsky. All Rights Reserved. |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame^] | 2 | * Copyright (C) 2011 D. R. Commander. All Rights Reserved. |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 3 | * |
| 4 | * This is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This software is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this software; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 17 | * USA. |
| 18 | */ |
| 19 | #ifndef __RFB_TIGHTDECODER_H__ |
| 20 | #define __RFB_TIGHTDECODER_H__ |
| 21 | |
| 22 | #include <rdr/ZlibInStream.h> |
| 23 | #include <rfb/Decoder.h> |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame^] | 24 | #include <rfb/JpegDecompressor.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 25 | |
| 26 | namespace rfb { |
| 27 | |
| 28 | class TightDecoder : public Decoder { |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame^] | 29 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 30 | public: |
| 31 | static Decoder* create(CMsgReader* reader); |
| 32 | virtual void readRect(const Rect& r, CMsgHandler* handler); |
| 33 | virtual ~TightDecoder(); |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame^] | 34 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 35 | private: |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame^] | 36 | void tightDecode8(const Rect& r); |
| 37 | void tightDecode16(const Rect& r); |
| 38 | void tightDecode32(const Rect& r); |
| 39 | |
| 40 | void DecompressJpegRect8(const Rect& r); |
| 41 | void DecompressJpegRect16(const Rect& r); |
| 42 | void DecompressJpegRect32(const Rect& r); |
| 43 | |
| 44 | void FilterGradient8(rdr::InStream* is, rdr::U8* buf, int stride, |
| 45 | const Rect& r, int dataSize); |
| 46 | void FilterGradient16(rdr::InStream* is, rdr::U16* buf, int stride, |
| 47 | const Rect& r, int dataSize); |
| 48 | void FilterGradient24(rdr::InStream* is, rdr::U32* buf, int stride, |
| 49 | const Rect& r, int dataSize); |
| 50 | void FilterGradient32(rdr::InStream* is, rdr::U32* buf, int stride, |
| 51 | const Rect& r, int dataSize); |
| 52 | |
| 53 | void directFillRect8(const Rect& r, Pixel pix); |
| 54 | void directFillRect16(const Rect& r, Pixel pix); |
| 55 | void directFillRect32(const Rect& r, Pixel pix); |
| 56 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 57 | TightDecoder(CMsgReader* reader); |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame^] | 58 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 59 | CMsgReader* reader; |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame^] | 60 | CMsgHandler* handler; |
| 61 | rdr::InStream* is; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 62 | rdr::ZlibInStream zis[4]; |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame^] | 63 | JpegDecompressor jd; |
| 64 | PixelFormat clientpf; |
| 65 | PixelFormat serverpf; |
| 66 | bool directDecode; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | // Compression control |
| 70 | const unsigned int rfbTightExplicitFilter = 0x04; |
| 71 | const unsigned int rfbTightFill = 0x08; |
| 72 | const unsigned int rfbTightJpeg = 0x09; |
| 73 | const unsigned int rfbTightMaxSubencoding = 0x09; |
| 74 | |
| 75 | // Filters to improve compression efficiency |
| 76 | const unsigned int rfbTightFilterCopy = 0x00; |
| 77 | const unsigned int rfbTightFilterPalette = 0x01; |
| 78 | const unsigned int rfbTightFilterGradient = 0x02; |
| 79 | } |
| 80 | |
| 81 | #endif |