summaryrefslogtreecommitdiffstats
path: root/common/rfb/TightDecoder.cxx
diff options
context:
space:
mode:
authorDRC <dcommander@users.sourceforge.net>2011-11-03 18:49:21 +0000
committerDRC <dcommander@users.sourceforge.net>2011-11-03 18:49:21 +0000
commit33c15e3a3a1db376feae90ef7521a107dd957752 (patch)
tree07a01bd47e977a94b2ead9d406fec736e0b613b4 /common/rfb/TightDecoder.cxx
parent3004cb640aba2ed81d31444064aa8087990c7212 (diff)
downloadtigervnc-33c15e3a3a1db376feae90ef7521a107dd957752.tar.gz
tigervnc-33c15e3a3a1db376feae90ef7521a107dd957752.zip
If the client and server are using identical pixel formats, then perform Tight decoding directly into the viewer's back buffer, rather than going through the slow fillRect/imageRect routines.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4757 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'common/rfb/TightDecoder.cxx')
-rw-r--r--common/rfb/TightDecoder.cxx100
1 files changed, 18 insertions, 82 deletions
diff --git a/common/rfb/TightDecoder.cxx b/common/rfb/TightDecoder.cxx
index daca00aa..670e480a 100644
--- a/common/rfb/TightDecoder.cxx
+++ b/common/rfb/TightDecoder.cxx
@@ -1,5 +1,6 @@
/* Copyright (C) 2000-2003 Constantin Kaplinsky. All Rights Reserved.
* Copyright 2004-2005 Cendio AB.
+ * Copyright (C) 2011 D. R. Commander. 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
@@ -19,19 +20,11 @@
#include <rfb/CMsgReader.h>
#include <rfb/CMsgHandler.h>
#include <rfb/TightDecoder.h>
-#include <stdio.h> /* jpeglib.h needs FILE */
-extern "C" {
-#include <jpeglib.h>
-}
using namespace rfb;
#define TIGHT_MAX_WIDTH 2048
-static void JpegSetSrcManager(j_decompress_ptr cinfo, char *compressedData,
- int compressedLen);
-static bool jpegError;
-
#define EXTRA_ARGS CMsgHandler* handler
#define FILL_RECT(r, p) handler->fillRect(r, p)
#define IMAGE_RECT(r, p) handler->imageRect(r, p)
@@ -60,82 +53,25 @@ TightDecoder::~TightDecoder()
void TightDecoder::readRect(const Rect& r, CMsgHandler* handler)
{
- rdr::InStream* is = reader->getInStream();
- /* Uncompressed RGB24 JPEG data, before translated, can be up to 3
- times larger, if VNC bpp is 8. */
- rdr::U8* buf = reader->getImageBuf(r.area()*3);
- switch (reader->bpp()) {
+ is = reader->getInStream();
+ this->handler = handler;
+ clientpf = handler->getPreferredPF();
+ serverpf = handler->cp.pf();
+
+ if (clientpf.equal(serverpf)) {
+ /* Decode directly into the framebuffer (fast path) */
+ directDecode = true;
+ } else {
+ /* Decode into an intermediate buffer and use pixel translation */
+ directDecode = false;
+ }
+
+ switch (serverpf.bpp) {
case 8:
- tightDecode8 (r, is, zis, (rdr::U8*) buf, handler); break;
+ tightDecode8 (r); break;
case 16:
- tightDecode16(r, is, zis, (rdr::U16*)buf, handler); break;
+ tightDecode16(r); break;
case 32:
- tightDecode32(r, is, zis, (rdr::U32*)buf, handler); break;
+ tightDecode32(r); break;
}
}
-
-
-//
-// A "Source manager" for the JPEG library.
-//
-
-static struct jpeg_source_mgr jpegSrcManager;
-static JOCTET *jpegBufferPtr;
-static size_t jpegBufferLen;
-
-static void JpegInitSource(j_decompress_ptr cinfo);
-static boolean JpegFillInputBuffer(j_decompress_ptr cinfo);
-static void JpegSkipInputData(j_decompress_ptr cinfo, long num_bytes);
-static void JpegTermSource(j_decompress_ptr cinfo);
-
-static void
-JpegInitSource(j_decompress_ptr cinfo)
-{
- jpegError = false;
-}
-
-static boolean
-JpegFillInputBuffer(j_decompress_ptr cinfo)
-{
- jpegError = true;
- jpegSrcManager.bytes_in_buffer = jpegBufferLen;
- jpegSrcManager.next_input_byte = (JOCTET *)jpegBufferPtr;
-
- return TRUE;
-}
-
-static void
-JpegSkipInputData(j_decompress_ptr cinfo, long num_bytes)
-{
- if (num_bytes < 0 || (size_t)num_bytes > jpegSrcManager.bytes_in_buffer) {
- jpegError = true;
- jpegSrcManager.bytes_in_buffer = jpegBufferLen;
- jpegSrcManager.next_input_byte = (JOCTET *)jpegBufferPtr;
- } else {
- jpegSrcManager.next_input_byte += (size_t) num_bytes;
- jpegSrcManager.bytes_in_buffer -= (size_t) num_bytes;
- }
-}
-
-static void
-JpegTermSource(j_decompress_ptr cinfo)
-{
- /* No work necessary here. */
-}
-
-static void
-JpegSetSrcManager(j_decompress_ptr cinfo, char *compressedData, int compressedLen)
-{
- jpegBufferPtr = (JOCTET *)compressedData;
- jpegBufferLen = (size_t)compressedLen;
-
- jpegSrcManager.init_source = JpegInitSource;
- jpegSrcManager.fill_input_buffer = JpegFillInputBuffer;
- jpegSrcManager.skip_input_data = JpegSkipInputData;
- jpegSrcManager.resync_to_restart = jpeg_resync_to_restart;
- jpegSrcManager.term_source = JpegTermSource;
- jpegSrcManager.next_input_byte = jpegBufferPtr;
- jpegSrcManager.bytes_in_buffer = jpegBufferLen;
-
- cinfo->src = &jpegSrcManager;
-}