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: |
Pierre Ossman | 316a324 | 2014-01-15 12:40:20 +0100 | [diff] [blame] | 31 | TightDecoder(CMsgReader* reader); |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 32 | virtual ~TightDecoder(); |
Pierre Ossman | 316a324 | 2014-01-15 12:40:20 +0100 | [diff] [blame] | 33 | virtual void readRect(const Rect& r, CMsgHandler* handler); |
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: |
Pierre Ossman | 7b5c069 | 2014-03-17 14:35:51 +0100 | [diff] [blame^] | 36 | rdr::U32 readCompact(rdr::InStream* is); |
| 37 | |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame] | 38 | void tightDecode8(const Rect& r); |
| 39 | void tightDecode16(const Rect& r); |
| 40 | void tightDecode32(const Rect& r); |
| 41 | |
| 42 | void DecompressJpegRect8(const Rect& r); |
| 43 | void DecompressJpegRect16(const Rect& r); |
| 44 | void DecompressJpegRect32(const Rect& r); |
| 45 | |
DRC | a5004a3 | 2011-11-04 04:51:17 +0000 | [diff] [blame] | 46 | void FilterGradient8(rdr::U8 *netbuf, rdr::U8* buf, int stride, |
| 47 | const Rect& r); |
| 48 | void FilterGradient16(rdr::U8 *netbuf, rdr::U16* buf, int stride, |
| 49 | const Rect& r); |
| 50 | void FilterGradient24(rdr::U8 *netbuf, rdr::U32* buf, int stride, |
| 51 | const Rect& r); |
| 52 | void FilterGradient32(rdr::U8 *netbuf, rdr::U32* buf, int stride, |
| 53 | const Rect& r); |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame] | 54 | |
| 55 | void directFillRect8(const Rect& r, Pixel pix); |
| 56 | void directFillRect16(const Rect& r, Pixel pix); |
| 57 | void directFillRect32(const Rect& r, Pixel pix); |
| 58 | |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame] | 59 | CMsgHandler* handler; |
| 60 | rdr::InStream* is; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 61 | rdr::ZlibInStream zis[4]; |
DRC | 33c15e3 | 2011-11-03 18:49:21 +0000 | [diff] [blame] | 62 | JpegDecompressor jd; |
| 63 | PixelFormat clientpf; |
| 64 | PixelFormat serverpf; |
| 65 | bool directDecode; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | // Compression control |
| 69 | const unsigned int rfbTightExplicitFilter = 0x04; |
| 70 | const unsigned int rfbTightFill = 0x08; |
| 71 | const unsigned int rfbTightJpeg = 0x09; |
| 72 | const unsigned int rfbTightMaxSubencoding = 0x09; |
| 73 | |
| 74 | // Filters to improve compression efficiency |
| 75 | const unsigned int rfbTightFilterCopy = 0x00; |
| 76 | const unsigned int rfbTightFilterPalette = 0x01; |
| 77 | const unsigned int rfbTightFilterGradient = 0x02; |
| 78 | } |
| 79 | |
| 80 | #endif |