Added JpegCompressor abstract class and two implementations -- one cross-platform and another IRIX-specific.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2320 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/rfb/IrixDMJpegCompressor.h b/common/rfb/IrixDMJpegCompressor.h
new file mode 100644
index 0000000..500884a
--- /dev/null
+++ b/common/rfb/IrixDMJpegCompressor.h
@@ -0,0 +1,62 @@
+#ifndef __IRIXDMJPEGCOMPRESSOR_H__
+#define __IRIXDMJPEGCOMPRESSOR_H__
+
+#include <sys/types.h>
+
+#include <rdr/types.h>
+#include <rfb/PixelFormat.h>
+
+#include <rfb/JpegCompressor.h>
+#include <rfb/IrixDMIC_RawToJpeg.h>
+
+namespace rfb {
+
+  //
+  // A C++ class for performing JPEG compression.
+  // This implementation uses IRIX Digital Media libraries.
+  //
+
+  class IrixDMJpegCompressor : public JpegCompressor
+  {
+  public:
+    IrixDMJpegCompressor();
+    virtual ~IrixDMJpegCompressor();
+
+    // Check if the object has been created successfully.
+    bool isValid() const { return m_ic.isValid(); }
+
+    // Set JPEG quality level (0..100).
+    void setQuality(int level);
+
+    // Actually compress the image.
+    void compress(const rdr::U32 *buf, const PixelFormat *fmt,
+                  int w, int h, int stride);
+
+    // Access results of the compression.
+    size_t getDataLength() { return m_compressedLength; }
+    const char *getDataPtr() { return m_compressedData; }
+
+  protected:
+    // Update image size and make sure that our buffer pools will
+    // allocate properly-sized buffers.
+    bool updateImageSize(int w, int h);
+
+  protected:
+    static const int DEFAULT_QUALITY;
+    int m_quality;
+
+    IrixDMIC_RawToJpeg m_ic;
+    int m_width;
+    int m_height;
+    DMbufferpool m_srcPool;
+    DMbufferpool m_dstPool;
+    int m_bufferSize;
+
+    char *m_compressedData;
+    size_t m_compressedLength;
+  };
+
+}
+
+#endif // __IRIXDMJPEGCOMPRESSOR_H__
+