Added IrixCLJpegCompressor class which will support JPEG compression via the Irix Compression Library. This version of IrixCLJpegCompressor is just a stub.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2375 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/rfb/IrixCLJpegCompressor.cxx b/common/rfb/IrixCLJpegCompressor.cxx
new file mode 100644
index 0000000..636c333
--- /dev/null
+++ b/common/rfb/IrixCLJpegCompressor.cxx
@@ -0,0 +1,67 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/poll.h>
+
+#include <rfb/IrixCLJpegCompressor.h>
+
+using namespace rfb;
+
+const int IrixCLJpegCompressor::DEFAULT_QUALITY = 75;
+
+//
+// Constructor and destructor.
+//
+
+IrixCLJpegCompressor::IrixCLJpegCompressor()
+  : m_quality(DEFAULT_QUALITY),
+    m_compressedData(0),
+    m_compressedLength(0)
+{
+}
+
+IrixCLJpegCompressor::~IrixCLJpegCompressor()
+{
+  if (m_compressedData)
+    delete[] m_compressedData;
+}
+
+//
+// Set JPEG quality level (1..99)
+//
+
+void
+IrixCLJpegCompressor::setQuality(int level)
+{
+  if (level < 1) {
+    level = 1;
+  } else if (level > 99) {
+    level = 99;
+  }
+  if (level != m_quality) {
+    m_quality = level;
+  }
+}
+
+//
+// Perform JPEG compression.
+//
+// FIXME: This function assumes that pixel format is 32-bit XBGR
+//        (depth 24), compatible with IRIX Digital Media libraries.
+//
+
+void
+IrixCLJpegCompressor::compress(const rdr::U32 *buf,
+                               const PixelFormat *fmt,
+                               int w, int h, int stride)
+{
+  // Discard previous compression results.
+  if (m_compressedData) {
+    delete[] m_compressedData;
+    m_compressedData = 0;
+  }
+  m_compressedLength = 0;
+
+  // FIXME: Do something.
+}
+
diff --git a/common/rfb/IrixCLJpegCompressor.h b/common/rfb/IrixCLJpegCompressor.h
new file mode 100644
index 0000000..e32659a
--- /dev/null
+++ b/common/rfb/IrixCLJpegCompressor.h
@@ -0,0 +1,49 @@
+#ifndef __IRIXCLJPEGCOMPRESSOR_H__
+#define __IRIXCLJPEGCOMPRESSOR_H__
+
+#include <sys/types.h>
+
+#include <rdr/types.h>
+#include <rfb/PixelFormat.h>
+
+#include <rfb/JpegCompressor.h>
+
+namespace rfb {
+
+  //
+  // A C++ class for performing JPEG compression.
+  // This implementation uses IRIX Compression Library (CL).
+  //
+
+  class IrixCLJpegCompressor : public JpegCompressor
+  {
+  public:
+    IrixCLJpegCompressor();
+    virtual ~IrixCLJpegCompressor();
+
+    // Check if the object has been created successfully.
+    bool isValid() const { return false; }
+
+    // Set JPEG quality level (0..100).
+    virtual void setQuality(int level);
+
+    // Actually compress the image.
+    virtual void compress(const rdr::U32 *buf, const PixelFormat *fmt,
+			  int w, int h, int stride);
+
+    // Access results of the compression.
+    virtual size_t getDataLength() { return m_compressedLength; }
+    virtual const char *getDataPtr() { return m_compressedData; }
+
+  protected:
+    static const int DEFAULT_QUALITY;
+    int m_quality;
+
+    char *m_compressedData;
+    size_t m_compressedLength;
+  };
+
+}
+
+#endif // __IRIXCLJPEGCOMPRESSOR_H__
+