summaryrefslogtreecommitdiffstats
path: root/common/rfb/IrixDMJpegCompressor.h
blob: db2420039efed6e51ed9bad83a14c075b53dafb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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).
    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:
    // 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__