blob: 500884af016d7181231300aa2d08d01a62167cb2 [file] [log] [blame]
Constantin Kaplinsky71a32f02007-07-24 12:10:16 +00001#ifndef __IRIXDMJPEGCOMPRESSOR_H__
2#define __IRIXDMJPEGCOMPRESSOR_H__
3
4#include <sys/types.h>
5
6#include <rdr/types.h>
7#include <rfb/PixelFormat.h>
8
9#include <rfb/JpegCompressor.h>
10#include <rfb/IrixDMIC_RawToJpeg.h>
11
12namespace rfb {
13
14 //
15 // A C++ class for performing JPEG compression.
16 // This implementation uses IRIX Digital Media libraries.
17 //
18
19 class IrixDMJpegCompressor : public JpegCompressor
20 {
21 public:
22 IrixDMJpegCompressor();
23 virtual ~IrixDMJpegCompressor();
24
25 // Check if the object has been created successfully.
26 bool isValid() const { return m_ic.isValid(); }
27
28 // Set JPEG quality level (0..100).
29 void setQuality(int level);
30
31 // Actually compress the image.
32 void compress(const rdr::U32 *buf, const PixelFormat *fmt,
33 int w, int h, int stride);
34
35 // Access results of the compression.
36 size_t getDataLength() { return m_compressedLength; }
37 const char *getDataPtr() { return m_compressedData; }
38
39 protected:
40 // Update image size and make sure that our buffer pools will
41 // allocate properly-sized buffers.
42 bool updateImageSize(int w, int h);
43
44 protected:
45 static const int DEFAULT_QUALITY;
46 int m_quality;
47
48 IrixDMIC_RawToJpeg m_ic;
49 int m_width;
50 int m_height;
51 DMbufferpool m_srcPool;
52 DMbufferpool m_dstPool;
53 int m_bufferSize;
54
55 char *m_compressedData;
56 size_t m_compressedLength;
57 };
58
59}
60
61#endif // __IRIXDMJPEGCOMPRESSOR_H__
62